ci: per-language CodeQL - Go scans on main and weekly, buildless languages on PRs#254
Conversation
The Go CodeQL job autobuilds the whole umbrella (~25 min). Today both the go and rust legs run on every code PR, so a Rust-only PR pays the full Go build for nothing. Add a detect job (GitHub API, no third-party actions per the org allowlist) that gates each language leg: on a PR only the changed language runs; pushes to main and the weekly schedule still run both for a complete baseline. A change to codeql.yml re-scans both. Go stays build-mode autobuild: CodeQL 2.26 confirmed Go does not support build-mode none. Co-authored-by: Balaji Ganesan <bganesan@nvidia.com> Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Enterprise Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughThe CodeQL workflow narrows its source path filters, detects changed Go and Rust files for pull requests, publishes a dynamic analysis matrix, and skips analysis when neither language changes. Non-PR runs continue analyzing both languages. ChangesCodeQL language routing
Estimated code review effort: 3 (Moderate) | ~20 minutes Sequence Diagram(s)sequenceDiagram
participant PullRequest
participant GitHubAPI
participant detect
participant analyze
PullRequest->>GitHubAPI: Request changed files
GitHubAPI-->>detect: Return file list
detect->>detect: Build selected language matrix and any flag
detect->>analyze: Provide selected language matrix
analyze->>analyze: Run matching CodeQL analysis
Possibly related PRs
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 3
🤖 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/codeql.yml:
- Around line 67-68: Update the Go and Rust file-detection regexes in the
workflow so manifest alternatives match either the repository root or a path
separator, using (^|/) before go.mod, go.sum, Cargo.toml, and Cargo.lock.
Preserve the existing extension matching and language-flag behavior.
- Line 61: Update the pull-request file lookup around the gh api invocation to
avoid suppressing command failures via “|| true”. Ensure an API error causes the
workflow step to fail, or explicitly fall back to scanning both languages rather
than treating an empty files value as no matching changes.
- Around line 75-81: Update the analyze job’s matrix gating so its if condition
does not reference matrix.language before matrix expansion. Use detect’s
generated matrix output, or split the job into language-specific jobs gated by
needs.detect.outputs.go and needs.detect.outputs.rust, while preserving the
behavior of running changed languages on pull requests and both languages on
pushes or schedules.
🪄 Autofix (Beta)
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: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Enterprise
Run ID: bcdcbaeb-9999-4d9f-bfd1-bc2450af32db
📒 Files selected for processing (1)
.github/workflows/codeql.yml
…ob if matrix context is not available in a job-level if, which caused a workflow startup failure. Have the detect job emit the matrix JSON (only the changed languages) and gate analyze on a simple needs output instead. Co-authored-by: Balaji Ganesan <bganesan@nvidia.com> Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
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/codeql.yml:
- Around line 72-73: Update the file-detection regexes in the workflow’s
language-selection logic to match repository-root go.mod, go.sum, Cargo.toml,
and Cargo.lock files as well as nested manifests; remove the requirement for a
preceding slash in those manifest alternatives while preserving source-file
matching.
🪄 Autofix (Beta)
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: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Enterprise
Run ID: c52efdb0-83d3-4627-b989-5fb8b1490e3d
📒 Files selected for processing (1)
.github/workflows/codeql.yml
🛡️ CodeQL Analysis🚨 Found 2 issue(s) Severity Breakdown:
📋 Top Issues🔗 View full details in Security tab 🕐 Last updated: 2026-07-19 04:27:31 UTC | Commit: 13b9f10 |
Go is the only language in the stack whose CodeQL analysis requires a traced build (build-mode none is supported for C/C++, C#, Java, and Rust, but not Go), and its autobuild compiles the whole umbrella (~21 min) for advisory-only PR feedback (fail-on-findings is false). Exclude Go from PR scans: every push to main and the weekly schedule still scan Go fully, so the security baseline is unchanged and detection moves from pre-merge to at-merge. Rust (buildless, ~2.5 min) keeps scanning on PRs, and Java can join as build-mode none when it lands. Co-authored-by: Balaji Ganesan <bganesan@nvidia.com> Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
balaji-g
left a comment
There was a problem hiding this comment.
Reviewed: verification evidence in the PR description checks out (local + CI runs).
Address review feedback on the per-language gating: - Do not swallow the changed-file lookup failure. Previously `gh api ... || true` left `files` empty on an API error, which the PR path treated as "no code changed" and silently skipped both scans. Now a lookup failure falls back to scanning all languages (fail-open), so a transient error never drops coverage. - Match repository-root manifests. gh api filenames are repo-relative with no leading slash, so anchor Cargo.toml/Cargo.lock (and the workflow self-match) with (^|/) to catch both root and nested files. - Do not run CodeQL on docs-only changes. Drop the broad "src/**" path trigger; code is already covered by the *.go/*.rs + manifest globs, so a Markdown or other non-code change under src/ no longer starts the workflow. Co-authored-by: Balaji Ganesan <bganesan@nvidia.com> Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
|
Addressed the review feedback in the latest commit:
|
Why
The Go CodeQL job autobuilds the entire umbrella (~21 min per run). Go is the
only language in the stack whose analysis requires a traced build: CodeQL's
build-mode: noneis supported for C/C++, C#, Java, and Rust, but not Go (theCLI rejects it, and #253 proved that live). The scan is also advisory on PRs
(
fail-on-findings: false), so every Go-touching PR paid 21 minutes fornon-blocking feedback.
What changed
.github/workflows/codeql.ymlgains adetectjob (GitHub API file listing,no third-party action per the org allowlist) that emits a dynamic analyze
matrix:
and only when the PR touches Rust files or this workflow. Go never scans on
PRs. Java joins as
build-mode: nonewhen it lands in the mirror.languages, Go included. The Security-tab baseline is unchanged; Go detection
moves from pre-merge to at-merge.
The matrix is emitted as JSON by
detect(a job-levelifcannot referencethe
matrixcontext, which caused this branch's earlier startup failure - nowalso guarded repo-wide by the actionlint gate in #255).
Testing
Rust-touching PR scans rust only, codeql.yml PR scans rust only, push and
schedule scan both.
detectselected rust only, and thechecks list shows CodeQL (rust) with no 21-minute Go leg.
References
NO-REF (CI efficiency change; no associated issue).
Summary by CodeRabbit