Skip to content

Commit

Permalink
fix: Self-Hosted Runner Tool Cache
Browse files Browse the repository at this point in the history
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 actions#459
  • Loading branch information
techman83 committed Jul 15, 2022
1 parent c4e89fa commit 2b8eff3
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 15 deletions.
13 changes: 5 additions & 8 deletions dist/setup/index.js
Expand Up @@ -65278,14 +65278,11 @@ 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';
process.env['RUNNER_TOOL_CACHE'] = process.env['AGENT_TOOLSDIRECTORY'];
// 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'];
}
core.debug(`Python is expected to be installed into RUNNER_TOOL_CACHE=${process.env['RUNNER_TOOL_CACHE']}`);
try {
Expand Down
13 changes: 6 additions & 7 deletions src/setup-python.ts
Expand Up @@ -5,7 +5,7 @@ import * as path from 'path';
import * as os from 'os';
import fs from 'fs';
import {getCacheDistributor} from './cache-distributions/cache-factory';
import {isCacheFeatureAvailable, IS_LINUX, IS_WINDOWS} from './utils';
import {isCacheFeatureAvailable} from './utils';

function isPyPyVersion(versionSpec: string) {
return versionSpec.startsWith('pypy');
Expand Down Expand Up @@ -61,12 +61,11 @@ 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';
process.env['RUNNER_TOOL_CACHE'] = process.env['AGENT_TOOLSDIRECTORY'];
// 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'];
}
core.debug(
`Python is expected to be installed into RUNNER_TOOL_CACHE=${process.env['RUNNER_TOOL_CACHE']}`
Expand Down

0 comments on commit 2b8eff3

Please sign in to comment.