mirror of
https://github.com/github/codeql-action.git
synced 2026-10-21 02:01:27 +00:00
Include failed bundle attempts in fallback timing
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import * as fs from "fs";
|
||||
import * as os from "os";
|
||||
import * as path from "path";
|
||||
import { performance } from "perf_hooks";
|
||||
|
||||
import * as github from "@actions/github";
|
||||
import * as toolcache from "@actions/tool-cache";
|
||||
@@ -1223,10 +1224,23 @@ for (const bundle of ["per-language", "combined", "fallback"] as const) {
|
||||
delete process.env[EnvVar.HAS_SET_UP_CODEQL];
|
||||
|
||||
const downloadSpy = sinon.spy(setupCodeql, "downloadCodeQL");
|
||||
const extractStub = stubDownloadAndExtract();
|
||||
if (bundle === "fallback") {
|
||||
extractStub.onFirstCall().rejects(new HTTPError("Not Found", 404));
|
||||
}
|
||||
let elapsedMs = 1000;
|
||||
sinon.stub(performance, "now").callsFake(() => elapsedMs);
|
||||
const extractStub = sinon
|
||||
.stub(toolsDownload, "downloadAndExtract")
|
||||
.callsFake(async (_url, _compressionMethod, dest) => {
|
||||
if (bundle === "fallback" && extractStub.callCount === 1) {
|
||||
elapsedMs += 700.2;
|
||||
throw new HTTPError("Not Found", 404);
|
||||
}
|
||||
elapsedMs += 300.2;
|
||||
fs.mkdirSync(dest, { recursive: true });
|
||||
return {
|
||||
downloadDurationMs: 200,
|
||||
extractionDurationMs: 100,
|
||||
totalDurationMs: 300,
|
||||
};
|
||||
});
|
||||
const addDiagnostic = sinon.stub(diagnostics, "addNoLanguageDiagnostic");
|
||||
const features = createFeatures([
|
||||
Feature.PerLanguageBundles,
|
||||
@@ -1255,6 +1269,12 @@ for (const bundle of ["per-language", "combined", "fallback"] as const) {
|
||||
bundle === "combined" ? "combined" : "per-language",
|
||||
);
|
||||
t.is(result.codeqlFolder, extractStub.lastCall.args[2]);
|
||||
t.is(
|
||||
result.toolsDownloadStatusReport?.totalDurationMs,
|
||||
bundle === "fallback" ? 1000 : 300,
|
||||
);
|
||||
t.is(result.toolsDownloadStatusReport?.downloadDurationMs, 200);
|
||||
t.is(result.toolsDownloadStatusReport?.extractionDurationMs, 100);
|
||||
t.is(extractStub.callCount, bundle === "fallback" ? 2 : 1);
|
||||
t.is(downloadSpy.callCount, extractStub.callCount);
|
||||
t.is(
|
||||
|
||||
Reference in New Issue
Block a user