diff --git a/lib/entry-points.js b/lib/entry-points.js index 2de9797e9..c714689f2 100644 --- a/lib/entry-points.js +++ b/lib/entry-points.js @@ -146251,7 +146251,7 @@ var cachedCodeQlVersion = void 0; function getCommandCacheFilePath(env) { return import_path.default.join(getTemporaryDirectory(env), COMMAND_CACHE_FILENAME); } -function cacheCodeQlVersion(cmd, version, env = getEnv()) { +function cacheCodeQlVersion(cmd, version, env) { if (cachedCodeQlVersion !== void 0) { throw new Error("cacheCodeQlVersion() should be called only once"); } @@ -146262,7 +146262,7 @@ function cacheCodeQlVersion(cmd, version, env = getEnv()) { "utf8" ); } -function getCachedCodeQlVersion(cmd, env = getEnv()) { +function getCachedCodeQlVersion(env, cmd) { if (cachedCodeQlVersion !== void 0) { return cachedCodeQlVersion; } @@ -146834,7 +146834,7 @@ async function createStatusReportBase(actionName, status, actionStartedAt, confi core7.exportVariable("CODEQL_WORKFLOW_STARTED_AT" /* WORKFLOW_STARTED_AT */, workflowStartedAt); } const runnerOs = getRequiredEnvParam("RUNNER_OS"); - const codeQlCliVersion = getCachedCodeQlVersion(); + const codeQlCliVersion = getCachedCodeQlVersion(getEnv()); const actionRef = process.env["GITHUB_ACTION_REF"] || ""; const testingEnvironment = getTestingEnvironment(); if (testingEnvironment) { @@ -151870,7 +151870,7 @@ async function getCodeQLForCmd(cmd, checkVersion) { return cmd; }, async getVersion() { - let result = getCachedCodeQlVersion(cmd); + let result = getCachedCodeQlVersion(getEnv(), cmd); if (result === void 0) { result = await runCliJson( cmd, @@ -151879,7 +151879,7 @@ async function getCodeQLForCmd(cmd, checkVersion) { noStreamStdout: true } ); - cacheCodeQlVersion(cmd, result); + cacheCodeQlVersion(cmd, result, getEnv()); } return result; }, diff --git a/src/cli/output-cache.test.ts b/src/cli/output-cache.test.ts index 83f206e0e..152f5de5d 100644 --- a/src/cli/output-cache.test.ts +++ b/src/cli/output-cache.test.ts @@ -25,7 +25,7 @@ test.serial( "utf8", ); const env = getTestEnv({ [EnvVar.TEMP]: tmpDir }); - t.deepEqual(outputCache.getCachedCodeQlVersion("/path/to/codeql", env), { + t.deepEqual(outputCache.getCachedCodeQlVersion(env, "/path/to/codeql"), { version: "2.20.0", }); }); @@ -47,7 +47,7 @@ test.serial( ); const env = getTestEnv({ [EnvVar.TEMP]: tmpDir }); t.is( - outputCache.getCachedCodeQlVersion("/path/to/codeql", env), + outputCache.getCachedCodeQlVersion(env, "/path/to/codeql"), undefined, ); }); @@ -62,7 +62,7 @@ test.serial( fs.writeFileSync(cacheFile, "not valid json", "utf8"); const env = getTestEnv({ [EnvVar.TEMP]: tmpDir }); t.is( - outputCache.getCachedCodeQlVersion("/path/to/codeql", env), + outputCache.getCachedCodeQlVersion(env, "/path/to/codeql"), undefined, ); }); @@ -94,7 +94,7 @@ test.serial( for (const value of testValues) { fs.writeFileSync(cacheFile, value, "utf8"); t.is( - outputCache.getCachedCodeQlVersion("/path/to/codeql", env), + outputCache.getCachedCodeQlVersion(env, "/path/to/codeql"), undefined, value, ); @@ -106,6 +106,6 @@ test.serial( test.serial("getCachedCodeQlVersion ignores non-existent file", async (t) => { await util.withTmpDir(async (tmpDir: string) => { const env = getTestEnv({ [EnvVar.TEMP]: tmpDir }); - t.is(outputCache.getCachedCodeQlVersion("/path/to/codeql", env), undefined); + t.is(outputCache.getCachedCodeQlVersion(env, "/path/to/codeql"), undefined); }); }); diff --git a/src/cli/output-cache.ts b/src/cli/output-cache.ts index e6b665b71..81b5084f8 100644 --- a/src/cli/output-cache.ts +++ b/src/cli/output-cache.ts @@ -2,7 +2,7 @@ import * as fs from "fs"; import path from "path"; import { getTemporaryDirectory } from "../actions-util"; -import { Env, getEnv } from "../environment"; +import { Env } from "../environment"; import type { VersionInfo } from "./types"; @@ -64,7 +64,7 @@ function getCommandCacheFilePath(env: Env): string { export function cacheCodeQlVersion( cmd: string, version: VersionInfo, - env: Env = getEnv(), + env: Env, ): void { if (cachedCodeQlVersion !== undefined) { throw new Error("cacheCodeQlVersion() should be called only once"); @@ -83,12 +83,12 @@ export function cacheCodeQlVersion( /** * Returns the cached CodeQL CLI version, if any. - * @param cmd The path to the CodeQL CLI. * @param env The environment variables to use. + * @param cmd The path to the CodeQL CLI. */ export function getCachedCodeQlVersion( + env: Env, cmd?: string, - env: Env = getEnv(), ): undefined | VersionInfo { if (cachedCodeQlVersion !== undefined) { return cachedCodeQlVersion; diff --git a/src/codeql.ts b/src/codeql.ts index fecc155bb..bf91df9a8 100644 --- a/src/codeql.ts +++ b/src/codeql.ts @@ -17,7 +17,7 @@ import type { VersionInfo } from "./cli/types"; import { CliError, wrapCliConfigurationError } from "./cli-errors"; import { appendExtraQueryExclusions, type Config } from "./config-utils"; import { DocUrl } from "./doc-url"; -import { EnvVar } from "./environment"; +import { EnvVar, getEnv } from "./environment"; import { CodeQLDefaultVersionInfo, Feature, @@ -490,7 +490,7 @@ async function getCodeQLForCmd( return cmd; }, async getVersion() { - let result = outputCache.getCachedCodeQlVersion(cmd); + let result = outputCache.getCachedCodeQlVersion(getEnv(), cmd); if (result === undefined) { result = await runCliJson( cmd, @@ -499,7 +499,7 @@ async function getCodeQLForCmd( noStreamStdout: true, }, ); - outputCache.cacheCodeQlVersion(cmd, result); + outputCache.cacheCodeQlVersion(cmd, result, getEnv()); } return result; }, diff --git a/src/status-report.ts b/src/status-report.ts index d2967a86f..043ff7b3c 100644 --- a/src/status-report.ts +++ b/src/status-report.ts @@ -376,7 +376,7 @@ export async function createStatusReportBase( core.exportVariable(EnvVar.WORKFLOW_STARTED_AT, workflowStartedAt); } const runnerOs = getRequiredEnvParam("RUNNER_OS"); - const codeQlCliVersion = getCachedCodeQlVersion(); + const codeQlCliVersion = getCachedCodeQlVersion(getEnv()); const actionRef = process.env["GITHUB_ACTION_REF"] || ""; const testingEnvironment = getTestingEnvironment(); // re-export the testing environment variable so that it is available to subsequent steps,