From 4b59c622562b8574eeea2db9ae345a907edc2918 Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Tue, 3 Nov 2020 15:31:56 +0100 Subject: [PATCH] Replace Travis and Appveyor by GitHub Actions --- .github/workflows/ci.yaml | 68 ++++++++++++++++++++++++++++ .github/workflows/lint.yaml | 88 +++++++++++++++++++++++++++++++++++++ .travis.yml | 81 ---------------------------------- appveyor.yml | 54 ----------------------- 4 files changed, 156 insertions(+), 135 deletions(-) create mode 100644 .github/workflows/ci.yaml create mode 100644 .github/workflows/lint.yaml delete mode 100644 .travis.yml delete mode 100644 appveyor.yml diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml new file mode 100644 index 000000000..b4209712c --- /dev/null +++ b/.github/workflows/ci.yaml @@ -0,0 +1,68 @@ +name: "CI" + +on: + pull_request: + push: + branches: + - 'master' + +env: + fail-fast: true + PHPUNIT_FLAGS: "-v" + SYMFONY_PHPUNIT_DIR: "$HOME/symfony-bridge/.phpunit" + SYMFONY_REQUIRE: ">=4.4" + +jobs: + test: + name: "${{ matrix.operating-system }} / PHP ${{ matrix.php-version }}" + runs-on: ${{ matrix.operating-system }} + continue-on-error: ${{ matrix.allow-failures }} + + strategy: + matrix: + operating-system: ['ubuntu-latest', 'windows-latest', 'macos-latest'] + php-version: ['7.2.9', '7.3', '7.4', '8.0'] + + steps: + - name: "Checkout code" + uses: actions/checkout@v2.3.3 + + - name: "Install PHP with extensions" + uses: shivammathur/setup-php@2.7.0 + with: + coverage: "none" + extensions: "intl, mbstring, pdo_sqlite" + php-version: ${{ matrix.php-version }} + tools: composer:v2 + + - name: "Add PHPUnit matcher" + run: echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json" + + - name: "Set composer cache directory" + id: composer-cache + run: echo "::set-output name=dir::$(composer config cache-files-dir)" + + - name: "Cache composer" + uses: actions/cache@v2.1.2 + with: + path: ${{ steps.composer-cache.outputs.dir }} + key: ${{ runner.os }}-${{ matrix.php-version }}-composer-${{ hashFiles('composer.json') }} + restore-keys: ${{ runner.os }}-${{ matrix.php-version }}-composer- + + - name: "Require symfony/flex" + run: composer global require --no-progress --no-scripts --no-plugins symfony/flex dev-main + + - if: matrix.php-version != '8.0' + run: composer update + + - if: matrix.php-version == '8.0' + run: composer update --ignore-platform-reqs=php + + - name: "Install PHPUnit" + run: vendor/bin/simple-phpunit install + + - name: "PHPUnit version" + run: vendor/bin/simple-phpunit --version + + - name: "Run tests" + run: vendor/bin/simple-phpunit ${{ env.PHPUNIT_FLAGS }} diff --git a/.github/workflows/lint.yaml b/.github/workflows/lint.yaml new file mode 100644 index 000000000..2a2254007 --- /dev/null +++ b/.github/workflows/lint.yaml @@ -0,0 +1,88 @@ +name: "Lint" + +on: [push, pull_request] + +env: + fail-fast: true + +jobs: + php-cs-fixer: + name: PHP-CS-Fixer + runs-on: ubuntu-latest + steps: + - name: "Checkout code" + uses: actions/checkout@v2 + + - name: PHP-CS-Fixer + uses: docker://oskarstark/php-cs-fixer-ga + with: + args: --diff --dry-run + + linters: + name: Linters + runs-on: ubuntu-latest + strategy: + matrix: + php-version: ['7.4'] + + steps: + - name: "Checkout code" + uses: actions/checkout@v2.3.3 + + - name: "Install PHP with extensions" + uses: shivammathur/setup-php@2.7.0 + with: + coverage: "none" + extensions: intl + php-version: ${{ matrix.php-version }} + tools: composer:v2 + + - name: "Set composer cache directory" + id: composer-cache + run: echo "::set-output name=dir::$(composer config cache-files-dir)" + + - name: "Cache composer" + uses: actions/cache@v2.1.2 + with: + path: ${{ steps.composer-cache.outputs.dir }} + key: ${{ runner.os }}-${{ matrix.php-version }}-composer-${{ hashFiles('composer.json') }} + restore-keys: ${{ runner.os }}-${{ matrix.php-version }}-composer- + + - name: "Require symfony/flex" + run: composer global require --no-progress --no-scripts --no-plugins symfony/flex dev-main + + - name: "Composer update" + id: install + run: composer update --no-scripts + + - name: Lint YAML files + if: always() && steps.install.outcome == 'success' + run: ./bin/console lint:yaml config --parse-tags + + - name: Lint Twig templates + if: always() && steps.install.outcome == 'success' + run: ./bin/console lint:twig templates --env=prod + + - name: Lint XLIFF translations + if: always() && steps.install.outcome == 'success' + run: ./bin/console lint:xliff translations + + - name: Lint Parameters and Services + if: always() && steps.install.outcome == 'success' + run: ./bin/console lint:container + + - name: Lint Doctrine entities + if: always() && steps.install.outcome == 'success' + run: ./bin/console doctrine:schema:validate --skip-sync -vvv --no-interaction + + - name: Lint Composer config + if: always() && steps.install.outcome == 'success' + run: composer validate --strict + + - name: Download Symfony CLI + if: always() && steps.install.outcome == 'success' + run: wget https://get.symfony.com/cli/installer -O - | bash + + - name: Check if any dependencies are compromised + if: always() && steps.install.outcome == 'success' + run: /home/runner/.symfony/bin/symfony check:security diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 6ab5f8be3..000000000 --- a/.travis.yml +++ /dev/null @@ -1,81 +0,0 @@ -# Ensure that PHP is installed in Travis' build environment. Travis provides several versions of -# PHP like 5.6, 7.0, 7.1, 7.2, 7.3, 7.4, etc., each of them including XDebug and PHPUnit. -language: php - -# Travis can cache content between builds. This speeds up the build process and saves resources. -cache: - yarn: true - directories: - # Cache composer packages so "composer install" is faster. - - $HOME/.composer/cache/files - # Cache the directory where Symfony stores its slightly modified version of PHPUnit. - - ./bin/.phpunit - # Cache the Symfony binary's directory so that it does not have to be reinstalled. - - $HOME/.symfony - -env: - global: - # Symfony's PHPUnit bridge provides a modified version of PHPUnit. The modified PHPUnit is - # written to a directory that can be configured by the SYMFONY_PHPUNIT_DIR env var, or in - # the same directory as the simple-phpunit if it is not provided. It's also possible to set - # this env var in the phpunit.xml.dist file. - - SYMFONY_PHPUNIT_DIR=./bin/.phpunit - - SYMFONY_DEPRECATIONS_HELPER=6 - - ACTION="install" - # Add the Symfony binary's path to PATH. - - PATH="$HOME/.symfony/bin:$PATH" - -# Defines all jobs which Travis will run in parallel. For each PHP version we support we will run one job. -jobs: - # With fast finishing enabled, Travis CI will mark your build as finished as soon as one of two - # conditions are met: The only remaining jobs are allowed to fail, or a job has already failed. In - # these cases, the status of the build can already be determined, so there’s no need to wait around - # until the other jobs finish. - fast_finish: true - include: - # Run tests with the dependencies from composer.lock - - php: 7.2 - - php: 7.4 - - php: nightly - # Run tests against dev-master (currently 5.2.x-dev) - - php: 7.4 - env: STABILITY=dev SYMFONY=5.* ACTION=update - allow_failures: - - php: nightly - -before_install: - - phpenv config-rm xdebug.ini || true - # Change minimum-stability to allow upcoming versions (dev | alpha | beta | RC) - - '[[ -z $STABILITY ]] || composer config minimum-stability "$STABILITY"' - # Change extra.symfony.require used by symfony flex - - '[[ -z $SYMFONY ]] || composer config extra.symfony.require "$SYMFONY"' - # If it is available update the Symfony binary, if not install it. - - if symfony self:version; then symfony self:update --yes ; else wget https://get.symfony.com/cli/installer -O - | bash ; fi - -install: - - php -r "echo ini_get('memory_limit').PHP_EOL;" - # Install or update Composer packages including dev dependencies listed in require-dev. - - COMPOSER_MEMORY_LIMIT=-1 composer $ACTION - - ./bin/phpunit install - -script: - # There's no need to load data fixtures before running tests because the project - # repository already includes a test database with all the fixtures needed to run the tests. - - ./bin/phpunit - # This checks that the source code follows the Symfony Code Syntax rules. - - '[[ $TRAVIS_PHP_VERSION != "7.4" ]] || ./vendor/bin/php-cs-fixer fix --diff --dry-run -v' - # This checks that the YAML config files contain no syntax errors. - - ./bin/console lint:yaml config --parse-tags - # This checks that the Twig template files contain no syntax errors. - - ./bin/console lint:twig templates --env=prod - # This checks that the XLIFF translations contain no syntax errors. - - ./bin/console lint:xliff translations - # This checks that arguments injected into services match type declarations. - - ./bin/console lint:container - # This checks that the application doesn't use dependencies with known security vulnerabilities. - - symfony check:security - # This checks that Doctrine's mapping configurations are valid. - - ./bin/console doctrine:schema:validate --skip-sync -vvv --no-interaction - # Fail CI if the repo is in a dirty state after building assets (only for current release ie install). - #- if [[ "$ACTION" == "install" ]]; then yarn install && yarn encore production && git add --all && git diff --staged --exit-code; fi - - composer validate --strict diff --git a/appveyor.yml b/appveyor.yml deleted file mode 100644 index ff416821a..000000000 --- a/appveyor.yml +++ /dev/null @@ -1,54 +0,0 @@ -build: false -clone_depth: 1 -clone_folder: c:\projects\symfony-demo - -cache: - - '%LOCALAPPDATA%\Composer\files' - - '%LOCALAPPDATA%\SymfonyBridge\phpunit' - - c:\projects\symfony-demo\composer.phar - -init: - - SET PATH=c:\php;%PATH% - - SET COMPOSER_NO_INTERACTION=1 - - SET SYMFONY_DEPRECATIONS_HELPER=strict - - SET SYMFONY_PHPUNIT_DIR=%LOCALAPPDATA%\SymfonyBridge\phpunit - - SET ANSICON=121x90 (121x90) - - REG ADD "HKEY_CURRENT_USER\Software\Microsoft\Command Processor" /v DelayedExpansion /t REG_DWORD /d 1 /f - -install: - - mkdir c:\php && cd c:\php - - appveyor DownloadFile https://raw.githubusercontent.com/symfony/binary-utils/master/cacert.pem - - appveyor DownloadFile https://github.com/symfony/binary-utils/releases/download/v0.1/php-7.1.3-Win32-VC14-x86.zip - - 7z x php-7.1.3-Win32-VC14-x86.zip -y >nul - - del /Q *.zip - - cd ext - - appveyor DownloadFile https://github.com/symfony/binary-utils/releases/download/v0.1/php_apcu-5.1.8-7.1-ts-vc14-x86.zip - - 7z x php_apcu-5.1.8-7.1-ts-vc14-x86.zip -y >nul - - del /Q *.zip - - cd .. - - copy /Y php.ini-development php.ini - - echo max_execution_time=1200 >> php.ini - - echo date.timezone="America/Los_Angeles" >> php.ini - - echo extension_dir=ext >> php.ini - - echo zend_extension=php_opcache.dll >> php.ini - - echo opcache.enable_cli=1 >> php.ini - - echo extension=php_openssl.dll >> php.ini - - echo extension=php_apcu.dll >> php.ini - - echo apc.enable_cli=1 >> php.ini - - echo extension=php_intl.dll >> php.ini - - echo extension=php_mbstring.dll >> php.ini - - echo extension=php_fileinfo.dll >> php.ini - - echo extension=php_pdo_sqlite.dll >> php.ini - - echo extension=php_curl.dll >> php.ini - - echo curl.cainfo=c:\php\cacert.pem >> php.ini - - cd c:\projects\symfony-demo - - IF NOT EXIST composer.phar (appveyor DownloadFile https://getcomposer.org/download/1.3.0/composer.phar) - - php composer.phar self-update - - IF %APPVEYOR_REPO_BRANCH%==master (SET COMPOSER_ROOT_VERSION=dev-master) ELSE (SET COMPOSER_ROOT_VERSION=%APPVEYOR_REPO_BRANCH%.x-dev) - - php composer.phar update --no-progress --ansi - - SET COMPOSER_ROOT_VERSION= - - vendor\bin\simple-phpunit install - -test_script: - - cd c:\projects\symfony-demo - - vendor/bin/simple-phpunit