Skip to content

ci(codeql): drop the unused build and cache the Rust extractor's cargo output - #320

Merged
jpage-godaddy merged 1 commit into
mainfrom
slow-codeql
Oct 12, 2026
Merged

jpage-godaddy merged 1 commit into
mainfrom
slow-codeql

Conversation

@jpage-godaddy

Copy link
Copy Markdown
Collaborator

Summary

CodeQL runs on this repo take about 10 minutes. Roughly 2 minutes of that is a cargo build step that the analysis never uses, and about 1m45s of extraction is the Rust extractor compiling build scripts and proc macros from scratch.

  • Remove the cargo build step. Rust is analyzed without a build, and the extractor runs its own cargo commands in a scratch CARGO_TARGET_DIR that is empty on every run, so our build output was never reused. Removing it also stops the extractor from picking up generated rust/target/**/out/*.rs files and logging "semantic analyzer unavailable" warnings for them.
  • Cache the extractor's cargo output. CODEQL_ACTION_EXTRA_OPTIONS passes --extractor-option rust.cargo_target_dir=<runner temp>/codeql-rust-target to the extraction step, and that directory is cached together with ~/.cargo/registry and ~/.cargo/git, keyed on rust/Cargo.lock.

Expected effect: about 2 minutes saved on every run, and more once the cache is warm.

Verifying

Not yet exercised on CI, so check on this PR's run:

  1. In "Perform CodeQL Analysis", the extractor configuration shows cargo_target_dir: Some(".../codeql-rust-target") (it was None). If it is still None, the option isn't being applied. The cache is then harmless but pointless, and only the build-step removal helps.
  2. number of inputs drops from 228 (the generated files are no longer included) and the alert results are unchanged from main.
  3. The cache is populated by the first run on a branch, and PR caches are only visible to that branch and its fallbacks to main. The speedup shows on the second run, or after the first push to main.
  4. The new cache's size. cicd.yml already caches about 1.8 GB against the 10 GB repo limit.

🤖 Generated with Claude Code

…o output

CodeQL analyzes Rust without a build, and the extractor runs its own cargo
commands in a fresh scratch target directory on every run, so the workflow's
`cargo build` step never fed it. Remove that step (about 2 minutes per run).

Point the extractor at a persistent target directory via
`CODEQL_ACTION_EXTRA_OPTIONS` (`rust.cargo_target_dir`) and cache it, along
with the cargo registry, so build scripts and proc macros are not recompiled
from scratch each run.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>

Copilot AI 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.

🟢 Approval recommended

The focused workflow changes are internally consistent and preserve CodeQL analysis behavior.

0 open findings

What changed in this PR

Removes redundant CodeQL compilation and caches Rust extractor artifacts to reduce analysis time.

Changes:

  • Removes the unused cargo build.
  • Caches Cargo dependencies and extractor output.
  • Configures a persistent extractor target directory.
File Description
.github/​workflows/​codeql-analysis.yml Optimizes Rust CodeQL analysis and caching.

🧠 Review effort: Balanced


💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@jpage-godaddy
jpage-godaddy merged commit a79b01b into main Oct 12, 2026
6 checks passed
@jpage-godaddy
jpage-godaddy deleted the slow-codeql branch October 12, 2026 21:10
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