Skip to content

Add GitHub native code coverage reporting#671

Merged
nikosavola merged 3 commits into
mainfrom
copilot/set-up-code-coverage-reporting
Jul 1, 2026
Merged

Add GitHub native code coverage reporting#671
nikosavola merged 3 commits into
mainfrom
copilot/set-up-code-coverage-reporting

Conversation

Copilot AI commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

Set up code coverage uploads to GitHub's Code Quality API via actions/upload-code-coverage@v1, so coverage results appear directly on pull requests.

Changes

  • Coverage generation expanded to PRs--cov flags now run on all ubuntu-latest matrix entries (not just main pushes), giving GitHub both a baseline and per-PR comparison
  • Added actions/upload-code-coverage@v1 step (pinned to 82c7aee) uploading coverage.xml as code-coverage/pytest with language Python
  • Added code-quality: write permission to test-code job
  • Checkout uses PR head SHA (ref: ${{ github.event.pull_request.head.sha || github.sha }}) so coverage line numbers map correctly to diffs
  • Fork PRs are skipped gracefully via the standard guard condition

Existing coverage badge generation and HTML artifact upload for main are unchanged.

Summary by Sourcery

Enable uploading Python test coverage reports to GitHub’s Code Quality API from CI.

CI:

  • Expand pytest coverage collection to all ubuntu-latest matrix runs instead of only main pushes.
  • Upload coverage.xml via actions/upload-code-coverage with appropriate label and language for GitHub-native coverage reporting.
  • Add code-quality: write and contents: read permissions and check out the PR head SHA to align coverage with diffs.
  • Skip coverage upload for forked pull requests to avoid permission issues.

…erage

Co-authored-by: nikosavola <7860886+nikosavola@users.noreply.github.com>
@github-actions github-actions Bot added the ci Pull requests that update GitHub Actions code label Jul 1, 2026
@sourcery-ai

sourcery-ai Bot commented Jul 1, 2026

Copy link
Copy Markdown
Contributor
Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Adds GitHub-native code coverage reporting for pytest runs by extending coverage generation to all ubuntu-latest matrix entries and uploading coverage.xml via actions/upload-code-coverage, with appropriate permissions and checkout ref adjustments so coverage maps correctly to PR diffs while preserving existing main-branch coverage artifacts and badges.

File-Level Changes

Change Details Files
Extend pytest coverage generation to all ubuntu-latest matrix runs instead of only main-branch pushes.
  • Modify just test command to always add --cov and coverage XML/HTML reports on ubuntu-latest matrix entries, regardless of branch.
  • Retain non-coverage test execution behavior for non-ubuntu matrix operating systems.
.github/workflows/test.yml
Integrate GitHub Code Quality coverage uploads using actions/upload-code-coverage with appropriate conditions and metadata.
  • Add Upload code coverage to GitHub job step gated to ubuntu-latest matrix runs and non-fork PRs.
  • Configure upload-code-coverage action with coverage.xml, language Python, and label code-coverage/pytest.
  • Pin upload-code-coverage action to a specific commit hash for reproducibility.
.github/workflows/test.yml
Adjust workflow permissions and checkout ref so coverage data can be written to Code Quality and aligned with PR diffs.
  • Add contents: read and code-quality: write permissions to the test-code job.
  • Update actions/checkout configuration to use the PR head SHA (or default github.sha) as the ref to align coverage with the diff being tested.
.github/workflows/test.yml
Preserve existing main-branch coverage badge generation and HTML artifact behavior.
  • Keep Generate coverage badge step conditioned on main branch and ubuntu-latest, still using coverage.xml for badge generation and HTML coverage output.
  • Ensure new coverage upload step does not alter or bypass existing artifact and badge generation logic for main.
.github/workflows/test.yml

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@nikosavola nikosavola marked this pull request as ready for review July 1, 2026 10:31
@nikosavola nikosavola enabled auto-merge July 1, 2026 10:31

@sourcery-ai sourcery-ai 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.

Hey - I've reviewed your changes and they look great!


Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@github-code-quality

github-code-quality Bot commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

Code Coverage Overview

Languages: Python

Python / code-coverage/pytest

The overall coverage in the branch is 90%. Coverage data for the branch is not yet available.

Show a code coverage summary of the most covered files.
File f78a95d +/-
utils.py 100%
cells/transmon.py 100%
tech.py 100%
models/waveguides.py 100%
models/qubit.py 100%
cells/waveguides.py 100%
cells/capacitor.py 99%
cells/unimon.py 98%
cells/resonator.py 97%
cells/inductor.py 93%

Updated July 01, 2026 10:56 UTC
Code Coverage is in Public Preview. Learn more and provide us with your feedback.

@nikosavola

Copy link
Copy Markdown
Member

@copilot Please fix the pre-commit hooks for this PR

…nlint config, fix version comments

Co-authored-by: nikosavola <7860886+nikosavola@users.noreply.github.com>
auto-merge was automatically disabled July 1, 2026 10:44

Head branch was pushed to by a user without write access

Copilot AI commented Jul 1, 2026

Copy link
Copy Markdown
Contributor Author

@copilot Please fix the pre-commit hooks for this PR

Fixed in 2nd commit. The issues were:

  1. actionlint didn't recognize the code-quality permission scope (too new). Moved the coverage upload into a dedicated upload-coverage job and added .github/actionlint.yaml with an ignore rule for that scope.
  2. zizmor ref-version-mismatch warnings on actions/checkout (v6v6.0.2) and xu-cheng/latex-action (v4.0.04.1.0) — fixed the version comments across all affected workflows.

All pre-commit hooks now pass cleanly.

Copilot AI requested a review from nikosavola July 1, 2026 10:44
@nikosavola nikosavola enabled auto-merge July 1, 2026 10:52
@nikosavola nikosavola added this pull request to the merge queue Jul 1, 2026
Merged via the queue into main with commit b4c93f9 Jul 1, 2026
29 checks passed
@nikosavola nikosavola deleted the copilot/set-up-code-coverage-reporting branch July 1, 2026 11:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci Pull requests that update GitHub Actions code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants