mirror of
https://github.com/actions/setup-go.git
synced 2025-09-07 18:53:38 -06:00
Set default cache
input to false for self-hosted runners
This commit is contained in:
parent
93397bea11
commit
8b0dfa3b5d
6 changed files with 102 additions and 19 deletions
|
@ -3,6 +3,7 @@ import * as cache from '@actions/cache';
|
|||
import fs from 'fs';
|
||||
import {State} from './constants';
|
||||
import {getCacheDirectoryPath, getPackageManagerInfo} from './cache-utils';
|
||||
import {getCacheInput} from './utils';
|
||||
|
||||
// Catch and log any unhandled exceptions. These exceptions can leak out of the uploadChunk method in
|
||||
// @actions/toolkit when a failed upload closes the file descriptor causing any in-process reads to
|
||||
|
@ -28,10 +29,7 @@ export async function run() {
|
|||
}
|
||||
|
||||
const cachePackages = async () => {
|
||||
const cacheInput = core.getBooleanInput('cache');
|
||||
if (!cacheInput) {
|
||||
return;
|
||||
}
|
||||
if (!getCacheInput()) return;
|
||||
|
||||
const packageManager = 'default';
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@ import * as httpm from '@actions/http-client';
|
|||
import * as sys from './system';
|
||||
import fs from 'fs';
|
||||
import os from 'os';
|
||||
import {StableReleaseAlias} from './utils';
|
||||
import {isSelfHosted, StableReleaseAlias} from './utils';
|
||||
|
||||
type InstallationType = 'dist' | 'manifest';
|
||||
|
||||
|
@ -175,11 +175,7 @@ async function cacheWindowsDir(
|
|||
if (os.platform() !== 'win32') return false;
|
||||
|
||||
// make sure the action runs in the hosted environment
|
||||
if (
|
||||
process.env['RUNNER_ENVIRONMENT'] !== 'github-hosted' &&
|
||||
process.env['AGENT_ISSELFHOSTED'] === '1'
|
||||
)
|
||||
return false;
|
||||
if (isSelfHosted()) return false;
|
||||
|
||||
const defaultToolCacheRoot = process.env['RUNNER_TOOL_CACHE'];
|
||||
if (!defaultToolCacheRoot) return false;
|
||||
|
|
|
@ -8,6 +8,7 @@ import {isCacheFeatureAvailable} from './cache-utils';
|
|||
import cp from 'child_process';
|
||||
import fs from 'fs';
|
||||
import os from 'os';
|
||||
import {getCacheInput} from './utils';
|
||||
|
||||
export async function run() {
|
||||
try {
|
||||
|
@ -17,7 +18,7 @@ export async function run() {
|
|||
//
|
||||
const versionSpec = resolveVersionInput();
|
||||
|
||||
const cache = core.getBooleanInput('cache');
|
||||
const cache = getCacheInput();
|
||||
core.info(`Setup go version spec ${versionSpec}`);
|
||||
|
||||
let arch = core.getInput('architecture');
|
||||
|
|
13
src/utils.ts
13
src/utils.ts
|
@ -1,4 +1,17 @@
|
|||
import * as core from '@actions/core';
|
||||
|
||||
export enum StableReleaseAlias {
|
||||
Stable = 'stable',
|
||||
OldStable = 'oldstable'
|
||||
}
|
||||
|
||||
export const isSelfHosted = (): boolean =>
|
||||
process.env['RUNNER_ENVIRONMENT'] !== 'github-hosted' &&
|
||||
process.env['AGENT_ISSELFHOSTED'] === '1';
|
||||
|
||||
export const getCacheInput = (): boolean => {
|
||||
// for self-hosted environment turn off cache by default
|
||||
if (isSelfHosted() && core.getInput('cache') === '') return false;
|
||||
|
||||
return core.getBooleanInput('cache');
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue