From 8304969d7a7208fef0fe1b4546df13797cb8995d Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Thu, 19 Jun 2025 16:51:54 +0000 Subject: [PATCH] Integrate Codecov for test coverage reporting This commit introduces Codecov integration into the GitHub Actions workflow. Key changes: - Added `pytest-cov` to project dependencies. - Modified the `run-tests.yml` workflow: - Adjusted `PYTHONPATH` for correct coverage path mapping. - Updated the `pytest` command to generate an XML coverage report (`coverage.xml`). - Added a new step to upload the `coverage.xml` report to Codecov using `codecov/codecov-action@v4`. This will enable tracking of test coverage over time and provide insights into code quality via Codecov. --- .github/workflows/run-tests.yml | 11 +++++++++-- backend/requirements.txt | 1 + 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index 22ce281b..1c4f315c 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -27,5 +27,12 @@ jobs: - name: Run tests run: | cd $GITHUB_WORKSPACE - export PYTHONPATH=$PYTHONPATH:./backend - pytest backend/tests/ \ No newline at end of file + export PYTHONPATH=$GITHUB_WORKSPACE:$GITHUB_WORKSPACE/backend + pytest --cov=./backend --cov-report=xml:coverage.xml backend/tests/ + + - name: Upload coverage to Codecov + uses: codecov/codecov-action@v4 + with: + token: ${{ secrets.CODECOV_TOKEN }} + files: ./coverage.xml + fail_ci_if_error: true diff --git a/backend/requirements.txt b/backend/requirements.txt index d969e6dc..61bf6da1 100644 --- a/backend/requirements.txt +++ b/backend/requirements.txt @@ -16,3 +16,4 @@ pytest-asyncio httpx mongomock-motor pytest-env +pytest-cov