use tmp dir for external queries test
This commit is contained in:
parent
5218f937b3
commit
ab918b676b
5 changed files with 32 additions and 6 deletions
3
lib/external-queries.js
generated
3
lib/external-queries.js
generated
|
|
@ -11,8 +11,9 @@ const core = __importStar(require("@actions/core"));
|
|||
const exec = __importStar(require("@actions/exec"));
|
||||
const fs = __importStar(require("fs"));
|
||||
const path = __importStar(require("path"));
|
||||
const util = __importStar(require("./util"));
|
||||
async function checkoutExternalQueries(config) {
|
||||
const folder = process.env['RUNNER_WORKSPACE'] || '/tmp/codeql-action';
|
||||
const folder = util.getRequiredEnvParam('RUNNER_WORKSPACE');
|
||||
for (const externalQuery of config.externalQueries) {
|
||||
core.info('Checking out ' + externalQuery.repository);
|
||||
const checkoutLocation = path.join(folder, externalQuery.repository);
|
||||
|
|
|
|||
10
lib/util.js
generated
10
lib/util.js
generated
|
|
@ -15,6 +15,8 @@ const http = __importStar(require("@actions/http-client"));
|
|||
const auth = __importStar(require("@actions/http-client/auth"));
|
||||
const octokit = __importStar(require("@octokit/rest"));
|
||||
const console_log_level_1 = __importDefault(require("console-log-level"));
|
||||
const fs = __importStar(require("fs"));
|
||||
const os = __importStar(require("os"));
|
||||
const path = __importStar(require("path"));
|
||||
const sharedEnv = __importStar(require("./shared-environment"));
|
||||
/**
|
||||
|
|
@ -280,3 +282,11 @@ function getToolNames(sarifContents) {
|
|||
return Object.keys(toolNames);
|
||||
}
|
||||
exports.getToolNames = getToolNames;
|
||||
// Creates a random temporary directory, runs the given body, and then deletes the directory.
|
||||
// Mostly intended for use within tests.
|
||||
async function withTmpDir(body) {
|
||||
const tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), 'codeql-action-'));
|
||||
await body(tmpDir);
|
||||
fs.rmdirSync(tmpDir, { recursive: true });
|
||||
}
|
||||
exports.withTmpDir = withTmpDir;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue