-
Notifications
You must be signed in to change notification settings - Fork 587
ci: use OIDC for codecov-action #5173
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -1,10 +1,10 @@ | ||||||||||||
| on: | ||||||||||||
| push: | ||||||||||||
| branches-ignore: | ||||||||||||
| - "gh-readonly-queue/**" | ||||||||||||
| - "copilot/**" | ||||||||||||
| - "dependabot/**" | ||||||||||||
| - "pre-commit-ci-update-config" | ||||||||||||
| - "gh-readonly-queue/**" | ||||||||||||
| - "copilot/**" | ||||||||||||
| - "dependabot/**" | ||||||||||||
| - "pre-commit-ci-update-config" | ||||||||||||
| pull_request: | ||||||||||||
| merge_group: | ||||||||||||
| concurrency: | ||||||||||||
|
|
@@ -18,22 +18,22 @@ jobs: | |||||||||||
| strategy: | ||||||||||||
| matrix: | ||||||||||||
| include: | ||||||||||||
| - check_memleak: true | ||||||||||||
| enable_tensorflow: true | ||||||||||||
| enable_pytorch: true | ||||||||||||
| enable_paddle: false | ||||||||||||
| - check_memleak: true | ||||||||||||
| enable_tensorflow: false | ||||||||||||
| enable_pytorch: false | ||||||||||||
| enable_paddle: true | ||||||||||||
| - check_memleak: false | ||||||||||||
| enable_tensorflow: true | ||||||||||||
| enable_pytorch: true | ||||||||||||
| enable_paddle: false | ||||||||||||
| - check_memleak: false | ||||||||||||
| enable_tensorflow: false | ||||||||||||
| enable_pytorch: false | ||||||||||||
| enable_paddle: true | ||||||||||||
| - check_memleak: true | ||||||||||||
| enable_tensorflow: true | ||||||||||||
| enable_pytorch: true | ||||||||||||
| enable_paddle: false | ||||||||||||
| - check_memleak: true | ||||||||||||
| enable_tensorflow: false | ||||||||||||
| enable_pytorch: false | ||||||||||||
| enable_paddle: true | ||||||||||||
| - check_memleak: false | ||||||||||||
| enable_tensorflow: true | ||||||||||||
| enable_pytorch: true | ||||||||||||
| enable_paddle: false | ||||||||||||
| - check_memleak: false | ||||||||||||
| enable_tensorflow: false | ||||||||||||
| enable_pytorch: false | ||||||||||||
| enable_paddle: true | ||||||||||||
| steps: | ||||||||||||
| - uses: actions/checkout@v6 | ||||||||||||
| - uses: actions/setup-python@v6 | ||||||||||||
|
|
@@ -54,7 +54,7 @@ jobs: | |||||||||||
| run: sudo sysctl vm.mmap_rnd_bits=28 | ||||||||||||
| if: ${{ matrix.check_memleak }} | ||||||||||||
| - run: | | ||||||||||||
| source/install/test_cc_local.sh | ||||||||||||
| source/install/test_cc_local.sh | ||||||||||||
| env: | ||||||||||||
| OMP_NUM_THREADS: 1 | ||||||||||||
| TF_INTRA_OP_PARALLELISM_THREADS: 1 | ||||||||||||
|
|
@@ -101,6 +101,8 @@ jobs: | |||||||||||
| - uses: codecov/codecov-action@v5 | ||||||||||||
| env: | ||||||||||||
| CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} | ||||||||||||
| with: | ||||||||||||
| use_oidc: true | ||||||||||||
| pass: | ||||||||||||
| name: Pass testing C++ | ||||||||||||
| needs: [testcc] | ||||||||||||
|
|
@@ -111,3 +113,5 @@ jobs: | |||||||||||
| uses: re-actors/alls-green@release/v1 | ||||||||||||
| with: | ||||||||||||
| jobs: ${{ toJSON(needs) }} | ||||||||||||
| permissions: | ||||||||||||
| id-token: write | ||||||||||||
|
Comment on lines
+116
to
+117
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 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 5Repository: deepmodeling/deepmd-kit Length of output: 274 🌐 Web query:
💡 Result:
Example: permissions:
contents: read
steps:
- uses: actions/checkout@v6Notes:
Sources: [1] [2] [3] Add Line 116 sets workflow-level permissions to only ✅ Suggested fix permissions:
+ contents: read
id-token: write📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -1,10 +1,10 @@ | ||||||||||||||||||
| on: | ||||||||||||||||||
| push: | ||||||||||||||||||
| branches-ignore: | ||||||||||||||||||
| - "gh-readonly-queue/**" | ||||||||||||||||||
| - "copilot/**" | ||||||||||||||||||
| - "dependabot/**" | ||||||||||||||||||
| - "pre-commit-ci-update-config" | ||||||||||||||||||
| - "gh-readonly-queue/**" | ||||||||||||||||||
| - "copilot/**" | ||||||||||||||||||
| - "dependabot/**" | ||||||||||||||||||
| - "pre-commit-ci-update-config" | ||||||||||||||||||
| pull_request: | ||||||||||||||||||
| merge_group: | ||||||||||||||||||
| concurrency: | ||||||||||||||||||
|
|
@@ -79,6 +79,8 @@ jobs: | |||||||||||||||||
| - uses: codecov/codecov-action@v5 | ||||||||||||||||||
| env: | ||||||||||||||||||
| CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} | ||||||||||||||||||
| with: | ||||||||||||||||||
| use_oidc: true | ||||||||||||||||||
|
Comment on lines
79
to
+83
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🌐 Web query:
💡 Result:
|
||||||||||||||||||
| - 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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
🏁 Script executed:
cat -n .github/workflows/test_python.yml | head -150Repository: 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: readYou 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@v5This 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).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
🌐 Web query:
codecov codecov-action v5 use_oidc CODECOV_TOKEN documentation💡 Result:
codecov/codecov-action@v5: using OIDC (noCODECOV_TOKEN)In v5, you can authenticate uploads with GitHub OIDC by setting
use_oidc: trueand granting the workflow (or job)id-token: writepermission. If you also pass a token, it will be ignored (OIDC is used instead). [1]Using
CODECOV_TOKEN(token-based upload)If you’re not using OIDC, pass a token either via the
token:input or theCODECOV_TOKENenvironment variable (typically sourced fromsecrets.CODECOV_TOKEN). [1][2]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_TOKENwhen using OIDC.When
use_oidc: trueis set in codecov-action v5, any provided token is ignored and OIDC is used for authentication instead. Exposing theCODECOV_TOKENsecret in this configuration unnecessarily increases secret exposure without providing any value.✅ Suggested fix
📝 Committable suggestion
🤖 Prompt for AI Agents