From d0e637842804134187f28d19031ad11f46d33baf Mon Sep 17 00:00:00 2001 From: Sergey Dolin Date: Fri, 6 May 2022 09:09:02 +0500 Subject: [PATCH] Handle each OS in its own way --- dist/setup/index.js | 7 +++++-- src/setup-python.ts | 7 ++++--- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/dist/setup/index.js b/dist/setup/index.js index a99eee3a4..e978190c5 100644 --- a/dist/setup/index.js +++ b/dist/setup/index.js @@ -6085,8 +6085,11 @@ function cacheDependencies(cache, pythonVersion) { function run() { var _a; return __awaiter(this, void 0, void 0, function* () { - if (!((_a = process.env.AGENT_TOOLSDIRECTORY) === null || _a === void 0 ? void 0 : _a.trim())) { - process.env['AGENT_TOOLSDIRECTORY'] = '/opt/hostedtoolcache'; + if (!utils_1.IS_WINDOWS && !((_a = process.env.AGENT_TOOLSDIRECTORY) === null || _a === void 0 ? void 0 : _a.trim())) { + if (utils_1.IS_LINUX) + process.env['AGENT_TOOLSDIRECTORY'] = '/opt/hostedtoolcache'; + else + process.env['AGENT_TOOLSDIRECTORY'] = '/Users/runner/hostedtoolcache'; } core.debug(`Python is expected to be installed into AGENT_TOOLSDIRECTORY=${process.env['AGENT_TOOLSDIRECTORY']}`); process.env['RUNNER_TOOL_CACHE'] = process.env['AGENT_TOOLSDIRECTORY']; diff --git a/src/setup-python.ts b/src/setup-python.ts index e723635c3..5636a95f3 100644 --- a/src/setup-python.ts +++ b/src/setup-python.ts @@ -4,7 +4,7 @@ import * as finderPyPy from './find-pypy'; import * as path from 'path'; import * as os from 'os'; import {getCacheDistributor} from './cache-distributions/cache-factory'; -import {isCacheFeatureAvailable} from './utils'; +import {isCacheFeatureAvailable, IS_LINUX, IS_WINDOWS} from './utils'; function isPyPyVersion(versionSpec: string) { return versionSpec.startsWith('pypy-'); @@ -22,8 +22,9 @@ async function cacheDependencies(cache: string, pythonVersion: string) { } async function run() { - if (!process.env.AGENT_TOOLSDIRECTORY?.trim()) { - process.env['AGENT_TOOLSDIRECTORY'] = '/opt/hostedtoolcache'; + if (!IS_WINDOWS && !process.env.AGENT_TOOLSDIRECTORY?.trim()) { + if (IS_LINUX) process.env['AGENT_TOOLSDIRECTORY'] = '/opt/hostedtoolcache'; + else process.env['AGENT_TOOLSDIRECTORY'] = '/Users/runner/hostedtoolcache'; } core.debug( `Python is expected to be installed into AGENT_TOOLSDIRECTORY=${process.env['AGENT_TOOLSDIRECTORY']}`