mirror of
https://github.com/actions/setup-go.git
synced 2025-11-07 12:36:55 +00:00
Compare commits
20 commits
1e25f2b888
...
9dd2a3e573
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9dd2a3e573 | ||
|
|
faf52423ec | ||
|
|
461004e4c9 | ||
|
|
6ccafa914b | ||
|
|
fdd38598b9 | ||
|
|
bda02de888 | ||
|
|
be775566d4 | ||
|
|
5b1dffca1b | ||
|
|
e91efc513b | ||
|
|
e3c077dd6d | ||
|
|
f8cf508b5f | ||
|
|
c8eefa5dde | ||
|
|
896e2cbf0f | ||
|
|
fd3fcb34ee | ||
|
|
6cd0eaadd6 | ||
|
|
0dc6404f6a | ||
|
|
434fb17078 | ||
|
|
97e00a50c1 | ||
|
|
0859a18f70 | ||
|
|
28b19b8019 |
11 changed files with 198 additions and 18 deletions
40
.github/workflows/versions.yml
vendored
40
.github/workflows/versions.yml
vendored
|
|
@ -18,7 +18,7 @@ jobs:
|
||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
os: [ubuntu-latest, windows-latest, macos-latest, macos-13]
|
os: [ubuntu-latest, windows-latest, macos-latest, macos-latest-large]
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v5
|
- uses: actions/checkout@v5
|
||||||
- name: Setup Go Stable
|
- name: Setup Go Stable
|
||||||
|
|
@ -33,7 +33,7 @@ jobs:
|
||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
os: [ubuntu-latest, windows-latest, macos-latest, macos-13]
|
os: [ubuntu-latest, windows-latest, macos-latest, macos-latest-large]
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v5
|
- uses: actions/checkout@v5
|
||||||
- name: Setup Go oldStable
|
- name: Setup Go oldStable
|
||||||
|
|
@ -48,13 +48,13 @@ jobs:
|
||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
os: [ubuntu-latest, windows-latest, macos-latest, macos-13]
|
os: [ubuntu-latest, windows-latest, macos-latest, macos-latest-large]
|
||||||
version: [stable, oldstable]
|
version: [stable, oldstable]
|
||||||
architecture: [x64, x32]
|
architecture: [x64, x32]
|
||||||
exclude:
|
exclude:
|
||||||
- os: macos-latest
|
- os: macos-latest
|
||||||
architecture: x32
|
architecture: x32
|
||||||
- os: macos-13
|
- os: macos-latest-large
|
||||||
architecture: x32
|
architecture: x32
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v5
|
- uses: actions/checkout@v5
|
||||||
|
|
@ -72,7 +72,7 @@ jobs:
|
||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
os: [macos-latest, windows-latest, ubuntu-latest, macos-13]
|
os: [macos-latest, windows-latest, ubuntu-latest, macos-latest-large]
|
||||||
go: [1.21.13, 1.22.8, 1.23.2]
|
go: [1.21.13, 1.22.8, 1.23.2]
|
||||||
include:
|
include:
|
||||||
- os: windows-latest
|
- os: windows-latest
|
||||||
|
|
@ -98,7 +98,7 @@ jobs:
|
||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
os: [ubuntu-latest, windows-latest, macos-latest, macos-13]
|
os: [ubuntu-latest, windows-latest, macos-latest, macos-latest-large]
|
||||||
go-version: ['1.20', '1.21', '1.22', '1.23']
|
go-version: ['1.20', '1.21', '1.22', '1.23']
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v5
|
- uses: actions/checkout@v5
|
||||||
|
|
@ -115,7 +115,7 @@ jobs:
|
||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
os: [ubuntu-latest, windows-latest, macos-latest, macos-13]
|
os: [ubuntu-latest, windows-latest, macos-latest, macos-latest-large]
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v5
|
- uses: actions/checkout@v5
|
||||||
- name: Setup Go and check latest
|
- name: Setup Go and check latest
|
||||||
|
|
@ -131,7 +131,7 @@ jobs:
|
||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
os: [ubuntu-latest, windows-latest, macos-latest, macos-13]
|
os: [ubuntu-latest, windows-latest, macos-latest, macos-latest-large]
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v5
|
- uses: actions/checkout@v5
|
||||||
- name: Setup Go and check latest
|
- name: Setup Go and check latest
|
||||||
|
|
@ -142,12 +142,28 @@ jobs:
|
||||||
run: __tests__/verify-go.sh 1.21
|
run: __tests__/verify-go.sh 1.21
|
||||||
shell: bash
|
shell: bash
|
||||||
|
|
||||||
|
go-version-file-with-tool-versions:
|
||||||
|
runs-on: ${{ matrix.os }}
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
os: [ubuntu-latest, windows-latest, macos-latest, macos-latest-large]
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v5
|
||||||
|
- name: Setup Go and check latest
|
||||||
|
uses: ./
|
||||||
|
with:
|
||||||
|
go-version-file: __tests__/data/.tool-versions
|
||||||
|
- name: verify go
|
||||||
|
run: __tests__/verify-go.sh 1.23.2
|
||||||
|
shell: bash
|
||||||
|
|
||||||
setup-versions-from-manifest:
|
setup-versions-from-manifest:
|
||||||
runs-on: ${{ matrix.os }}
|
runs-on: ${{ matrix.os }}
|
||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
os: [macos-latest, windows-latest, ubuntu-latest, macos-13]
|
os: [macos-latest, windows-latest, ubuntu-latest, macos-latest-large]
|
||||||
go: [1.20.14, 1.21.10, 1.22.8, 1.23.2]
|
go: [1.20.14, 1.21.10, 1.22.8, 1.23.2]
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
|
|
@ -167,7 +183,7 @@ jobs:
|
||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
os: [windows-latest, ubuntu-latest, macos-13]
|
os: [windows-latest, ubuntu-latest, macos-latest-large]
|
||||||
go: [1.11.12]
|
go: [1.11.12]
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
|
|
@ -187,7 +203,7 @@ jobs:
|
||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
os: [ubuntu-latest, windows-latest, macos-latest, macos-13]
|
os: [ubuntu-latest, windows-latest, macos-latest, macos-latest-large]
|
||||||
go-version: [1.20.14, 1.21, 1.22, 1.23]
|
go-version: [1.20.14, 1.21, 1.22, 1.23]
|
||||||
include:
|
include:
|
||||||
- os: macos-latest
|
- os: macos-latest
|
||||||
|
|
@ -196,7 +212,7 @@ jobs:
|
||||||
architecture: x64
|
architecture: x64
|
||||||
- os: windows-latest
|
- os: windows-latest
|
||||||
architecture: x64
|
architecture: x64
|
||||||
- os: macos-13
|
- os: macos-latest-large
|
||||||
architecture: x64
|
architecture: x64
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v5
|
- uses: actions/checkout@v5
|
||||||
|
|
|
||||||
37
.github/workflows/windows-validation.yml
vendored
37
.github/workflows/windows-validation.yml
vendored
|
|
@ -134,3 +134,40 @@ jobs:
|
||||||
with:
|
with:
|
||||||
go-version: ${{ matrix.go }}
|
go-version: ${{ matrix.go }}
|
||||||
cache: ${{ matrix.cache }}
|
cache: ${{ matrix.cache }}
|
||||||
|
|
||||||
|
go-mod-cache-and-tmp-location:
|
||||||
|
name: 'Validate if GOCACHE, GOMODCACHE, GOTMPDIR is set to drive D:'
|
||||||
|
runs-on: windows-latest
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
cache: [false]
|
||||||
|
go: [1.20.1]
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: 'Setup ${{ matrix.go }}, cache: ${{ matrix.cache }}'
|
||||||
|
uses: ./
|
||||||
|
with:
|
||||||
|
go-version: ${{ matrix.go }}
|
||||||
|
cache: ${{ matrix.cache }}
|
||||||
|
|
||||||
|
- name: 'Check if go mod cache and tmp location is set correctly'
|
||||||
|
run: |
|
||||||
|
go env GOCACHE
|
||||||
|
go env GOMODCACHE
|
||||||
|
go env GOTMPDIR
|
||||||
|
|
||||||
|
if [ $(go env GOCACHE) != 'D:\Users\runneradmin\AppData\Local\go-build' ];then
|
||||||
|
echo 'go env GOCACHE should return "D:\Users\runneradmin\AppData\Local\go-build"'
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
if [ $(go env GOMODCACHE) != 'D:\Users\runneradmin\go\pkg\mod' ];then
|
||||||
|
echo 'go env GOMODCACHE should return "D:\Users\runneradmin\go\pkg\mod"'
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
if [ $(go env GOTMPDIR) != 'D:\gotmp' ];then
|
||||||
|
echo 'go env GOTMPDIR should return "D:\gotmp"'
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
shell: bash
|
||||||
|
|
|
||||||
11
README.md
11
README.md
|
|
@ -178,7 +178,7 @@ steps:
|
||||||
|
|
||||||
## Getting go version from the go.mod file
|
## Getting go version from the go.mod file
|
||||||
|
|
||||||
The `go-version-file` input accepts a path to a `go.mod` file or a `go.work`
|
The `go-version-file` input accepts a path to a `go.mod` file, `.tool-versions` file or a `go.work`
|
||||||
file that contains the version of Go to be used by a project. The version taken
|
file that contains the version of Go to be used by a project. The version taken
|
||||||
from thils file will be:
|
from thils file will be:
|
||||||
|
|
||||||
|
|
@ -203,6 +203,15 @@ steps:
|
||||||
go-version-file: 'path/to/go.mod'
|
go-version-file: 'path/to/go.mod'
|
||||||
- run: go version
|
- run: go version
|
||||||
```
|
```
|
||||||
|
```yaml
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v5
|
||||||
|
- uses: actions/setup-go@v6
|
||||||
|
with:
|
||||||
|
go-version-file: '.tool-versions'
|
||||||
|
- run: go version
|
||||||
|
```
|
||||||
|
> The [.tool-versions file](https://asdf-vm.com/manage/configuration.html#tool-versions) supports version specifications in accordance with asdf standards, adhering to Semantic Versioning ([semver](https://semver.org)).
|
||||||
|
|
||||||
## Matrix testing
|
## Matrix testing
|
||||||
|
|
||||||
|
|
|
||||||
1
__tests__/data/.tool-versions
Normal file
1
__tests__/data/.tool-versions
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
golang 1.23.2
|
||||||
|
|
@ -866,6 +866,9 @@ exclude example.com/thismodule v1.3.0
|
||||||
|
|
||||||
use .
|
use .
|
||||||
|
|
||||||
|
`;
|
||||||
|
|
||||||
|
const toolVersionsContents = `golang 1.23
|
||||||
`;
|
`;
|
||||||
|
|
||||||
it('reads version from go.mod', async () => {
|
it('reads version from go.mod', async () => {
|
||||||
|
|
@ -892,6 +895,18 @@ use .
|
||||||
expect(logSpy).toHaveBeenCalledWith('matching 1.19...');
|
expect(logSpy).toHaveBeenCalledWith('matching 1.19...');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('reads version from .tool-versions', async () => {
|
||||||
|
inputs['go-version-file'] = '.tool-versions';
|
||||||
|
existsSpy.mockImplementation(() => true);
|
||||||
|
readFileSpy.mockImplementation(() => Buffer.from(toolVersionsContents));
|
||||||
|
|
||||||
|
await main.run();
|
||||||
|
|
||||||
|
expect(logSpy).toHaveBeenCalledWith('Setup go version spec 1.23');
|
||||||
|
expect(logSpy).toHaveBeenCalledWith('Attempting to download 1.23...');
|
||||||
|
expect(logSpy).toHaveBeenCalledWith('matching 1.23...');
|
||||||
|
});
|
||||||
|
|
||||||
it('reads version from .go-version', async () => {
|
it('reads version from .go-version', async () => {
|
||||||
inputs['go-version-file'] = '.go-version';
|
inputs['go-version-file'] = '.go-version';
|
||||||
existsSpy.mockImplementation(() => true);
|
existsSpy.mockImplementation(() => true);
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@ inputs:
|
||||||
go-version:
|
go-version:
|
||||||
description: 'The Go version to download (if necessary) and use. Supports semver spec and ranges. Be sure to enclose this option in single quotation marks.'
|
description: 'The Go version to download (if necessary) and use. Supports semver spec and ranges. Be sure to enclose this option in single quotation marks.'
|
||||||
go-version-file:
|
go-version-file:
|
||||||
description: 'Path to the go.mod or go.work file.'
|
description: 'Path to the go.mod, .tool-versions, or go.work file.'
|
||||||
check-latest:
|
check-latest:
|
||||||
description: 'Set this option to true if you want the action to always check for the latest available version that satisfies the version spec'
|
description: 'Set this option to true if you want the action to always check for the latest available version that satisfies the version spec'
|
||||||
default: false
|
default: false
|
||||||
|
|
|
||||||
45
dist/setup/index.js
vendored
45
dist/setup/index.js
vendored
|
|
@ -94077,7 +94077,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||||
};
|
};
|
||||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||||
exports.restoreCache = void 0;
|
exports.setWindowsCacheDirectories = exports.restoreCache = void 0;
|
||||||
const cache = __importStar(__nccwpck_require__(7799));
|
const cache = __importStar(__nccwpck_require__(7799));
|
||||||
const core = __importStar(__nccwpck_require__(2186));
|
const core = __importStar(__nccwpck_require__(2186));
|
||||||
const glob = __importStar(__nccwpck_require__(8090));
|
const glob = __importStar(__nccwpck_require__(8090));
|
||||||
|
|
@ -94085,6 +94085,7 @@ const path_1 = __importDefault(__nccwpck_require__(1017));
|
||||||
const fs_1 = __importDefault(__nccwpck_require__(7147));
|
const fs_1 = __importDefault(__nccwpck_require__(7147));
|
||||||
const constants_1 = __nccwpck_require__(9042);
|
const constants_1 = __nccwpck_require__(9042);
|
||||||
const cache_utils_1 = __nccwpck_require__(1678);
|
const cache_utils_1 = __nccwpck_require__(1678);
|
||||||
|
const os_1 = __importDefault(__nccwpck_require__(2037));
|
||||||
const restoreCache = (versionSpec, packageManager, cacheDependencyPath) => __awaiter(void 0, void 0, void 0, function* () {
|
const restoreCache = (versionSpec, packageManager, cacheDependencyPath) => __awaiter(void 0, void 0, void 0, function* () {
|
||||||
const packageManagerInfo = yield (0, cache_utils_1.getPackageManagerInfo)(packageManager);
|
const packageManagerInfo = yield (0, cache_utils_1.getPackageManagerInfo)(packageManager);
|
||||||
const platform = process.env.RUNNER_OS;
|
const platform = process.env.RUNNER_OS;
|
||||||
|
|
@ -94112,6 +94113,43 @@ const restoreCache = (versionSpec, packageManager, cacheDependencyPath) => __awa
|
||||||
core.info(`Cache restored from key: ${cacheKey}`);
|
core.info(`Cache restored from key: ${cacheKey}`);
|
||||||
});
|
});
|
||||||
exports.restoreCache = restoreCache;
|
exports.restoreCache = restoreCache;
|
||||||
|
const setWindowsCacheDirectories = () => __awaiter(void 0, void 0, void 0, function* () {
|
||||||
|
if (os_1.default.platform() !== 'win32')
|
||||||
|
return;
|
||||||
|
if (!fs_1.default.existsSync('D:'))
|
||||||
|
return;
|
||||||
|
let goCache = yield (0, cache_utils_1.getCommandOutput)(`go env GOCACHE`);
|
||||||
|
core.info(`GOCACHE: ${goCache}`);
|
||||||
|
goCache = goCache.replace('C:', 'D:').replace('c:', 'd:');
|
||||||
|
if (!fs_1.default.existsSync(goCache)) {
|
||||||
|
core.info(`${goCache} does not exist. Creating`);
|
||||||
|
fs_1.default.mkdirSync(goCache, { recursive: true });
|
||||||
|
}
|
||||||
|
const setOutput = yield (0, cache_utils_1.getCommandOutput)(`go env -w GOCACHE=${goCache}`);
|
||||||
|
core.info(`go env -w GOCACHE output: ${setOutput}`);
|
||||||
|
let goModCache = yield (0, cache_utils_1.getCommandOutput)(`go env GOMODCACHE`);
|
||||||
|
core.info(`GOMODCACHE: ${goModCache}`);
|
||||||
|
goModCache = goModCache.replace('C:', 'D:').replace('c:', 'd:');
|
||||||
|
if (!fs_1.default.existsSync(goModCache)) {
|
||||||
|
core.info(`${goModCache} does not exist. Creating`);
|
||||||
|
fs_1.default.mkdirSync(goModCache, { recursive: true });
|
||||||
|
}
|
||||||
|
const setModOutput = yield (0, cache_utils_1.getCommandOutput)(`go env -w GOMODCACHE=${goModCache}`);
|
||||||
|
core.info(`go env -w GOMODCACHE output: ${setModOutput}`);
|
||||||
|
let goTmpDir = yield (0, cache_utils_1.getCommandOutput)(`go env GOTMPDIR`);
|
||||||
|
core.info(`GOTMPDIR: ${goTmpDir}`);
|
||||||
|
if (!goTmpDir || goTmpDir === '') {
|
||||||
|
goTmpDir = 'D:\\gotmp';
|
||||||
|
}
|
||||||
|
goTmpDir = goTmpDir.replace('C:', 'D:').replace('c:', 'd:');
|
||||||
|
if (!fs_1.default.existsSync(goTmpDir)) {
|
||||||
|
core.info(`${goTmpDir} does not exist. Creating`);
|
||||||
|
fs_1.default.mkdirSync(goTmpDir, { recursive: true });
|
||||||
|
}
|
||||||
|
const setGoTmpOutput = yield (0, cache_utils_1.getCommandOutput)(`go env -w GOTMPDIR=${goTmpDir}`);
|
||||||
|
core.info(`go env -w GOTMPDIR output: ${setGoTmpOutput}`);
|
||||||
|
});
|
||||||
|
exports.setWindowsCacheDirectories = setWindowsCacheDirectories;
|
||||||
const findDependencyFile = (packageManager) => {
|
const findDependencyFile = (packageManager) => {
|
||||||
const dependencyFile = packageManager.dependencyFilePattern;
|
const dependencyFile = packageManager.dependencyFilePattern;
|
||||||
const workspace = process.env.GITHUB_WORKSPACE;
|
const workspace = process.env.GITHUB_WORKSPACE;
|
||||||
|
|
@ -94679,6 +94717,10 @@ function parseGoVersionFile(versionFilePath) {
|
||||||
const matchGo = contents.match(/^go (\d+(\.\d+)*)/m);
|
const matchGo = contents.match(/^go (\d+(\.\d+)*)/m);
|
||||||
return matchGo ? matchGo[1] : '';
|
return matchGo ? matchGo[1] : '';
|
||||||
}
|
}
|
||||||
|
else if (path.basename(versionFilePath) === '.tool-versions') {
|
||||||
|
const match = contents.match(/^golang\s+([^\n#]+)/m);
|
||||||
|
return match ? match[1].trim() : '';
|
||||||
|
}
|
||||||
return contents.trim();
|
return contents.trim();
|
||||||
}
|
}
|
||||||
function resolveStableVersionDist(versionSpec, arch) {
|
function resolveStableVersionDist(versionSpec, arch) {
|
||||||
|
|
@ -94790,6 +94832,7 @@ const os_1 = __importDefault(__nccwpck_require__(2037));
|
||||||
function run() {
|
function run() {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
try {
|
try {
|
||||||
|
yield (0, cache_restore_1.setWindowsCacheDirectories)();
|
||||||
//
|
//
|
||||||
// versionSpec is optional. If supplied, install / use from the tool cache
|
// versionSpec is optional. If supplied, install / use from the tool cache
|
||||||
// If not supplied then problem matchers will still be setup. Useful for self-hosted.
|
// If not supplied then problem matchers will still be setup. Useful for self-hosted.
|
||||||
|
|
|
||||||
|
|
@ -4,9 +4,14 @@ import * as glob from '@actions/glob';
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
import fs from 'fs';
|
import fs from 'fs';
|
||||||
|
|
||||||
import {State, Outputs} from './constants';
|
import {Outputs, State} from './constants';
|
||||||
import {PackageManagerInfo} from './package-managers';
|
import {PackageManagerInfo} from './package-managers';
|
||||||
import {getCacheDirectoryPath, getPackageManagerInfo} from './cache-utils';
|
import {
|
||||||
|
getCacheDirectoryPath,
|
||||||
|
getCommandOutput,
|
||||||
|
getPackageManagerInfo
|
||||||
|
} from './cache-utils';
|
||||||
|
import os from 'os';
|
||||||
|
|
||||||
export const restoreCache = async (
|
export const restoreCache = async (
|
||||||
versionSpec: string,
|
versionSpec: string,
|
||||||
|
|
@ -50,6 +55,55 @@ export const restoreCache = async (
|
||||||
core.info(`Cache restored from key: ${cacheKey}`);
|
core.info(`Cache restored from key: ${cacheKey}`);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const setWindowsCacheDirectories = async () => {
|
||||||
|
if (os.platform() !== 'win32') return;
|
||||||
|
|
||||||
|
if (!fs.existsSync('D:')) return;
|
||||||
|
|
||||||
|
let goCache = await getCommandOutput(`go env GOCACHE`);
|
||||||
|
core.info(`GOCACHE: ${goCache}`);
|
||||||
|
goCache = goCache.replace('C:', 'D:').replace('c:', 'd:');
|
||||||
|
|
||||||
|
if (!fs.existsSync(goCache)) {
|
||||||
|
core.info(`${goCache} does not exist. Creating`);
|
||||||
|
fs.mkdirSync(goCache, {recursive: true});
|
||||||
|
}
|
||||||
|
|
||||||
|
const setOutput = await getCommandOutput(`go env -w GOCACHE=${goCache}`);
|
||||||
|
core.info(`go env -w GOCACHE output: ${setOutput}`);
|
||||||
|
|
||||||
|
let goModCache = await getCommandOutput(`go env GOMODCACHE`);
|
||||||
|
core.info(`GOMODCACHE: ${goModCache}`);
|
||||||
|
goModCache = goModCache.replace('C:', 'D:').replace('c:', 'd:');
|
||||||
|
|
||||||
|
if (!fs.existsSync(goModCache)) {
|
||||||
|
core.info(`${goModCache} does not exist. Creating`);
|
||||||
|
fs.mkdirSync(goModCache, {recursive: true});
|
||||||
|
}
|
||||||
|
|
||||||
|
const setModOutput = await getCommandOutput(
|
||||||
|
`go env -w GOMODCACHE=${goModCache}`
|
||||||
|
);
|
||||||
|
core.info(`go env -w GOMODCACHE output: ${setModOutput}`);
|
||||||
|
|
||||||
|
let goTmpDir = await getCommandOutput(`go env GOTMPDIR`);
|
||||||
|
core.info(`GOTMPDIR: ${goTmpDir}`);
|
||||||
|
if (!goTmpDir || goTmpDir === '') {
|
||||||
|
goTmpDir = 'D:\\gotmp';
|
||||||
|
}
|
||||||
|
goTmpDir = goTmpDir.replace('C:', 'D:').replace('c:', 'd:');
|
||||||
|
|
||||||
|
if (!fs.existsSync(goTmpDir)) {
|
||||||
|
core.info(`${goTmpDir} does not exist. Creating`);
|
||||||
|
fs.mkdirSync(goTmpDir, {recursive: true});
|
||||||
|
}
|
||||||
|
|
||||||
|
const setGoTmpOutput = await getCommandOutput(
|
||||||
|
`go env -w GOTMPDIR=${goTmpDir}`
|
||||||
|
);
|
||||||
|
core.info(`go env -w GOTMPDIR output: ${setGoTmpOutput}`);
|
||||||
|
};
|
||||||
|
|
||||||
const findDependencyFile = (packageManager: PackageManagerInfo) => {
|
const findDependencyFile = (packageManager: PackageManagerInfo) => {
|
||||||
const dependencyFile = packageManager.dependencyFilePattern;
|
const dependencyFile = packageManager.dependencyFilePattern;
|
||||||
const workspace = process.env.GITHUB_WORKSPACE!;
|
const workspace = process.env.GITHUB_WORKSPACE!;
|
||||||
|
|
|
||||||
|
|
@ -15,6 +15,7 @@ process.on('uncaughtException', e => {
|
||||||
// Added early exit to resolve issue with slow post action step:
|
// Added early exit to resolve issue with slow post action step:
|
||||||
// - https://github.com/actions/setup-node/issues/878
|
// - https://github.com/actions/setup-node/issues/878
|
||||||
// https://github.com/actions/cache/pull/1217
|
// https://github.com/actions/cache/pull/1217
|
||||||
|
|
||||||
export async function run(earlyExit?: boolean) {
|
export async function run(earlyExit?: boolean) {
|
||||||
try {
|
try {
|
||||||
const cacheInput = core.getBooleanInput('cache');
|
const cacheInput = core.getBooleanInput('cache');
|
||||||
|
|
|
||||||
|
|
@ -513,6 +513,9 @@ export function parseGoVersionFile(versionFilePath: string): string {
|
||||||
// go directive: https://go.dev/ref/mod#go-mod-file-go
|
// go directive: https://go.dev/ref/mod#go-mod-file-go
|
||||||
const matchGo = contents.match(/^go (\d+(\.\d+)*)/m);
|
const matchGo = contents.match(/^go (\d+(\.\d+)*)/m);
|
||||||
return matchGo ? matchGo[1] : '';
|
return matchGo ? matchGo[1] : '';
|
||||||
|
} else if (path.basename(versionFilePath) === '.tool-versions') {
|
||||||
|
const match = contents.match(/^golang\s+([^\n#]+)/m);
|
||||||
|
return match ? match[1].trim() : '';
|
||||||
}
|
}
|
||||||
|
|
||||||
return contents.trim();
|
return contents.trim();
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@ import * as io from '@actions/io';
|
||||||
import * as installer from './installer';
|
import * as installer from './installer';
|
||||||
import * as semver from 'semver';
|
import * as semver from 'semver';
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
import {restoreCache} from './cache-restore';
|
import {restoreCache, setWindowsCacheDirectories} from './cache-restore';
|
||||||
import {isCacheFeatureAvailable} from './cache-utils';
|
import {isCacheFeatureAvailable} from './cache-utils';
|
||||||
import cp from 'child_process';
|
import cp from 'child_process';
|
||||||
import fs from 'fs';
|
import fs from 'fs';
|
||||||
|
|
@ -12,6 +12,7 @@ import {Architecture} from './types';
|
||||||
|
|
||||||
export async function run() {
|
export async function run() {
|
||||||
try {
|
try {
|
||||||
|
await setWindowsCacheDirectories();
|
||||||
//
|
//
|
||||||
// versionSpec is optional. If supplied, install / use from the tool cache
|
// versionSpec is optional. If supplied, install / use from the tool cache
|
||||||
// If not supplied then problem matchers will still be setup. Useful for self-hosted.
|
// If not supplied then problem matchers will still be setup. Useful for self-hosted.
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue