Skip to content

Conversation

@njzjz-bot
Copy link
Contributor

@njzjz-bot njzjz-bot commented Jan 24, 2026

Replace token-based authentication with OIDC (OpenID Connect) for codecov-action.
This is more secure and eliminates the need to manage upload tokens.

Changes:

  • Add use_oidc: true to codecov-action configuration
  • Add id-token: write permission at workflow level
  • Remove token parameter from codecov-action (ignored when using OIDC)

This improves security and follows codecov-action best practices.

Generated by the task: njzjz-bot/njzjz-bot#25.

Summary by CodeRabbit

  • Chores
    • Enhanced CI/CD pipeline security with OIDC-based authentication for code coverage reporting and updated workflow permissions configuration.

✏️ Tip: You can customize this high-level summary in your review settings.

Replace token-based authentication with OIDC (OpenID Connect) for codecov-action.
This is more secure and eliminates the need to manage upload tokens.

Changes:
- Add use_oidc: true to codecov-action configuration
- Add id-token: write permission at workflow level
- Remove token parameter from codecov-action (ignored when using OIDC)

This improves security and follows codecov-action best practices.

Generated by the task: njzjz-bot/njzjz-bot#25.
@dosubot dosubot bot added the build label Jan 24, 2026
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 24, 2026

📝 Walkthrough

Walkthrough

Two GitHub Actions workflow files are updated to enable OIDC-based authentication for Codecov integration. Both workflows receive top-level permissions blocks granting id-token write access, the codecov-action step is configured with use_oidc: true, and YAML formatting is adjusted for consistency.

Changes

Cohort / File(s) Summary
GitHub Actions OIDC Configuration
.github/workflows/test_cc.yml, .github/workflows/test_python.yml
Added top-level permissions block with id-token: write to both workflows. Updated codecov-action to use OIDC authentication via use_oidc: true. Minor YAML formatting adjustments including re-indentation of branch filtering arrays.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'ci: use OIDC for codecov-action' directly and accurately describes the main change: enabling OIDC authentication for codecov-action in CI workflows.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 4

🤖 Fix all issues with AI agents
In @.github/workflows/test_cc.yml:
- Around line 116-117: The workflow-level permissions block currently sets only
"id-token: write"; update the permissions block to include "contents: read"
alongside "id-token: write" so actions/checkout@v6 has the required repo read
access—modify the permissions section (the permissions: id-token: write entry)
to add contents: read at the same level.
- Around line 101-105: Remove the unnecessary CODECOV_TOKEN environment variable
from the codecov action block since codecov/codecov-action@v5 uses OIDC when
use_oidc: true; update the action stanza that references uses:
codecov/codecov-action@v5 and env: CODECOV_TOKEN to delete the CODECOV_TOKEN
entry so only use_oidc: true remains for authentication.

In @.github/workflows/test_python.yml:
- Around line 119-120: The workflow-level permissions currently set only
"id-token: write" override defaults and break actions/checkout; update the
permissions block by adding "contents: read" alongside "id-token: write" so
actions/checkout can access the repository contents (i.e., change the
permissions stanza that contains "id-token: write" to include "contents: read"
as well).
- Around line 79-83: The workflow still defines the CODECOV_TOKEN environment
variable for the codecov/codecov-action@v5 step while also setting with:
use_oidc: true; remove the unnecessary secret exposure by deleting the env:
CODECOV_TOKEN line (or conditionally set it only when use_oidc is false) so the
Codecov action relies on OIDC instead of the secret; locate the
codecov/codecov-action@v5 step to remove the CODECOV_TOKEN env entry and ensure
the with: use_oidc: true remains.

Comment on lines 101 to +105
- uses: codecov/codecov-action@v5
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
with:
use_oidc: true
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🌐 Web query:

codecov codecov-action v5 use_oidc CODECOV_TOKEN documentation

💡 Result:

codecov/codecov-action@v5: using OIDC (no CODECOV_TOKEN)

In v5, you can authenticate uploads with GitHub OIDC by setting use_oidc: true and granting the workflow (or job) id-token: write permission. If you also pass a token, it will be ignored (OIDC is used instead). [1]

permissions:
  id-token: write

steps:
  - uses: actions/checkout@v4
  - uses: codecov/codecov-action@v5
    with:
      use_oidc: true

