From 4a0d9b76597b1e2318a6bbe0d628ff2002829e10 Mon Sep 17 00:00:00 2001 From: SirDomin Date: Wed, 11 Nov 2020 10:16:15 +0100 Subject: [PATCH] Introduce github Actions --- .github/workflows/build.yml | 170 ++++++++++++++++++++++++++++++++++++ .travis.yml | 91 ------------------- composer.json | 7 +- 3 files changed, 174 insertions(+), 94 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..db289cd6 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,170 @@ +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 + 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 + tools: symfony + coverage: none + + - + name: Setup Node + uses: actions/setup-node@v1 + with: + node-version: "${{ matrix.node }}" + + - + name: Require Sylius + run: composer require sylius/sylius:${{ matrix.sylius }} --no-interaction --no-update + + - + name: Sylius 1.8 conflicts + if: matrix.sylius == '1.8.*' + run: | + composer require sylius-labs/doctrine-migrations-extra-bundle --no-interaction --no-update + cp etc/travis/sylius18/bundles.php tests/Application/config/ + cp etc/travis/sylius18/doctrine_migrations.yaml tests/Application/config/packages/ + cp etc/travis/sylius18/lexik_jwt_authentication.yaml tests/Application/config/packages/ + cp etc/travis/sylius18/security.yaml tests/Application/config/packages/ + cp etc/travis/sylius18/sylius_api.yaml tests/Application/config/routes/ + rm tests/Application/src/Migrations/Version20200604080033.php + + - + 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: 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: Install PHP dependencies + run: composer install --no-interaction + + - + 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: | + cp -R migrations/* tests/Application/src/Migrations/ + (cd tests/Application && bin/console doctrine:database: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) + composer link-templates + + - + 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: Run analysis + run: composer analyse + + - + 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 7a2759c8..00000000 --- a/.travis.yml +++ /dev/null @@ -1,91 +0,0 @@ -language: php - -os: linux - -dist: bionic - -jobs: - include: - - php: '7.4' - env: SYLIUS_VERSION=1.7.* - - php: '7.4' - env: SYLIUS_VERSION=1.8.* - -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}" - - - cp -R migrations/* tests/Application/src/Migrations/ - -install: - - composer require sylius/sylius:${SYLIUS_VERSION} --no-interaction --no-update - - | - if [ $SYLIUS_VERSION = "1.8.*" ]; then - composer require sylius-labs/doctrine-migrations-extra-bundle --no-interaction --no-update - cp etc/travis/sylius18/bundles.php tests/Application/config/ - cp etc/travis/sylius18/doctrine_migrations.yaml tests/Application/config/packages/ - cp etc/travis/sylius18/lexik_jwt_authentication.yaml tests/Application/config/packages/ - cp etc/travis/sylius18/security.yaml tests/Application/config/packages/ - cp etc/travis/sylius18/sylius_api.yaml tests/Application/config/routes/ - rm tests/Application/src/Migrations/Version20200604080033.php - fi - - composer update --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:migrations:migrate -n -vvv) - - (cd tests/Application && bin/console assets:install public -vvv) - - (cd tests/Application && bin/console cache:warmup -vvv) - - (cd tests/Application && yarn build) - - - composer link-templates - - # Downloading 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 - - # 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 - - composer analyse - - - vendor/bin/phpunit - - vendor/bin/phpspec run - - vendor/bin/behat -vvv --no-interaction || vendor/bin/behat -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 8878dc1e..e391935c 100644 --- a/composer.json +++ b/composer.json @@ -58,14 +58,15 @@ } }, "scripts": { - "fix": [ - "vendor/bin/ecs check src/ spec/ --fix" - ], "analyse": [ + "@composer validate --strict", "vendor/bin/ecs check src/ spec/", "vendor/bin/phpstan.phar analyse -c phpstan.neon -l max src/", "vendor/bin/psalm" ], + "fix": [ + "vendor/bin/ecs check src/ spec/ --fix" + ], "link-templates": [ "ln -s $(pwd)/src/Resources/views/bundles/* $(pwd)/tests/Application/templates/bundles" ]