Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions src/per-language-bundles.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ async function checkEligibility(
[ActionsEnvVars.RUNNER_ENVIRONMENT]: "github-hosted",
}),
features: createFeatures([Feature.PerLanguageBundles]),
logger: getRecordingLogger([], { logToConsole: false }),
...stateOverrides,
}),
{ ...ELIGIBLE_OPTIONS, ...overrides },
Expand Down Expand Up @@ -134,7 +133,6 @@ test("getPerLanguageBundleLanguage explains a disabled feature before checking e
const messages: LoggedMessage[] = [];
const language = await getPerLanguageBundleLanguage(
initAllState({
env: getTestEnv(),
features: createFeatures([]),
logger: getRecordingLogger(messages, { logToConsole: false }),
}),
Expand Down
7 changes: 5 additions & 2 deletions src/per-language-bundles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,11 @@ export async function getPerLanguageBundleLanguage(
return explain("the job is not running on a GitHub-hosted runner");
}

// Check whether per-language bundles are published for the requested CLI version.
// Latest-nightly selection skips this release-version check, but not the other eligibility checks.
// Nightly releases are identified by dates rather than versions. If
// `isLatestNightly` is `true`, the latest nightly is requested with
// `tools: nightly` and we don't yet have the corresponding tag at this point.
// Therefore, we skip the version check and don't have an equivalent.
// We can safely assume that the latest nightly will have per-language bundles.
if (!isLatestNightly) {
if (cliVersion === undefined) {
return explain("the requested CLI version is unknown");
Expand Down
36 changes: 20 additions & 16 deletions src/setup-codeql.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,25 +69,29 @@ function stubHostedNightly(tagName: string) {
available: true,
foundZstdBinary: true,
});
const fetchRelease = sinon
.stub<Parameters<typeof fetch>, ReturnType<typeof fetch>>()
.rejects(new Error("Unexpected API request in nightly bundle test"));
fetchRelease
.withArgs(
"https://api.github.com/repos/dsp-testing/codeql-cli-nightlies/releases?per_page=1&page=1&prerelease=true",
sinon.match({ method: "GET" }),
)
.callsFake(
async () =>
new Response(JSON.stringify([{ tag_name: tagName }]), {
headers: { "content-type": "application/json" },
}),
);
const client = github.getOctokit("123", {
request: { fetch: fetchRelease },
request: {
fetch: async () => {
throw new Error("Unexpected API request in nightly bundle test");
},
},
});
const listReleases = sinon
.stub(client.rest.repos, "listReleases")
.rejects(new Error("Unexpected release request in nightly bundle test"));
listReleases
.withArgs({
owner: "dsp-testing",
repo: "codeql-cli-nightlies",
per_page: 1,
page: 1,
prerelease: true,
})
.resolves({
data: [{ tag_name: tagName }],
} as Awaited<ReturnType<typeof client.rest.repos.listReleases>>);
sinon.stub(api, "getApiClient").value(() => client);
return fetchRelease;
return listReleases;
}

test.serial("parse codeql bundle url version", (t) => {
Expand Down
2 changes: 1 addition & 1 deletion src/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -682,7 +682,7 @@ export async function bundleDb(
return databaseBundlePath;
}

/** Returns the elapsed milliseconds, rounded, since a `performance.now()` timestamp. */
/** Returns the elapsed milliseconds, rounded, since `startTime` was recorded with `performance.now()`. */
export function durationMsSince(startTime: number): number {
return Math.round(performance.now() - startTime);
}
Expand Down
Loading