call setupActionsVars in the tests too

This commit is contained in:
Robert 2021-03-16 13:43:28 +00:00
parent d698cb3d2b
commit 378f30f95d
10 changed files with 58 additions and 38 deletions

21
lib/runner.js generated
View file

@ -77,21 +77,6 @@ function parseTraceProcessLevel() {
}
return undefined;
}
// Sets environment variables that make using some libraries designed for
// use only on actions safe to use outside of actions.
//
// Obviously this is not a tremendously great thing we're doing and it
// would be better to write our own implementation of libraries to use
// outside of actions. For now this works well enough.
//
// Currently this list of libraries that is deemed to now be safe includes:
// - @actions/tool-cache
//
// Also see "queries/unguarded-action-lib.ql".
function setupActionsVars(tempDir, toolsDir) {
process.env["RUNNER_TEMP"] = tempDir;
process.env["RUNNER_TOOL_CACHE"] = toolsDir;
}
program
.command("init")
.description("Initializes CodeQL")
@ -115,7 +100,7 @@ program
try {
const tempDir = getTempDir(cmd.tempDir);
const toolsDir = getToolsDir(cmd.toolsDir);
setupActionsVars(tempDir, toolsDir);
util_1.setupActionsVars(tempDir, toolsDir);
// Wipe the temp dir
logger.info(`Cleaning temp directory ${tempDir}`);
fs.rmdirSync(tempDir, { recursive: true });
@ -195,7 +180,7 @@ program
throw new Error("Config file could not be found at expected location. " +
"Was the 'init' command run with the same '--temp-dir' argument as this command.");
}
setupActionsVars(config.tempDir, config.toolCacheDir);
util_1.setupActionsVars(config.tempDir, config.toolCacheDir);
importTracerEnvironment(config);
let language = undefined;
if (cmd.language !== undefined) {
@ -244,7 +229,7 @@ program
throw new Error("Config file could not be found at expected location. " +
"Was the 'init' command run with the same '--temp-dir' argument as this command.");
}
setupActionsVars(config.tempDir, config.toolCacheDir);
util_1.setupActionsVars(config.tempDir, config.toolCacheDir);
const auth = await util_1.getGitHubAuth(logger, cmd.githubAuth, cmd.githubAuthStdin);
const apiDetails = {
auth,