{"id":15159607,"url":"https://github.com/orbeji/phpunit-pr-coverage-check","last_synced_at":"2026-01-31T02:32:07.774Z","repository":{"id":230961651,"uuid":"765844055","full_name":"orbeji/phpunit-pr-coverage-check","owner":"orbeji","description":"php package to analyze code coverage of pull request","archived":false,"fork":false,"pushed_at":"2025-11-05T18:53:55.000Z","size":78,"stargazers_count":1,"open_issues_count":0,"forks_count":2,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-12-22T20:23:54.826Z","etag":null,"topics":["coverage","php","pr","pull-request"],"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/orbeji.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-03-01T18:21:58.000Z","updated_at":"2025-11-05T18:51:59.000Z","dependencies_parsed_at":"2025-04-10T02:56:01.282Z","dependency_job_id":"1c6dbdf1-2dab-4156-9437-71cde2e1aa70","html_url":"https://github.com/orbeji/phpunit-pr-coverage-check","commit_stats":null,"previous_names":["orbeji/phpunit-pr-coverage-check"],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/orbeji/phpunit-pr-coverage-check","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/orbeji%2Fphpunit-pr-coverage-check","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/orbeji%2Fphpunit-pr-coverage-check/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/orbeji%2Fphpunit-pr-coverage-check/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/orbeji%2Fphpunit-pr-coverage-check/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/orbeji","download_url":"https://codeload.github.com/orbeji/phpunit-pr-coverage-check/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/orbeji%2Fphpunit-pr-coverage-check/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28927174,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-30T22:32:35.345Z","status":"online","status_checked_at":"2026-01-31T02:00:09.179Z","response_time":128,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["coverage","php","pr","pull-request"],"created_at":"2024-09-26T21:40:43.616Z","updated_at":"2026-01-31T02:32:07.758Z","avatar_url":"https://github.com/orbeji.png","language":"PHP","readme":"\u003ca name=\"readme-top\"\u003e\u003c/a\u003e\n\n\n\u003c!-- PROJECT LOGO --\u003e\n\u003cbr /\u003e\n\u003cdiv align=\"center\"\u003e\n\u003ch1 align=\"center\"\u003ePhpunit PR Coverage Check\u003c/h1\u003e\n  \u003cp align=\"center\"\u003e\n    \u003ca href=\"https://github.com/orbeji/phpunit-pr-coverage-check/issues\"\u003eReport Bug\u003c/a\u003e\n    ·\n    \u003ca href=\"https://github.com/orbeji/phpunit-pr-coverage-check/issues\"\u003eRequest Feature\u003c/a\u003e\n  \u003c/p\u003e\n\u003c/div\u003e\n\n\n![Tests](https://github.com/orbeji/phpunit-pr-coverage-check/actions/workflows/tests.yml/badge.svg)\n![Static analysis](https://github.com/orbeji/phpunit-pr-coverage-check/actions/workflows/static.yml/badge.svg)\n![Symfony \u0026 php compatibility](https://github.com/orbeji/phpunit-pr-coverage-check/actions/workflows/compatibility.yml/badge.svg)\n\n\n\u003c!-- ABOUT THE PROJECT --\u003e\n## About The Project\n\nInspired by https://github.com/richardregeer/phpunit-coverage-check\n\nThis project is a console command that filters the coverage report of your Phpunit tests to only take into account the \nmodifications of a PullRequest, so you can be sure that the PR has enough tests.\n\n\u003cp align=\"right\"\u003e(\u003ca href=\"#readme-top\"\u003eback to top\u003c/a\u003e)\u003c/p\u003e\n\n\u003c!-- GETTING STARTED --\u003e\n## Getting Started\n\n### Installation\n\nMake sure Composer is installed globally, as explained in the\n[installation chapter](https://getcomposer.org/doc/00-intro.md)\nof the Composer documentation.\n\nOpen a command console, enter your project directory and execute:\n\n```console\n$ composer require --dev orbeji/phpunit-pr-coverage-check\n```\n\n\u003c!-- USAGE EXAMPLES --\u003e\n## Usage\nThere are two ways of using this command:\n* Passing a diff file\n* Passing git repo information\n\nWith the first option you need to generate the appropiate diff file to pass to the command.\nThe diff file must only contain the modified files/lines of the pr. To do that you can call\n`git diff DESTINATION_BRANCH...PR_BRANCH \u003e diff.txt` with \n[Bitbucket](https://support.atlassian.com/bitbucket-cloud/docs/variables-and-secrets/) and \n[GitHub](https://docs.github.com/en/actions/learn-github-actions/variables#default-environment-variables) \nyou have environment variables to know \nthe current and destination branches.\n\nDiff file example:\nBitbucket\n```bash\nvendor/bin/phpunit --configuration phpunit.xml.dist --testsuite pipelines --coverage-clover 'clover.xml'\ngit diff origin/${BITBUCKET_PR_DESTINATION_BRANCH}...origin/${BITBUCKET_BRANCH} \u003e diff.txt\nvendor/bin/pr-coverage-check check clover.xml 100 --diff=diff.txt --report=ansi\n```\nGitHub\n```bash\nvendor/bin/phpunit --coverage-clover clover.xml\ngit diff ${GITHUB_BASE_REF}...${GITHUB_REF_NAME} \u003e diff.txt\nvendor/bin/pr-coverage-check check clover.xml 100 --diff=diff.txt\n```\nGit repo information\n```bash\nvendor/bin/pr-coverage-check check clover.xml 100 --pullrequest-id=1 --provider=Github --workspace=orbeji --repository=test --api_token=API_TOKEN \n```\nThe API token must have permissions to the PullRequest scope.\n\nFor GitHub in the workspace option put the owner of the repo.\n\nIn any case if the coverage is not met the command will return the covered percentage\n```bash\nCoverage 40%\n ```\n\n### Reports\nWhen executing the command line you can pass the option `--report` to generate a table with the uncovered lines of the PR\n\nThis option accepts 3 values:\n* ansi: Coverage table in console output\n* comment: Coverage table in PR comment\n* report: Bitbucket report\n\n#### Examples:\nansi:\n```\nroot@bbfb2d246e64:/app# bin/pr-coverage-check check tests/clover.xml 90 --diff=tests/diff.txt --report=ansi\nCoverage: 40%\n--------------- ------------ \nFile            Uncovered Lines\n--------------- ------------ \nsrc/Dummy.php   19, 20, 26\n--------------- ------------ \n```\ncomment:\n  ![](docs/screenshots/github_comment.png)\n  ![](docs/screenshots/bitbucket_comment.png)\nreport:\n\n### CI Integration\n#### Bitbucket Pipelines\n```yaml\npipelines:\n  pull-requests:\n      feature/*:\n        - step:\n            name: phpunit coverage check\n            image:\n              name: orbeji/base:7.2-xdebug-cli\n            script:\n              - composer install\n              - vendor/bin/phpunit --configuration phpunit.xml.dist --testsuite pipelines --coverage-clover 'clover.xml'\n              - git diff origin/${BITBUCKET_PR_DESTINATION_BRANCH}...origin/${BITBUCKET_BRANCH} \u003e diff.txt\n              - vendor/bin/pr-coverage-check check clover.xml 100 --diff=diff.txt --report=ansi\n            caches:\n              - composer\n```\n#### GitHub Actions\n```yaml\nname: PHPUnit and Coverage Check\n\non: [pull_request]\n\njobs:\n  test:\n    runs-on: ubuntu-22.04\n\n    steps:\n    - name: Checkout code\n      uses: actions/checkout@v4\n\n    - name: Set up PHP\n      uses: shivammathur/setup-php@v2\n      with:\n        php-version: '7.2'\n\n    - name: Install dependencies\n      run: composer install\n\n    - name: Run PHPUnit with coverage\n      run: vendor/bin/phpunit --configuration phpunit.xml.dist --testsuite pipelines --coverage-clover 'clover.xml'\n\n    - name: Git diff\n      run: git fetch \u0026\u0026 git diff origin/${GITHUB_BASE_REF}...origin/${GITHUB_HEAD_REF} \u003e diff.txt\n\n    - name: PR Coverage Check\n      run: vendor/bin/pr-coverage-check check clover.xml 100 --diff=diff.txt --report=ansi\n\n```\n\n\u003c!-- ROADMAP --\u003e\n## Roadmap\n\n- [ ] Add Bitbucket report example screenshot\n- [x] Add examples of CI for Bitbucket and GitHub \n\n\nSee the [open issues](https://github.com/orbeji/phpunit-pr-coverage-check/issues) for a full list of proposed features (and known issues).\n\n\u003cp align=\"right\"\u003e(\u003ca href=\"#readme-top\"\u003eback to top\u003c/a\u003e)\u003c/p\u003e\n\n\n\n\u003c!-- CONTRIBUTING --\u003e\n## Contributing\n\nPull requests are welcome. For major changes, please open an issue first\nto discuss what you would like to change.\n\nPlease make sure to update tests as appropriate and that all the GitHub Actions are passing.\n\n\u003cp align=\"right\"\u003e(\u003ca href=\"#readme-top\"\u003eback to top\u003c/a\u003e)\u003c/p\u003e\n\n\n\n\u003c!-- LICENSE --\u003e\n## License\n\nDistributed under the [MIT](https://choosealicense.com/licenses/mit/) License. \n\n\u003cp align=\"right\"\u003e(\u003ca href=\"#readme-top\"\u003eback to top\u003c/a\u003e)\u003c/p\u003e\n\n\n\n\u003c!-- CONTACT --\u003e\n## Contact\n\nProject Link: [https://github.com/orbeji/phpunit-pr-coverage-check](https://github.com/orbeji/phpunit-pr-coverage-check)\n\n\u003cp align=\"right\"\u003e(\u003ca href=\"#readme-top\"\u003eback to top\u003c/a\u003e)\u003c/p\u003e\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Forbeji%2Fphpunit-pr-coverage-check","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Forbeji%2Fphpunit-pr-coverage-check","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Forbeji%2Fphpunit-pr-coverage-check/lists"}