{"id":21466546,"url":"https://github.com/permafrost-dev/coverage-check","last_synced_at":"2025-08-20T03:31:55.709Z","repository":{"id":40546792,"uuid":"382474363","full_name":"permafrost-dev/coverage-check","owner":"permafrost-dev","description":"Check a project's code coverage, optionally enforcing a minimum value","archived":false,"fork":false,"pushed_at":"2024-11-25T21:02:19.000Z","size":162,"stargazers_count":17,"open_issues_count":2,"forks_count":4,"subscribers_count":2,"default_branch":"main","last_synced_at":"2024-12-06T15:52:42.339Z","etag":null,"topics":["code-coverage","code-quality","continuous-integration","test-automation","testing"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/permafrost-dev.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":".github/CONTRIBUTING.md","funding":".github/FUNDING.yml","license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":".github/SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":"permafrost-dev","custom":"https://permafrost.dev/open-source"}},"created_at":"2021-07-02T22:07:09.000Z","updated_at":"2024-10-07T21:26:53.000Z","dependencies_parsed_at":"2024-01-05T11:47:40.993Z","dependency_job_id":"98775ad3-d8c3-41d9-8f1e-9dc9d7fc3c85","html_url":"https://github.com/permafrost-dev/coverage-check","commit_stats":{"total_commits":79,"total_committers":3,"mean_commits":"26.333333333333332","dds":0.5822784810126582,"last_synced_commit":"2bb5b484ab33d6462604d813c5897faf9796e492"},"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/permafrost-dev%2Fcoverage-check","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/permafrost-dev%2Fcoverage-check/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/permafrost-dev%2Fcoverage-check/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/permafrost-dev%2Fcoverage-check/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/permafrost-dev","download_url":"https://codeload.github.com/permafrost-dev/coverage-check/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":230388131,"owners_count":18217755,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["code-coverage","code-quality","continuous-integration","test-automation","testing"],"created_at":"2024-11-23T08:14:26.148Z","updated_at":"2024-12-19T06:10:18.051Z","avatar_url":"https://github.com/permafrost-dev.png","language":"PHP","funding_links":["https://github.com/sponsors/permafrost-dev","https://permafrost.dev/open-source"],"categories":[],"sub_categories":[],"readme":"# coverage-check\n\n\u003cp align=\"center\"\u003e\n    \u003cimg src=\"https://static.permafrost.dev/images/coverage-check/coverage-check-logo-alt.png\" alt=\"coverage-check logo\" height=\"200\" style=\"block\"\u003e\n    \u003cbr\u003e\u003cbr\u003e\n    \u003cimg src=\"https://img.shields.io/github/v/release/permafrost-dev/coverage-check.svg?sort=semver\u0026logo=github\" alt=\"Package Version\"\u003e\n    \u003cimg src=\"https://img.shields.io/packagist/dt/permafrost-dev/coverage-check?logo=packagist\u0026logoColor=%23fff\" alt=\"Downloads\"\u003e\n    \u003cimg src=\"https://github.com/permafrost-dev/coverage-check/actions/workflows/run-tests.yml/badge.svg?branch=main\" alt=\"Test Run Status\"\u003e\n    \u003cbr\u003e\n    \u003cimg src=\"https://img.shields.io/github/license/permafrost-dev/coverage-check.svg?logo=opensourceinitiative\" alt=\"license\"\u003e\n    \u003cimg src=\"https://codecov.io/gh/permafrost-dev/coverage-check/branch/main/graph/badge.svg?token=Xau3YK5548\" alt=\"code coverage\"\u003e\n\u003c/p\u003e\n\n---\n\nDisplay the code coverage for a project using a clover.xml file, optionally enforcing a minimum code coverage percentage.\n\nThis package is designed to be used in your CI/CD or automated testing process _(i.e., using GitHub Workflows)_.\n\nThe concept for this package is based on [this article](https://ocramius.github.io/blog/automated-code-coverage-check-for-github-pull-requests-with-travis/).\n\n---\n``\n\u003e Note on PHP 7.x support: \n\u003e If you are using PHP 7.x, use the 1.x version of this package.\n\u003e \n\n## Installation\n\n```bash\ncomposer require permafrost-dev/coverage-check --dev\n```\n\n## Usage\n\nSpecify a valid clover.xml file and (optionally) a minimum coverage percentage to require using the `--require` or `-r` flag.  A percentage can be either a whole number (integer) or a decimal (float).\n\nIf you specify the `--require/-r` flag, the check will fail if coverage percent is below the value you provide, and the process exit code will be non-zero.\n\nIf you don't specify the `--require/-r` flag, only the percentage of code coverage will be displayed and the exit code will always be zero.\n\n```bash\n./vendor/bin/coverage-check clover.xml\n./vendor/bin/coverage-check clover.xml --require=50\n./vendor/bin/coverage-check clover.xml -r 80.5\n./vendor/bin/coverage-check clover.xml -m statement -r 75\n./vendor/bin/coverage-check clover.xml --precision=1\n```\n\n## Available Options\n\n| Option | Description |\n| --- | --- |\n| `--coverage-only` or `-C` | Only display the code coverage value |\n| `--metric` or `-m` `\u003cname\u003e` | Use the specified metric field for calculating coverage. Valid values are `element` _(default)_, `method`, or `statement` |\n| `--precision` or `-p` `\u003cvalue\u003e` | Use the specified precision when calculating the code coverage percentage, where `\u003cvalue\u003e` is an integer _(default: 4)_ |\n| `--require` or `-r` `\u003cvalue\u003e` | Enforce a minimum code coverage value, where `\u003cvalue\u003e` is an integer or decimal value |\n\n## Metric fields\n\nThe field that is used to calculate code coverage can be specified using the `--metric=\u003cname\u003e` or `-m \u003cname\u003e` option.\n\nValid field names are `element` _(the default)_, `statement`, and `method`.\n\n## Generating clover-format coverage files\n\nPHPUnit can generate coverage reports in clover format:\n\n```bash\n./vendor/bin/phpunit --coverage-clover clover.xml\n```\n\n## Sample Github Workflow\n\n```yaml\nname: run-tests\n\non: [push, pull_request]\n\njobs:\n  test:\n    runs-on: ${{ matrix.os }}\n    strategy:\n      fail-fast: true\n      matrix:\n        os: [ubuntu-latest]\n        php: [8.1, 8.0, 7.4, 7.3]\n\n    name: P${{ matrix.php }} - ${{ matrix.os }}\n\n    steps:\n      - name: Checkout code\n        uses: actions/checkout@v3\n\n      - name: Setup PHP\n        uses: shivammathur/setup-php@v2\n        with:\n          php-version: ${{ matrix.php }}\n          extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, intl, iconv, fileinfo\n          coverage: pcov\n\n      - name: Setup problem matchers\n        run: |\n          echo \"::add-matcher::${{ runner.tool_cache }}/php.json\"\n          echo \"::add-matcher::${{ runner.tool_cache }}/phpunit.json\"\n\n      - name: Install dependencies\n        run: composer update --prefer-stable --prefer-dist --no-interaction\n\n      - name: Execute tests\n        run: ./vendor/bin/phpunit --coverage-clover clover.xml\n\n      - name: Enforce 75% code coverage\n        run: ./vendor/bin/coverage-check clover.xml --require=75 --precision=2\n```\n\n## Testing\n\n```bash\n./vendor/bin/phpunit\n```\n\n## Changelog\n\nPlease see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.\n\n## Contributing\n\nPlease see [CONTRIBUTING](.github/CONTRIBUTING.md) for details.\n\n## Security Vulnerabilities\n\nPlease review [our security policy](../../security/policy) on how to report security vulnerabilities.\n\n## Credits\n\n- [Patrick Organ](https://github.com/patinthehat)\n- [All Contributors](../../contributors)\n\n## License\n\nThe MIT License (MIT). Please see [License File](LICENSE.md) for more information.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpermafrost-dev%2Fcoverage-check","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpermafrost-dev%2Fcoverage-check","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpermafrost-dev%2Fcoverage-check/lists"}