mirror of
https://github.com/actions/setup-go.git
synced 2026-07-05 23:35:37 +00:00
Compare commits
6 Commits
7cb572c174
...
cec5ef1307
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
cec5ef1307 | ||
|
|
d085b4fe57 | ||
|
|
48ac8fd236 | ||
|
|
89a192af9d | ||
|
|
aabcd82874 | ||
|
|
28cfea2580 |
24
.github/workflows/windows-validation.yml
vendored
24
.github/workflows/windows-validation.yml
vendored
@ -105,10 +105,32 @@ jobs:
|
|||||||
fi
|
fi
|
||||||
shell: bash
|
shell: bash
|
||||||
|
|
||||||
- name: 'Drive D: should not have Go installation, cache: ${{ matrix.cache}}'
|
- name: 'Drive D: should not have Go installation, cache: ${{ matrix.cache }}'
|
||||||
run: |
|
run: |
|
||||||
if [ -e 'D:\hostedtoolcache\windows\go\${{ needs.find-default-go.outputs.version }}\x64' ];then
|
if [ -e 'D:\hostedtoolcache\windows\go\${{ needs.find-default-go.outputs.version }}\x64' ];then
|
||||||
echo 'D:\hostedtoolcache\windows\go\${{ needs.find-default-go.outputs.version }}\x64 should not exist for hosted version of go';
|
echo 'D:\hostedtoolcache\windows\go\${{ needs.find-default-go.outputs.version }}\x64 should not exist for hosted version of go';
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
shell: bash
|
shell: bash
|
||||||
|
|
||||||
|
hostedtoolcache:
|
||||||
|
name: 'Validate if hostedtoolcache works as expected'
|
||||||
|
runs-on: windows-latest
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
cache: [false]
|
||||||
|
go: [1.20.1]
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
|
||||||
|
- name: 'Setup ${{ matrix.go }}, cache: ${{ matrix.cache }}'
|
||||||
|
uses: ./
|
||||||
|
with:
|
||||||
|
go-version: ${{ matrix.go }}
|
||||||
|
cache: ${{ matrix.cache }}
|
||||||
|
|
||||||
|
- name: 'Setup ${{ matrix.go }}, cache: ${{ matrix.cache }} (from hostedtoolcache)'
|
||||||
|
uses: ./
|
||||||
|
with:
|
||||||
|
go-version: ${{ matrix.go }}
|
||||||
|
cache: ${{ matrix.cache }}
|
||||||
|
|||||||
@ -17,6 +17,9 @@ inputs:
|
|||||||
default: true
|
default: true
|
||||||
cache-dependency-path:
|
cache-dependency-path:
|
||||||
description: 'Used to specify the path to a dependency file - go.sum'
|
description: 'Used to specify the path to a dependency file - go.sum'
|
||||||
|
cache-restore-only:
|
||||||
|
description: Used to specify the cache . Set to true, if you'd like to reuse existing cache but did not update it
|
||||||
|
default: false
|
||||||
architecture:
|
architecture:
|
||||||
description: 'Target architecture for Go to use. Examples: x86, x64. Will use system architecture by default.'
|
description: 'Target architecture for Go to use. Examples: x86, x64. Will use system architecture by default.'
|
||||||
outputs:
|
outputs:
|
||||||
|
|||||||
7
dist/cache-save/index.js
vendored
7
dist/cache-save/index.js
vendored
@ -58504,6 +58504,10 @@ process.on('uncaughtException', e => {
|
|||||||
});
|
});
|
||||||
function run() {
|
function run() {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
|
if (core.getState(constants_1.State.CacheRestoreOnly) === constants_1.State.True) {
|
||||||
|
core.info('"cache-restore-only" set to true, skip caching');
|
||||||
|
return;
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
yield cachePackages();
|
yield cachePackages();
|
||||||
}
|
}
|
||||||
@ -58669,6 +58673,9 @@ var State;
|
|||||||
(function (State) {
|
(function (State) {
|
||||||
State["CachePrimaryKey"] = "CACHE_KEY";
|
State["CachePrimaryKey"] = "CACHE_KEY";
|
||||||
State["CacheMatchedKey"] = "CACHE_RESULT";
|
State["CacheMatchedKey"] = "CACHE_RESULT";
|
||||||
|
State["CacheRestoreOnly"] = "CACHE_RESTORE_ONLY";
|
||||||
|
State["True"] = "true";
|
||||||
|
State["False"] = "false";
|
||||||
})(State = exports.State || (exports.State = {}));
|
})(State = exports.State || (exports.State = {}));
|
||||||
var Outputs;
|
var Outputs;
|
||||||
(function (Outputs) {
|
(function (Outputs) {
|
||||||
|
|||||||
10
dist/setup/index.js
vendored
10
dist/setup/index.js
vendored
@ -61339,6 +61339,9 @@ var State;
|
|||||||
(function (State) {
|
(function (State) {
|
||||||
State["CachePrimaryKey"] = "CACHE_KEY";
|
State["CachePrimaryKey"] = "CACHE_KEY";
|
||||||
State["CacheMatchedKey"] = "CACHE_RESULT";
|
State["CacheMatchedKey"] = "CACHE_RESULT";
|
||||||
|
State["CacheRestoreOnly"] = "CACHE_RESTORE_ONLY";
|
||||||
|
State["True"] = "true";
|
||||||
|
State["False"] = "false";
|
||||||
})(State = exports.State || (exports.State = {}));
|
})(State = exports.State || (exports.State = {}));
|
||||||
var Outputs;
|
var Outputs;
|
||||||
(function (Outputs) {
|
(function (Outputs) {
|
||||||
@ -61514,6 +61517,10 @@ function cacheWindowsDir(extPath, tool, version, arch) {
|
|||||||
fs_1.default.mkdirSync(path.dirname(defaultToolCacheDir), { recursive: true });
|
fs_1.default.mkdirSync(path.dirname(defaultToolCacheDir), { recursive: true });
|
||||||
fs_1.default.symlinkSync(actualToolCacheDir, defaultToolCacheDir, 'junction');
|
fs_1.default.symlinkSync(actualToolCacheDir, defaultToolCacheDir, 'junction');
|
||||||
core.info(`Created link ${defaultToolCacheDir} => ${actualToolCacheDir}`);
|
core.info(`Created link ${defaultToolCacheDir} => ${actualToolCacheDir}`);
|
||||||
|
const actualToolCacheCompleteFile = `${actualToolCacheDir}.complete`;
|
||||||
|
const defaultToolCacheCompleteFile = `${defaultToolCacheDir}.complete`;
|
||||||
|
fs_1.default.symlinkSync(actualToolCacheCompleteFile, defaultToolCacheCompleteFile, 'file');
|
||||||
|
core.info(`Created link ${defaultToolCacheCompleteFile} => ${actualToolCacheCompleteFile}`);
|
||||||
// make outer code to continue using toolcache as if it were installed on c:
|
// make outer code to continue using toolcache as if it were installed on c:
|
||||||
// restore toolcache root to default drive c:
|
// restore toolcache root to default drive c:
|
||||||
process.env['RUNNER_TOOL_CACHE'] = defaultToolCacheRoot;
|
process.env['RUNNER_TOOL_CACHE'] = defaultToolCacheRoot;
|
||||||
@ -61777,6 +61784,7 @@ const cache_utils_1 = __nccwpck_require__(1678);
|
|||||||
const child_process_1 = __importDefault(__nccwpck_require__(2081));
|
const child_process_1 = __importDefault(__nccwpck_require__(2081));
|
||||||
const fs_1 = __importDefault(__nccwpck_require__(7147));
|
const fs_1 = __importDefault(__nccwpck_require__(7147));
|
||||||
const os_1 = __importDefault(__nccwpck_require__(2037));
|
const os_1 = __importDefault(__nccwpck_require__(2037));
|
||||||
|
const constants_1 = __nccwpck_require__(9042);
|
||||||
function run() {
|
function run() {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
try {
|
try {
|
||||||
@ -61814,6 +61822,8 @@ function run() {
|
|||||||
core.debug(`add bin ${added}`);
|
core.debug(`add bin ${added}`);
|
||||||
const goPath = yield io.which('go');
|
const goPath = yield io.which('go');
|
||||||
const goVersion = (child_process_1.default.execSync(`${goPath} version`) || '').toString();
|
const goVersion = (child_process_1.default.execSync(`${goPath} version`) || '').toString();
|
||||||
|
const cacheRestoreOnly = core.getBooleanInput('cache-restore-only');
|
||||||
|
core.saveState(constants_1.State.CacheRestoreOnly, cacheRestoreOnly ? constants_1.State.True : constants_1.State.False);
|
||||||
if (cache && cache_utils_1.isCacheFeatureAvailable()) {
|
if (cache && cache_utils_1.isCacheFeatureAvailable()) {
|
||||||
const packageManager = 'default';
|
const packageManager = 'default';
|
||||||
const cacheDependencyPath = core.getInput('cache-dependency-path');
|
const cacheDependencyPath = core.getInput('cache-dependency-path');
|
||||||
|
|||||||
@ -13,6 +13,10 @@ process.on('uncaughtException', e => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
export async function run() {
|
export async function run() {
|
||||||
|
if (core.getState(State.CacheRestoreOnly) === State.True) {
|
||||||
|
core.info('"cache-restore-only" set to true, skip caching');
|
||||||
|
return;
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
await cachePackages();
|
await cachePackages();
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
|||||||
@ -1,6 +1,9 @@
|
|||||||
export enum State {
|
export enum State {
|
||||||
CachePrimaryKey = 'CACHE_KEY',
|
CachePrimaryKey = 'CACHE_KEY',
|
||||||
CacheMatchedKey = 'CACHE_RESULT'
|
CacheMatchedKey = 'CACHE_RESULT',
|
||||||
|
CacheRestoreOnly = 'CACHE_RESTORE_ONLY',
|
||||||
|
True = 'true',
|
||||||
|
False = 'false'
|
||||||
}
|
}
|
||||||
|
|
||||||
export enum Outputs {
|
export enum Outputs {
|
||||||
|
|||||||
@ -203,6 +203,17 @@ async function cacheWindowsDir(
|
|||||||
fs.symlinkSync(actualToolCacheDir, defaultToolCacheDir, 'junction');
|
fs.symlinkSync(actualToolCacheDir, defaultToolCacheDir, 'junction');
|
||||||
core.info(`Created link ${defaultToolCacheDir} => ${actualToolCacheDir}`);
|
core.info(`Created link ${defaultToolCacheDir} => ${actualToolCacheDir}`);
|
||||||
|
|
||||||
|
const actualToolCacheCompleteFile = `${actualToolCacheDir}.complete`;
|
||||||
|
const defaultToolCacheCompleteFile = `${defaultToolCacheDir}.complete`;
|
||||||
|
fs.symlinkSync(
|
||||||
|
actualToolCacheCompleteFile,
|
||||||
|
defaultToolCacheCompleteFile,
|
||||||
|
'file'
|
||||||
|
);
|
||||||
|
core.info(
|
||||||
|
`Created link ${defaultToolCacheCompleteFile} => ${actualToolCacheCompleteFile}`
|
||||||
|
);
|
||||||
|
|
||||||
// make outer code to continue using toolcache as if it were installed on c:
|
// make outer code to continue using toolcache as if it were installed on c:
|
||||||
// restore toolcache root to default drive c:
|
// restore toolcache root to default drive c:
|
||||||
process.env['RUNNER_TOOL_CACHE'] = defaultToolCacheRoot;
|
process.env['RUNNER_TOOL_CACHE'] = defaultToolCacheRoot;
|
||||||
|
|||||||
@ -8,6 +8,7 @@ import {isCacheFeatureAvailable} from './cache-utils';
|
|||||||
import cp from 'child_process';
|
import cp from 'child_process';
|
||||||
import fs from 'fs';
|
import fs from 'fs';
|
||||||
import os from 'os';
|
import os from 'os';
|
||||||
|
import {State} from './constants';
|
||||||
|
|
||||||
export async function run() {
|
export async function run() {
|
||||||
try {
|
try {
|
||||||
@ -64,6 +65,11 @@ export async function run() {
|
|||||||
const goPath = await io.which('go');
|
const goPath = await io.which('go');
|
||||||
const goVersion = (cp.execSync(`${goPath} version`) || '').toString();
|
const goVersion = (cp.execSync(`${goPath} version`) || '').toString();
|
||||||
|
|
||||||
|
const cacheRestoreOnly = core.getBooleanInput('cache-restore-only');
|
||||||
|
core.saveState(
|
||||||
|
State.CacheRestoreOnly,
|
||||||
|
cacheRestoreOnly ? State.True : State.False
|
||||||
|
);
|
||||||
if (cache && isCacheFeatureAvailable()) {
|
if (cache && isCacheFeatureAvailable()) {
|
||||||
const packageManager = 'default';
|
const packageManager = 'default';
|
||||||
const cacheDependencyPath = core.getInput('cache-dependency-path');
|
const cacheDependencyPath = core.getInput('cache-dependency-path');
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user