Skip to content

Commit 71844e5

Browse files
Copilotfelickz
andauthored
Replace nightly-until-stable-<version> with nightly-until-default-<version>
Compares the threshold directly against the Action's known default CLI version instead of querying the release list, per feedback. Co-authored-by: felickz <1760475+felickz@users.noreply.github.com>
1 parent 8f22549 commit 71844e5

6 files changed

Lines changed: 298 additions & 101 deletions

File tree

‎CHANGELOG.md‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ See the [releases page](https://github.com/github/codeql-action/releases) for th
66

77
- The `tools` input for the `init` and `setup-codeql` Actions now accepts a bare CodeQL CLI version number, for example `2.19.0` or `v2.19.0`. The Action will automatically download the CodeQL Bundle release asset that matches the runner's operating system and architecture, preferring the smaller `zstd`-compressed bundle where it is supported.
88
- The `tools` input also now accepts a CodeQL CLI version range, for example `2.24.x`, `2.x`, `~2.24.0`, or `^2.24.0`, as well as `latest-<N>` (for example `latest-1`), which resolves to the CodeQL Bundle release `N` stable releases before the most recent one.
9-
- The `tools` input also now accepts `latest-prerelease`, which resolves to the most recent CodeQL Bundle release, whether it is a stable release or a GitHub prerelease, as well as `nightly-until-<version>` and `nightly-until-stable-<version>` (for example `nightly-until-2.24.0`), which resolve to the most recent CodeQL Bundle release satisfying that version threshold, considering GitHub prereleases too unless `-stable` is specified, or fall back to the latest nightly version of the CodeQL tools if no such release exists.
9+
- The `tools` input also now accepts `latest-prerelease`, which resolves to the most recent CodeQL Bundle release, whether it is a stable release or a GitHub prerelease, as well as `nightly-until-<version>` (for example `nightly-until-2.24.0`), which resolves to the most recent CodeQL Bundle release satisfying that version threshold, considering GitHub prereleases too, or falls back to the latest nightly version of the CodeQL tools if no such release exists.
10+
- The `tools` input also now accepts `nightly-until-default-<version>` (for example `nightly-until-default-2.24.0`), which uses the default CodeQL CLI version for this environment if it satisfies that version threshold, or falls back to the latest nightly version of the CodeQL tools otherwise.
1011

1112
## 4.37.5 - 03 Aug 2026
1213

‎init/action.yml‎

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,14 @@ inputs:
2020
uses the CodeQL Bundle release `N` stable releases before the most recent one, or
2121
- A special value `latest-prerelease` (matching is case insensitive) which uses the most
2222
recent CodeQL Bundle release, whether it is a stable release or a GitHub prerelease, or
23-
- `nightly-until-<version>` or `nightly-until-stable-<version>`, for example
24-
`nightly-until-2.24.0` or `NIGHTLY-UNTIL-STABLE-2.24.0` (matching is case insensitive),
25-
which uses the most recent CodeQL Bundle release satisfying that version threshold,
26-
considering GitHub prereleases too unless `-stable` is specified, or falls back to the
27-
latest nightly version of the CodeQL tools if no such release exists, or
23+
- `nightly-until-<version>`, for example `nightly-until-2.24.0` or
24+
`NIGHTLY-UNTIL-2.24.0` (matching is case insensitive), which uses the most recent CodeQL
25+
Bundle release satisfying that version threshold, considering GitHub prereleases too, or
26+
falls back to the latest nightly version of the CodeQL tools if no such release exists, or
27+
- `nightly-until-default-<version>`, for example `nightly-until-default-2.24.0` (matching
28+
is case insensitive), which uses the default CodeQL CLI version if it satisfies that
29+
version threshold, or falls back to the latest nightly version of the CodeQL tools
30+
otherwise, or
2831
- A special value `linked` which uses the version of the CodeQL tools
2932
that the Action has been bundled with.
3033
- A special value `nightly` which uses the latest nightly version of the

‎lib/entry-points.js‎

Lines changed: 32 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎setup-codeql/action.yml‎

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,14 @@ inputs:
2020
uses the CodeQL Bundle release `N` stable releases before the most recent one, or
2121
- A special value `latest-prerelease` (matching is case insensitive) which uses the most
2222
recent CodeQL Bundle release, whether it is a stable release or a GitHub prerelease, or
23-
- `nightly-until-<version>` or `nightly-until-stable-<version>`, for example
24-
`nightly-until-2.24.0` or `NIGHTLY-UNTIL-STABLE-2.24.0` (matching is case insensitive),
25-
which uses the most recent CodeQL Bundle release satisfying that version threshold,
26-
considering GitHub prereleases too unless `-stable` is specified, or falls back to the
27-
latest nightly version of the CodeQL tools if no such release exists, or
23+
- `nightly-until-<version>`, for example `nightly-until-2.24.0` or
24+
`NIGHTLY-UNTIL-2.24.0` (matching is case insensitive), which uses the most recent CodeQL
25+
Bundle release satisfying that version threshold, considering GitHub prereleases too, or
26+
falls back to the latest nightly version of the CodeQL tools if no such release exists, or
27+
- `nightly-until-default-<version>`, for example `nightly-until-default-2.24.0` (matching
28+
is case insensitive), which uses the default CodeQL CLI version if it satisfies that
29+
version threshold, or falls back to the latest nightly version of the CodeQL tools
30+
otherwise, or
2831
- A special value `linked` which uses the version of the CodeQL tools
2932
that the Action has been bundled with.
3033
- A special value `nightly` which uses the latest nightly version of the

‎src/setup-codeql.test.ts‎

Lines changed: 138 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -422,8 +422,7 @@ function mockListStableCodeQLBundleReleases(
422422
/**
423423
* As `mockListStableCodeQLBundleReleases`, but additionally mocks the CodeQL nightlies
424424
* repository's release list, so that fallback to the latest nightly bundle can be tested when no
425-
* release satisfies a `nightly-until-<version>` or `nightly-until-stable-<version>` version
426-
* threshold.
425+
* release satisfies a `nightly-until-<version>` version threshold.
427426
*/
428427
function mockListCodeQLBundleReleasesWithNightlyFallback(
429428
releases: unknown[],
@@ -662,9 +661,9 @@ test.serial(
662661

663662
/**
664663
* A set of CodeQL bundle releases that includes GitHub prereleases, used to test resolution of
665-
* the `latest-prerelease` and `nightly-until-<version>`/`nightly-until-stable-<version>` forms of
666-
* the `tools` input in the case where the newest release overall is a stable release, even though
667-
* prereleases exist. `STABLE_BUNDLE_RELEASES_TEST_SET` above covers the opposite case, where the
664+
* the `latest-prerelease` and `nightly-until-<version>` forms of the `tools` input in the case
665+
* where the newest release overall is a stable release, even though prereleases exist.
666+
* `STABLE_BUNDLE_RELEASES_TEST_SET` above covers the opposite case, where the
668667
* newest release overall is a prerelease.
669668
*/
670669
const PRERELEASE_BUNDLE_RELEASES_TEST_SET = [
@@ -798,24 +797,6 @@ const NIGHTLY_UNTIL_RESOLVES_TOOLS_INPUT_TEST_CASES = [
798797
releases: PRERELEASE_BUNDLE_RELEASES_TEST_SET,
799798
expectedCliVersion: "2.27.0",
800799
},
801-
{
802-
name: "nightly-until-stable: threshold exactly matches the newest stable release",
803-
toolsInput: "nightly-until-stable-2.25.3",
804-
releases: STABLE_BUNDLE_RELEASES_TEST_SET,
805-
expectedCliVersion: "2.25.3",
806-
},
807-
{
808-
name: "nightly-until-stable: the newest stable release comfortably exceeds the threshold",
809-
toolsInput: "nightly-until-stable-2.20.0",
810-
releases: STABLE_BUNDLE_RELEASES_TEST_SET,
811-
expectedCliVersion: "2.25.3",
812-
},
813-
{
814-
name: "nightly-until-stable: matching is case insensitive",
815-
toolsInput: "NIGHTLY-UNTIL-STABLE-2.25.3",
816-
releases: STABLE_BUNDLE_RELEASES_TEST_SET,
817-
expectedCliVersion: "2.25.3",
818-
},
819800
] as const;
820801

821802
for (const {
@@ -853,15 +834,142 @@ for (const {
853834
);
854835
}
855836

837+
/**
838+
* `nightly-until-default-<version>` compares the given version threshold directly against
839+
* `SAMPLE_DEFAULT_CLI_VERSION`'s CLI version, `2.20.0`, without ever listing CodeQL bundle
840+
* releases. When the default version is at or above the threshold, resolution should proceed
841+
* exactly as if `tools` were not specified at all.
842+
*/
843+
const NIGHTLY_UNTIL_DEFAULT_RESUMES_DEFAULT_TOOLS_INPUT_TEST_CASES = [
844+
{
845+
name: "the default CLI version exactly matches the threshold",
846+
toolsInput: "nightly-until-default-2.20.0",
847+
},
848+
{
849+
name: "the default CLI version exceeds the threshold",
850+
toolsInput: "nightly-until-default-2.19.0",
851+
},
852+
{
853+
name: "matching is case insensitive",
854+
toolsInput: "NIGHTLY-UNTIL-DEFAULT-2.20.0",
855+
},
856+
] as const;
857+
858+
for (const {
859+
name,
860+
toolsInput,
861+
} of NIGHTLY_UNTIL_DEFAULT_RESUMES_DEFAULT_TOOLS_INPUT_TEST_CASES) {
862+
test.serial(
863+
`getCodeQLSource resumes normal default CLI version selection for 'tools: ${toolsInput}', since ${name}`,
864+
async (t) => {
865+
const loggedMessages: LoggedMessage[] = [];
866+
const logger = getRecordingLogger(loggedMessages);
867+
const features = createFeatures([]);
868+
869+
// No release-list API request should be made, so if one is attempted, the test will fail.
870+
const client = github.getOctokit("123");
871+
const listReleases = sinon.stub(client.rest.repos, "listReleases");
872+
sinon.stub(api, "getApiClient").value(() => client);
873+
874+
await withTmpDir(async (tmpDir) => {
875+
setupActionsVars(tmpDir, tmpDir);
876+
const source = await setupCodeql.getCodeQLSource(
877+
toolsInput,
878+
SAMPLE_DEFAULT_CLI_VERSION,
879+
undefined, // rawLanguages
880+
false, // useOverlayAwareDefaultCliVersion
881+
SAMPLE_DOTCOM_API_DETAILS,
882+
GitHubVariant.DOTCOM,
883+
false,
884+
features,
885+
logger,
886+
);
887+
888+
t.is(
889+
source.toolsVersion,
890+
SAMPLE_DEFAULT_CLI_VERSION.enabledVersions[0].cliVersion,
891+
);
892+
t.true(listReleases.notCalled);
893+
checkExpectedLogMessages(t, loggedMessages, [
894+
`'tools: ${toolsInput}' was requested, so using the default CodeQL version`,
895+
]);
896+
});
897+
},
898+
);
899+
}
900+
901+
test.serial(
902+
"getCodeQLSource falls back to the latest nightly bundle for 'tools: nightly-until-default-<version>', since the default CLI version does not satisfy the threshold",
903+
async (t) => {
904+
const loggedMessages: LoggedMessage[] = [];
905+
const logger = getRecordingLogger(loggedMessages);
906+
const features = createFeatures([]);
907+
908+
const expectedDate = "30260213";
909+
const expectedTag = `codeql-bundle-${expectedDate}`;
910+
911+
// Ensure that we consistently select "zstd" for the test.
912+
sinon.stub(process, "platform").value("linux");
913+
sinon.stub(tar, "isZstdAvailable").resolves({
914+
available: true,
915+
foundZstdBinary: true,
916+
});
917+
918+
// No release-list API request for the canonical CodeQL Action repository should be made;
919+
// only the nightly repository's release list should be queried, via the same authenticated
920+
// client used elsewhere in this file.
921+
const client = github.getOctokit("123");
922+
const listReleases = sinon.stub(client.rest.repos, "listReleases");
923+
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
924+
listReleases.resolves({
925+
data: [{ tag_name: expectedTag }],
926+
} as any);
927+
sinon.stub(api, "getApiClient").value(() => client);
928+
929+
const toolsInput = "nightly-until-default-2.21.0";
930+
931+
await withTmpDir(async (tmpDir) => {
932+
setupActionsVars(tmpDir, tmpDir);
933+
const source = await setupCodeql.getCodeQLSource(
934+
toolsInput,
935+
SAMPLE_DEFAULT_CLI_VERSION,
936+
undefined, // rawLanguages
937+
false, // useOverlayAwareDefaultCliVersion
938+
SAMPLE_DOTCOM_API_DETAILS,
939+
GitHubVariant.DOTCOM,
940+
false,
941+
features,
942+
logger,
943+
);
944+
945+
const expectedVersion = `0.0.0-${expectedDate}`;
946+
const expectedURL = `https://github.com/dsp-testing/codeql-cli-nightlies/releases/download/${expectedTag}/${setupCodeql.getCodeQLBundleName("zstd")}`;
947+
t.deepEqual(source, {
948+
bundleVersion: expectedDate,
949+
cliVersion: undefined,
950+
codeqlURL: expectedURL,
951+
compressionMethod: "zstd",
952+
sourceType: "download",
953+
toolsVersion: expectedVersion,
954+
} satisfies setupCodeql.CodeQLToolsSource);
955+
956+
t.true(
957+
listReleases.neverCalledWith(
958+
sinon.match({ owner: "github", repo: "codeql-action" }),
959+
),
960+
);
961+
checkExpectedLogMessages(t, loggedMessages, [
962+
`Using the latest CodeQL CLI nightly, as requested by 'tools: ${toolsInput}', since the`,
963+
]);
964+
});
965+
},
966+
);
967+
856968
const NIGHTLY_UNTIL_FALLBACK_TOOLS_INPUT_TEST_CASES = [
857969
{
858970
name: "no release, stable or prerelease, satisfies the threshold",
859971
toolsInput: "nightly-until-9.0.0",
860972
},
861-
{
862-
name: "only a prerelease, not a stable release, would satisfy the threshold",
863-
toolsInput: "nightly-until-stable-2.25.4",
864-
},
865973
] as const;
866974

867975
for (const {
@@ -925,7 +1033,7 @@ for (const {
9251033
const MALFORMED_NIGHTLY_UNTIL_THRESHOLD_TOOLS_INPUT_TEST_CASES = [
9261034
{ toolsInput: "nightly-until-bogus", expectedRawThreshold: "bogus" },
9271035
{
928-
toolsInput: "nightly-until-stable-bogus",
1036+
toolsInput: "nightly-until-default-bogus",
9291037
expectedRawThreshold: "bogus",
9301038
},
9311039
] as const;
@@ -967,8 +1075,8 @@ for (const {
9671075
}
9681076

9691077
/**
970-
* `latest-<N>`, SemVer ranges, `latest-prerelease`, and `nightly-until-<version>`/
971-
* `nightly-until-stable-<version>` all need to look up the canonical CodeQL Action repository's
1078+
* `latest-<N>`, SemVer ranges, `latest-prerelease`, and `nightly-until-<version>` all need to
1079+
* look up the canonical CodeQL Action repository's
9721080
* release history. That repository only ever exists on GitHub.com, so on a non-dotcom `variant`
9731081
* (GHES or GHEC with data residency) this lookup must be made directly, and unauthenticated,
9741082
* against GitHub.com, rather than against the current GitHub instance as for all other API

0 commit comments

Comments
 (0)