Overlay: Use overlay-aware CLI version when analyzing PRs#3880
Open
henrymercer wants to merge 6 commits intomainfrom
Open
Overlay: Use overlay-aware CLI version when analyzing PRs#3880henrymercer wants to merge 6 commits intomainfrom
henrymercer wants to merge 6 commits intomainfrom
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates how the Action selects the default CodeQL CLI version so that, when analyzing pull requests, it can prefer an enabled CLI version that already has cached overlay-base databases for the configured languages (to speed up overlay/incremental analysis), while still respecting feature-flag rollback constraints.
Changes:
- Extend the default CLI “version info” returned from feature flags to include a sorted list of enabled default versions (not just a single version).
- Add PR-aware logic in
setup-codeqlto optionally pick the highest enabled version that intersects with overlay-base DB cache entries (with dry-run telemetry support). - Thread the new version-info shape through callers and update unit tests and the changelog entry.
Show a summary per file
| File | Description |
|---|---|
| src/upload-lib.ts | Switches to the new getEnabledDefaultCliVersions API and passes rawLanguages through initCodeQL. |
| src/testing-utils.ts | Updates test fixtures/mocks for the new CodeQLDefaultVersionInfo.enabledVersions shape. |
| src/start-proxy.ts | Adapts to the new version-info shape by selecting enabledVersions[0] for proxy downloads. |
| src/start-proxy.test.ts | Updates stubbing to getEnabledDefaultCliVersions. |
| src/setup-codeql.ts | Implements overlay-aware default-version resolution for PR analyses (feature-flag gated) and threads rawLanguages. |
| src/setup-codeql.test.ts | Updates call sites for new rawLanguages parameter and adds unit tests for overlay-cache version filtering. |
| src/setup-codeql-action.ts | Updates to getEnabledDefaultCliVersions and passes rawLanguages (currently undefined). |
| src/init.ts | Threads rawLanguages through to setupCodeQL. |
| src/init-action.ts | Uses getEnabledDefaultCliVersions and passes rawLanguages derived from the languages input. |
| src/feature-flags.ts | Introduces CodeQLVersionInfo, changes default version info to enabledVersions[], and adds new overlay match feature flags. |
| src/feature-flags.test.ts | Updates tests to validate multi-version enablement ordering/fallback behavior. |
| src/codeql.ts | Threads rawLanguages into tool setup to support PR-aware version resolution. |
| src/codeql.test.ts | Updates tests for the new default-version info shape and new function signatures. |
| CHANGELOG.md | Adds an UNRELEASED entry describing the experimental overlay-aware default version selection. |
| lib/upload-sarif-action-post.js | Generated JS output (not reviewed). |
| lib/upload-lib.js | Generated JS output (not reviewed). |
| lib/start-proxy-action.js | Generated JS output (not reviewed). |
| lib/start-proxy-action-post.js | Generated JS output (not reviewed). |
| lib/resolve-environment-action.js | Generated JS output (not reviewed). |
| lib/init-action.js | Generated JS output (not reviewed). |
| lib/autobuild-action.js | Generated JS output (not reviewed). |
| lib/analyze-action.js | Generated JS output (not reviewed). |
| lib/analyze-action-post.js | Generated JS output (not reviewed). |
Copilot's findings
Comments suppressed due to low confidence (1)
src/start-proxy.test.ts:1029
- The stub variable is named
getDefaultCliVersion, but it actually stubsgetEnabledDefaultCliVersions. Renaming the local variable (and the later assertion) would avoid confusion and better reflect what’s being tested.
const getDefaultCliVersion = sinon
.stub(features, "getEnabledDefaultCliVersions")
.resolves({
enabledVersions: [{ cliVersion: "2.20.1", tagName: expectedTag }],
});
const path = await startProxyExports.getProxyBinaryPath(logger, features);
t.assert(getDefaultCliVersion.calledOnce);
sinon.assert.calledOnceWithMatch(
- Files reviewed: 14/26 changed files
- Comments generated: 3
Comment on lines
+303
to
+306
| let cachedVersions: string[] | undefined; | ||
| try { | ||
| cachedVersions = await getCodeQlVersionsForOverlayBaseDatabases( | ||
| rawLanguages, |
Comment on lines
+568
to
576
| const version = await resolveDefaultCliVersion( | ||
| defaultCliVersion, | ||
| rawLanguages, | ||
| features, | ||
| logger, | ||
| ); | ||
| cliVersion = version.cliVersion; | ||
| tagName = version.tagName; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When analyzing PRs, prefer CLI versions that have cached overlay-base databases to speed up analysis time. However to ensure we can effectively rollback new versions, do not use a CodeQL version whose feature flag is disabled, even if this means running without overlay analysis.
This will be shipped via two feature flags:
overlay_analysis_match_codeql_version_dry_runlogs a diagnostic when the overlay-aware version differs from the latest enabled versionoverlay_analysis_match_codeql_versionuses the overlay-aware version when analysing PRsRisk assessment
For internal use only. Please select the risk level of this change:
Which use cases does this change impact?
Workflow types:
dynamicworkflows (Default Setup, Code Quality, ...).Products:
analysis-kinds: code-scanning.analysis-kinds: code-quality.Environments:
github.comand/or GitHub Enterprise Cloud with Data Residency.How did/will you validate this change?
.test.tsfiles).If something goes wrong after this change is released, what are the mitigation and rollback strategies?
How will you know if something goes wrong after this change is released?
Are there any special considerations for merging or releasing this change?
Merge / deployment checklist