fix: Self-Hosted Runner Tool Cache

This aligns the tool cache path logic with the process used by
actions/python-versions, maintaining the ability to locate the
version binaries, and fixing self-hosted runners.

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

13
dist/setup/index.js vendored
View file

@ -65278,14 +65278,11 @@ function resolveVersionInput() {
function run() { function run() {
var _a; var _a;
return __awaiter(this, void 0, void 0, function* () { return __awaiter(this, void 0, void 0, function* () {
// According to the README windows binaries do not require to be installed // This aligns us with actions/setup-python, which defaults their
// in the specific location, but Mac and Linux do // internal TOOLCACHE_ROOT to RUNNER_TOOL_CACHE when AGENT_TOOLSDIRECTORY
if (!utils_1.IS_WINDOWS && !((_a = process.env.AGENT_TOOLSDIRECTORY) === null || _a === void 0 ? void 0 : _a.trim())) { // is not set.
if (utils_1.IS_LINUX) if (!((_a = process.env.AGENT_TOOLSDIRECTORY) === null || _a === void 0 ? void 0 : _a.trim())) {
process.env['AGENT_TOOLSDIRECTORY'] = '/opt/hostedtoolcache'; process.env['AGENT_TOOLSDIRECTORY'] = process.env['RUNNER_TOOL_CACHE'];
else
process.env['AGENT_TOOLSDIRECTORY'] = '/Users/runner/hostedtoolcache';
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']}`); core.debug(`Python is expected to be installed into RUNNER_TOOL_CACHE=${process.env['RUNNER_TOOL_CACHE']}`);
try { try {

View file

@ -5,7 +5,7 @@ import * as path from 'path';
import * as os from 'os'; import * as os from 'os';
import fs from 'fs'; import fs from 'fs';
import {getCacheDistributor} from './cache-distributions/cache-factory'; import {getCacheDistributor} from './cache-distributions/cache-factory';
import {isCacheFeatureAvailable, IS_LINUX, IS_WINDOWS} from './utils'; import {isCacheFeatureAvailable} from './utils';
function isPyPyVersion(versionSpec: string) { function isPyPyVersion(versionSpec: string) {
return versionSpec.startsWith('pypy'); return versionSpec.startsWith('pypy');
@ -61,12 +61,11 @@ function resolveVersionInput(): string {
} }
async function run() { async function run() {
// According to the README windows binaries do not require to be installed // This aligns us with actions/setup-python, which defaults their
// in the specific location, but Mac and Linux do // internal TOOLCACHE_ROOT to RUNNER_TOOL_CACHE when AGENT_TOOLSDIRECTORY
if (!IS_WINDOWS && !process.env.AGENT_TOOLSDIRECTORY?.trim()) { // is not set.
if (IS_LINUX) process.env['AGENT_TOOLSDIRECTORY'] = '/opt/hostedtoolcache'; if (!process.env.AGENT_TOOLSDIRECTORY?.trim()) {
else process.env['AGENT_TOOLSDIRECTORY'] = '/Users/runner/hostedtoolcache'; process.env['AGENT_TOOLSDIRECTORY'] = process.env['RUNNER_TOOL_CACHE'];
process.env['RUNNER_TOOL_CACHE'] = process.env['AGENT_TOOLSDIRECTORY'];
} }
core.debug( core.debug(
`Python is expected to be installed into RUNNER_TOOL_CACHE=${process.env['RUNNER_TOOL_CACHE']}` `Python is expected to be installed into RUNNER_TOOL_CACHE=${process.env['RUNNER_TOOL_CACHE']}`