Skip to content

Commit

Permalink
This fixes the tool cache path for self-hosted runners, along
Browse files Browse the repository at this point in the history
with handling AGENT_TOOLSDIRECTORY for both hosted + self-hosted.

    Fixes #459
  • Loading branch information
techman83 committed Jul 18, 2022
1 parent ab1a29b commit 3332663
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 13 deletions.
10 changes: 3 additions & 7 deletions dist/setup/index.js
Expand Up @@ -65278,13 +65278,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']}`);
Expand Down
10 changes: 4 additions & 6 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,11 +61,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(
Expand Down

0 comments on commit 3332663

Please sign in to comment.