From 0be0b31585d6734f8c45fc089eab2a328c092fec Mon Sep 17 00:00:00 2001 From: Benjamin Eberlei Date: Sun, 18 Oct 2020 00:18:28 +0200 Subject: [PATCH] Use Github actions for phpunit, remove Travis CI --- .github/workflows/continuous-integration.yml | 61 ++++++++++++++++++++ .github/workflows/static-analysis.yml | 45 +++++++++++++++ .travis.yml | 44 -------------- 3 files changed, 106 insertions(+), 44 deletions(-) create mode 100644 .github/workflows/continuous-integration.yml create mode 100644 .github/workflows/static-analysis.yml delete mode 100644 .travis.yml diff --git a/.github/workflows/continuous-integration.yml b/.github/workflows/continuous-integration.yml new file mode 100644 index 000000000..d81974cc7 --- /dev/null +++ b/.github/workflows/continuous-integration.yml @@ -0,0 +1,61 @@ +name: "Continuous Integration" + +on: + pull_request: + branches: + - "*.x" + - "master" + push: + branches: + - "*.x" + - "master" + +jobs: + phpunit: + name: "PHPUnit" + runs-on: "ubuntu-20.04" + + strategy: + matrix: + php-version: + - "7.1" + - "7.2" + - "7.3" + - "7.4" + - "8.0" + deps: + - "normal" + include: + - deps: "low" + php-version: "7.2" + + steps: + - name: "Checkout" + uses: "actions/checkout@v2" + with: + fetch-depth: 2 + + - name: "Install PHP" + uses: "shivammathur/setup-php@v2" + with: + php-version: "${{ matrix.php-version }}" + coverage: "pcov" + ini-values: "zend.assertions=1" + + - name: "Cache dependencies installed with composer" + uses: "actions/cache@v2" + with: + path: "~/.composer/cache" + key: "php-${{ matrix.php-version }}-composer-locked-${{ hashFiles('composer.lock') }}" + restore-keys: "php-${{ matrix.php-version }}-composer-locked-" + + - name: "Update dependencies with composer" + run: "composer update --no-interaction --no-progress --no-suggest" + if: "${{ matrix.deps == 'normal' }}" + + - name: "Install lowest possible dependencies with composer" + run: "composer update --no-interaction --no-progress --no-suggest --prefer-dist --prefer-lowest" + if: "${{ matrix.deps == 'low' }}" + + - name: "Run PHPUnit" + run: "vendor/bin/phpunit" diff --git a/.github/workflows/static-analysis.yml b/.github/workflows/static-analysis.yml new file mode 100644 index 000000000..eca2fe87e --- /dev/null +++ b/.github/workflows/static-analysis.yml @@ -0,0 +1,45 @@ +name: "Static Analysis" + +on: + pull_request: + branches: + - "*.x" + - "master" + push: + branches: + - "*.x" + - "master" + +jobs: + static-analysis-phpstan: + name: "Static Analysis with PHPStan" + runs-on: "ubuntu-20.04" + + strategy: + matrix: + php-version: + - "7.4" + + steps: + - name: "Checkout code" + uses: "actions/checkout@v2" + + - name: "Install PHP" + uses: "shivammathur/setup-php@v2" + with: + coverage: "none" + php-version: "${{ matrix.php-version }}" + tools: "cs2pr" + + - name: "Cache dependencies installed with composer" + uses: "actions/cache@v2" + with: + path: "~/.composer/cache" + key: "php-${{ matrix.php-version }}-composer-locked-${{ hashFiles('composer.lock') }}" + restore-keys: "php-${{ matrix.php-version }}-composer-locked-" + + - name: "Install dependencies with composer" + run: "composer install --no-interaction --no-progress --no-suggest" + + - name: "Run a static analysis with phpstan/phpstan" + run: "vendor/bin/phpstan analyse -l 3 -c phpstan.neon --error-format=checkstyle lib/ tests/ | cs2pr" diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 349cd2a1c..000000000 --- a/.travis.yml +++ /dev/null @@ -1,44 +0,0 @@ -dist: xenial - -language: php - -php: - - 7.2 - - 7.3 - - 7.4 - -cache: - directories: - - $HOME/.composer/cache - -before_install: - - mv ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini{,.disabled} || echo "xdebug not available" - -install: travis_retry composer update --prefer-dist - -script: - - ./vendor/bin/phpunit - -jobs: - allow_failures: - - php: nightly - - include: - - stage: Test - php: nightly - before_install: - - composer config platform.php 7.4.99 - - - stage: Lint - before_script: - - travis_retry composer require --dev --prefer-dist --prefer-stable phpstan/phpstan:^0.12.20 - script: vendor/bin/phpstan analyse -l 3 -c phpstan.neon lib tests - php: 7.4 - - - stage: Benchmark - install: - - travis_retry composer update --prefer-dist - - curl -o phpbench.phar https://phpbench.github.io/phpbench/phpbench.phar - - curl -o phpbench.phar.pubkey https://phpbench.github.io/phpbench/phpbench.phar.pubkey - script: php phpbench.phar run - php: 7.4