Skip to content

fix: turn on pytest-cov so api CI writes coverage.xml - #2054

Open
panish16 wants to merge 1 commit into
bcgov:mainfrom
panish16:fix/api-coverage-report
Open

panish16 wants to merge 1 commit into
bcgov:mainfrom
panish16:fix/api-coverage-report

Conversation

@panish16

Copy link
Copy Markdown
Collaborator

Issue #, if available: n/a (CI fix)

Description of changes:
namex-api-ci / code-coverage fails on every PR with Artifact not found for name: coverage-<run>, even when unit-testing is green (e.g. run 40948356553).

Cause: backend-ci runs pytest --cov-report=term --cov-report=xml, but nothing passes --cov, so pytest-cov never turns on and coverage.xml never gets written (No files were found with the provided path: ./api/coverage.xml). The pyproject [tool.pytest.ini_options] is ignored because api/pytest.ini takes precedence.

Fix: addopts = --cov=namex in api/pytest.ini. One line, test config only, so no version bump.

Expect this to still be red after merge: the job requires 80% and namex api is at 50% (full suite, measured locally). So it goes from "artifact not found" to an actual coverage number below the gate. Kept at 80 on purpose. Lowering the gate is a team call.

Testing:

  • CI's exact args with this pytest.ini → Coverage XML written to file coverage.xml, covering namex/
  • same args with main's pytest.ini → no coverage, no coverage.xml (matches the CI failure)
  • full suite with --cov=namex → 373 passed, 367 skipped, TOTAL 50%
  • unit-testing here will be red until fix: create missing restricted-word sequences on a fresh database #2053 (restricted-word sequence migration fix) merges

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of the namex license (Apache 2.0).

backend-ci runs pytest --cov-report=term --cov-report=xml, but nothing
passed --cov, so pytest-cov never activated, coverage.xml was never
written and code-coverage failed with 'Artifact not found'. Add
--cov=namex to addopts in pytest.ini (the active config).
@sonarqubecloud

Copy link
Copy Markdown

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant