mirror of
https://github.com/github/codeql-action.git
synced 2026-10-03 09:14:58 +00:00
Merge pull request #4159 from github/henrymercer/pr-4146-follow-ups
Address per-language bundle review follow-ups
This commit is contained in:
@@ -38,7 +38,6 @@ async function checkEligibility(
|
||||
[ActionsEnvVars.RUNNER_ENVIRONMENT]: "github-hosted",
|
||||
}),
|
||||
features: createFeatures([Feature.PerLanguageBundles]),
|
||||
logger: getRecordingLogger([], { logToConsole: false }),
|
||||
...stateOverrides,
|
||||
}),
|
||||
{ ...ELIGIBLE_OPTIONS, ...overrides },
|
||||
@@ -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 }),
|
||||
}),
|
||||
|
||||
@@ -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");
|
||||
|
||||
@@ -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) => {
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user