Using CODECOV_TOKEN (token-based upload)

If you’re not using OIDC, pass a token either via the token: input or the CODECOV_TOKEN environment variable (typically sourced from secrets.CODECOV_TOKEN). [1][2]

- uses: codecov/codecov-action@v5
  with:
    token: ${{ secrets.CODECOV_TOKEN }}
# or:
- uses: codecov/codecov-action@v5
  env:
    CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}

When a token is required

Codecov’s docs note: private repos require a token; for public repos, token requirements depend on org/repo settings and whether the upload is for a protected branch (unless token auth for public repos is disabled). [2]

Sources: [1] codecov/codecov-action README (v5, “Using OIDC”, token env/input) • [2] Codecov Docs: “Codecov Tokens” (when tokens are required, how to set CODECOV_TOKEN)


Remove CODECOV_TOKEN when using OIDC.

When use_oidc: true is set in codecov-action v5, any provided token is ignored and OIDC is used for authentication instead. Exposing the CODECOV_TOKEN secret in this configuration unnecessarily increases secret exposure without providing any value.

✅ Suggested fix
 - uses: codecov/codecov-action@v5
-  env:
-    CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
   with:
     use_oidc: true
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
- uses: codecov/codecov-action@v5
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
with:
use_oidc: true
- uses: codecov/codecov-action@v5
with:
use_oidc: true
🤖 Prompt for AI Agents
In @.github/workflows/test_cc.yml around lines 101 - 105, Remove the unnecessary
CODECOV_TOKEN environment variable from the codecov action block since
codecov/codecov-action@v5 uses OIDC when use_oidc: true; update the action
stanza that references uses: codecov/codecov-action@v5 and env: CODECOV_TOKEN to
delete the CODECOV_TOKEN entry so only use_oidc: true remains for
authentication.

Comment on lines +116 to +117
permissions:
id-token: write
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

cat -n .github/workflows/test_cc.yml | sed -n '100,130p'

Repository: deepmodeling/deepmd-kit

Length of output: 662


🏁 Script executed:

rg 'actions/checkout' .github/workflows/test_cc.yml -B 2 -A 5

Repository: deepmodeling/deepmd-kit

Length of output: 274


🌐 Web query:

GitHub Actions actions/checkout permissions requirements contents read

💡 Result:

actions/checkout needs permission to read repository contents (so it can fetch/clone the repo) when it uses the default GITHUB_TOKEN. The action’s docs recommend explicitly setting: permissions: contents: read, unless you provide alternate auth via the token or ssh-key inputs. [1][2]

Example:

permissions:
  contents: read

steps:
  - uses: actions/checkout@v6

Notes:

  • Many orgs default GITHUB_TOKEN to read-only; explicitly setting contents: read makes the requirement clear and avoids failures when workflows otherwise have restricted permissions. [3]
  • If your workflow needs to push commits/tags, you’ll need contents: write (not just read). [3]

Sources: [1] [2] [3]


Add contents: read alongside id-token: write.

Line 116 sets workflow-level permissions to only id-token: write, which overrides defaults. The actions/checkout@v6 step requires contents: read permission and will fail without it.

✅ Suggested fix
 permissions:
+  contents: read
   id-token: write
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
permissions:
id-token: write
permissions:
contents: read
id-token: write
🤖 Prompt for AI Agents
In @.github/workflows/test_cc.yml around lines 116 - 117, The workflow-level
permissions block currently sets only "id-token: write"; update the permissions
block to include "contents: read" alongside "id-token: write" so
actions/checkout@v6 has the required repo read access—modify the permissions
section (the permissions: id-token: write entry) to add contents: read at the
same level.

Comment on lines 79 to +83
- uses: codecov/codecov-action@v5
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
with:
use_oidc: true
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🌐 Web query:

codecov/codecov-action v5 OIDC use_oidc CODECOV_TOKEN documentation

💡 Result:

codecov/codecov-action@v5: use_oidc vs CODECOV_TOKEN

Where it’s documented

  • The official action README documents OIDC uploads via the use_oidc input and explains that any provided token is ignored when OIDC is enabled. (github.com)
  • Codecov’s docs explain when a CODECOV_TOKEN is required (e.g., private repos; certain public/protected-branch scenarios) and how tokenless uploads can work in some public-repo configurations. (docs.codecov.com)

