From a1b3b101bb1f0e199a986808073e4b28cb158620 Mon Sep 17 00:00:00 2001 From: Leon Wright Date: Mon, 18 Jul 2022 14:57:46 +0800 Subject: [PATCH] This fixes the tool cache path for self-hosted runners, along with handling AGENT_TOOLSDIRECTORY for both hosted + self-hosted. Fixes actions#459 --- dist/setup/index.js | 9 ++++----- src/setup-python.ts | 9 ++++----- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/dist/setup/index.js b/dist/setup/index.js index 74dfe4689..1146f32ae 100644 --- a/dist/setup/index.js +++ b/dist/setup/index.js @@ -65278,11 +65278,10 @@ function resolveVersionInput() { function run() { var _a; return __awaiter(this, void 0, void 0, function* () { - // This aligns us with actions/setup-python, which defaults their - // internal TOOLCACHE_ROOT to RUNNER_TOOL_CACHE when AGENT_TOOLSDIRECTORY - // is not set. - if (!((_a = process.env.AGENT_TOOLSDIRECTORY) === null || _a === void 0 ? void 0 : _a.trim())) { - process.env['AGENT_TOOLSDIRECTORY'] = process.env['RUNNER_TOOL_CACHE']; + // When setting AGENT_TOOLSDIRECTORY, the actions/tool-cache function find + // is not able to find the files cached by actions/python-version. + if ((_a = process.env.AGENT_TOOLSDIRECTORY) === null || _a === void 0 ? void 0 : _a.trim()) { + process.env['RUNNER_TOOL_CACHE'] = process.env['AGENT_TOOLSDIRECTORY']; } core.debug(`Python is expected to be installed into RUNNER_TOOL_CACHE=${process.env['RUNNER_TOOL_CACHE']}`); try { diff --git a/src/setup-python.ts b/src/setup-python.ts index 630af6e66..5426081f3 100644 --- a/src/setup-python.ts +++ b/src/setup-python.ts @@ -61,11 +61,10 @@ function resolveVersionInput(): string { } async function run() { - // This aligns us with actions/setup-python, which defaults their - // internal TOOLCACHE_ROOT to RUNNER_TOOL_CACHE when AGENT_TOOLSDIRECTORY - // is not set. - if (!process.env.AGENT_TOOLSDIRECTORY?.trim()) { - process.env['AGENT_TOOLSDIRECTORY'] = process.env['RUNNER_TOOL_CACHE']; + // When setting AGENT_TOOLSDIRECTORY, the actions/tool-cache function find + // is not able to find the files cached by actions/python-version. + if (process.env.AGENT_TOOLSDIRECTORY?.trim()) { + process.env['RUNNER_TOOL_CACHE'] = process.env['AGENT_TOOLSDIRECTORY']; } core.debug( `Python is expected to be installed into RUNNER_TOOL_CACHE=${process.env['RUNNER_TOOL_CACHE']}`