From 80ff37ca7f340fa41791f43bdf879a6fa6547cf2 Mon Sep 17 00:00:00 2001 From: Henrique Moody Date: Thu, 27 Aug 2020 16:48:26 +0200 Subject: [PATCH] Configure continuous integration with GitHub actions This commit will also remove Travis and Scrutinizer and will configure Codecov as a code coverage tool. A few changes in the PHPUnit configuration already had to be made before, but became more visible now. They're along with this commit. Signed-off-by: Henrique Moody --- .github/workflows/continuous-integration.yml | 116 +++++++++++++++++++ .gitignore | 1 + .scrutinizer.yml | 37 ------ .travis.yml | 55 --------- README.md | 5 +- phpunit.xml.dist | 27 +++-- 6 files changed, 136 insertions(+), 105 deletions(-) create mode 100644 .github/workflows/continuous-integration.yml delete mode 100644 .scrutinizer.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 00000000..90d7e41f --- /dev/null +++ b/.github/workflows/continuous-integration.yml @@ -0,0 +1,116 @@ +name: Continuous Integration + +on: + push: + paths-ignore: + - 'bin/**' + - 'docs/**' + pull_request: + paths-ignore: + - 'bin/**' + - 'docs/**' + +jobs: + tests: + name: Tests + + runs-on: ubuntu-latest + continue-on-error: ${{ matrix.experimental }} + + strategy: + matrix: + php-version: + - "7.3" + - "7.4" + experimental: [false] + include: + - php-version: 8.0 + experimental: true + + steps: + - name: Checkout + uses: actions/checkout@v2 + + - name: Install PHP + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php-version }} + coverage: none + extensions: uopz + tools: pecl + + - name: Install localisation files + run: | + sudo locale-gen --no-purge --lang nl_NL.UTF-8 + sudo locale-gen --no-purge --lang pt_BR.UTF-8 + sudo locale-gen --no-purge --lang ru_RU.UTF-8 + + - name: Install dependencies + run: composer install --prefer-dist + + - name: Run unit tests + run: vendor/bin/phpunit --testsuite=unit + + - name: Run integration tests + run: vendor/bin/phpunit --testsuite=integration + + code-coverage: + name: Code coverage + + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v2 + + - name: Install PHP + uses: shivammathur/setup-php@v2 + with: + php-version: 7.4 + coverage: pcov + extensions: uopz + tools: pecl + + - name: Install localisation files + run: | + sudo locale-gen --no-purge --lang nl_NL.UTF-8 + sudo locale-gen --no-purge --lang pt_BR.UTF-8 + sudo locale-gen --no-purge --lang ru_RU.UTF-8 + + - name: Install dependencies + run: composer install --prefer-dist + + - name: Generating code coverage report + run: vendor/bin/phpunit --coverage-clover=coverage.xml + + - name: Send code coverage report to Codecov.io + uses: codecov/codecov-action@v1 + with: + token: ${{ secrets.CODECOV_TOKEN }} + + static-analysis: + name: Static analysis + + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v2 + + - name: Install PHP + uses: shivammathur/setup-php@v2 + with: + php-version: 7.4 + coverage: none + + - name: Install dependencies + run: composer install --prefer-dist + + - name: Run DocHeader + run: vendor/bin/docheader check library/ tests/ + + - name: Run PHP_CodeSniffer + run: vendor/bin/phpcs + + - name: Run PHPStan + run: vendor/bin/phpstan analyze diff --git a/.gitignore b/.gitignore index 9d78b7eb..b39342ff 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ .couscous/ .phpcs.cache +.phpunit.result.cache composer.lock Makefile phpcs.xml diff --git a/.scrutinizer.yml b/.scrutinizer.yml deleted file mode 100644 index dc883158..00000000 --- a/.scrutinizer.yml +++ /dev/null @@ -1,37 +0,0 @@ -filter: - excluded_paths: - - tests/* - -checks: - php: - code_rating: true - -tools: - external_code_coverage: true - php_analyzer: true - php_changetracking: true - php_code_sniffer: - config: - standard: "PSR2" - php_cpd: true - php_mess_detector: true - php_pdepend: true - sensiolabs_security_checker: true - -build: - environment: - mysql: false - postgresql: false - mongodb: false - elasticsearch: false - redis: false - memcached: false - neo4j: false - rabbitmq: false - nodes: - analysis: - project_setup: - override: true - tests: - override: - - php-scrutinizer-run --enable-security-analysis diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 90e56dca..00000000 --- a/.travis.yml +++ /dev/null @@ -1,55 +0,0 @@ -sudo: false -language: php - -php: - - 7.3 - - 7.4 - - nightly - -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 install - - sudo locale-gen --no-purge --lang nl_NL.UTF-8 - - sudo locale-gen --no-purge --lang pt_BR.UTF-8 - - sudo locale-gen --no-purge --lang ru_RU.UTF-8 - - pecl install uopz || echo "Cound not install uopz" 1>&2 - -script: - - vendor/bin/phpunit --testsuite=unit --verbose --colors - - vendor/bin/phpunit --testsuite=integration --verbose --colors - -jobs: - allow_failures: - - php: nightly - - include: - - stage: Quality assurance - env: CODE_COVERAGE - before_script: - - mv ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini{.disabled,} - - if [[ ! $(php -m | grep -si xdebug) ]]; then echo "xdebug required for coverage"; exit 1; fi - script: vendor/bin/phpunit --coverage-clover ./clover.xml - after_script: - - wget https://scrutinizer-ci.com/ocular.phar - - php ocular.phar code-coverage:upload --format=php-clover ./clover.xml - - - stage: Quality assurance - env: DOCHEADER - install: travis_retry composer install - script: vendor/bin/docheader check library/ tests/ - - - stage: Quality assurance - env: CODE_STANDARD - install: travis_retry composer install - script: vendor/bin/phpcs - - - stage: Quality assurance - env: STATIC_ANALYSIS - install: travis_retry composer install - script: vendor/bin/phpstan analyze diff --git a/README.md b/README.md index d02494ea..2eb73f0f 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,7 @@ # Respect\Validation -[![Build Status](https://img.shields.io/travis/Respect/Validation/master.svg?style=flat-square)](http://travis-ci.org/Respect/Validation) -[![Scrutinizer Code Quality](https://img.shields.io/scrutinizer/g/Respect/Validation/master.svg?style=flat-square)](https://scrutinizer-ci.com/g/Respect/Validation/?branch=master) -[![Code Coverage](https://img.shields.io/scrutinizer/coverage/g/Respect/Validation/master.svg?style=flat-square)](https://scrutinizer-ci.com/g/Respect/Validation/?branch=master) +[![Build Status](https://img.shields.io/github/workflow/status/Respect/Validation/Continuous%20Integration/master?style=flat-square)](https://github.com/Respect/Validation/actions?query=workflow%3A%22Continuous+Integration%22) +[![Code Coverage](https://img.shields.io/codecov/c/github/Respect/Validation?style=flat-square)](https://codecov.io/gh/Respect/Validation) [![Latest Stable Version](https://img.shields.io/packagist/v/respect/validation.svg?style=flat-square)](https://packagist.org/packages/respect/validation) [![Total Downloads](https://img.shields.io/packagist/dt/respect/validation.svg?style=flat-square)](https://packagist.org/packages/respect/validation) [![License](https://img.shields.io/packagist/l/respect/validation.svg?style=flat-square)](https://packagist.org/packages/respect/validation) diff --git a/phpunit.xml.dist b/phpunit.xml.dist index b9a87735..d0c51721 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -1,19 +1,26 @@ - + - - - tests/unit/ - - - tests/integration/ - - + + + tests/unit/ + + + tests/integration/ + + + + + library/ + +