diff --git a/.github/workflows/quicktest.yml b/.github/workflows/quicktest.yml index d00eec5d3c..417766cc02 100644 --- a/.github/workflows/quicktest.yml +++ b/.github/workflows/quicktest.yml @@ -54,7 +54,7 @@ jobs: run: php bin/phpcs --config-set php_path php - name: 'PHPUnit: run the tests' - run: vendor/bin/phpunit tests/AllTests.php + run: vendor/bin/phpunit tests/AllTests.php --no-coverage # Note: The code style check is run as an integration test. - name: 'PHPCS: check code style without cache, no parallel' diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 7dcf4f41b4..ef2fd41465 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -69,16 +69,31 @@ jobs: # Keys: # - custom_ini: Whether to run with specific custom ini settings to hit very specific # code conditions. + # - coverage: Whether to run the tests with code coverage. matrix: - php: ['5.4', '5.5', '5.6', '7.0', '7.1', '7.2', '7.3', '7.4', '8.0', '8.1', '8.2', '8.3', '8.4'] + php: ['5.5', '5.6', '7.0', '7.1', '7.3', '7.4', '8.0', '8.1', '8.2', '8.4'] custom_ini: [false] + coverage: [false] include: # Builds running the basic tests with different PHP ini settings. - php: '5.5' custom_ini: true + coverage: false - php: '7.0' custom_ini: true + coverage: false + + # Builds running the tests with code coverage. + - php: '5.4' + custom_ini: false + coverage: true + - php: '7.2' + custom_ini: true + coverage: true + - php: '8.3' + custom_ini: false + coverage: true name: "PHP: ${{ matrix.php }} ${{ matrix.custom_ini && ' with custom ini settings' || '' }}" @@ -93,9 +108,9 @@ jobs: run: | # Set the "short_open_tag" ini to make sure specific conditions are tested. # Also turn on error_reporting to ensure all notices are shown. - if [[ ${{ matrix.custom_ini }} == true && "${{ matrix.php }}" == '5.5' ]]; then + if [[ ${{ matrix.custom_ini }} == true && "${{ startsWith( matrix.php, '5.' ) }}" == true ]]; then echo 'PHP_INI=error_reporting=-1, display_errors=On, date.timezone=Australia/Sydney, short_open_tag=On, asp_tags=On' >> $GITHUB_OUTPUT - elif [[ ${{ matrix.custom_ini }} == true && "${{ matrix.php }}" == '7.0' ]]; then + elif [[ ${{ matrix.custom_ini }} == true && "${{ startsWith( matrix.php, '7.' ) }}" == true ]]; then echo 'PHP_INI=error_reporting=-1, display_errors=On, date.timezone=Australia/Sydney, short_open_tag=On' >> $GITHUB_OUTPUT else echo 'PHP_INI=error_reporting=-1, display_errors=On' >> $GITHUB_OUTPUT @@ -106,7 +121,7 @@ jobs: with: php-version: ${{ matrix.php }} ini-values: ${{ steps.set_ini.outputs.PHP_INI }} - coverage: none + coverage: ${{ matrix.coverage == true && 'xdebug' || 'none' }} tools: cs2pr # This action also handles the caching of the dependencies. @@ -144,7 +159,12 @@ jobs: - name: 'PHPCS: set the path to PHP' run: php bin/phpcs --config-set php_path php - - name: 'PHPUnit: run the tests' + - name: 'PHPUnit: run the tests without code coverage' + if: ${{ matrix.coverage == false }} + run: vendor/bin/phpunit tests/AllTests.php --no-coverage + + - name: 'PHPUnit: run the tests with code coverage' + if: ${{ matrix.coverage == true }} run: vendor/bin/phpunit tests/AllTests.php - name: 'PHPCS: check code style without cache, no parallel' @@ -169,3 +189,24 @@ jobs: - name: 'PHPCS: check code style using the Phar file' if: ${{ matrix.custom_ini == false }} run: php phpcs.phar + + - name: Upload coverage results to Coveralls + if: ${{ success() && matrix.coverage == true }} + uses: coverallsapp/github-action@v2 + with: + format: clover + file: build/logs/clover.xml + flag-name: php-${{ matrix.php }}-custom-ini-${{ matrix.custom_ini }} + parallel: true + + coveralls-finish: + needs: test + if: always() && needs.test.result == 'success' + + runs-on: ubuntu-latest + + steps: + - name: Coveralls Finished + uses: coverallsapp/github-action@v2 + with: + parallel-finished: true diff --git a/README.md b/README.md index e65acb61e0..7c9932e9a1 100644 --- a/README.md +++ b/README.md @@ -6,6 +6,7 @@ PHP_CodeSniffer [![Latest Stable Version](http://poser.pugx.org/phpcsstandards/php_codesniffer/v)](https://github.com/PHPCSStandards/PHP_CodeSniffer/releases) [![Validate](https://github.com/PHPCSStandards/PHP_CodeSniffer/actions/workflows/validate.yml/badge.svg?branch=master)](https://github.com/PHPCSStandards/PHP_CodeSniffer/actions/workflows/validate.yml) [![Test](https://github.com/PHPCSStandards/PHP_CodeSniffer/actions/workflows/test.yml/badge.svg?branch=master)](https://github.com/PHPCSStandards/PHP_CodeSniffer/actions/workflows/test.yml) +[![Coverage Status](https://coveralls.io/repos/github/PHPCSStandards/PHP_CodeSniffer/badge.svg?branch=master)](https://coveralls.io/github/PHPCSStandards/PHP_CodeSniffer?branch=master) [![License](http://poser.pugx.org/phpcsstandards/php_codesniffer/license)](https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt) ![Minimum PHP Version](https://img.shields.io/packagist/php-v/squizlabs/php_codesniffer.svg?maxAge=3600)