OIDC (tokenless) example (v5)

permissions:
  id-token: write

steps:
  - uses: actions/checkout@v4
  - uses: codecov/codecov-action@v5
    with:
      use_oidc: true
  • Requires GitHub Actions permission: id-token: write. (github.com)
  • If you set use_oidc: true, any token: / CODECOV_TOKEN you provide is ignored (OIDC is used instead). (github.com)

Token-based example (v5)

steps:
  - uses: actions/checkout@v4
  - uses: codecov/codecov-action@v5
    with:
      token: ${{ secrets.CODECOV_TOKEN }}

(or equivalently via env)

steps:
  - uses: actions/checkout@v4
  - uses: codecov/codecov-action@v5
    env:
      CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}

Both patterns are shown in the v5 README. (github.com)

When you still need CODECOV_TOKEN

Codecov documents that uploads generally require tokens for private repos, and for some public repo cases (notably protected branches depending on org settings). (docs.codecov.com)

Citations:


Remove CODECOV_TOKEN when using OIDC.

When use_oidc: true is configured, the CODECOV_TOKEN environment variable is ignored per the official codecov-action documentation. Keeping it exposes an unnecessary secret to the workflow and contradicts the security goal of OIDC adoption.

Suggested fix
 - uses: codecov/codecov-action@v5
-  env:
-    CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
   with:
     use_oidc: true
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
- uses: codecov/codecov-action@v5
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
with:
use_oidc: true
- uses: codecov/codecov-action@v5
with:
use_oidc: true
🤖 Prompt for AI Agents
In @.github/workflows/test_python.yml around lines 79 - 83, The workflow still
defines the CODECOV_TOKEN environment variable for the codecov/codecov-action@v5
step while also setting with: use_oidc: true; remove the unnecessary secret
exposure by deleting the env: CODECOV_TOKEN line (or conditionally set it only
when use_oidc is false) so the Codecov action relies on OIDC instead of the
secret; locate the codecov/codecov-action@v5 step to remove the CODECOV_TOKEN
env entry and ensure the with: use_oidc: true remains.

Comment on lines +119 to +120
permissions:
id-token: write
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

cat -n .github/workflows/test_python.yml | head -150

Repository: deepmodeling/deepmd-kit

Length of output: 5648


🌐 Web query:

GitHub Actions checkout requires contents: read permission workflow level

💡 Result:

actions/checkout needs the workflow’s GITHUB_TOKEN to be able to read the repository contents. If your workflow/job sets a restrictive permissions: block (or your org/repo default token permissions are restricted), you must grant at least:

permissions:
  contents: read

You can set this at the workflow level (applies to all jobs) or per-job:

name: CI
on: [push, pull_request]

permissions:
  contents: read

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v5

This is the permission recommended by actions/checkout itself. [1] GitHub also supports configuring default GITHUB_TOKEN permissions at the repo/org level, but an explicit permissions: block in the workflow/job is the reliable way to ensure checkout can read code. [2]

Sources: [1] [2]


Add contents: read alongside id-token: write.

Line 119 sets workflow permissions to only id-token: write, which overrides defaults. actions/checkout (line 25) requires contents: read permission and will fail without it when workflow-level permissions are explicitly set.

Suggested fix
 permissions:
+  contents: read
   id-token: write
🤖 Prompt for AI Agents
In @.github/workflows/test_python.yml around lines 119 - 120, The workflow-level
permissions currently set only "id-token: write" override defaults and break
actions/checkout; update the permissions block by adding "contents: read"
alongside "id-token: write" so actions/checkout can access the repository
contents (i.e., change the permissions stanza that contains "id-token: write" to
include "contents: read" as well).

@codecov
Copy link

codecov bot commented Jan 24, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 81.95%. Comparing base (e8afb6e) to head (06cc9c1).

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #5173   +/-   ##
=======================================
  Coverage   81.95%   81.95%           
=======================================
  Files         714      714           
  Lines       73434    73434           
  Branches     3616     3617    +1     
=======================================
  Hits        60180    60180           
  Misses      12091    12091           
  Partials     1163     1163           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant