From b28fbeee14650d8ff3d9fa1570cb52a2b93ac17e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Bundyra?= Date: Mon, 1 Mar 2021 20:44:46 +0000 Subject: [PATCH] Move to Github Actions from Travis CI Add the following workflows: - Unit Tests - phpunit - Coding Standards - phpcs - Coverage - run tests with coverage and upload to coveralls --- .github/workflows/coverage.yml | 29 ++++++++++++++++ .github/workflows/phpcs.yml | 24 +++++++++++++ .github/workflows/phpunit.yml | 31 +++++++++++++++++ .travis.yml | 63 ---------------------------------- README.md | 3 +- 5 files changed, 86 insertions(+), 64 deletions(-) create mode 100644 .github/workflows/coverage.yml create mode 100644 .github/workflows/phpcs.yml create mode 100644 .github/workflows/phpunit.yml delete mode 100644 .travis.yml diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml new file mode 100644 index 00000000..964b5d58 --- /dev/null +++ b/.github/workflows/coverage.yml @@ -0,0 +1,29 @@ +name: Coverage + +on: [push, pull_request] + +jobs: + coverage: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v2 + + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: 7.4 + + - name: Install dependencies + run: composer install --no-progress --no-suggest --optimize-autoloader + + - name: Add coveralls dependency + run: composer require --dev php-coveralls/php-coveralls --no-progress --no-suggest --no-interaction + + - name: Run tests with coverage + run: composer test-coverage + + - name: Upload coverage to Coveralls + env: + COVERALLS_REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: php vendor/bin/php-coveralls -v diff --git a/.github/workflows/phpcs.yml b/.github/workflows/phpcs.yml new file mode 100644 index 00000000..7cb215dc --- /dev/null +++ b/.github/workflows/phpcs.yml @@ -0,0 +1,24 @@ +name: Coding Standards + +on: [push, pull_request] + +jobs: + phpcs: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v2 + + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: 7.4 + + - name: Validate composer.json + run: composer validate --strict + + - name: Install dependencies + run: composer install --no-progress --no-suggest --optimize-autoloader + + - name: Run CS checks + run: composer cs-check diff --git a/.github/workflows/phpunit.yml b/.github/workflows/phpunit.yml new file mode 100644 index 00000000..a4e83101 --- /dev/null +++ b/.github/workflows/phpunit.yml @@ -0,0 +1,31 @@ +name: Unit Tests + +on: [push, pull_request] + +jobs: + phpunit: + runs-on: ubuntu-latest + strategy: + fail-fast: false + max-parallel: 15 + matrix: + dependencies: ['lowest', 'latest'] + php-versions: ['7.3', '7.4', '8.0'] + name: PHP ${{ matrix.php-versions }}, ${{ matrix.dependencies }} dependencies + steps: + - name: Checkout + uses: actions/checkout@v2 + + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php-versions }} + + - name: Install dependencies + env: + DEPS: ${{ matrix.dependencies }} + run: | + if [[ $DEPS != 'lowest' ]]; then composer update --no-progress --no-suggest --prefer-lowest --prefer-stable --optimize-autoloader ; else composer update --no-progress --no-suggest --prefer-dist --optimize-autoloader ; fi + + - name: Run tests + run: composer test diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 096ecf48..00000000 --- a/.travis.yml +++ /dev/null @@ -1,63 +0,0 @@ -language: php - -cache: - directories: - - $HOME/.composer/cache - -env: - global: - - COMPOSER_ARGS="--no-interaction" - - COVERAGE_DEPS="php-coveralls/php-coveralls" - -matrix: - fast_finish: true - include: - - php: 7.3 - env: - - DEPS=lowest - - php: 7.3 - env: - - DEPS=locked - - CS_CHECK=true - - TEST_COVERAGE=true - - php: 7.3 - env: - - DEPS=latest - - php: 7.4 - env: - - DEPS=lowest - - php: 7.4 - env: - - DEPS=locked - - php: 7.4 - env: - - DEPS=latest - - php: 8.0 - env: - - DEPS=lowest - - COMPOSER_ARGS="--no-interaction --ignore-platform-reqs" - - php: 8.0 - env: - - DEPS=latest - - COMPOSER_ARGS="--no-interaction --ignore-platform-reqs" - -before_install: - - if [[ $TEST_COVERAGE != 'true' ]]; then phpenv config-rm xdebug.ini || true ; fi - -install: - - composer validate --strict - - travis_retry composer install $COMPOSER_ARGS --ignore-platform-reqs - - if [[ $DEPS == 'latest' ]]; then travis_retry composer update $COMPOSER_ARGS ; fi - - if [[ $DEPS == 'lowest' ]]; then travis_retry composer update $COMPOSER_ARGS --prefer-lowest --prefer-stable ; fi - - if [[ $TEST_COVERAGE == 'true' ]]; then travis_retry composer require --dev $COMPOSER_ARGS $COVERAGE_DEPS ; fi - - composer show | cat - -script: - - if [[ $TEST_COVERAGE == 'true' ]]; then composer test-coverage ; else composer test ; fi - - if [[ $CS_CHECK == 'true' ]]; then composer cs-check ; fi - -after_script: - - if [[ $TEST_COVERAGE == 'true' ]]; then travis_retry php vendor/bin/php-coveralls -v ; fi - -notifications: - email: false diff --git a/README.md b/README.md index 2ad34a38..c096a2fb 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,7 @@ # Webimpress Coding Standard -[![Build Status](https://travis-ci.com/webimpress/coding-standard.svg?branch=master)](https://travis-ci.com/webimpress/coding-standard) +[![Unit Tests](https://github.com/webimpress/coding-standard/actions/workflows/phpunit.yml/badge.svg)](https://github.com/webimpress/coding-standard/actions/workflows/phpunit.yml) +[![Coding Standards](https://github.com/webimpress/coding-standard/actions/workflows/phpcs.yml/badge.svg)](https://github.com/webimpress/coding-standard/actions/workflows/phpcs.yml) [![Coverage Status](https://coveralls.io/repos/github/webimpress/coding-standard/badge.svg?branch=master)](https://coveralls.io/github/webimpress/coding-standard?branch=master) ## Installation