From 1bb6847ba2e5b75b841752ec3d8817785825c6ff Mon Sep 17 00:00:00 2001 From: turegjorup Date: Wed, 8 Jul 2026 10:04:26 +0200 Subject: [PATCH 1/2] ci: upload test coverage to Codecov The README already links a Codecov badge but CI never uploaded a report. Generate a Clover report from the API test suite and upload it, matching the event-database-imports setup. - Add a `api:test:coverage` Task target running PHPUnit with XDEBUG_MODE=coverage and --coverage-clover=coverage/unit.xml. - Run it in the pr.yaml api-test job and upload via codecov/codecov-action@v5 (org-level CODECOV_TOKEN secret). - Ignore the generated /coverage directory. --- .github/workflows/pr.yaml | 10 +++++++++- .gitignore | 3 +++ CHANGELOG.md | 2 ++ Taskfile.yml | 7 +++++++ 4 files changed, 21 insertions(+), 1 deletion(-) diff --git a/.github/workflows/pr.yaml b/.github/workflows/pr.yaml index 1c27f6e..5d2f1f5 100644 --- a/.github/workflows/pr.yaml +++ b/.github/workflows/pr.yaml @@ -27,7 +27,15 @@ jobs: - name: Run API tests run: | - task --yes api:test + task --yes api:test:coverage + + - name: Upload coverage to Codecov + uses: codecov/codecov-action@v5 + with: + files: ./coverage/unit.xml + flags: unittests + env: + CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} code-analysis-phpstan: runs-on: ubuntu-latest diff --git a/.gitignore b/.gitignore index e34bf05..6b0cf92 100644 --- a/.gitignore +++ b/.gitignore @@ -36,3 +36,6 @@ phpstan.neon ###> claude-code ### /.claude/settings.local.json ###< claude-code ### + +# Coverage reports (generated in CI, uploaded to Codecov). +/coverage diff --git a/CHANGELOG.md b/CHANGELOG.md index 3bbee56..42413b0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,8 @@ See [keep a changelog] for information about writing changes to this log. ## [Unreleased] +- [PR-37](https://github.com/itk-dev/event-database-api/pull/37) + Upload test coverage to Codecov in CI - [PR-33](https://github.com/itk-dev/event-database-api/pull/33) Mature the API test suite ahead of the API Platform upgrade (contract, filter, pagination and error tests) - [PR-32](https://github.com/itk-dev/event-database-api/pull/32) diff --git a/Taskfile.yml b/Taskfile.yml index db67805..381a462 100644 --- a/Taskfile.yml +++ b/Taskfile.yml @@ -186,6 +186,13 @@ tasks: vars: COMPOSE_ARGS: exec phpfpm bin/phpunit + api:test:coverage: + desc: Run API tests with a Clover coverage report (coverage/unit.xml) + cmds: + - task: compose + vars: + COMPOSE_ARGS: exec --env XDEBUG_MODE=coverage phpfpm bin/phpunit --coverage-clover=coverage/unit.xml + api:spec:export: desc: Export API spec cmds: From 7dc5364eb8ebbedb27980fb6c8bb98031f76d010 Mon Sep 17 00:00:00 2001 From: turegjorup Date: Wed, 8 Jul 2026 10:06:33 +0200 Subject: [PATCH 2/2] ci: use codecov-action@v7 --- .github/workflows/pr.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pr.yaml b/.github/workflows/pr.yaml index 5d2f1f5..4ef94a1 100644 --- a/.github/workflows/pr.yaml +++ b/.github/workflows/pr.yaml @@ -30,7 +30,7 @@ jobs: task --yes api:test:coverage - name: Upload coverage to Codecov - uses: codecov/codecov-action@v5 + uses: codecov/codecov-action@v7 with: files: ./coverage/unit.xml flags: unittests