1
0
Fork 0
mirror of https://github.com/actions/setup-python.git synced 2024-12-27 14:33:01 +00:00

fix: Self-Hosted Tool Cache

This fixes the tool cache path for self-hosted runners, along
with handling AGENT_TOOLSDIRECTORY for both hosted + self-hosted.

    Fixes actions#459
This commit is contained in:
Leon Wright 2022-07-15 12:57:51 +08:00
parent 10b840936c
commit 9f1915a970
No known key found for this signature in database
GPG key ID: 95F5A1DE99BFCA3D
2 changed files with 7 additions and 15 deletions

10
dist/setup/index.js vendored
View file

@ -65340,13 +65340,9 @@ function resolveVersionInput() {
function run() {
var _a;
return __awaiter(this, void 0, void 0, function* () {
// According to the README windows binaries do not require to be installed
// in the specific location, but Mac and Linux do
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';
// 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']}`);

View file

@ -7,9 +7,7 @@ import fs from 'fs';
import {getCacheDistributor} from './cache-distributions/cache-factory';
import {
isCacheFeatureAvailable,
logWarning,
IS_LINUX,
IS_WINDOWS
logWarning
} from './utils';
function isPyPyVersion(versionSpec: string) {
@ -68,11 +66,9 @@ function resolveVersionInput(): string {
}
async function run() {
// According to the README windows binaries do not require to be installed
// in the specific location, but Mac and Linux do
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';
// 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(