codacy/coverage
Deprecated PHP coverage reporter that sends PHPUnit coverage results (Clover XML, or PHPUnit XML for PHPUnit <4) to your Codacy dashboard. No longer maintained; use the codacy-coverage-reporter instead.
First, decide whether you should install this at all. The repository is archived and deprecated; the README points you at codacy-coverage-reporter instead. Use codacy/coverage only if you are maintaining a legacy PHP 5.x/7.x pipeline that already depends on it — for anything new, wire up the reporter (Docker image or GitHub Action) directly. Both consume the same Clover input, so the migration is a one-line CI change.
If you do proceed, the minimal path is:
"codacy/coverage": "dev-master", but pin a tagged 1.x release instead — dev-master on an archived repo is unreproducible if the branch ever moves.
composer require --dev codacy/coverage:^1.4
XDEBUG_MODE=coverage vendor/bin/phpunit --coverage-clover build/logs/clover.xml
CODACY_PROJECT_TOKEN in your CI environment. Never commit it.vendor/bin/codacycoverage clover build/logs/clover.xml
Where to look first: the README's usage section (it is short), then vendor/bin/codacycoverage --help for the exact flags of the version you pinned, and finally your Codacy project's coverage tab to confirm the commit landed.
The first realistic use case is a single upload from your default branch on CI to get a baseline coverage percentage and a badge. Do that before touching PR builds — it isolates token/CI problems from branch/commit-attribution problems.
Separate generation from upload. Have the test job write build/logs/clover.xml and publish it as a CI artifact; have the upload run as a distinct step (or even a separate job) that consumes the artifact. You then re-upload after a Codacy outage or a bad token without re-running the whole suite.
Wrap the call in a Makefile/script target. Something like make coverage-upload that shells out to codacycoverage. When you migrate to codacy-coverage-reporter (report -l PHP -r build/logs/clover.xml), you edit one file instead of hunting through YAML.
Upload from exactly one job. In a CI matrix (PHP 7.4/8.0/8.1), gate the upload on one leg only. Multiple concurrent uploads race, and the last write wins — often from the leg you least expected.
# GitHub Actions-ish sketch
- run: XDEBUG_MODE=coverage vendor/bin/phpunit --coverage-clover build/logs/clover.xml
- if: matrix.php == '8.1' && github.event_name == 'push'
run: vendor/bin/codacycoverage clover build/logs/clover.xml
env:
CODACY_PROJECT_TOKEN: ${{ secrets.CODACY_PROJECT_TOKEN }}
Merge suites before uploading. If you run PHPUnit plus Behat/PHPSpec, merge Clover files with phpcov merge --clover build/logs/merged.xml build/coverage/ and upload the merged file. The uploader accepts one report per invocation.
Full clone in CI. Commit attribution relies on git metadata in the workspace; actions/checkout defaults to fetch-depth: 1, which can break it. Use fetch-depth: 0 so coverage is attached to the right commit rather than the branch tip.
Skip uploads on forked PRs. Secrets aren't exposed there, so the step either fails or no-ops noisily. Guard it: if: github.event.pull_request.head.repo.fork == false.
phpunit subcommand is dead weight. It handles PHPUnit's XML format, which only PHPUnit < 4 emits. On any modern PHPUnit, use clover only.test -s build/logs/clover.xml || exit 1 before uploading.XDEBUG_MODE=coverage. Without it, no coverage data is generated at all. This is the single most common cause of "the upload worked but coverage is 0".build/logs/ at the start of the job and gitignore it; a leftover Clover file from a previous branch will happily get uploaded.HTTPS_PROXY/JAVA_TOOL_OPTIONS set for the upload to reach api.codacy.com.CODACY_PROJECT_TOKEN over --token on the command line; CLI args land in CI logs.vendor/bin may not exist. If your CI installs with --no-dev, the binary is absent. Either install dev deps in the coverage job or download the phar explicitly.--coverage-text parsing or a threshold check) if you want PRs blocked on regression.How can I help you explore Laravel packages today?