mirror of
https://github.com/github/codeql-action.git
synced 2026-10-03 09:14:58 +00:00
Pass environment explicitly to CLI caching functions
This commit is contained in:
10
lib/entry-points.js
generated
10
lib/entry-points.js
generated
@@ -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;
|
||||
},
|
||||
|
||||
@@ -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);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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<VersionInfo>(
|
||||
cmd,
|
||||
@@ -499,7 +499,7 @@ async function getCodeQLForCmd(
|
||||
noStreamStdout: true,
|
||||
},
|
||||
);
|
||||
outputCache.cacheCodeQlVersion(cmd, result);
|
||||
outputCache.cacheCodeQlVersion(cmd, result, getEnv());
|
||||
}
|
||||
return result;
|
||||
},
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user