ci: target compile/test to touched .ql files, fix silent test-step stderr - #199
Conversation
…derr pr-compile.sh: replace unconditional full-language compile with a three-way gate. A PR that only touches leaf .ql files now gets a fast, strict per-file recompile instead of compiling every query in the language. Any change to a shared library (.qll anywhere, not just lib/), qlpack.yml/lockfile/suite metadata, or a dependency/CLI version bump (.codeqlversion, .release.yml) still triggers a full, strict recompile - this also fixes a latent gap where a deleted dependency file was silently ignored. .github/** changes get a lenient full compile (matching the prior no-PR-context behavior) plus a strict per-file recompile of any touched queries. ci.yml Test Queries step: mirror the same classification to scope codeql test run to just the .qlref file(s) that test the touched .ql file(s), resolved via each .qlref's authoritative query: line (not folder-name convention, which is unreliable - see CWE-089/ CWE-208 test layouts). Falls back to the full 4-way sliced suite for any non-fast-path change. Also fixes test-step stderr always being discarded on success: the child's progress output now goes to a real per-slice log file that is always printed after the process exits, instead of being captured via communicate() and only shown on failure. Upload test results now also picks up these log files for post-hoc debugging. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 84006984-666d-4926-bbb8-795d91f3b5ab
There was a problem hiding this comment.
Pull request overview
This PR optimizes CI for CodeQL pack validation by scoping query compilation and test execution to the specific .ql files changed in a pull request when it’s safe to do so, while preserving full-suite behavior for changes that can affect the broader build/test surface. It also improves observability of codeql test run by always surfacing progress output that previously went missing on successful runs.
Changes:
- Update
.github/scripts/pr-compile.shto choose between strict full-language compile vs strict per-file compile based on PR file changes. - Update the CI “Test Queries” step to run targeted
.qlreftests for touched leaf queries (when eligible), otherwise run the full sliced suite. - Persist and upload per-slice test stderr/progress logs so successful runs are no longer silent and logs are available for debugging.
Show a summary per file
| File | Description |
|---|---|
.github/workflows/ci.yml |
Adds targeted test selection via .qlref→query: mapping, fixes missing stderr/progress visibility, and uploads per-slice logs. |
.github/scripts/pr-compile.sh |
Replaces unconditional full-language compilation with a gated strict full vs strict per-file compile strategy based on the PR diff. |
Review details
Suppressed comments (1)
.github/workflows/ci.yml:107
- This PR adds logic to treat changes to
.codeqlversion/.release.ymlas “must run full suite”, but thedorny/paths-filtergate forcompile-and-testonly matches${{ matrix.language }}/**and.github/**. A PR that only bumps.codeqlversion/.release.ymlwill skip the entire compile/test job, so these checks never take effect (and CI won’t validate dependency/CLI bumps as described).
for f in changed_files:
if f in (".codeqlversion", ".release.yml") or f.startswith(".github/"):
return None
if f.startswith(f"{language}/"):
- Files reviewed: 2/2 changed files
- Comments generated: 2
- Review effort level: Lite
Live validation: targeted CI on a real single-file PRTo validate this without guessing, I stacked a throwaway PR (#200, closing it now that it's confirmed) Before (full-suite java After (targeted java
The two steps this PR actually changes ( Any PR that touches a shared Closing #200 now - it's served its purpose. |
…le bug
The compile-and-test job's dorny/paths-filter only watched
`${{ matrix.language }}/**` and `.github/**`, so a PR that only bumps
.codeqlversion/.release.yml never set steps.changes.outputs.src and
the whole Install Packs/Compile Queries/Test Queries sequence was
skipped for every language on a real pull_request-triggered run - the
DEPENDENCY_CHANGED full-recompile branch this PR adds was unreachable
outside workflow_dispatch. Add both paths to the filter so a
dependency/CLI version bump actually triggers full validation across
every language, as intended.
Also fix print_error_and_fail passing args as an unpacked tuple
instead of *args - it printed a stray '()' after fatal error messages.
Pre-existing bug carried over unchanged from main, but it's inside the
block this PR rewrites, so fixing it here.
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 84006984-666d-4926-bbb8-795d91f3b5ab
pr-compile.sh: replace unconditional full-language compile with a
three-way gate. A PR that only touches leaf .ql files now gets a fast,
strict per-file recompile instead of compiling every query in the
language. Any change to a shared library (.qll anywhere, not just
lib/), qlpack.yml/lockfile/suite metadata, or a dependency/CLI version
bump (.codeqlversion, .release.yml) still triggers a full, strict
recompile - this also fixes a latent gap where a deleted dependency
file was silently ignored. .github/** changes get a lenient full
compile (matching the prior no-PR-context behavior) plus a strict
per-file recompile of any touched queries.
ci.yml Test Queries step: mirror the same classification to scope
codeql test run to just the .qlref file(s) that test the touched
.ql file(s), resolved via each .qlref's authoritative query: line
(not folder-name convention, which is unreliable - see CWE-089/
CWE-208 test layouts). Falls back to the full 4-way sliced suite for
any non-fast-path change.
Also fixes test-step stderr always being discarded on success: the
child's progress output now goes to a real per-slice log file that is
always printed after the process exits, instead of being captured via
communicate() and only shown on failure. Upload test results now also
picks up these log files for post-hoc debugging.
Co-authored-by: Copilot App 223556219+Copilot@users.noreply.github.com
Copilot-Session: 84006984-666d-4926-bbb8-795d91f3b5ab
Stack created with GitHub Stacks CLI • Give Feedback 💬