Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add additional clover coverage features #1152

Merged
merged 1 commit into from
Sep 16, 2024
Merged

Conversation

veewee
Copy link
Contributor

@veewee veewee commented Sep 12, 2024

Q A
Branch master
Bug fix? no
New feature? yes
BC breaks? no
Deprecations? yes
Documented? yes
Fixed tickets

This task introduces some additional features:

clover_coverage

grumphp:
    tasks:
        clover_coverage:
            clover_file: clover.xml
            minimum_level: 70
            target_level: 100

This task now has the possibility to:

  • Optional target_level in case you want to upgrade gradually in a non-blocking way, whilst keeping track of the current status in the command output.

phpunit

This task got new coverage settings that work the same as in the paratest task:

grumphp:
    tasks:
        phpunit:
            coverage-clover: null
            coverage-html: null
            coverage-php: null
            coverage-xml: null

In case you want to combine the coverage report from multiple sources into 1 clover XML file, you can use following grumphp extension:
https://github.com/phpro/grumphp-combined-coverage-extension/

Example usage

grumphp:
    tasks:
        paratest:
            config: phpunit.xml.dist
            testsuite: unit
            coverage-php: cov/unit.cov
        phpunit:
            config_file: phpunit.xml.dist
            testsuite: functional
            coverage-php: cov/functional.cov
        clover_coverage:
            clover_file: "coverage-all.xml"
            minimum_level: 80
            target_level: 100
            metadata:
                priority: -100

Example output:

GrumPHP is sniffing your code!

Running tasks with priority 0!
==============================

Running task 1/2: paratest... ✔
Running task 2/2: phpunit... ✔

Running tasks with priority -100!
=================================

Running task 1/1: clover_coverage... ✘

       _    _ _                         _ _
      / \  | | |   __ _  ___   ___   __| | |
     / _ \ | | |  / _` |/ _ \ / _ \ / _` | |
    / ___ \| | | | (_| | (_) | (_) | (_| |_|
   /_/   \_\_|_|  \__, |\___/ \___/ \__,_(_)
                  |___/


clover_coverage
===============

Code coverage is 90%, which is below the target 100%
> echo $?
0

Deprecations

level is deprecated and will be removed in v3.0: change option to minimum_level.

grumphp:
    tasks:
        clover_coverage:
-            level: 30
+            minimum_level: 30

src/Task/CloverCoverage.php Outdated Show resolved Hide resolved
composer.json Show resolved Hide resolved
@veewee veewee added this to the 2.8.0 milestone Sep 16, 2024
@veewee veewee merged commit b12f61e into phpro:v2.x Sep 16, 2024
20 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant