Skip to content

feat: fix Codecov uploads#480

Merged
martimlobao merged 4 commits intomainfrom
codex/fix-codecov-oidc
Mar 10, 2026
Merged

feat: fix Codecov uploads#480
martimlobao merged 4 commits intomainfrom
codex/fix-codecov-oidc

Conversation

@martimlobao
Copy link
Owner

@martimlobao martimlobao commented Mar 10, 2026

  • add token

@sourcery-ai
Copy link
Contributor

sourcery-ai bot commented Mar 10, 2026

Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Configure the PR validation workflow to upload coverage to Codecov using GitHub OIDC instead of a static token, by granting the workflow minimal required permissions and enabling OIDC on the Codecov action step.

Sequence diagram for GitHub Actions OIDC authentication with Codecov

sequenceDiagram
    actor Developer
    participant GitHubActions as GitHub_Actions_Workflow
    participant GitHubOIDC as GitHub_OIDC_Provider
    participant Codecov as Codecov_Service

    Developer->>GitHubActions: Push or open pull_request
    GitHubActions->>GitHubActions: Start validate_pr workflow (permissions: contents read, id-token write)
    GitHubActions->>GitHubOIDC: Request ID token for Codecov audience
    GitHubOIDC-->>GitHubActions: Signed OIDC ID token
    GitHubActions->>Codecov: Run codecov_action with use_oidc true and coverage.xml
    Codecov->>GitHubOIDC: Verify ID token with GitHub OIDC
    Codecov-->>GitHubActions: Accept coverage upload (authenticated via OIDC)
Loading

File-Level Changes

Change Details Files
Enable GitHub OIDC-based authentication for Codecov uploads in the validate_pr workflow.
  • Add minimal workflow permissions, granting read access to repository contents and write access to id-token for OIDC federation
  • Update the Codecov upload step configuration to use OIDC-based authentication instead of a token by setting use_oidc to true
.github/workflows/validate_pr.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

Copy link
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey - I've found 1 issue, and left some high level feedback:

  • Consider scoping the id-token: write permission to only the job that performs the Codecov upload instead of setting it at the workflow level, so other jobs keep the most minimal permissions possible.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- Consider scoping the `id-token: write` permission to only the job that performs the Codecov upload instead of setting it at the workflow level, so other jobs keep the most minimal permissions possible.

## Individual Comments

### Comment 1
<location path=".github/workflows/validate_pr.yml" line_range="9-11" />
<code_context>
   pull_request:
     branches: [main]

+permissions:
+  contents: read
+  id-token: write
+
 jobs:
</code_context>
<issue_to_address>
**🚨 suggestion (security):** Consider scoping `id-token: write` to the specific job that needs it instead of at the workflow level.

Defining `id-token: write` at the workflow level gives that permission to every job, including future ones that don’t need OIDC. To limit exposure, move this permission to only the job that runs the Codecov upload (or other OIDC steps) and keep the workflow defaults as restrictive as possible.

Suggested implementation:

```
permissions:
  contents: read

```

```
jobs:
  lint:
    name: Lint
    permissions:
      id-token: write
        with:
          files: coverage.xml
          fail_ci_if_error: true
          use_oidc: true

```

1. Ensure the indentation under the `lint` job is correct YAML (the `with:` block should likely be nested under a specific step, not directly under the job). My change only adds the `permissions` block to the `lint` job; adjust indentation of the surrounding keys to match your existing steps structure.
2. If more jobs in this workflow also require OIDC, add a similar `permissions: id-token: write` block under those specific jobs rather than reintroducing it at the workflow level.
</issue_to_address>

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.

@martimlobao martimlobao changed the title feat: use OIDC for Codecov uploads feat: fix Codecov uploads Mar 10, 2026
@martimlobao martimlobao enabled auto-merge (squash) March 10, 2026 00:27
@martimlobao martimlobao disabled auto-merge March 10, 2026 00:27
@martimlobao martimlobao merged commit db86479 into main Mar 10, 2026
6 checks passed
@martimlobao martimlobao deleted the codex/fix-codecov-oidc branch March 10, 2026 00:27
@codecov-commenter
Copy link

Welcome to Codecov 🎉

Once you merge this PR into your default branch, you're all set! Codecov will compare coverage reports and display results in all future pull requests.

Thanks for integrating Codecov - We've got you covered ☂️

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.

2 participants