Cache CLI version information across Actions steps

This commit is contained in:
Henry Mercer
2026-06-02 14:55:09 +01:00
parent 8ed7f7c384
commit bab673d0e0
5 changed files with 211 additions and 125 deletions

View File

@@ -532,3 +532,26 @@ test("Failure.orElse returns the default value for a failure result", (t) => {
const result = new util.Failure(new Error("test error"));
t.is(result.orElse("default value"), "default value");
});
test("getCachedCodeQlVersion reuses a version persisted by an earlier step", (t) => {
process.env[EnvVar.CODEQL_VERSION_INFO] = JSON.stringify({
cmd: "/path/to/codeql",
version: { version: "2.20.0" },
});
t.deepEqual(util.getCachedCodeQlVersion("/path/to/codeql"), {
version: "2.20.0",
});
});
test("getCachedCodeQlVersion ignores a persisted version from a different CLI", (t) => {
process.env[EnvVar.CODEQL_VERSION_INFO] = JSON.stringify({
cmd: "/path/to/other-codeql",
version: { version: "2.20.0" },
});
t.is(util.getCachedCodeQlVersion("/path/to/codeql"), undefined);
});
test("getCachedCodeQlVersion ignores a malformed persisted value", (t) => {
process.env[EnvVar.CODEQL_VERSION_INFO] = "not valid json";
t.is(util.getCachedCodeQlVersion("/path/to/codeql"), undefined);
});