php-actions / phpunit

Run PHPUnit tests in Github Actions.
108 stars 24 forks source link

Code coverage is tricky to set up and references deprecated flags #59

Open shish opened 7 months ago

shish commented 7 months ago

It would be nice if just specifying coverage_* automatically did whatever it needed, so I try that

    - uses: php-actions/phpunit@v3
      with:
        version: 10
        php_version: ${{ matrix.php }}
        php_extensions: xdebug
        coverage_text: true
        bootstrap: vendor/autoload.php
        args: tests
1) XDEBUG_MODE=coverage or xdebug.mode=coverage has to be set

There are no instructions about how to set either of these flags, but by blind guessing I manage to figure it out:

    - uses: php-actions/phpunit@v3
      with:
        version: 10
        php_version: ${{ matrix.php }}
        php_extensions: xdebug
        coverage_text: true
        bootstrap: vendor/autoload.php
        args: tests
      env:
        XDEBUG_MODE: coverage
1) No filter is configured, code coverage will not be processed

Ok I need a filter -- The README mentions a whitelist parameter that seems to be what I want

    - uses: php-actions/phpunit@v3
      with:
        version: 10
        php_version: ${{ matrix.php }}
        php_extensions: xdebug
        coverage_text: true
        bootstrap: vendor/autoload.php
        whitelist: src
        args: tests
      env:
        XDEBUG_MODE: coverage
Unknown option "--whitelist"

Ok, looks like a few years ago whitelist was replaced with coverage-filter

    - uses: php-actions/phpunit@v3
      with:
        version: 10
        php_version: ${{ matrix.php }}
        php_extensions: xdebug
        coverage_text: true
        bootstrap: vendor/autoload.php
        coverage_filter: src
        args: tests
      env:
        XDEBUG_MODE: coverage
Warning: Unexpected input(s) 'coverage_filter', valid inputs are ['version', 'php_version', 'php_extensions', 'vendored_phpunit_path', 'configuration', 'log_junit', 'log_teamcity', 'testdox_html', 'testdox_text', 'memory_limit', 'bootstrap', 'filter', 'testsuite', 'group', 'exclude_group', 'test_suffix', 'whitelist', 'coverage_clover', 'coverage_cobertura', 'coverage_crap4j', 'coverage_html', 'coverage_php', 'coverage_text', 'coverage_xml', 'args']

Ok, so the action hasn't been updated to be compatible with the last few major releases, let's try args

    - uses: php-actions/phpunit@v3
      with:
        version: 10
        php_version: ${{ matrix.php }}
        php_extensions: xdebug
        coverage_text: true
        bootstrap: vendor/autoload.php
        args: --coverage-filter src tests
      env:
        XDEBUG_MODE: coverage

Success \o/

And now let's try using that coverage - The README mentions https://github.com/php-actions/code-coverage ... which is 404 ;(

g105b commented 7 months ago

Thank you for the issue report. I'll work on making this easier to set up and automating some of the steps.