From 4c55857f4012dbba2eac941255026585f409b9d7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tobias=20Lu=CC=88ckel?= Date: Thu, 26 Aug 2021 11:20:58 +0200 Subject: [PATCH 01/17] Added github actions configuration --- .github/workflows/test-and-build.yml | 46 ++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 .github/workflows/test-and-build.yml diff --git a/.github/workflows/test-and-build.yml b/.github/workflows/test-and-build.yml new file mode 100644 index 0000000..f986cfd --- /dev/null +++ b/.github/workflows/test-and-build.yml @@ -0,0 +1,46 @@ +name: Test and build +on: [push, pull_request] +jobs: + test-and-build: + name: '[PHP ${{ matrix.php-version }}] test and build' + runs-on: ubuntu-latest + + strategy: + fail-fast: false + matrix: + php-version: [ 7.1, 7.2, 7.3, 7.4 ] + + steps: + - uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php-version }} + tools: composer:v1 + + - uses: actions/checkout@v2 + + - name: composer install + run: composer install --optimize-autoloader -n + + - name: run lint script + run: ./etc/scripts/lintFiles.sh + shell: bash + + - name: run codingstandard script + run: ./etc/scripts/checkCodingStandards.sh + shell: bash + + - name: run specs script + run: ./etc/scripts/runSpecs.sh + shell: bash + + - name: install kherge/box globally + run: composer global require kherge/box + + - name: box build + run: ${HOME}/.composer/vendor/bin/box build + + - name: info output + run: echo "Built following version:" && php ./build/sd-sw-plugin-manager.phar sd:plugins:info -v + + - name: prepare deployment + run: mv ./build/sd-sw-plugin-manager.phar ./build/sd-sw-plugin-manager.php${TRAVIS_PHP_VERSION}.phar From 0e9286390a0ba0ae53a80d140e93df74db6069d9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tobias=20Lu=CC=88ckel?= Date: Thu, 26 Aug 2021 11:26:09 +0200 Subject: [PATCH 02/17] Changed coding standard file because it is not necessary to have the php version in the filename --- composer.json | 2 +- etc/scripts/checkCodingStandards.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/composer.json b/composer.json index a623333..9cdcbfa 100644 --- a/composer.json +++ b/composer.json @@ -32,7 +32,7 @@ "phpspec-standalone.php7.2.phar": "http://build-tools.cloud.solutiondrive.de/phar/phpspec-standalone.php7.2.phar", "phpspec-standalone.php7.3.phar": "http://build-tools.cloud.solutiondrive.de/phar/phpspec-standalone.php7.3.phar", "ecs-standalone.phar": "http://build-tools.cloud.solutiondrive.de/phar/coding-standard-standalone.ecs.php7.2.phar", - "easy-coding-standard-php7.1.yml": "http://build-tools.cloud.solutiondrive.de/phar/easy-coding-standard-php7.1.yml" + "easy-coding-standard.yml": "http://build-tools.cloud.solutiondrive.de/phar/easy-coding-standard-php7.1.yml" } } } diff --git a/etc/scripts/checkCodingStandards.sh b/etc/scripts/checkCodingStandards.sh index f04d866..e9923da 100755 --- a/etc/scripts/checkCodingStandards.sh +++ b/etc/scripts/checkCodingStandards.sh @@ -1,4 +1,4 @@ #!/usr/bin/env bash FOLDERS="./src ./spec" -vendor/bin/ecs-standalone.phar check --no-progress-bar -n -c vendor/bin/easy-coding-standard-php7.1.yml $FOLDERS $@ +vendor/bin/ecs-standalone.phar check --no-progress-bar -n -c vendor/bin/easy-coding-standard.yml $FOLDERS $@ From 62d306d31d8d44554a6bb4a9c3865e8737bf327f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tobias=20Lu=CC=88ckel?= Date: Thu, 26 Aug 2021 11:27:47 +0200 Subject: [PATCH 03/17] Added status badge to the README --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index cc87cef..5114c8a 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,8 @@ Shopware plugin manager ======================= +[![Test and build](https://github.com/solutionDrive/sdSwPluginManager/actions/workflows/test-and-build.yml/badge.svg)](https://github.com/solutionDrive/sdSwPluginManager/actions/workflows/test-and-build.yml) + This is a CLI based plugin manager that can simply install, uninstall, enable or disable plugins in a shopware shop. The shopware instance needs not to be fully working for this plugin manager to work as it is designed to be independent from the Shopware core itself. From 427d3ad9c3f5cdbc766e505885a48fd824e5fdea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tobias=20Lu=CC=88ckel?= Date: Thu, 26 Aug 2021 11:32:00 +0200 Subject: [PATCH 04/17] Disabled phar.readonly because otherwise the box cannot be build --- .github/workflows/test-and-build.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/test-and-build.yml b/.github/workflows/test-and-build.yml index f986cfd..312bfe9 100644 --- a/.github/workflows/test-and-build.yml +++ b/.github/workflows/test-and-build.yml @@ -14,6 +14,7 @@ jobs: - uses: shivammathur/setup-php@v2 with: php-version: ${{ matrix.php-version }} + ini-values: phar.readonly=off tools: composer:v1 - uses: actions/checkout@v2 From 723e06f193bcac7d01ac67029decc4e9fadfab11 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tobias=20Lu=CC=88ckel?= Date: Thu, 26 Aug 2021 11:35:51 +0200 Subject: [PATCH 05/17] Added php 7.4 to the composer json because it is needed to run the specs --- composer.json | 1 + 1 file changed, 1 insertion(+) diff --git a/composer.json b/composer.json index 9cdcbfa..0ed6571 100644 --- a/composer.json +++ b/composer.json @@ -31,6 +31,7 @@ "phpspec-standalone.php7.1.phar": "http://build-tools.cloud.solutiondrive.de/phar/phpspec-standalone.php7.1.phar", "phpspec-standalone.php7.2.phar": "http://build-tools.cloud.solutiondrive.de/phar/phpspec-standalone.php7.2.phar", "phpspec-standalone.php7.3.phar": "http://build-tools.cloud.solutiondrive.de/phar/phpspec-standalone.php7.3.phar", + "phpspec-standalone.php7.4.phar": "http://build-tools.cloud.solutiondrive.de/phar/phpspec-standalone.php7.4.phar", "ecs-standalone.phar": "http://build-tools.cloud.solutiondrive.de/phar/coding-standard-standalone.ecs.php7.2.phar", "easy-coding-standard.yml": "http://build-tools.cloud.solutiondrive.de/phar/easy-coding-standard-php7.1.yml" } From ebb5bc547aedd335a26e4946e2278849fe49bed5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tobias=20Lu=CC=88ckel?= Date: Thu, 26 Aug 2021 11:38:32 +0200 Subject: [PATCH 06/17] Added a step to create the version file --- .github/workflows/test-and-build.yml | 3 +++ .version.yml.dist | 4 ++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test-and-build.yml b/.github/workflows/test-and-build.yml index 312bfe9..c89e7a2 100644 --- a/.github/workflows/test-and-build.yml +++ b/.github/workflows/test-and-build.yml @@ -22,6 +22,9 @@ jobs: - name: composer install run: composer install --optimize-autoloader -n + - name: create version file + run: versionYaml="$(cat .version.yml.dist | envsubst)" && echo "$versionYaml" > .version.yml + - name: run lint script run: ./etc/scripts/lintFiles.sh shell: bash diff --git a/.version.yml.dist b/.version.yml.dist index 8f9ea50..af920a5 100644 --- a/.version.yml.dist +++ b/.version.yml.dist @@ -1,3 +1,3 @@ version: - tag: "${TRAVIS_BRANCH}" - commit: "${TRAVIS_COMMIT}" + tag: "${GITHUB_REF}" + commit: "${GITHUB_SHA}" From bb2bb4b4a2b31b25c353d2008cdb13092ead8769 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tobias=20Lu=CC=88ckel?= Date: Thu, 26 Aug 2021 13:40:42 +0200 Subject: [PATCH 07/17] Added deploy step --- .github/workflows/test-and-build.yml | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/.github/workflows/test-and-build.yml b/.github/workflows/test-and-build.yml index c89e7a2..51f2d6a 100644 --- a/.github/workflows/test-and-build.yml +++ b/.github/workflows/test-and-build.yml @@ -48,3 +48,13 @@ jobs: - name: prepare deployment run: mv ./build/sd-sw-plugin-manager.phar ./build/sd-sw-plugin-manager.php${TRAVIS_PHP_VERSION}.phar + + - name: deploy + uses: shallwefootball/s3-upload-action@master + id: S3 + with: + aws_key_id: ${{ secrets.S3_BUILD_ACCESS_KEY }} + aws_secret_access_key: ${{ secrets.S3_BUILD_SECRET_KEY }} + aws_bucket: ${{ secrets.S3_BUILD_BUCKET }} + source_dir: 'build' + destination_dir: 'phar' From a08cf15514c88e6f0a2117671fdd5501956b42a0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tobias=20Lu=CC=88ckel?= Date: Thu, 26 Aug 2021 13:53:26 +0200 Subject: [PATCH 08/17] Changed the deploy step to an own job because we want to upload everything at the same time --- .github/workflows/test-and-build.yml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/.github/workflows/test-and-build.yml b/.github/workflows/test-and-build.yml index 51f2d6a..4cb0b8e 100644 --- a/.github/workflows/test-and-build.yml +++ b/.github/workflows/test-and-build.yml @@ -49,6 +49,14 @@ jobs: - name: prepare deployment run: mv ./build/sd-sw-plugin-manager.phar ./build/sd-sw-plugin-manager.php${TRAVIS_PHP_VERSION}.phar + deploy: + runs-on: ubuntu-latest + needs: [test-and-build] + if: + contains(' + refs/heads/master + ', github.ref) + steps: - name: deploy uses: shallwefootball/s3-upload-action@master id: S3 From ff37f448b98c53fc6e62a99d2aeb616802ee7ab1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tobias=20Lu=CC=88ckel?= Date: Thu, 26 Aug 2021 13:53:36 +0200 Subject: [PATCH 09/17] Fixed wrong variable --- .github/workflows/test-and-build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test-and-build.yml b/.github/workflows/test-and-build.yml index 4cb0b8e..f83a5c1 100644 --- a/.github/workflows/test-and-build.yml +++ b/.github/workflows/test-and-build.yml @@ -47,7 +47,7 @@ jobs: run: echo "Built following version:" && php ./build/sd-sw-plugin-manager.phar sd:plugins:info -v - name: prepare deployment - run: mv ./build/sd-sw-plugin-manager.phar ./build/sd-sw-plugin-manager.php${TRAVIS_PHP_VERSION}.phar + run: mv ./build/sd-sw-plugin-manager.phar ./build/sd-sw-plugin-manager.php${matrix.php-version}.phar deploy: runs-on: ubuntu-latest From 67564cd9ec17f7ede400e2fce75d90b1a7629a6c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tobias=20Lu=CC=88ckel?= Date: Thu, 26 Aug 2021 13:57:16 +0200 Subject: [PATCH 10/17] Fix bad substition error --- .github/workflows/test-and-build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test-and-build.yml b/.github/workflows/test-and-build.yml index f83a5c1..0532646 100644 --- a/.github/workflows/test-and-build.yml +++ b/.github/workflows/test-and-build.yml @@ -47,7 +47,7 @@ jobs: run: echo "Built following version:" && php ./build/sd-sw-plugin-manager.phar sd:plugins:info -v - name: prepare deployment - run: mv ./build/sd-sw-plugin-manager.phar ./build/sd-sw-plugin-manager.php${matrix.php-version}.phar + run: mv ./build/sd-sw-plugin-manager.phar ./build/sd-sw-plugin-manager.php${{matrix.php-version}}.phar deploy: runs-on: ubuntu-latest From 4a9c93d0d7785db62adafaba3a9ccf0f021c5392 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tobias=20Lu=CC=88ckel?= Date: Thu, 26 Aug 2021 13:59:13 +0200 Subject: [PATCH 11/17] Removed travis related stuff, because it is not needed anymore --- .php.travis.ini | 1 - .travis.yml | 50 ------------------------------------------------- 2 files changed, 51 deletions(-) delete mode 100644 .php.travis.ini delete mode 100644 .travis.yml diff --git a/.php.travis.ini b/.php.travis.ini deleted file mode 100644 index 95eb3c9..0000000 --- a/.php.travis.ini +++ /dev/null @@ -1 +0,0 @@ -error_reporting = E_ALL & ~E_NOTICE diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 4438155..0000000 --- a/.travis.yml +++ /dev/null @@ -1,50 +0,0 @@ -language: php -dist: bionic -sudo: false - -php: - - '7.1' - - '7.2' - - '7.3' - -env: - global: - - S3_BUCKET="build-tools.cloud.solutiondrive.de" - - secure: "B5P5TLTUi4oUBCGNpHUY258NFV5/4WjxHrM/27TiV0J4uuYcqcme5J9O5NTU6OGxxweM1XA5mkApvf8lMmI5uelQfnR6fPRzx+a4LTLOGFwoJJ+/ZZcw3bjAlV5RUeJocMUG1F0ohNMoJkV0Du8+YOSoSicFfRkh6nOuv4pzMgUSPIqHqGCvLBoQ1Z1WxZIlRSlwmgyPMYBquRp5uS2td5xf4Yg/VQ0XKdt31oiOLyuh5jPJeK4fBYEvbLIHidAR+geQLscj4OS9xfTHphTonFU7G7czC+7Drb3XdRQxod86GFUAiADRzbclmhzqBDps934VjmLStV/pD6GBxqciUU3oT7GxXGf0rpq3bAnRdeo4/f8Mk7mwa20HgZPKqw1k44LpUva2hFLPvDjazOkHPAPwp9oXw1q7xKDnDszRRbUANkjBzVIj7oosxXs9Aqat1wN4nzLUAlQdEZ+7Go323gTq7K4ID5qHsWnzvQGP2QSi0NbvKRfAhANIsP46YiAlbSvvit3ZItdQjCpfevAtDHbuMretl9hwW8SGYxGcLzrc2HnBYi0uIYAgmBzYiedfxNx2M8rVhhcaq51jh6VmGM0kDZaHKkPofxXTCmZdUIqXIM9B+hwTIPX4Y7tV2gSV6MPWQ36yflUkc/6FyxqXKrX9g1GV3z028uQcekn3wtY=" - - secure: "BqKu9oGWPbT50MttdoQAg5GbvCaz4Lan5fK+czB7SzWUoQX4sW6PeTd3KmhzO1f4Kc3ivxIx/193t0kZAfHx90htmdNL5RSGN5acAthSgWbGjPP1+N8KcVhp3ms5LmyZDbUORbVzvuXzT0uVFuH//x90vwROkunXPFqNpO0/NUnIfAwPSel5vCDyfihRfypU3GhFRWF5vaQPkVdT/naOyzAeTbIhFPNCQkl4UooZ4OXOPnCQkT8HlEn7hma/fvgWafuen+Y5W8qEXTq/KLJVsK6LhnW4voKOiNpTNF8oPx7J4n1+EHh9wFxCQQImzs0fx4SDQCrFkS2hu9wcFpTYssmqILAcWihGLlu3TNUPyW/fUp5Q3u35CqjuHMqN7yR4DPHTd5kH7+69Hqo+Pecwb8DOgiVkdrvjIsJdbLxlCmjTlIoAXEKMLEfwI0TEbN6klYnn/f7317eUkuT/x0oQMXu1Ub3lYR73h9K0K+H1R3BVabPdZu6bm8Vsk9qXmVLPK6pVYfaDC/KXgy2Jxol4A4l44cTfrbJsyezqaKGcqQvz/wYf4wx/Jlnh9dsevG5065FHg6rULeNHh8B44KSMnusN/B3QOr4eXc1ygg/0pbFSwPeUdHdxNP4el+iB4wPVFHbMGTi0VI3AeZ9+DqT9ds27pDPBcic6//OpkiYMxv4=" - -before_install: - - phpenv config-add .php.travis.ini - - export PATH=$PATH:$HOME/.composer/vendor/bin - - travis_retry composer self-update --1; - -install: - - composer install --optimize-autoloader -n - -before_script: - - versionYaml="$(cat .version.yml.dist | envsubst)" - - echo "$versionYaml" > .version.yml - -script: - - ./etc/scripts/lintFiles.sh - - if [ "${TRAVIS_PHP_VERSION}" == "7.3" ]; then ./etc/scripts/checkCodingStandards.sh ; fi - - ./etc/scripts/runSpecs.sh - -before_deploy: - - composer global require kherge/box - - ${HOME}/.config/composer/vendor/bin/box build - - echo "Built following version:" && php ./build/sd-sw-plugin-manager.phar sd:plugins:info -v - - mv ./build/sd-sw-plugin-manager.phar ./build/sd-sw-plugin-manager.php${TRAVIS_PHP_VERSION}.phar - -deploy: - provider: s3 - access_key_id: "${S3_ACCESS_KEY}" - secret_access_key: "${S3_SECRET_KEY}" - bucket: "${S3_BUCKET}" - skip_cleanup: true - region: "eu-central-1" - local_dir: "build" - upload-dir: "phar" - acl: "public-read" - on: - branch: master From dcbf9fd8643c768bac47ee75c0a84103742eea15 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tobias=20Lu=CC=88ckel?= Date: Thu, 26 Aug 2021 15:06:36 +0200 Subject: [PATCH 12/17] Added an output for the .version.yml file because it is easier to check the correct output of the info command --- .github/workflows/test-and-build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test-and-build.yml b/.github/workflows/test-and-build.yml index 0532646..f2e92bb 100644 --- a/.github/workflows/test-and-build.yml +++ b/.github/workflows/test-and-build.yml @@ -44,7 +44,7 @@ jobs: run: ${HOME}/.composer/vendor/bin/box build - name: info output - run: echo "Built following version:" && php ./build/sd-sw-plugin-manager.phar sd:plugins:info -v + run: cat .version.yml && echo "Built following version:" && php ./build/sd-sw-plugin-manager.phar sd:plugins:info -v - name: prepare deployment run: mv ./build/sd-sw-plugin-manager.phar ./build/sd-sw-plugin-manager.php${{matrix.php-version}}.phar From a2a9e6c4e1fd5b396c10b3051e96bbc81847a88f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tobias=20Lu=CC=88ckel?= Date: Wed, 15 Sep 2021 12:12:13 +0200 Subject: [PATCH 13/17] Fixed broken master build --- spec/Entity/ConfiguredPluginStateSpec.php | 2 +- spec/Repository/StateFileSpec.php | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/spec/Entity/ConfiguredPluginStateSpec.php b/spec/Entity/ConfiguredPluginStateSpec.php index 08ae1eb..b326f34 100644 --- a/spec/Entity/ConfiguredPluginStateSpec.php +++ b/spec/Entity/ConfiguredPluginStateSpec.php @@ -82,7 +82,7 @@ public function it_has_default_parameters(): void false ); - $this->getAlwaysReinstall()->shouldReturn(true); + $this->getAlwaysReinstall()->shouldReturn(false); $this->getRemoveDataOnReinstall()->shouldReturn(false); $this->getAlwaysClearCache()->shouldReturn(false); } diff --git a/spec/Repository/StateFileSpec.php b/spec/Repository/StateFileSpec.php index 18bb650..c3360ab 100644 --- a/spec/Repository/StateFileSpec.php +++ b/spec/Repository/StateFileSpec.php @@ -57,7 +57,7 @@ public function it_can_read_from_array_and_get_plugins( 'testPlugin2' => [ 'provider' => 'http', 'version' => '1', - 'alwaysReinstall' => false, + 'alwaysReinstall' => true, 'removeDataOnReinstall' => true, 'alwaysClearCache' => true, ], @@ -73,7 +73,7 @@ public function it_can_read_from_array_and_get_plugins( 'installed' => true, 'activated' => true, 'env' => [], - 'alwaysReinstall' => true, + 'alwaysReinstall' => false, 'removeDataOnReinstall' => false, 'alwaysClearCache' => false, ]) @@ -90,7 +90,7 @@ public function it_can_read_from_array_and_get_plugins( 'installed' => true, 'activated' => true, 'env' => [], - 'alwaysReinstall' => false, + 'alwaysReinstall' => true, 'removeDataOnReinstall' => true, 'alwaysClearCache' => true, ]) From 62f404b0af8e358532df7903f3fe1e43b4ee69d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tobias=20Lu=CC=88ckel?= Date: Tue, 21 Sep 2021 10:41:45 +0200 Subject: [PATCH 14/17] Moved the deploy step to the test-and-build job because otherwise we needed to up- and download the phar files between the steps --- .github/workflows/test-and-build.yml | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/.github/workflows/test-and-build.yml b/.github/workflows/test-and-build.yml index f2e92bb..d9e0a2a 100644 --- a/.github/workflows/test-and-build.yml +++ b/.github/workflows/test-and-build.yml @@ -49,15 +49,11 @@ jobs: - name: prepare deployment run: mv ./build/sd-sw-plugin-manager.phar ./build/sd-sw-plugin-manager.php${{matrix.php-version}}.phar - deploy: - runs-on: ubuntu-latest - needs: [test-and-build] - if: - contains(' - refs/heads/master - ', github.ref) - steps: - name: deploy + if: + contains(' + refs/heads/master + ', github.ref) uses: shallwefootball/s3-upload-action@master id: S3 with: From 541e376f8e065b360efedee5e1ec9e285ae69bb0 Mon Sep 17 00:00:00 2001 From: Julius Noack Date: Tue, 8 Nov 2022 10:34:19 +0100 Subject: [PATCH 15/17] add composer2 support --- composer.json | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 0ed6571..e89e19e 100644 --- a/composer.json +++ b/composer.json @@ -23,7 +23,8 @@ ], "require-dev": { "mikey179/vfsstream": "^1.6", - "solutiondrive/standalone-build-tools": "^1.0" + "solutiondrive/standalone-build-tools": "^2.0", + "symfony/var-dumper": "^2.1" }, "config": { "sort-packages": true, @@ -34,6 +35,9 @@ "phpspec-standalone.php7.4.phar": "http://build-tools.cloud.solutiondrive.de/phar/phpspec-standalone.php7.4.phar", "ecs-standalone.phar": "http://build-tools.cloud.solutiondrive.de/phar/coding-standard-standalone.ecs.php7.2.phar", "easy-coding-standard.yml": "http://build-tools.cloud.solutiondrive.de/phar/easy-coding-standard-php7.1.yml" + }, + "allow-plugins": { + "solutiondrive/standalone-build-tools": true } } } From be4c53f25f281804625ee21be79e24fce1331e44 Mon Sep 17 00:00:00 2001 From: Julius Noack Date: Tue, 8 Nov 2022 10:35:35 +0100 Subject: [PATCH 16/17] add multistage support by allow adding multiple env options and filter plugin accordingly --- src/Command/AutomaticDeployCommand.php | 44 ++++++++++++++++---------- 1 file changed, 27 insertions(+), 17 deletions(-) diff --git a/src/Command/AutomaticDeployCommand.php b/src/Command/AutomaticDeployCommand.php index 6cc8487..33fbad3 100644 --- a/src/Command/AutomaticDeployCommand.php +++ b/src/Command/AutomaticDeployCommand.php @@ -63,9 +63,9 @@ protected function configure(): void ->addOption( 'env', 'e', - InputOption::VALUE_REQUIRED, - 'The current environment to use for plugin filtering', - 'production' + InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY, + 'The current environment(s) to use for plugin filtering, when using multiple only the first one is used for shopware commands.', + ['production'] ) ->addOption( 'skip-download', @@ -105,7 +105,8 @@ protected function execute( $forceDownload = (bool) $input->getOption('force-download'); $skipInstall = (bool) $input->getOption('skip-install'); - $environment = $input->getOption('env'); + $environments = $input->getOption('env'); + $yamlStateFilePath = $input->getArgument('statefile'); if (false === \is_readable($yamlStateFilePath)) { throw new \RuntimeException( @@ -122,7 +123,7 @@ protected function execute( if (false === $skipDownload) { foreach ($this->stateFile->getPlugins() as $configuredPluginState) { // Skip if plugin should not be installed in the current environment - if ($this->skipPluginByEnviroment($environment, $configuredPluginState->getEnvironments())) { + if ($this->skipPluginByEnviroments($environments, $configuredPluginState->getEnvironments())) { continue; } @@ -151,13 +152,13 @@ protected function execute( if (false === $skipInstall) { $refreshPluginCommand = new ArrayInput([ 'command' => 'sd:plugins:refresh', - '--env' => $environment, + '--env' => $environments[0], ]); $app->run($refreshPluginCommand, $output); $pluginListCommand = new ArrayInput([ 'command' => 'sd:plugin:list', - '--env' => $environment, + '--env' => $environments[0], ]); $bufferedOutput = new BufferedOutput($output->getVerbosity(), $output->isDecorated()); @@ -168,7 +169,7 @@ protected function execute( // And now install and activate all plugins (if configured) foreach ($this->stateFile->getPlugins() as $configuredPluginState) { // Skip if plugin should not be installed in the current environment - if ($this->skipPluginByEnviroment($environment, $configuredPluginState->getEnvironments())) { + if ($this->skipPluginByEnviroments($environments, $configuredPluginState->getEnvironments())) { continue; } @@ -176,7 +177,7 @@ protected function execute( $parameters = [ 'command' => 'sd:plugins:install', 'pluginId' => $configuredPluginState->getId(), - '--env' => $environment, + '--env' => $environments[0], ]; if (false === $configuredPluginState->getAlwaysReinstall()) { @@ -206,7 +207,7 @@ protected function execute( 'command' => 'sd:plugins:uninstall', '--secure' => true, 'pluginId' => $configuredPluginState->getId(), - '--env' => $environment, + '--env' => $environments[0], ]; if ($configuredPluginState->getAlwaysClearCache()) { @@ -222,7 +223,7 @@ protected function execute( $parameters = [ 'command' => 'sd:plugins:activate', 'pluginId' => $configuredPluginState->getId(), - '--env' => $environment, + '--env' => $environments[0], ]; if ($configuredPluginState->getAlwaysClearCache()) { @@ -235,7 +236,7 @@ protected function execute( $parameters = [ 'command' => 'sd:plugins:deactivate', 'pluginId' => $configuredPluginState->getId(), - '--env' => $environment, + '--env' => $environments[0], ]; if ($configuredPluginState->getAlwaysClearCache()) { @@ -264,14 +265,23 @@ protected function execute( } /** + * @param string[] $currentEnvironments * @param string[] $targetEnvironments */ - private function skipPluginByEnviroment( - string $currentEnvironment, + private function skipPluginByEnviroments( + array $currentEnvironments, array $targetEnvironments ): bool { - return - false === empty($targetEnvironments) && - false === \in_array($currentEnvironment, $targetEnvironments); + if (empty($targetEnvironments)) { + return false; + } + + foreach ($currentEnvironments as $environment) { + if (\in_array($environment, $targetEnvironments)) { + return false; + } + } + + return true; } } From 6ac8d2d6c2914f4eb7b44185325ea16dab6d44ba Mon Sep 17 00:00:00 2001 From: Julius Noack Date: Thu, 10 Nov 2022 11:27:07 +0100 Subject: [PATCH 17/17] fix unexpected behavior by respecting environment and clear cache parameters in update --- src/Command/AutomaticDeployCommand.php | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/Command/AutomaticDeployCommand.php b/src/Command/AutomaticDeployCommand.php index 33fbad3..4205d28 100644 --- a/src/Command/AutomaticDeployCommand.php +++ b/src/Command/AutomaticDeployCommand.php @@ -196,10 +196,17 @@ protected function execute( $app->run($input, $output); if ($this->pluginVersionService->pluginNeedsUpdate($configuredPluginState)) { - $updatePluginCommand = new ArrayInput([ + $parameters = [ 'command' => 'sd:plugin:update', 'plugin' => $configuredPluginState->getId(), - ]); + '--env' => $environments[0], + ]; + + if ($configuredPluginState->getAlwaysClearCache()) { + $parameters['--clear-cache'] = null; + } + + $updatePluginCommand = new ArrayInput($parameters); $app->run($updatePluginCommand, $output); } } else {