Skip to content

Commit 027ab31

Browse files
henrymercerCopilot
andcommitted
Test falling back to the public release for the default bundle
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
1 parent caa2cae commit 027ab31

1 file changed

Lines changed: 58 additions & 0 deletions

File tree

‎src/setup-codeql.test.ts‎

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1214,6 +1214,64 @@ test.serial(
12141214
},
12151215
);
12161216

1217+
for (const status of [200, 404]) {
1218+
test.serial(
1219+
`getCodeQLSource falls back to the public release when the Action's release ${status === 200 ? "lacks a compatible bundle" : "can't be found"}`,
1220+
async (t) => {
1221+
sinon.stub(process, "platform").value("linux");
1222+
sinon.stub(process, "arch").value("x64");
1223+
sinon.stub(actionsUtil, "isRunningLocalAction").returns(false);
1224+
const tag = PER_LANGUAGE_CLI_VERSION.enabledVersions[0].tagName;
1225+
const fetchRelease = sinon
1226+
.stub<Parameters<typeof fetch>, ReturnType<typeof fetch>>()
1227+
.callsFake(
1228+
async () =>
1229+
new Response(
1230+
JSON.stringify({
1231+
assets: [
1232+
{
1233+
name: "codeql-bundle-java-linux64.tar.zst",
1234+
url: "https://api.github.com/repos/codeql-testing/action-fork/releases/assets/1",
1235+
},
1236+
],
1237+
}),
1238+
{ status, headers: { "content-type": "application/json" } },
1239+
),
1240+
);
1241+
const client = github.getOctokit("123", {
1242+
request: { fetch: fetchRelease },
1243+
});
1244+
sinon.stub(api, "getApiClient").value(() => client);
1245+
1246+
await withTmpDir(async (tmpDir) => {
1247+
setupActionsVars(tmpDir, tmpDir, {
1248+
GITHUB_ACTION_REPOSITORY: "codeql-testing/action-fork",
1249+
});
1250+
const source = await setupCodeql.getCodeQLSource(
1251+
undefined,
1252+
PER_LANGUAGE_CLI_VERSION,
1253+
undefined, // rawLanguages
1254+
false, // useOverlayAwareDefaultCliVersion
1255+
SAMPLE_DOTCOM_API_DETAILS,
1256+
GitHubVariant.DOTCOM,
1257+
true, // tarSupportsZstd
1258+
createFeatures([]),
1259+
getRunnerLogger(true),
1260+
);
1261+
1262+
t.true(fetchRelease.calledOnce);
1263+
t.like(source, {
1264+
sourceType: "download",
1265+
bundle: {
1266+
kind: "combined",
1267+
url: `https://github.com/github/codeql-action/releases/download/${tag}/codeql-bundle-linux64.tar.zst`,
1268+
},
1269+
});
1270+
});
1271+
},
1272+
);
1273+
}
1274+
12171275
for (const fallback of [false, true]) {
12181276
test.serial(
12191277
`setupCodeQLBundle retains the selected release identity for an opaque asset URL${fallback ? " with fallback" : ""}`,

0 commit comments

Comments
 (0)