Skip to content

ci: add GitHub Code Quality coverage (Python + Go) alongside Codecov - #4308

Merged
jiridanek merged 4 commits into
mainfrom
ci/setup-github-code-coverage
Aug 12, 2026
Merged

jiridanek merged 4 commits into
mainfrom
ci/setup-github-code-coverage

Conversation

@jiridanek

@jiridanek jiridanek commented Aug 6, 2026 •

Copy link
Copy Markdown
Member

Description

Report code coverage to GitHub Code Quality (the native, first-party coverage view on PRs, GA July 2026) in addition to the existing Codecov uploads. The actions/upload-code-coverage steps are added next to the Codecov steps in the two jobs of code-quality.yaml that already generate coverage — no tests are re-run.

What changed (.github/workflows/code-quality.yaml)

  • pytest-tests — reuses the coverage.xml (Cobertura) already produced by pytest-cov via PYTEST_ADDOPTS; uploads it with language: Python, label: code-coverage/python.
  • go-tests — upload-code-coverage only accepts Cobertura, while go test/Codecov use the native .out. Adds a conversion step (gocover-cobertura — GitHub's documented Go recipe, pinned @v1.5.0) → coverage-go.xml, then uploads with language: Go, label: code-coverage/go.
  • Adds the code-quality: write permission to both jobs.
  • Uploads are non-blocking (fail-on-error: false, matching the existing fail_ci_if_error: false Codecov steps). The action self-skips fork PRs (read-only token) and merge-queue runs.
  • Checkout of the PR head (ref: ${{ github.event.pull_request.head.sha || github.sha }}) in both coverage jobs, so reports map to the commit the action attributes them to (matches the action's README example).
  • persist-credentials: false on the go-tests checkout (matches every other checkout here; avoids leaving the code-quality:write token in .git/config for PR code).
  • The Go conversion step is non-blocking (continue-on-error: true) and the Go upload is gated on its success, so optional coverage tooling can't fail the go-tests job.

Repo prerequisite: Code Quality must be enabled once — Settings → Security → Code quality → Enable code quality. If it isn't, the upload API returns 404, which is non-blocking (logged as a warning).

Docs: set-up-code-coverage · enable-code-quality · actions/upload-code-coverage

Known upstream limitations (tracked, not blocking)

Both live in the same gh pr list --head "${{ github.ref_name }}" line of actions/upload-code-coverage and only affect the push path:

  • Script injection — the action interpolates github.ref_name/github.ref into a shell run:. Reachable only with write access (which already grants CI code execution), so no marginal risk here. Reported upstream: actions/upload-code-coverage#26. (An earlier local metachar-denylist guard was reverted as security theater.)
  • Cross-repo PR misattribution — gh pr list --head matches by branch name only, so a fork PR whose head branch shares a pushed branch's name can capture the push's coverage and prevent the branch baseline from being recorded. Upstream: actions/upload-code-coverage#14. Intermittent, non-security, non-blocking. The action exposes no input to pass an explicit ref, so we'll adopt the upstream fix when it lands.

How Has This Been Tested?

  • yamllint --strict --config-file ci/yamllint-config.yaml passes on the edited workflow; actionlint accepts the workflow (its only complaints are the stale-schema code-quality-scope false positive — the scope is real but predates the bundled SchemaStore/actionlint definitions — and a pre-existing SC2038 unrelated to this PR).
  • actions/[email protected] was smoke-tested end-to-end on a fork branch: it generates and posts the report; the only failure mode was HTTP 404 when Code Quality isn't enabled on the repo (expected, non-blocking).
  • This PR's own code-quality.yaml run exercises the real path (same-repo PR → has code-quality:write + CODECOV_TOKEN).

Note: make test was not run locally — this is a CI-workflow-only change with no product code touched.

Self checklist (all need to be checked):

  • Ensure that you have run make test (gmake on macOS) before asking for review
  • Changes to everything except Dockerfile.konflux files should be done in odh/notebooks and automatically synced to rhds/notebooks. For Konflux-specific changes, modify Dockerfile.konflux files directly in rhds/notebooks as these require special attention in the downstream repository and flow to the upcoming RHOAI release.

Merge criteria:

  • The commits are squashed in a cohesive manner and have meaningful messages.
  • Testing instructions have been added in the PR body (for PRs involving changes that are not immediately obvious).
  • The developer has manually tested the changes and verified that the changes work

Add actions/upload-code-coverage steps next to the existing Codecov
uploads in code-quality.yaml so coverage also lands in GitHub's native
Code Quality view on PRs. Python reuses the pytest-cov coverage.xml; Go
converts coverage-go.out to Cobertura via gocover-cobertura (GitHub's
documented recipe). Both are non-blocking (fail-on-error: false) and the
action self-skips fork PRs and merge_group runs. Adds code-quality:write
to the pytest-tests and go-tests jobs.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
@openshift-ci
openshift-ci Bot requested review from dibryant and ysok August 6, 2026 08:15
@openshift-ci openshift-ci Bot added the size/m label Aug 6, 2026
@github-actions github-actions Bot added the review-requested GitHub Bot creates notification on #pr-review-ai-ide-team slack channel label Aug 6, 2026
@coderabbitai

coderabbitai Bot commented Aug 6, 2026 •

Copy link
Copy Markdown
Contributor
📝 Walkthrough

Walkthrough

The workflow grants code-quality: write permission to the Python and Go test jobs. Both jobs check out the PR head SHA when available. The Python job uploads coverage.xml to GitHub Code Quality. The Go job converts its coverage profile to Cobertura XML and uploads the result. Coverage conversion and uploads are non-blocking. No public entities change.

Estimated code review effort: 2 (Simple) | ~10 minutes

🚥 Pre-merge checks | ✅ 10 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
No Injection Vectors ⚠️ Warning CWE-78: pinned upload-code-coverage v1.4.1 interpolates github.ref and github.ref_name into shell code on push/dispatch; issue #26 confirms command execution from crafted branch names. Use a patched env-safe action version or fork, and pin it; otherwise restrict these uploads to pull_request events until the upstream fix is available.
✅ Passed checks (10 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Branch Prefix Policy ✅ Passed GitHub metadata shows baseRefName=main and title "ci: report code coverage to GitHub Code Quality (Python + Go)"; it has no branch prefix and is not exempt.
Contribution Quality And Spam Detection ✅ Passed The workflow change is codebase-specific and SHA-pinned, and the author has extensive prior repository history; no security-theater or code-quality signal is present.
No Hardcoded Secrets ✅ Passed The PR adds no literal credentials: it uses GitHub secret references, immutable action SHAs, and credential-free URLs; no hardcoded secret assignments were found (CWE-798).
No Weak Cryptography ✅ Passed The PR only changes CI coverage steps; added lines contain no MD5, SHA-1, DES, RC4, Blowfish, ECB, custom crypto, or secret comparisons (CWE-327 not triggered).
No Privileged Containers ✅ Passed PASS: The PR changes only .github/workflows/code-quality.yaml; it adds GitHub token permissions, not container privileges, and changes no Kubernetes/OpenShift manifest or Dockerfile.
No Sensitive Data In Logs ✅ Passed PASS: The PR adds no sensitive logging; credentials remain in stdin/action inputs, and coverage conversion writes files without printing payloads. CWE-532 not observed.
Title check ✅ Passed The title clearly describes the CI workflow change, uses imperative mood, and has no trailing period; it omits the recommended NO-JIRA reference.
Description check ✅ Passed The description includes the required change details and testing information, but two self-checklist items remain unchecked.

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

@github-actions

github-actions Bot commented Aug 6, 2026 •

Copy link
Copy Markdown
Contributor

📋 Review Summary

This pull request correctly adds native GitHub Code Quality coverage reporting for both Python and Go alongside existing Codecov uploads in .github/workflows/code-quality.yaml. The workflow changes are well-structured, securely non-blocking, and adhere to GitHub best practices.

🔍 General Feedback

  • The use of non-blocking error handling (fail-on-error: false and continue-on-error: true) ensures that optional coverage tool failures will not disrupt critical CI test jobs.
  • Checkout configuration properly balances persistence, depth, and PR-head mapping for accurate commit attribution.

I did not post any inline review comments.

@openshift-ci openshift-ci Bot added size/m and removed size/m labels Aug 6, 2026
@github-actions

github-actions Bot commented Aug 6, 2026 •

Copy link
Copy Markdown
Contributor

Superseded by newer run: https://github.com/opendatahub-io/notebooks/actions/runs/31085639052

CI status [antigravity]

Run: Build Notebooks (pr) #31084187378 — 3/3 complete · 1 passed · 2 skipped
Last updated: 2026-08-06T08:16:42Z

No workbench image jobs ran; all matrix jobs were skipped.

@codecov-commenter

codecov-commenter commented Aug 6, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 44.67%. Comparing base (3d2e97d) to head (a3b4b3f).
⚠️ Report is 4 commits behind head on main.
✅ All tests successful. No failed tests found.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #4308      +/-   ##
==========================================
+ Coverage   43.75%   44.67%   +0.91%     
==========================================
  Files          45       49       +4     
  Lines        5814     5997     +183     
  Branches      974      974              
==========================================
+ Hits         2544     2679     +135     
- Misses       3053     3101      +48     
  Partials      217      217              
Flag Coverage Δ
go 73.77% <ø> (?)
python 43.75% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.
see 4 files with indirect coverage changes


Continue to review full report in Codecov by Harness.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 3d2e97d...a3b4b3f. Read the comment docs.

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

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.

🧩 Analysis chain

🤖 web_search executed:

GitHub Code Quality pricing availability public private repositories GitHub Code Quality code coverage upload pricing

Length of output: 13803


@jiridanek, GitHub Code Quality has these charges:

  • Private repositories: USD 10 per active committer per month.
  • A committer is active when they push a commit to a repository with Code Quality enabled within the previous 90 days.
  • GitHub counts a person once across the organization or enterprise, even if they contribute to multiple enabled repositories.
  • GitHub App bots do not consume Code Quality licenses.
  • Public repositories: GitHub states USD 0 per committer, but AI-powered features can still incur usage charges.

Additional metered costs:

  • AI-assisted detection and Copilot Autofix consume GitHub AI Credits. GitHub documents 1 AI Credit = USD 0.01.
  • Deterministic Code Quality scans consume standard GitHub Actions minutes when they use GitHub-hosted runners. Self-hosted runners avoid GitHub-hosted runner minute charges.
  • The coverage upload action has no separately documented per-report fee. Cobertura coverage ingestion is included in Code Quality. The action uploads the existing coverage.xml; it does not run tests or generate coverage.

For this workflow, adding code-quality: write and actions/upload-code-coverage permits coverage upload. Charges start only when Code Quality is enabled for the repository or organization and applicable usage occurs.

GitHub Code Quality is available on GitHub Team and GitHub Enterprise Cloud. It is not available on GitHub Enterprise Server.

Sources: GitHub Code Quality billing, GitHub Code Quality pricing, Code Quality overview.

🐇🔍


🧠 Learnings used
Learnt from: jiridanek
Repo: opendatahub-io/notebooks PR: 3964
File: .github/workflows/build-notebooks-TEMPLATE.yaml:478-487
Timestamp: 2026-06-27T11:34:15.697Z
Learning: In GitHub Actions workflow files, don’t assume the default implicit `success()` guard is applied to steps when you write a step `if:` expression that includes status-checking functions (e.g., `!cancelled()` / `cancelled()`). If you want a step (or later steps) to run only when prior steps succeeded, include `success()` explicitly in the condition (e.g., `if: ${{ success() && !cancelled() && <other conditions> }}`); otherwise later steps may still run after an earlier failure unless the job is cancelled.

Learnt from: jiridanek
Repo: opendatahub-io/notebooks PR: 3977
File: .github/workflows/code-quality.yaml:58-74
Timestamp: 2026-06-29T19:39:22.589Z
Learning: In this repo’s GitHub Actions CI workflows (including `.github/workflows/code-quality.yaml` and other workflows under `.github/workflows/`), don’t add extra job steps or slower/complex setup (e.g., additional `actions/setup-go`, extra caching, or local buildinputs/build steps) solely to make PRs from forks pass when those fork PRs still can’t be fully tested anyway. Prefer improving the clarity of failure output/messages over introducing special-case logic or performance/complexity changes intended only to support fork PRs.

You are interacting with an AI system.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

This is a public repository, and same is true for the rhds fork. What does that mean about fees?

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.

🧩 Analysis chain

🤖 web_search executed:

site:docs.github.com GitHub Code Quality billing public repositories per active committer code coverage upload pricing

Length of output: 7417


🤖 web_search executed:

site:github.com/features/code-quality OR site:docs.github.com/en "*public repositories*" "Code Quality" pricing

Length of output: 9107


🤖 web_search executed:

site:github.com/features/code-quality GitHub Code Quality "$" active committer price

Length of output: 494


@jiridanek, public visibility removes the USD 10 per active committer per month GitHub Code Quality license fee for both opendatahub-io/notebooks and the public RHDS fork.

This workflow’s actions/upload-code-coverage uploads do not have a separately documented fee.

The remaining possible costs are:

  • GitHub Actions minutes: Standard GitHub-hosted runner usage is free for public repositories.
  • GitHub AI Credits: Charges can apply only if you enable and use AI-powered Code Quality features, such as AI-assisted detections or Copilot Autofix.

Therefore, enabling Code Quality only to ingest these Python and Go Cobertura reports should not create Code Quality license fees for either public repository.

My prior answer was incomplete because it did not make the public-repository license exemption clear.

Sources: GitHub Code Quality pricing, GitHub Code Quality billing, GitHub Actions billing.

You are interacting with an AI system.

@coderabbitai coderabbitai 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.

Actionable comments posted: 4

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In @.github/workflows/code-quality.yaml:
- Around line 204-206: Update the Go coverage conversion step containing
gocover-cobertura to set continue-on-error: true, then assign it an id and
condition the GitHub Code Quality coverage upload on that step's success.
Preserve the Go tests job even when installation or conversion fails.
- Line 156: Update the workflow conditions at
.github/workflows/code-quality.yaml lines 156, 198, and 220 to include success()
so coverage operations only run after preceding steps succeed. At line 156,
additionally require the static-tests step to have a successful conclusion
before Python coverage upload; apply the corresponding success guard to the
conversion and Go coverage upload conditions at lines 198 and 220.
- Around line 155-161: Update the Python checkout associated with
.github/workflows/code-quality.yaml lines 155-161 and the Go checkout at lines
219-225 to set ref to github.event.pull_request.head.sha with github.sha as
fallback. Do not modify the upload steps; ensure both language workflows check
out the PR head revision before generating coverage.
- Line 157: Remove the push-path shell injection by patching or replacing the
actions/upload-code-coverage usage at .github/workflows/code-quality.yaml lines
157-157 and 221-221, or restrict both invocations to trusted refs so
attacker-controlled github.ref_name values cannot reach shell execution while
preserving coverage uploads for trusted branches.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository YAML (base), Central YAML (inherited), Repository UI (inherited)

Review profile: CHILL

Plan: Enterprise

Run ID: 26865e40-a261-4658-b881-f8c07516a17e

📥 Commits

Reviewing files that changed from the base of the PR and between 3d2e97d and 481c847.

📒 Files selected for processing (1)
  • .github/workflows/code-quality.yaml
🔗 Linked repositories identified

CodeRabbit considers these linked repositories for cross-repo context during reviews:

  • opendatahub-io/kubeflow (manual)
  • opendatahub-io/opendatahub-operator (manual)
  • opendatahub-io/odh-dashboard (manual)

Comment thread .github/workflows/code-quality.yaml Resolved
Comment thread .github/workflows/code-quality.yaml Resolved
Comment thread .github/workflows/code-quality.yaml Resolved
Comment thread .github/workflows/code-quality.yaml Resolved
- Guard both upload-code-coverage steps against a script injection in the
  action's push path (it interpolates github.ref_name/github.ref into a
  shell run:); skip the upload when the branch name contains $ ` " \ .
- Make the Go Cobertura conversion non-blocking (continue-on-error) and gate
  the Go upload on its success, so optional coverage tooling can't fail the
  go-tests job.
- Check out the PR head (head.sha) in both coverage jobs so reports map to the
  commit the action attributes them to (matches the action's README example).

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
@openshift-ci openshift-ci Bot added size/m and removed size/m labels Aug 6, 2026
@github-actions

github-actions Bot commented Aug 6, 2026 •

Copy link
Copy Markdown
Contributor

Superseded by newer run: https://github.com/opendatahub-io/notebooks/actions/runs/31085641994

CI status [antigravity]

Run: Build Notebooks (push) #31085639052 — 3/3 complete · 3 skipped
Last updated: 2026-08-06T08:37:26Z

No workbench image jobs ran; all matrix jobs were skipped.

@openshift-ci openshift-ci Bot added size/m and removed size/m labels Aug 6, 2026
@github-actions

github-actions Bot commented Aug 6, 2026 •

Copy link
Copy Markdown
Contributor

Superseded by newer run: https://github.com/opendatahub-io/notebooks/actions/runs/31086894378

CI status [antigravity]

Run: Build Notebooks (pr) #31085641994 — 3/3 complete · 1 passed · 2 skipped
Last updated: 2026-08-06T08:37:50Z

No workbench image jobs ran; all matrix jobs were skipped.

@coderabbitai coderabbitai 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.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In @.github/workflows/code-quality.yaml:
- Around line 187-192: Update the checkout step in the Go code-quality job,
identified by the `actions/checkout` entry and its `ref` configuration, to set
`persist-credentials` to false. Keep the existing commit selection unchanged.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository YAML (base), Central YAML (inherited), Repository UI (inherited)

Review profile: CHILL

Plan: Enterprise

Run ID: 92d9af5f-2fc2-42ab-8831-978e5135d88a

📥 Commits

Reviewing files that changed from the base of the PR and between 481c847 and 1816873.

📒 Files selected for processing (1)
  • .github/workflows/code-quality.yaml
🔗 Linked repositories identified

CodeRabbit considers these linked repositories for cross-repo context during reviews:

  • opendatahub-io/kubeflow (manual)
  • opendatahub-io/opendatahub-operator (manual)
  • opendatahub-io/odh-dashboard (manual)

Comment thread .github/workflows/code-quality.yaml Resolved
The guard was security theater: the injection in actions/upload-code-coverage
is only reachable via push/workflow_dispatch to trusted branches, which already
require write access (= arbitrary CI execution). Replace the denylist with a
note linking the upstream report (actions/upload-code-coverage#26); the real
fix (inject via env:) belongs there.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
@openshift-ci openshift-ci Bot added size/m and removed size/m labels Aug 6, 2026
@github-actions

github-actions Bot commented Aug 6, 2026 •

Copy link
Copy Markdown
Contributor

Superseded by newer run: https://github.com/opendatahub-io/notebooks/actions/runs/31086897861

CI status [antigravity]

Run: Build Notebooks (push) #31086894378 — 3/3 complete · 3 skipped
Last updated: 2026-08-06T08:55:43Z

No workbench image jobs ran; all matrix jobs were skipped.

@openshift-ci openshift-ci Bot added size/m and removed size/m labels Aug 6, 2026
@github-actions

github-actions Bot commented Aug 6, 2026 •

Copy link
Copy Markdown
Contributor

Superseded by newer run: https://github.com/opendatahub-io/notebooks/actions/runs/31094189689

CI status [antigravity]

Run: Build Notebooks (pr) #31086897861 — 3/3 complete · 1 passed · 2 skipped
Last updated: 2026-08-06T08:56:13Z

No workbench image jobs ran; all matrix jobs were skipped.

@jiridanek

Copy link
Copy Markdown
Member Author

@coderabbitai thanks for the review — dispositions below (all pushed):

# Finding Disposition
① Script injection via github.ref_name Acknowledged, not guarded locally. The sink is inside actions/upload-code-coverage itself (it interpolates github.ref_name/github.ref into a shell run: on the push path), and it's only reachable via push/workflow_dispatch to trusted branches — which already require write access (= arbitrary CI execution). So a workflow-side guard adds no marginal risk. Reported upstream with the proper fix (env:): actions/upload-code-coverage#26.
② Go conversion could fail the job Fixed. Added continue-on-error: true + an id to the Cobertura conversion step, and gated the Go upload on steps.go-cobertura.outcome == 'success'.
③ Add success() guards on uploads Won't fix. The Python upload deliberately mirrors the existing "Upload Python coverage to Codecov" step's guard — pytest-cov writes coverage.xml even on failing tests, and coverage on a red run is desirable. Adding success() would drop coverage exactly when it's useful and diverge from the established pattern. The Go concern is covered more precisely by ②'s outcome-gate.
④ Check out PR head before generating coverage Fixed. Added `ref: ${{ github.event.pull_request.head.sha

Note: the two "unknown permission scope: code-quality" warnings from schema-based linters are false positives — the scope is real (shipped with GitHub Code Quality GA, July 2026) but predates the bundled SchemaStore/actionlint definitions.

@coderabbitai

coderabbitai Bot commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

Tip

For best results, initiate chat on the files or code changes.

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

ast-grep outline .github/workflows/code-quality.yaml --items all || true
printf '\n--- relevant workflow lines ---\n'
nl -ba .github/workflows/code-quality.yaml | sed -n '1,280p'
printf '\n--- current PR diff ---\n'
git diff --no-ext-diff HEAD^ HEAD -- .github/workflows/code-quality.yaml

Length of output: 785


🏁 Script executed:

#!/bin/bash
set -euo pipefail

printf '%s\n' '--- workflow ---'
sed -n '=' .github/workflows/code-quality.yaml | sed 'N;s/\n/\t/'

printf '%s\n' '--- recent commits affecting workflow ---'
git log --format='%H %s' -n 8 -- .github/workflows/code-quality.yaml

printf '%s\n' '--- latest workflow change ---'
git show --format=fuller --no-ext-diff -p -1 -- .github/workflows/code-quality.yaml

Length of output: 18699


@jiridanek I verified the current workflow.

I withdraw finding ①. The affected action path is limited here to push and workflow_dispatch on trusted branches. A user with that access can already execute arbitrary CI code. The upstream action still has a CWE-78 shell-injection defect. The upstream env: fix is the correct remediation.

Finding ② is addressed. The conversion step uses continue-on-error: true, and the Go Code Quality upload requires steps.go-cobertura.outcome == 'success'.

I withdraw finding ③. The Python upload condition permits coverage upload after a test failure. This matches the existing Codecov behavior and preserves failure diagnostics.

Finding ④ is addressed. Both coverage jobs check out ${{ github.event.pull_request.head.sha || github.sha }} before generating reports.

I found no remaining finding in these areas. The code-quality: write schema warnings do not require a workflow change.

ʕᵔᴥᵔʔ


✏️ Learnings added
Learnt from: jiridanek
URL: https://github.com/opendatahub-io/notebooks/pull/4308

Timestamp: 2026-08-06T08:59:37.306Z
Learning: In `.github/workflows/code-quality.yaml`, the Python GitHub Code Quality coverage upload must remain eligible after `make test` fails, provided dependency installation succeeded and the workflow is not cancelled. `pytest-cov` can still write `coverage.xml` on a failing test run, and the workflow intentionally mirrors the existing Codecov upload condition to preserve failure diagnostics.

Note: Learnings are effective only in the context of similar code segments. To apply general coding guidelines, please configure review instructions. You can manage existing learnings in the app.

You are interacting with an AI system.

@coderabbitai coderabbitai 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.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In @.github/workflows/code-quality.yaml:
- Around line 163-165: Update both coverage upload steps in
.github/workflows/code-quality.yaml at lines 163-165 and 233-235 to scope
pull-request lookup by the head repository. Use a patched
actions/upload-code-coverage revision that provides this protection, or submit
coverage with an explicit branch ref at each upload step.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository YAML (base), Central YAML (inherited), Repository UI (inherited)

Review profile: CHILL

Plan: Enterprise

Run ID: ffaab20a-d041-4494-a2b8-b71f64dd41dd

📥 Commits

Reviewing files that changed from the base of the PR and between 1816873 and 1a2c435.

📒 Files selected for processing (1)
  • .github/workflows/code-quality.yaml
🔗 Linked repositories identified

CodeRabbit considers these linked repositories for cross-repo context during reviews:

  • opendatahub-io/kubeflow (manual)
  • opendatahub-io/opendatahub-operator (manual)
  • opendatahub-io/odh-dashboard (manual)

Comment on lines +163 to +165
- name: Upload Python coverage to GitHub Code Quality
if: ${{ !cancelled() && steps.install-deps.conclusion == 'success' }}
uses: actions/upload-code-coverage@1c15be36fc3733ba839b1dd643bd9556e4426dc1 # v1.4.1

@coderabbitai coderabbitai Bot Aug 6, 2026 •

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.

🗄️ Data Integrity & Integration | 🟠 Major | 🏗️ Heavy lift

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -eu
printf '%s\n' '--- workflow context ---'
sed -n '1,280p' .github/workflows/code-quality.yaml
printf '%s\n' '--- GitHub workflow guidance ---'
if [ -f .github/AGENTS.md ]; then cat .github/AGENTS.md; fi
printf '%s\n' '--- all coverage-action references ---'
rg -n -C 3 'upload-code-coverage|coverage' .github/workflows .github/AGENTS.md 2>/dev/null || true

Repository: opendatahub-io/notebooks

Length of output: 24847


🏁 Script executed (no clone):

#!/bin/bash
set -eu
python3 - <<'PY'
import json, urllib.request
for url in [
    "https://api.github.com/repos/actions/upload-code-coverage/commits/1c15be36fc3733ba839b1dd643bd9556e4426dc1",
    "https://api.github.com/repos/actions/upload-code-coverage/git/ref/tags/v1.4.1",
    "https://raw.githubusercontent.com/actions/upload-code-coverage/1c15be36fc3733ba839b1dd643bd9556e4426dc1/action.yml",
]:
    print(f"--- {url} ---")
    try:
        with urllib.request.urlopen(url) as r:
            data = r.read().decode()
        if url.endswith("action.yml"):
            print(data)
        else:
            obj = json.loads(data)
            print(json.dumps({
                k: obj.get(k) for k in ("sha", "message", "html_url", "object", "type")
            }, indent=2))
    except Exception as e:
        print(type(e).__name__, e)
PY

Length of output: 881


🏁 Script executed (no clone):

#!/bin/bash
set -eu
api='https://api.github.com/repos/actions/upload-code-coverage'
curl_args=(-fsSLk -H 'Accept: application/vnd.github+json')

printf '%s\n' '--- pinned commit ---'
curl "${curl_args[@]}" "$api/commits/1c15be36fc3733ba839b1dd643bd9556e4426dc1" |
  jq '{sha, message: .commit.message, parents: [.parents[].sha]}'

printf '%s\n' '--- v1.4.1 tag ref ---'
ref=$(curl "${curl_args[@]}" "$api/git/ref/tags/v1.4.1")
printf '%s\n' "$ref" | jq '{ref, object}'
type=$(printf '%s\n' "$ref" | jq -r '.object.type')
object_sha=$(printf '%s\n' "$ref" | jq -r '.object.sha')
if [ "$type" = tag ]; then
  printf '%s\n' '--- dereferenced annotated tag ---'
  tagobj=$(curl "${curl_args[@]}" "$api/git/tags/$object_sha")
  printf '%s\n' "$tagobj" | jq '{tag, object}'
  tag_commit=$(printf '%s\n' "$tagobj" | jq -r '.object.sha')
else
  tag_commit=$object_sha
fi
printf '%s\n' '--- resolved tag commit ---'
curl "${curl_args[@]}" "$api/commits/$tag_commit" | jq '{sha, message: .commit.message}'
printf '%s\n' '--- pinned SHA resolution ---'
curl "${curl_args[@]}" "$api/commits/1c15be36fc3733ba839b1dd643bd9556e4426dc1" | jq -r '.sha'

printf '%s\n' '--- repository tree at pinned commit ---'
curl "${curl_args[@]}" "$api/git/trees/1c15be36fc3733ba839b1dd643bd9556e4426dc1?recursive=1" |
  jq -r '.tree[] | select(.path|test("(^|/)(action.yml|action.yaml|src/|dist/)")) | .path'

printf '%s\n' '--- action metadata ---'
curl "${curl_args[@]}" "https://raw.githubusercontent.com/actions/upload-code-coverage/1c15be36fc3733ba839b1dd643bd9556e4426dc1/action.yml"

printf '%s\n' '--- issue 26 ---'
curl "${curl_args[@]}" "$api/issues/26" |
  jq '{title, state, html_url, body, comments}'

Length of output: 372


🏁 Script executed (no clone):

#!/bin/bash
set -u
base='https://api.github.com/repos/actions/upload-code-coverage'
get() { curl --insecure --silent --show-error --location "$1"; }

printf '%s\n' '--- pinned commit ---'
get "$base/commits/1c15be36fc3733ba839b1dd643bd9556e4426dc1" |
  jq '{sha, message: .commit.message, parents: [.parents[].sha]}' || true

printf '%s\n' '--- v1.4.1 ref ---'
ref=$(get "$base/git/ref/tags/v1.4.1")
printf '%s\n' "$ref" | jq '{ref, object}' || true
type=$(printf '%s\n' "$ref" | jq -r '.object.type // empty')
object_sha=$(printf '%s\n' "$ref" | jq -r '.object.sha // empty')
if [ "$type" = tag ]; then
  printf '%s\n' '--- annotated tag object ---'
  tagobj=$(get "$base/git/tags/$object_sha")
  printf '%s\n' "$tagobj" | jq '{tag, object}' || true
  tag_commit=$(printf '%s\n' "$tagobj" | jq -r '.object.sha // empty')
else
  tag_commit=$object_sha
fi
printf '%s\n' '--- resolved tag commit ---'
[ -z "$tag_commit" ] || get "$base/commits/$tag_commit" | jq '{sha, message: .commit.message}' || true

printf '%s\n' '--- pinned action metadata ---'
get 'https://raw.githubusercontent.com/actions/upload-code-coverage/1c15be36fc3733ba839b1dd643bd9556e4426dc1/action.yml' || true

printf '%s\n' '--- pinned tree paths ---'
get "$base/git/trees/1c15be36fc3733ba839b1dd643bd9556e4426dc1?recursive=1" |
  jq -r '.tree[]? | .path' | sed -n '1,160p' || true

printf '%s\n' '--- issue 26 ---'
get "$base/issues/26" | jq '{title, state, html_url, body}' || true

Length of output: 4027


🌐 Web query:

actions/upload-code-coverage v1.4.1 branch name head repository association issue 26

💡 Result:

The issue described, specifically tracked in GitHub issue #14 of the actions/upload-code-coverage repository, concerns an incorrect association between push events and unrelated pull requests [1]. When a push event occurs on a branch (such as the default branch, e.g., 'main'), the action attempts to identify if there is an associated open pull request using the command 'gh pr list --head "${{ github.ref_name }}"' [1]. This command matches pull requests based solely on the head branch name across all repositories [1]. If a contributor has an open cross-repository (fork) pull request whose head branch happens to share the same name as the branch being pushed to (e.g., the contributor also uses 'main' in their fork), the action incorrectly selects that open PR [1]. As a result, the coverage data for the push event is attributed to the unrelated PR rather than the branch itself, preventing the branch baseline from being recorded correctly [1]. This often leads to PR comments stating that coverage data for the default branch is not yet available [1][2]. Workarounds identified by the community include: - Pinning the action to a patched fork that scopes the PR lookup to the base repository (e.g., checking 'headRepositoryOwner' and 'headRepository.name') to ignore cross-repo forks [1][2]. - Modifying the workflow logic to explicitly skip PR association for default branch pushes [1]. The official repository for actions/upload-code-coverage is https://github.com/actions/upload-code-coverage [3].

Citations:


🏁 Script executed (no clone):

#!/bin/bash
set -eu
raw='https://raw.githubusercontent.com/actions/upload-code-coverage/1c15be36fc3733ba839b1dd643bd9556e4426dc1'
get() { curl --insecure --silent --show-error --location "$1"; }

printf '%s\n' '--- upload script ---'
get "$raw/upload_coverage.py" | nl -ba | sed -n '1,280p'

printf '%s\n' '--- issue 14 ---'
curl --insecure --silent --show-error --location \
  'https://api.github.com/repos/actions/upload-code-coverage/issues/14' |
  jq '{title, state, html_url, body}' || true

printf '%s\n' '--- raw tag ref response ---'
curl --insecure --silent --show-error --location \
  'https://api.github.com/repos/actions/upload-code-coverage/git/ref/tags/v1.4.1' |
  sed -n '1,80p' || true

printf '%s\n' '--- raw commit response ---'
curl --insecure --silent --show-error --location \
  'https://api.github.com/repos/actions/upload-code-coverage/commits/1c15be36fc3733ba839b1dd643bd9556e4426dc1' |
  sed -n '1,80p' || true

Length of output: 990


🏁 Script executed (no clone):

#!/bin/bash
set -eu
python3 - <<'PY'
# Read-only behavioral verifier for the lookup described by action.yml.
# It demonstrates that the lookup key contains only the branch name and
# therefore cannot distinguish same-named branches in different repositories.
lookup = lambda branch, prs: next((pr for pr in prs if pr["head_ref"] == branch), None)
prs = [
    {"number": 101, "head_repo": "contributor/notebooks", "head_ref": "main"},
    {"number": 202, "head_repo": "opendatahub-io/notebooks", "head_ref": "main"},
]
selected = lookup("main", prs)
print({"selected_pr": selected["number"], "selected_head_repo": selected["head_repo"]})
print({"repository_scoping_present": "head_repo" in ["head_ref"]})
PY

Length of output: 231


Scope PR lookup by repository for both coverage uploads.

On push events, the pinned action matches open PRs by head branch name only. A same-named branch in a fork can receive the coverage report and prevent the branch baseline from being recorded (CWE-345). Use a patched revision that scopes the lookup to the head repository, or submit coverage with an explicit branch ref at both upload steps.

📍 Affects 1 file
  • .github/workflows/code-quality.yaml#L163-L165 (this comment)
  • .github/workflows/code-quality.yaml#L233-L235
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @.github/workflows/code-quality.yaml around lines 163 - 165, Update both
coverage upload steps in .github/workflows/code-quality.yaml at lines 163-165
and 233-235 to scope pull-request lookup by the head repository. Use a patched
actions/upload-code-coverage revision that provides this protection, or submit
coverage with an explicit branch ref at each upload step.

Source: MCP tools

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

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.

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

repo='actions/upload-code-coverage'
sha='1c15be36fc3733ba839b1dd643bd9556e4426dc1'

echo '--- pinned action metadata ---'
curl -fsSL "https://raw.githubusercontent.com/${repo}/${sha}/action.yml"

echo '--- pinned repository tree ---'
curl -fsSL "https://api.github.com/repos/${repo}/git/trees/${sha}?recursive=1" |
  jq -r '.tree[] | select(.path | test("\\.(py|js|sh)$")) | .path'

echo '--- potential PR lookup and ref handling in pinned source ---'
for file in action.yml upload_coverage.py; do
  echo "--- ${file} ---"
  curl -fsSL "https://raw.githubusercontent.com/${repo}/${sha}/${file}" |
    grep -nE -C 4 'pr list|head|ref_name|github\.ref|branch|pull request' || true
done

for issue in 14 26; do
  echo "--- issue ${issue} ---"
  curl -fsSL "https://api.github.com/repos/${repo}/issues/${issue}" |
    jq '{number, title, state, html_url, body}'
  echo "--- issue ${issue} comments ---"
  curl -fsSL "https://api.github.com/repos/${repo}/issues/${issue}/comments" |
    jq '[.[] | {html_url, body}]'
done

Length of output: 14526


@jiridanek, both issues apply to the pinned v1.4.1 revision.

  • Issue #26 confirms shell injection on the non-PR path. The action interpolates github.ref and github.ref_name directly into run:. This is CWE-94. The workflow currently reaches this path on push and workflow_dispatch.
  • Issue #14 confirms the separate coverage-association defect. The action runs gh pr list --head "${{ github.ref_name }}" without filtering headRepositoryOwner and headRepository. A same-named fork branch can receive coverage from a push to this repository. The branch baseline then is not recorded.

The original finding remains valid for issue #14. However, the “explicit branch ref” remediation is not available through the action’s declared inputs. The action internally chooses pull_request_number over ref on the push path.

A safe fix requires a patched action revision or a maintained local fork that:

  1. passes github.ref and github.ref_name through environment variables, and
  2. scopes the PR lookup to GITHUB_REPOSITORY.

The existing pinned upstream revision does neither.


🧠 Learnings used
Learnt from: jiridanek
Repo: opendatahub-io/notebooks PR: 3964
File: .github/workflows/build-notebooks-TEMPLATE.yaml:478-487
Timestamp: 2026-06-27T11:34:15.697Z
Learning: In GitHub Actions workflow files, don’t assume the default implicit `success()` guard is applied to steps when you write a step `if:` expression that includes status-checking functions (e.g., `!cancelled()` / `cancelled()`). If you want a step (or later steps) to run only when prior steps succeeded, include `success()` explicitly in the condition (e.g., `if: ${{ success() && !cancelled() && <other conditions> }}`); otherwise later steps may still run after an earlier failure unless the job is cancelled.

You are interacting with an AI system.

@jiridanek jiridanek added the tide/merge-method-squash Denotes a PR that should be squashed by tide when it merges. label Aug 6, 2026
Matches every other checkout in this workflow; the go-tests job now has
code-quality:write, so don't leave the token in .git/config for PR code to
reuse. The job only fetches public Go modules, so it needs no persisted creds.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
@openshift-ci openshift-ci Bot added size/m and removed size/m labels Aug 6, 2026
@github-actions

github-actions Bot commented Aug 6, 2026 •

Copy link
Copy Markdown
Contributor

Superseded by newer run: https://github.com/opendatahub-io/notebooks/actions/runs/31094194303

CI status [antigravity]

Run: Build Notebooks (push) #31094189689 — 3/3 complete · 3 skipped
Last updated: 2026-08-06T10:40:46Z

No workbench image jobs ran; all matrix jobs were skipped.

@github-actions

github-actions Bot commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

CI status [antigravity]

Run: Build Notebooks (pr) #31094194303 — 3/3 complete · 1 passed · 2 skipped
Last updated: 2026-08-06T10:41:28Z

No workbench image jobs ran; all matrix jobs were skipped.

@jiridanek

Copy link
Copy Markdown
Member Author

@coderabbitai two more findings addressed:

  • persist-credentials on the go-tests checkout (CWE-522): Fixed — added persist-credentials: false. Matches every other checkout in this workflow, and the job only fetches public Go modules so it needs no persisted creds.
  • PR lookup scoped by branch name only (CWE-345): Accepting, tracking upstream. Already an open upstream bug — Push to default branch attributes coverage to an unrelated fork PR with a same-named head branch actions/upload-code-coverage#14 — in the same gh pr list --head line as the injection (Display Python version on launcher  #26). The action exposes no input to pass an explicit ref, so the only local "fixes" are a maintained fork or dropping push-association (which loses the baseline). Impact here is intermittent, non-security, and non-blocking (fail-on-error: false): it only misattributes the push baseline when an open fork PR's head branch name collides with a pushed protected branch. We'll adopt the upstream fix when it lands.

@coderabbitai

coderabbitai Bot commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

Tip

For best results, initiate chat on the files or code changes.

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

printf '%s\n' '--- workflow structure ---'
ast-grep outline .github/workflows/code-quality.yaml --items all || true

printf '%s\n' '--- go-tests checkout and coverage steps ---'
nl -ba .github/workflows/code-quality.yaml | sed -n '1,280p'

printf '%s\n' '--- PR workflow diff ---'
git diff --no-ext-diff "$(git merge-base HEAD origin/main)" HEAD -- .github/workflows/code-quality.yaml || true

Length of output: 928


🏁 Script executed:

#!/bin/bash
set -euo pipefail

printf '%s\n' '--- upstream issues ---'
gh issue view 14 --repo actions/upload-code-coverage --json number,state,title,url,body
gh issue view 26 --repo actions/upload-code-coverage --json number,state,title,url,body

printf '%s\n' '--- upstream action metadata ---'
gh api repos/actions/upload-code-coverage/contents/action.yml --jq '.content' | base64 --decode | sed -n '1,260p'

Length of output: 10034


🏁 Script executed:

#!/bin/bash
set -euo pipefail

printf '%s\n' '--- workflow lines ---'
awk '{ printf "%5d  %s\n", NR, $0 }' .github/workflows/code-quality.yaml

printf '%s\n' '--- checkout blocks ---'
grep -n -A12 -B3 'uses: actions/checkout' .github/workflows/code-quality.yaml || true

printf '%s\n' '--- Go job context ---'
grep -n -A160 -B10 '^  go-tests:' .github/workflows/code-quality.yaml || true

printf '%s\n' '--- changed workflow lines versus merge base ---'
base="$(git merge-base HEAD origin/main)"
git diff --no-ext-diff "$base" HEAD -- .github/workflows/code-quality.yaml || true

Length of output: 31748


@jiridanek persist-credentials: false is present in the go-tests checkout at Line 187. This prevents the code-quality: write job token from being persisted in .git/config. The CWE-522 finding is addressed.

actions/upload-code-coverage#14 remains open. The action has no input for an explicit ref or PR association. Its push path still uses branch-name-only lookup. The CWE-345 attribution defect remains upstream. Keep this finding tracked until the action provides a fix.


✏️ Learnings added
Learnt from: jiridanek
URL: https://github.com/opendatahub-io/notebooks/pull/4308

Timestamp: 2026-08-06T11:17:29.507Z
Learning: In `.github/workflows/code-quality.yaml`, the `go-tests` job grants `code-quality: write`. Its `actions/checkout` step must set `persist-credentials: false` so the job token is not persisted in `.git/config` where pull request code could access it.

Note: Learnings are effective only in the context of similar code segments. To apply general coding guidelines, please configure review instructions. You can manage existing learnings in the app.

You are interacting with an AI system.

@jiridanek jiridanek changed the title ci: report code coverage to GitHub Code Quality (Python + Go) ci: add GitHub Code Quality coverage (Python + Go) alongside Codecov Aug 6, 2026
@openshift-ci openshift-ci Bot added size/m and removed size/m labels Aug 6, 2026
@jiridanek
jiridanek enabled auto-merge (squash) August 12, 2026 16:02
@jiridanek
jiridanek merged commit 200a08e into main Aug 12, 2026
36 of 37 checks passed
@jiridanek
jiridanek deleted the ci/setup-github-code-coverage branch August 12, 2026 16:02
@openshift-ci openshift-ci Bot added the lgtm label Aug 12, 2026
@openshift-ci

openshift-ci Bot commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: ide-developer
Once this PR has been reviewed and has the lgtm label, please assign daniellutz for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

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

Labels

lgtm review-requested GitHub Bot creates notification on #pr-review-ai-ide-team slack channel size/m tide/merge-method-squash Denotes a PR that should be squashed by tide when it merges.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants