From 4cac3711a6ddced195ac02f646fcbcf385547923 Mon Sep 17 00:00:00 2001 From: Johannes Pichler Date: Tue, 23 Feb 2016 08:45:58 +0100 Subject: [PATCH 01/15] Issue #245 remove illegal option from mv command --- Mage/Task/BuiltIn/Deployment/ReleaseTask.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Mage/Task/BuiltIn/Deployment/ReleaseTask.php b/Mage/Task/BuiltIn/Deployment/ReleaseTask.php index 93df8cf..31ed5b0 100644 --- a/Mage/Task/BuiltIn/Deployment/ReleaseTask.php +++ b/Mage/Task/BuiltIn/Deployment/ReleaseTask.php @@ -90,7 +90,7 @@ class ReleaseTask extends AbstractTask implements IsReleaseAware, SkipOnOverride if ($resultFetch && $userGroup != '') { $command.= " && chown -h {$userGroup} {$tmplink}"; } - $command.= " && mv -fT {$tmplink} {$symlink}"; + $command.= " && mv -f {$tmplink} {$symlink}"; $result = $this->runCommandRemote($command); if ($result) { From d4ba1530b3b62f8c9c39217cfc29c3b5b47e6f69 Mon Sep 17 00:00:00 2001 From: Bernhard Poiss Date: Tue, 23 Feb 2016 11:26:09 +0100 Subject: [PATCH 02/15] Fix deployment for FreeBSD Remove existing symlink for `current` folder before generating a new one, otherwise it would not be overwritten. --- Mage/Task/BuiltIn/Deployment/ReleaseTask.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Mage/Task/BuiltIn/Deployment/ReleaseTask.php b/Mage/Task/BuiltIn/Deployment/ReleaseTask.php index 31ed5b0..96aad16 100644 --- a/Mage/Task/BuiltIn/Deployment/ReleaseTask.php +++ b/Mage/Task/BuiltIn/Deployment/ReleaseTask.php @@ -90,7 +90,7 @@ class ReleaseTask extends AbstractTask implements IsReleaseAware, SkipOnOverride if ($resultFetch && $userGroup != '') { $command.= " && chown -h {$userGroup} {$tmplink}"; } - $command.= " && mv -f {$tmplink} {$symlink}"; + $command.= " && rm -rf {$symlink} && mv -f {$tmplink} {$symlink}"; $result = $this->runCommandRemote($command); if ($result) { From 76e0bd327876511bbf8dc58c15125554c256cf46 Mon Sep 17 00:00:00 2001 From: Johannes Pichler Date: Wed, 2 Mar 2016 20:16:01 +0100 Subject: [PATCH 03/15] add link to original repository --- README.md | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/README.md b/README.md index 9fe1b3b..887ab11 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,5 @@ # Magallanes # - -[![SensioLabsInsight](https://insight.sensiolabs.com/projects/ed0de53a-a12e-459b-9464-34def5907b56/mini.png)](https://insight.sensiolabs.com/projects/ed0de53a-a12e-459b-9464-34def5907b56) -[![Build Status](https://travis-ci.org/andres-montanez/Magallanes.svg?branch=master)](https://travis-ci.org/andres-montanez/Magallanes) -[![Coverage Status](https://coveralls.io/repos/andres-montanez/Magallanes/badge.svg?branch=master)](https://coveralls.io/r/andres-montanez/Magallanes?branch=master) +This repository is a fork of [andres-montanez/Magallanes](https://github.com/andres-montanez/Magallanes) due to project inactivity. ### What's Magallanes? ### Magallanes is a deployment tool for PHP applications; it's quite simple to use and manage. From 7aa17cae32e54d7a681467d1b9760a5fe46df29f Mon Sep 17 00:00:00 2001 From: Johannes Pichler Date: Wed, 2 Mar 2016 20:17:51 +0100 Subject: [PATCH 04/15] add default environment configuration to general configuration --- Mage/Config.php | 19 +++++++++++++++- docs/example-config/.mage/config/general.yml | 24 ++++++++++++++++++++ 2 files changed, 42 insertions(+), 1 deletion(-) diff --git a/Mage/Config.php b/Mage/Config.php index 3f70f6c..6133578 100644 --- a/Mage/Config.php +++ b/Mage/Config.php @@ -147,13 +147,30 @@ class Config $configFilePath = getcwd() . '/.mage/config/environment/' . $environment . '.yml'; try { - $this->environmentConfig = $this->loadEnvironment($configFilePath); + $defaults = $this->getDefaultEnvironment(); + $environmentConfig = $this->loadEnvironment($configFilePath); + $this->environmentConfig = array_replace_recursive($defaults, $environmentConfig); } catch (ConfigNotFoundException $e) { throw new RequiredConfigNotFoundException("Not found required config $configFilePath for environment $environment", 0, $e); } } } + /** + * Returns the default deployment configuration from general configuration + * + * @return array the default deployment configuration + */ + protected function getDefaultEnvironment() { + $defaults = $this->general('defaults', null); + + if(!empty($defaults) && array_key_exists('deployment', $defaults)) { + return $defaults['deployment']; + } + + return array(); + } + /** * * @param array $parameters diff --git a/docs/example-config/.mage/config/general.yml b/docs/example-config/.mage/config/general.yml index c3a9b6d..6ae9298 100644 --- a/docs/example-config/.mage/config/general.yml +++ b/docs/example-config/.mage/config/general.yml @@ -7,3 +7,27 @@ verbose_logging: false scm: type: git url: git://github.com/andres-montanez/Zend-Framework-Twig-example-app.git +defaults: + deployment: + user: root + from: ./ + to: /var/www/vhosts/example.com/www + excludes: + - application/data/cache/twig/* + releases: + enabled: true + max: 5 + symlink: current + directory: releases + hosts: + - s01.example.com + - s02.example.com + tasks: + pre-deploy: + - scm/update + on-deploy: + - symfony2/cache-warmup: { env: prod } + - privileges + - sampleTask + - sampleTaskRollbackAware + verbose_logging: true \ No newline at end of file From 05f07474ebb77fc0f305c42e980a841e21b2aac8 Mon Sep 17 00:00:00 2001 From: Johannes Pichler Date: Wed, 2 Mar 2016 20:33:58 +0100 Subject: [PATCH 05/15] changed to cyberhouse namespace --- .editorconfig | 12 ++++++++++++ composer.json | 20 +++++++++++++++++++- 2 files changed, 31 insertions(+), 1 deletion(-) create mode 100644 .editorconfig diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..9ec525e --- /dev/null +++ b/.editorconfig @@ -0,0 +1,12 @@ +root = true + +[*] +end_of_line = lf +insert_final_newline = true +indent_style = space +indent_size = 4 +charset = utf-8 +trim_trailing_whitespace = true + +[*.{json,lock,yml,less,scss,sass}] +indent_size = 2 \ No newline at end of file diff --git a/composer.json b/composer.json index a8b9d75..a2aab93 100644 --- a/composer.json +++ b/composer.json @@ -1,9 +1,27 @@ { - "name": "andres-montanez/magallanes", + "name": "cyberhouse/magallanes", "description": "A Deployment Tool for PHP Applications", "homepage": "http://magephp.com", "license": "MIT", "type": "library", + "authors": [ + { + "name": "Andrés Montañez", + "role": "Developer" + }, + { + "name": "Johannes Pichler", + "email": "johannes.pichler@cyberhouse.at", + "homepage": "https://www.cyberhouse.at", + "role": "Developer" + }, + { + "name": "Georg Großberger", + "email": "georg.grossberger@cyberhouse.ats", + "homepage": "https://www.cyberhouse.at", + "role": "Developer" + } + ], "keywords": ["deployment"], "require": { "php": ">=5.3" From edf9c86890b4da923297c8ba46c7aa8d84af5a46 Mon Sep 17 00:00:00 2001 From: Johannes Pichler Date: Wed, 2 Mar 2016 20:44:39 +0100 Subject: [PATCH 06/15] update defaults configuration --- Mage/Config.php | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/Mage/Config.php b/Mage/Config.php index 6133578..18e45c3 100644 --- a/Mage/Config.php +++ b/Mage/Config.php @@ -157,18 +157,13 @@ class Config } /** - * Returns the default deployment configuration from general configuration + * Returns the default environment configuration from general configuration * - * @return array the default deployment configuration + * @return array the default environment configuration */ protected function getDefaultEnvironment() { $defaults = $this->general('defaults', null); - - if(!empty($defaults) && array_key_exists('deployment', $defaults)) { - return $defaults['deployment']; - } - - return array(); + return !empty($defaults) ? $defaults : array(); } /** From 9d569cbcc99948daaa259d8653ac497f6cc43404 Mon Sep 17 00:00:00 2001 From: Johannes Pichler Date: Thu, 3 Mar 2016 09:15:56 +0100 Subject: [PATCH 07/15] Update README.md Add Travis CI Badges --- README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.md b/README.md index 887ab11..0a68e4c 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,10 @@ # Magallanes # This repository is a fork of [andres-montanez/Magallanes](https://github.com/andres-montanez/Magallanes) due to project inactivity. +**Master:** [![Build Status](https://travis-ci.org/cyberhouse/Magallanes.svg?branch=master)](https://travis-ci.org/cyberhouse/Magallanes) + +**Develop:** [![Build Status](https://travis-ci.org/cyberhouse/Magallanes.svg?branch=master)](https://travis-ci.org/cyberhouse/Magallanes) + ### What's Magallanes? ### Magallanes is a deployment tool for PHP applications; it's quite simple to use and manage. It will get your application to a safe harbor. From a0e1f5a6a551a4ef2bb1e6ecbcc5a6c36b550fa6 Mon Sep 17 00:00:00 2001 From: Johannes Pichler Date: Thu, 3 Mar 2016 09:19:31 +0100 Subject: [PATCH 08/15] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 0a68e4c..a767bad 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ This repository is a fork of [andres-montanez/Magallanes](https://github.com/and **Master:** [![Build Status](https://travis-ci.org/cyberhouse/Magallanes.svg?branch=master)](https://travis-ci.org/cyberhouse/Magallanes) -**Develop:** [![Build Status](https://travis-ci.org/cyberhouse/Magallanes.svg?branch=master)](https://travis-ci.org/cyberhouse/Magallanes) +**Develop:** [![Build Status](https://travis-ci.org/cyberhouse/Magallanes.svg?branch=develop)](https://travis-ci.org/cyberhouse/Magallanes) ### What's Magallanes? ### Magallanes is a deployment tool for PHP applications; it's quite simple to use and manage. From 15248ce0d9c95b987365968c9caba3141fd0adad Mon Sep 17 00:00:00 2001 From: Johannes Pichler Date: Thu, 3 Mar 2016 10:07:13 +0100 Subject: [PATCH 09/15] Update README.md Add Code Coverage details --- README.md | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index a767bad..be354db 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,11 @@ # Magallanes # This repository is a fork of [andres-montanez/Magallanes](https://github.com/andres-montanez/Magallanes) due to project inactivity. -**Master:** [![Build Status](https://travis-ci.org/cyberhouse/Magallanes.svg?branch=master)](https://travis-ci.org/cyberhouse/Magallanes) - -**Develop:** [![Build Status](https://travis-ci.org/cyberhouse/Magallanes.svg?branch=develop)](https://travis-ci.org/cyberhouse/Magallanes) +### Project Status +| Branch | Build Status | Code Coverage | +| ------- |:------------:|:-------------:| +| Master | [![Build Status](https://travis-ci.org/cyberhouse/Magallanes.svg?branch=master)](https://travis-ci.org/cyberhouse/Magallanes) | [![Coverage Status](https://coveralls.io/repos/github/cyberhouse/Magallanes/badge.svg?branch=master)](https://coveralls.io/github/cyberhouse/Magallanes?branch=master) | +| Develop | [![Build Status](https://travis-ci.org/cyberhouse/Magallanes.svg?branch=develop)](https://travis-ci.org/cyberhouse/Magallanes) | [![Coverage Status](https://coveralls.io/repos/github/cyberhouse/Magallanes/badge.svg?branch=develop)](https://coveralls.io/github/cyberhouse/Magallanes?branch=develop) | ### What's Magallanes? ### Magallanes is a deployment tool for PHP applications; it's quite simple to use and manage. From ac89d759fcc200d60fcae0425748a8ccde5fb9b9 Mon Sep 17 00:00:00 2001 From: Johannes Pichler Date: Fri, 4 Mar 2016 11:09:28 +0100 Subject: [PATCH 10/15] Update README.md --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index be354db..20f54f2 100644 --- a/README.md +++ b/README.md @@ -4,8 +4,8 @@ This repository is a fork of [andres-montanez/Magallanes](https://github.com/and ### Project Status | Branch | Build Status | Code Coverage | | ------- |:------------:|:-------------:| -| Master | [![Build Status](https://travis-ci.org/cyberhouse/Magallanes.svg?branch=master)](https://travis-ci.org/cyberhouse/Magallanes) | [![Coverage Status](https://coveralls.io/repos/github/cyberhouse/Magallanes/badge.svg?branch=master)](https://coveralls.io/github/cyberhouse/Magallanes?branch=master) | -| Develop | [![Build Status](https://travis-ci.org/cyberhouse/Magallanes.svg?branch=develop)](https://travis-ci.org/cyberhouse/Magallanes) | [![Coverage Status](https://coveralls.io/repos/github/cyberhouse/Magallanes/badge.svg?branch=develop)](https://coveralls.io/github/cyberhouse/Magallanes?branch=develop) | +| master | [![Build Status](https://travis-ci.org/cyberhouse/Magallanes.svg?branch=master)](https://travis-ci.org/cyberhouse/Magallanes) | [![Coverage Status](https://coveralls.io/repos/github/cyberhouse/Magallanes/badge.svg?branch=master)](https://coveralls.io/github/cyberhouse/Magallanes?branch=master) | +| 2.0 | [![Build Status](https://travis-ci.org/cyberhouse/Magallanes.svg?branch=2.0)](https://travis-ci.org/cyberhouse/Magallanes) | [![Coverage Status](https://coveralls.io/repos/github/cyberhouse/Magallanes/badge.svg?branch=2.0)](https://coveralls.io/github/cyberhouse/Magallanes?branch=2.0) | ### What's Magallanes? ### Magallanes is a deployment tool for PHP applications; it's quite simple to use and manage. From 7fc3fc2d7045f2b0d7024dc6bb0802b4efd4e49a Mon Sep 17 00:00:00 2001 From: Johannes Pichler Date: Fri, 4 Mar 2016 11:21:49 +0100 Subject: [PATCH 11/15] Update .travis.yml --- .travis.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.travis.yml b/.travis.yml index 13a647c..5a346ef 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,5 +1,8 @@ language: php +notifications: + slack: magallanesteam:o1tIx9lVTyoGy677Dgm7HRap + php: - 5.3 - 5.4 From f1484e5f4d771cd8cfaeab326f834b77d682a341 Mon Sep 17 00:00:00 2001 From: Johannes Pichler Date: Fri, 4 Mar 2016 11:55:07 +0100 Subject: [PATCH 12/15] Update .travis.yml add gitter webhook --- .travis.yml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 5a346ef..389c556 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,7 +1,12 @@ language: php notifications: - slack: magallanesteam:o1tIx9lVTyoGy677Dgm7HRap + webhooks: + urls: + - https://webhooks.gitter.im/e/edf0bb825450673efbf5 + on_success: change + on_failure: always + on_start: never php: - 5.3 From 436348657feb14095a01afab6b9b2ea87e5609db Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Georg=20Gro=C3=9Fberger?= Date: Fri, 7 Oct 2016 20:32:40 +0200 Subject: [PATCH 13/15] Support custom task class name patterns --- Mage/Task/Factory.php | 28 +++++++++++++++++++++++----- 1 file changed, 23 insertions(+), 5 deletions(-) diff --git a/Mage/Task/Factory.php b/Mage/Task/Factory.php index 9384d4c..536e377 100644 --- a/Mage/Task/Factory.php +++ b/Mage/Task/Factory.php @@ -45,13 +45,31 @@ class Factory $taskName = ucwords(str_replace('-', ' ', $taskName)); $taskName = str_replace(' ', '', $taskName); - if (strpos($taskName, '/') === false) { - $className = 'Task\\' . $taskName; - } else { - $className = 'Mage\\Task\\BuiltIn\\' . str_replace(' ', '\\', ucwords(str_replace('/', ' ', $taskName))) . 'Task'; + $patterns = []; + + if (is_array($taskConfig->general('taskPatterns'))) { + $patterns = $taskConfig->general('taskPatterns'); } - if (!class_exists($className)) { + $patterns[] = 'Task\\%s'; + $patterns[] = 'Mage\\Task\\BuiltIn\\%sTask'; + + $className = null; + + $taskClass = trim($taskName, '/\\'); + $taskClass = str_replace(' ', '\\', ucwords(str_replace('/', ' ', $taskClass))); + $taskClass = str_replace(' ', '', ucwords(str_replace('-', ' ', $taskClass))); + + foreach ($patterns as $pattern) { + $possibleClass = sprintf($pattern, $taskClass); + + if (class_exists($possibleClass)) { + $className = $possibleClass; + break; + } + } + + if (!$className) { throw new Exception('Task "' . $taskName . '" not found.'); } From 9b75f33abe6e5ae1bb315ee6e82f0e57b68ad863 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Georg=20Gro=C3=9Fberger?= Date: Fri, 7 Oct 2016 20:38:32 +0200 Subject: [PATCH 14/15] Remove -T parameter from mv command in rollback Resolves: #15 --- Mage/Task/BuiltIn/Releases/RollbackTask.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Mage/Task/BuiltIn/Releases/RollbackTask.php b/Mage/Task/BuiltIn/Releases/RollbackTask.php index 9d9fb4b..dca8767 100644 --- a/Mage/Task/BuiltIn/Releases/RollbackTask.php +++ b/Mage/Task/BuiltIn/Releases/RollbackTask.php @@ -140,7 +140,7 @@ class RollbackTask extends AbstractTask implements IsReleaseAware if ($resultFetch && $userGroup) { $command .= " && chown -h {$userGroup} ${tmplink}"; } - $command .= " && mv -T {$tmplink} {$symlink}"; + $command .= " && mv -f {$tmplink} {$symlink}"; $result = $this->runCommandRemote($command); From c96315103ddbcd1ed540f0c501999e8475389514 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Georg=20Gro=C3=9Fberger?= Date: Fri, 7 Oct 2016 20:44:29 +0200 Subject: [PATCH 15/15] Preserve mtimes when releasing incrementally with rsync --- Mage/Task/BuiltIn/Deployment/Strategy/RsyncTask.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Mage/Task/BuiltIn/Deployment/Strategy/RsyncTask.php b/Mage/Task/BuiltIn/Deployment/Strategy/RsyncTask.php index 16804b0..c9ac298 100644 --- a/Mage/Task/BuiltIn/Deployment/Strategy/RsyncTask.php +++ b/Mage/Task/BuiltIn/Deployment/Strategy/RsyncTask.php @@ -75,10 +75,10 @@ class RsyncTask extends BaseStrategyTaskAbstract implements IsReleaseAware // If copy_tool_rsync, use rsync rather than cp for finer control of what is copied if ($rsync_copy && is_array($rsync_copy) && $rsync_copy['copy'] && $this->runCommandRemote('test -d ' . $releasesDirectory . '/' . $currentRelease)) { if (isset($rsync_copy['copy_tool_rsync'])) { - $this->runCommandRemote("rsync -a {$this->excludes(array_merge($excludes, $rsync_copy['rsync_excludes']))} " + $this->runCommandRemote("rsync -rlptgom {$this->excludes(array_merge($excludes, $rsync_copy['rsync_excludes']))} " . "$releasesDirectory/$currentRelease/ $releasesDirectory/{$this->getConfig()->getReleaseId()}"); } else { - $this->runCommandRemote('cp -R ' . $releasesDirectory . '/' . $currentRelease . ' ' . $releasesDirectory . '/' . $this->getConfig()->getReleaseId()); + $this->runCommandRemote('cp -a ' . $releasesDirectory . '/' . $currentRelease . ' ' . $releasesDirectory . '/' . $this->getConfig()->getReleaseId()); } } else { $this->runCommandRemote('mkdir -p ' . $releasesDirectory . '/' . $this->getConfig()->getReleaseId());