From bd0d7a33710429b0a6bbb082ad26e3156e6fc61f Mon Sep 17 00:00:00 2001 From: Clemence Date: Fri, 4 Dec 2020 14:33:35 +0100 Subject: [PATCH 1/3] intialize Github Actions add build file remove typo remove psalm in build file change behat feature change composer.json add sylius 1.8 add gt extension in setup php Rollback composer file --- .github/workflows/build.yml | 177 ++++++++++++++++++ .travis.yml | 77 -------- composer.json | 6 +- .../previewing_order_before_creation.feature | 4 +- 4 files changed, 184 insertions(+), 80 deletions(-) create mode 100644 .github/workflows/build.yml delete mode 100644 .travis.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 00000000..05bb7e2a --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,177 @@ +name: Build + +on: + push: ~ + pull_request: ~ + release: + types: [created] + schedule: + - + cron: "0 1 * * 6" # Run at 1am every Saturday + +jobs: + tests: + runs-on: ubuntu-latest + + name: "PHP ${{ matrix.php }}, MySQL ${{ matrix.mysql }}, Sylius ${{ matrix.sylius }}" + + strategy: + fail-fast: false + matrix: + php: [7.4, 7.3] + node: [10.x] + mysql: [5.7, 8.0] + sylius: [1.7.*, 1.8.*] + + exclude: + - # PHP 7.3 does not support "caching_sha2_password" authentication plugin which is a default one in MySQL 8.0 + php: 7.3 + mysql: 8.0 + + env: + APP_ENV: test + DATABASE_URL: "mysql://root:root@127.0.0.1/sylius?serverVersion=${{ matrix.mysql }}" + + steps: + - + uses: actions/checkout@v2 + + - + name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: "${{ matrix.php }}" + extensions: intl, gd + tools: symfony + coverage: none + + - + name: Setup Node + uses: actions/setup-node@v1 + with: + node-version: "${{ matrix.node }}" + + - + name: Shutdown default MySQL + run: sudo service mysql stop + + - + name: Setup MySQL + uses: mirromutth/mysql-action@v1.1 + with: + mysql version: "${{ matrix.mysql }}" + mysql root password: "root" + + - + name: Output PHP version for Symfony CLI + run: php -v | head -n 1 | awk '{ print $2 }' > .php-version + + - + name: Install certificates + run: symfony server:ca:install + + - + name: Run Chrome Headless + run: google-chrome-stable --enable-automation --disable-background-networking --no-default-browser-check --no-first-run --disable-popup-blocking --disable-default-apps --allow-insecure-localhost --disable-translate --disable-extensions --no-sandbox --enable-features=Metal --headless --remote-debugging-port=9222 --window-size=2880,1800 --proxy-server='direct://' --proxy-bypass-list='*' http://127.0.0.1 > /dev/null 2>&1 & + + - + name: Run webserver + run: (cd tests/Application && symfony server:start --port=8080 --dir=public --daemon) + + - + name: Get Composer cache directory + id: composer-cache + run: echo "::set-output name=dir::$(composer config cache-files-dir)" + + - + name: Cache Composer + uses: actions/cache@v2 + with: + path: ${{ steps.composer-cache.outputs.dir }} + key: ${{ runner.os }}-php-${{ matrix.php }}-composer-${{ hashFiles('**/composer.json **/composer.lock') }} + restore-keys: | + ${{ runner.os }}-php-${{ matrix.php }}-composer- + + - + name: Prepare migrations for Sylius 1.8 + if: matrix.sylius == '1.8.*' + run: | + composer require sylius-labs/doctrine-migrations-extra-bundle --no-interaction --no-update + + - + name: Install Sylius version + run: | + composer require "sylius/sylius:${{ matrix.sylius }}" --no-update + + - + name: Install PHP dependencies + run: composer install --no-interaction --prefer-dist + + - + name: Get Yarn cache directory + id: yarn-cache + run: echo "::set-output name=dir::$(yarn cache dir)" + + - + name: Cache Yarn + uses: actions/cache@v2 + with: + path: ${{ steps.yarn-cache.outputs.dir }} + key: ${{ runner.os }}-node-${{ matrix.node }}-yarn-${{ hashFiles('**/package.json **/yarn.lock') }} + restore-keys: | + ${{ runner.os }}-node-${{ matrix.node }}-yarn- + - + name: Install JS dependencies + run: (cd tests/Application && yarn install) + + - + name: Prepare test application database + run: | + (cd tests/Application && bin/console doctrine:database:create -vvv) + (cd tests/Application && bin/console doctrine:schema:create -vvv) + + - + name: Prepare test application assets + run: | + (cd tests/Application && bin/console assets:install public -vvv) + (cd tests/Application && yarn build) + - + name: Prepare test application cache + run: (cd tests/Application && bin/console cache:warmup -vvv) + + - + name: Load fixtures in test application + run: (cd tests/Application && bin/console sylius:fixtures:load -n) + + - + name: Validate composer.json + run: composer validate --ansi --strict + + - + name: Validate database schema + run: (cd tests/Application && bin/console doctrine:schema:validate) + + - + name: Run PHPStan + run: vendor/bin/phpstan analyse -c phpstan.neon -l max src/ + + - + name: Run PHPSpec + run: vendor/bin/phpspec run --ansi -f progress --no-interaction + + - + name: Run PHPUnit + run: vendor/bin/phpunit --colors=always + + - + name: Run Behat + run: vendor/bin/behat --colors --strict -vvv --no-interaction || vendor/bin/behat --colors --strict -vvv --no-interaction --rerun + + - + name: Upload Behat logs + uses: actions/upload-artifact@v2 + if: failure() + with: + name: Behat logs + path: etc/build/ + if-no-files-found: ignore diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 5b3c07dd..00000000 --- a/.travis.yml +++ /dev/null @@ -1,77 +0,0 @@ -language: php - -os: linux - -dist: bionic - -php: - - '7.3' - - '7.4' - -services: - - mysql - -addons: - apt: - sources: - - google-chrome - packages: - - google-chrome-stable - chrome: stable - -cache: - yarn: true - directories: - - ~/.composer/cache/files - - $SYLIUS_CACHE_DIR - -env: - global: - - APP_ENV=test - - SYLIUS_CACHE_DIR=$HOME/.sylius-cache - - SYLIUS_BUILD_DIR=etc/build - -before_install: - - phpenv config-rm xdebug.ini - - echo "memory_limit=4096M" >> ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/travis.ini - - mkdir -p "${SYLIUS_CACHE_DIR}" - -install: - - composer install --no-interaction --prefer-dist - - (cd tests/Application && yarn install) - -before_script: - - (cd tests/Application && bin/console doctrine:database:create -vvv) - - (cd tests/Application && bin/console doctrine:schema:create -vvv) - - (cd tests/Application && bin/console assets:install public -vvv) - - (cd tests/Application && bin/console cache:warmup -vvv) - - (cd tests/Application && yarn build) - - # Download Symfony CLI - - | - if [ ! -f $SYLIUS_CACHE_DIR/symfony ]; then - wget https://get.symfony.com/cli/installer -O - | bash - mv ~/.symfony/bin/symfony $SYLIUS_CACHE_DIR - fi - php -v | head -n 1 | awk '{ print $2 }' > .php-version - - # Install certificates - - $SYLIUS_CACHE_DIR/symfony server:ca:install - - # Run Chrome Headless - - google-chrome-stable --enable-automation --disable-background-networking --no-default-browser-check --no-first-run --disable-popup-blocking --disable-default-apps --allow-insecure-localhost --disable-translate --disable-extensions --no-sandbox --enable-features=Metal --headless --remote-debugging-port=9222 --window-size=2880,1800 --proxy-server='direct://' --proxy-bypass-list='*' http://127.0.0.1 > /dev/null 2>&1 & - - # Run webserver - - (cd tests/Application && $SYLIUS_CACHE_DIR/symfony server:start --port=8080 --dir=public --daemon) - -script: - - composer validate - - - vendor/bin/phpstan analyse -c phpstan.neon -l max src/ - - - vendor/bin/phpunit - - vendor/bin/phpspec run - - vendor/bin/behat --strict -vvv --no-interaction || vendor/bin/behat --strict -vvv --no-interaction --rerun - -after_failure: - - vendor/lakion/mink-debug-extension/travis/tools/upload-textfiles "${SYLIUS_BUILD_DIR}/*.log" diff --git a/composer.json b/composer.json index 8bb303d4..ac71e870 100644 --- a/composer.json +++ b/composer.json @@ -21,7 +21,7 @@ "require": { "php": "^7.3", - "sylius/sylius": "^1.7", + "sylius/sylius": "^1.7|^1.8", "friendsofsymfony/jsrouting-bundle": "^2.2" }, "require-dev": { @@ -66,8 +66,12 @@ }, "scripts": { "analyse": [ + "@composer validate --strict", "vendor/bin/phpstan analyse -c phpstan.neon -l max src/", "vendor/bin/ecs check src/ spec/" + ], + "fix": [ + "vendor/bin/ecs check src/ spec/ --fix" ] }, "extra": { diff --git a/features/creating_order/previewing_order_before_creation.feature b/features/creating_order/previewing_order_before_creation.feature index 3f8cb2a3..ec8fc23e 100644 --- a/features/creating_order/previewing_order_before_creation.feature +++ b/features/creating_order/previewing_order_before_creation.feature @@ -24,9 +24,9 @@ Feature: Previewing order before creation And I select "Free" shipping method And I select "Cash on Delivery" payment method And I place this order - Then I should see preview of the order with total "PLN100.00" + Then I should see preview of the order with total "PLN 100.00" And this order should contain "Stark Coat" product - And its shipping total should be "PLN0.00" + And its shipping total should be "PLN 0.00" And it should have one "Cash on Delivery" payment And it should have "English (United States)" locale And it should have "PLN" currency From e1b0814e395b17ea5a31eee0392620d05d6c435c Mon Sep 17 00:00:00 2001 From: GSadee Date: Tue, 13 Apr 2021 07:26:27 +0200 Subject: [PATCH 2/3] Fixes to GitHub Actions build configuration --- .github/workflows/build.yml | 33 +++++++++++++++++++++------------ composer.json | 2 +- 2 files changed, 22 insertions(+), 13 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 05bb7e2a..341c424e 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -13,15 +13,16 @@ jobs: tests: runs-on: ubuntu-latest - name: "PHP ${{ matrix.php }}, MySQL ${{ matrix.mysql }}, Sylius ${{ matrix.sylius }}" + name: "Sylius ${{ matrix.sylius }}, PHP ${{ matrix.php }}, Symfony ${{ matrix.symfony }}, MySQL ${{ matrix.mysql }}" strategy: fail-fast: false matrix: - php: [7.4, 7.3] + php: [7.3, 7.4] + symfony: [^4.4] + sylius: [~1.7.0] node: [10.x] mysql: [5.7, 8.0] - sylius: [1.7.*, 1.8.*] exclude: - # PHP 7.3 does not support "caching_sha2_password" authentication plugin which is a default one in MySQL 8.0 @@ -93,19 +94,20 @@ jobs: ${{ runner.os }}-php-${{ matrix.php }}-composer- - - name: Prepare migrations for Sylius 1.8 - if: matrix.sylius == '1.8.*' + name: Restrict Symfony version + if: matrix.symfony != '' run: | - composer require sylius-labs/doctrine-migrations-extra-bundle --no-interaction --no-update + composer global require --no-progress --no-scripts --no-plugins "symfony/flex:^1.10" + composer config extra.symfony.require "${{ matrix.symfony }}" - - name: Install Sylius version - run: | - composer require "sylius/sylius:${{ matrix.sylius }}" --no-update + name: Restrict Sylius version + if: matrix.sylius != '' + run: composer require "sylius/sylius:${{ matrix.sylius }}" --no-update --no-scripts --no-interaction - name: Install PHP dependencies - run: composer install --no-interaction --prefer-dist + run: composer update --no-interaction - name: Get Yarn cache directory @@ -120,6 +122,7 @@ jobs: key: ${{ runner.os }}-node-${{ matrix.node }}-yarn-${{ hashFiles('**/package.json **/yarn.lock') }} restore-keys: | ${{ runner.os }}-node-${{ matrix.node }}-yarn- + - name: Install JS dependencies run: (cd tests/Application && yarn install) @@ -127,14 +130,16 @@ jobs: - name: Prepare test application database run: | + (cp migrations/* tests/Application/src/Migrations/) (cd tests/Application && bin/console doctrine:database:create -vvv) - (cd tests/Application && bin/console doctrine:schema:create -vvv) + (cd tests/Application && bin/console doctrine:migrations:migrate -n -vvv -q) - name: Prepare test application assets run: | (cd tests/Application && bin/console assets:install public -vvv) (cd tests/Application && yarn build) + - name: Prepare test application cache run: (cd tests/Application && bin/console cache:warmup -vvv) @@ -151,6 +156,10 @@ jobs: name: Validate database schema run: (cd tests/Application && bin/console doctrine:schema:validate) + - + name: Run security check + run: symfony security:check + - name: Run PHPStan run: vendor/bin/phpstan analyse -c phpstan.neon -l max src/ @@ -165,7 +174,7 @@ jobs: - name: Run Behat - run: vendor/bin/behat --colors --strict -vvv --no-interaction || vendor/bin/behat --colors --strict -vvv --no-interaction --rerun + run: vendor/bin/behat --colors --strict -vvv --no-interaction -f progress || vendor/bin/behat --colors --strict -vvv --no-interaction -f progress --rerun - name: Upload Behat logs diff --git a/composer.json b/composer.json index ac71e870..f2b0c04f 100644 --- a/composer.json +++ b/composer.json @@ -21,7 +21,7 @@ "require": { "php": "^7.3", - "sylius/sylius": "^1.7|^1.8", + "sylius/sylius": "^1.7", "friendsofsymfony/jsrouting-bundle": "^2.2" }, "require-dev": { From 4053c7fadb7724189f3138603e983bc01a618088 Mon Sep 17 00:00:00 2001 From: GSadee Date: Tue, 13 Apr 2021 07:48:24 +0200 Subject: [PATCH 3/3] Add missing migrations for Sylius 1.7 --- .../src/Migrations/Version20191119131635.php | 25 +++++++++++ .../src/Migrations/Version20200301170604.php | 45 +++++++++++++++++++ .../src/Migrations/Version20200916093101.php | 32 +++++++++++++ 3 files changed, 102 insertions(+) create mode 100644 tests/Application/src/Migrations/Version20191119131635.php create mode 100644 tests/Application/src/Migrations/Version20200301170604.php create mode 100644 tests/Application/src/Migrations/Version20200916093101.php diff --git a/tests/Application/src/Migrations/Version20191119131635.php b/tests/Application/src/Migrations/Version20191119131635.php new file mode 100644 index 00000000..35e53199 --- /dev/null +++ b/tests/Application/src/Migrations/Version20191119131635.php @@ -0,0 +1,25 @@ +abortIf($this->connection->getDatabasePlatform()->getName() !== 'mysql', 'Migration can only be executed safely on \'mysql\'.'); + + $this->addSql('ALTER TABLE sylius_channel ADD type VARCHAR(255) DEFAULT NULL'); + } + + public function down(Schema $schema): void + { + $this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'mysql', 'Migration can only be executed safely on \'mysql\'.'); + + $this->addSql('ALTER TABLE sylius_channel DROP type'); + } +} diff --git a/tests/Application/src/Migrations/Version20200301170604.php b/tests/Application/src/Migrations/Version20200301170604.php new file mode 100644 index 00000000..1ae247c5 --- /dev/null +++ b/tests/Application/src/Migrations/Version20200301170604.php @@ -0,0 +1,45 @@ +abortIf($this->connection->getDatabasePlatform()->getName() !== 'mysql', 'Migration can only be executed safely on \'mysql\'.'); + + $this->addSql('CREATE TABLE sylius_channel_countries (channel_id INT NOT NULL, country_id INT NOT NULL, INDEX IDX_D96E51AE72F5A1AA (channel_id), INDEX IDX_D96E51AEF92F3E70 (country_id), PRIMARY KEY(channel_id, country_id)) DEFAULT CHARACTER SET UTF8 COLLATE `UTF8_unicode_ci` ENGINE = InnoDB'); + $this->addSql('ALTER TABLE sylius_channel_countries ADD CONSTRAINT FK_D96E51AE72F5A1AA FOREIGN KEY (channel_id) REFERENCES sylius_channel (id) ON DELETE CASCADE'); + $this->addSql('ALTER TABLE sylius_channel_countries ADD CONSTRAINT FK_D96E51AEF92F3E70 FOREIGN KEY (country_id) REFERENCES sylius_country (id) ON DELETE CASCADE'); + $this->addSql('ALTER TABLE sylius_shipment ADD shipped_at DATETIME DEFAULT NULL'); + $this->addSql('ALTER TABLE sylius_channel ADD menu_taxon_id INT DEFAULT NULL, DROP type'); + $this->addSql('ALTER TABLE sylius_channel ADD CONSTRAINT FK_16C8119EF242B1E6 FOREIGN KEY (menu_taxon_id) REFERENCES sylius_taxon (id) ON DELETE SET NULL'); + $this->addSql('CREATE INDEX IDX_16C8119EF242B1E6 ON sylius_channel (menu_taxon_id)'); + } + + public function down(Schema $schema): void + { + // this down() migration is auto-generated, please modify it to your needs + $this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'mysql', 'Migration can only be executed safely on \'mysql\'.'); + + $this->addSql('DROP TABLE sylius_channel_countries'); + $this->addSql('ALTER TABLE sylius_channel DROP FOREIGN KEY FK_16C8119EF242B1E6'); + $this->addSql('DROP INDEX IDX_16C8119EF242B1E6 ON sylius_channel'); + $this->addSql('ALTER TABLE sylius_channel ADD type VARCHAR(255) CHARACTER SET utf8 DEFAULT NULL COLLATE `utf8_unicode_ci`, DROP menu_taxon_id'); + $this->addSql('ALTER TABLE sylius_shipment DROP shipped_at'); + } +} diff --git a/tests/Application/src/Migrations/Version20200916093101.php b/tests/Application/src/Migrations/Version20200916093101.php new file mode 100644 index 00000000..eb7bb3b9 --- /dev/null +++ b/tests/Application/src/Migrations/Version20200916093101.php @@ -0,0 +1,32 @@ +abortIf($this->connection->getDatabasePlatform()->getName() !== 'mysql', 'Migration can only be executed safely on \'mysql\'.'); + + $this->addSql('ALTER TABLE sylius_channel_pricing CHANGE price price INT DEFAULT NULL'); + } + + public function down(Schema $schema): void + { + // this down() migration is auto-generated, please modify it to your needs + $this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'mysql', 'Migration can only be executed safely on \'mysql\'.'); + + $this->addSql('ALTER TABLE sylius_channel_pricing CHANGE price price INT NOT NULL'); + } +}