Skip to content

fix(ci): run coverage report from package directory to fix path matching#17580

Open
chalmerlowe wants to merge 12 commits into
mainfrom
fix/core-coverage-omit
Open

fix(ci): run coverage report from package directory to fix path matching#17580
chalmerlowe wants to merge 12 commits into
mainfrom
fix/core-coverage-omit

Conversation

@chalmerlowe

@chalmerlowe chalmerlowe commented Jun 25, 2026

Copy link
Copy Markdown
Contributor

Fixes coverage evaluation issues in the monorepo by isolating package coverage reports and ensuring correct path matching for omit rules in local .coveragerc files.

Issue Details

In the CI/CD pipeline (unittest.yml), coverage reports were being generated pointing to the aggregated .coverage file in the root. This caused two main problems:

  1. Pollution: coverage report without --include reported on ALL packages present in the aggregated file. Smaller packages with lower coverage (like google-cloud-spanner-dbapi-driver) were artificially dragged up by larger packages with high coverage (like google-cloud-logging), hiding coverage deficits.
  2. Path Mismatch: The aggregated file refers to absolute paths (e.g., /home/runner/...), while omit rules in package .coveragerc files are typically relative paths (e.g., google/cloud/_testing/__init__.py). This mismatch prevented files from being omitted correctly thus falsely inflating coverage deficits.

Solution

  1. Isolate and Fix Paths: Added --include="$PWD/**" to the coverage report command in unittest.yml. Combined with pushd "${pkg}", this ensures that:
    • The report is isolated to files within the specific package directory.
    • Relative omit paths in .coveragerc match correctly against the files being evaluated.
  2. Expose and Lock Coverage: This fix exposed a genuine coverage deficit in google-cloud-spanner-dbapi-driver (89%). It has never had full coverage (and updating that coverage is outside the scope of this PR). We updated its .coveragerc with fail_under = 89 to prevent regressions while acknowledging known missing coverage.
  3. Limited system test capability in spanner-dbapi-driver lib: the spanner-dbapi-driver package is in the planning phase so the full system test suite is not functional. We added a pytest.skip to prevent system test failures in CI/CD.

Note

To ensure the correctness of the fix, we used dummy comments in version files to trigger unittests and cover, but we have removed them to avoid cluttering the PR. The passing results can be seen here

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request updates the coverage configuration in .coveragerc to use wildcard patterns for omitting initialization files. The reviewer pointed out that using */ requires a leading directory and will fail when running coverage locally from within the package directory. They suggested using *google/cloud/... instead to ensure compatibility in both environments.

Comment thread packages/google-cloud-core/.coveragerc Outdated
@chalmerlowe chalmerlowe force-pushed the fix/core-coverage-omit branch from 5e8a002 to 36ccd3d Compare June 25, 2026 22:31
@chalmerlowe chalmerlowe force-pushed the fix/core-coverage-omit branch from 36ccd3d to 4ffa231 Compare June 25, 2026 22:54
@chalmerlowe chalmerlowe changed the title fix(core): fix coverage omit patterns for monorepo compatibility fix(ci): run coverage report from package directory to fix path matching Jun 25, 2026
@chalmerlowe chalmerlowe marked this pull request as ready for review June 26, 2026 08:11
@chalmerlowe chalmerlowe requested a review from a team as a code owner June 26, 2026 08:11
Comment thread packages/google-cloud-core/google/cloud/version.py Outdated
Comment thread packages/google-cloud-logging/google/cloud/logging/gapic_version.py Outdated
Comment thread packages/google-cloud-spanner-dbapi-driver/google/cloud/spanner_driver/version.py Outdated
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