mirror of
https://github.com/actions/setup-go.git
synced 2025-04-23 17:40:50 +00:00
Enable caching by default
This commit is contained in:
parent
6b848af622
commit
0cb66e4719
7 changed files with 75 additions and 6228 deletions
|
@ -129,6 +129,8 @@ The action has a built-in functionality for caching and restoring go modules and
|
||||||
|
|
||||||
The action defaults to search for the dependency file - go.sum in the repository root, and uses its hash as a part of the cache key. Use `cache-dependency-path` input for cases when multiple dependency files are used, or they are located in different subdirectories.
|
The action defaults to search for the dependency file - go.sum in the repository root, and uses its hash as a part of the cache key. Use `cache-dependency-path` input for cases when multiple dependency files are used, or they are located in different subdirectories.
|
||||||
|
|
||||||
|
Since 4.0.0 the cache is enabled by default.
|
||||||
|
|
||||||
**Caching without specifying dependency file path**
|
**Caching without specifying dependency file path**
|
||||||
```yaml
|
```yaml
|
||||||
steps:
|
steps:
|
||||||
|
|
|
@ -14,7 +14,7 @@ inputs:
|
||||||
default: ${{ github.server_url == 'https://github.com' && github.token || '' }}
|
default: ${{ github.server_url == 'https://github.com' && github.token || '' }}
|
||||||
cache:
|
cache:
|
||||||
description: Used to specify whether caching is needed. Set to true, if you'd like to enable caching.
|
description: Used to specify whether caching is needed. Set to true, if you'd like to enable caching.
|
||||||
default: false
|
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'
|
||||||
architecture:
|
architecture:
|
||||||
|
|
10
dist/cache-save/index.js
vendored
10
dist/cache-save/index.js
vendored
|
@ -60457,8 +60457,14 @@ const getPackageManagerInfo = (packageManager) => __awaiter(void 0, void 0, void
|
||||||
});
|
});
|
||||||
exports.getPackageManagerInfo = getPackageManagerInfo;
|
exports.getPackageManagerInfo = getPackageManagerInfo;
|
||||||
const getCacheDirectoryPath = (packageManagerInfo) => __awaiter(void 0, void 0, void 0, function* () {
|
const getCacheDirectoryPath = (packageManagerInfo) => __awaiter(void 0, void 0, void 0, function* () {
|
||||||
const pathList = yield Promise.all(packageManagerInfo.cacheFolderCommandList.map((command) => __awaiter(void 0, void 0, void 0, function* () { return exports.getCommandOutput(command); })));
|
const pathOutputs = yield Promise.allSettled(packageManagerInfo.cacheFolderCommandList.map((command) => __awaiter(void 0, void 0, void 0, function* () { return exports.getCommandOutput(command); })));
|
||||||
const cachePaths = pathList.filter(item => item);
|
pathOutputs
|
||||||
|
.filter(output => output.status === 'rejected')
|
||||||
|
.forEach(output => core.warning(`getting cache directory path failed: ${output.reason}`));
|
||||||
|
const cachePaths = pathOutputs
|
||||||
|
.filter(output => output.status === 'fulfilled' &&
|
||||||
|
output.value)
|
||||||
|
.map(output => output.value);
|
||||||
if (!cachePaths.length) {
|
if (!cachePaths.length) {
|
||||||
throw new Error(`Could not get cache folder paths.`);
|
throw new Error(`Could not get cache folder paths.`);
|
||||||
}
|
}
|
||||||
|
|
10
dist/setup/index.js
vendored
10
dist/setup/index.js
vendored
|
@ -63130,8 +63130,14 @@ const getPackageManagerInfo = (packageManager) => __awaiter(void 0, void 0, void
|
||||||
});
|
});
|
||||||
exports.getPackageManagerInfo = getPackageManagerInfo;
|
exports.getPackageManagerInfo = getPackageManagerInfo;
|
||||||
const getCacheDirectoryPath = (packageManagerInfo) => __awaiter(void 0, void 0, void 0, function* () {
|
const getCacheDirectoryPath = (packageManagerInfo) => __awaiter(void 0, void 0, void 0, function* () {
|
||||||
const pathList = yield Promise.all(packageManagerInfo.cacheFolderCommandList.map((command) => __awaiter(void 0, void 0, void 0, function* () { return exports.getCommandOutput(command); })));
|
const pathOutputs = yield Promise.allSettled(packageManagerInfo.cacheFolderCommandList.map((command) => __awaiter(void 0, void 0, void 0, function* () { return exports.getCommandOutput(command); })));
|
||||||
const cachePaths = pathList.filter(item => item);
|
pathOutputs
|
||||||
|
.filter(output => output.status === 'rejected')
|
||||||
|
.forEach(output => core.warning(`getting cache directory path failed: ${output.reason}`));
|
||||||
|
const cachePaths = pathOutputs
|
||||||
|
.filter(output => output.status === 'fulfilled' &&
|
||||||
|
output.value)
|
||||||
|
.map(output => output.value);
|
||||||
if (!cachePaths.length) {
|
if (!cachePaths.length) {
|
||||||
throw new Error(`Could not get cache folder paths.`);
|
throw new Error(`Could not get cache folder paths.`);
|
||||||
}
|
}
|
||||||
|
|
6257
package-lock.json
generated
6257
package-lock.json
generated
File diff suppressed because it is too large
Load diff
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "setup-go",
|
"name": "setup-go",
|
||||||
"version": "3.3.0",
|
"version": "4.0.0",
|
||||||
"private": true,
|
"private": true,
|
||||||
"description": "setup go action",
|
"description": "setup go action",
|
||||||
"main": "lib/setup-go.js",
|
"main": "lib/setup-go.js",
|
||||||
|
|
|
@ -34,13 +34,29 @@ export const getPackageManagerInfo = async (packageManager: string) => {
|
||||||
export const getCacheDirectoryPath = async (
|
export const getCacheDirectoryPath = async (
|
||||||
packageManagerInfo: PackageManagerInfo
|
packageManagerInfo: PackageManagerInfo
|
||||||
) => {
|
) => {
|
||||||
const pathList = await Promise.all(
|
const pathOutputs = await Promise.allSettled(
|
||||||
packageManagerInfo.cacheFolderCommandList.map(async command =>
|
packageManagerInfo.cacheFolderCommandList.map(async command =>
|
||||||
getCommandOutput(command)
|
getCommandOutput(command)
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
const cachePaths = pathList.filter(item => item);
|
pathOutputs
|
||||||
|
.filter(output => output.status === 'rejected')
|
||||||
|
.forEach(output =>
|
||||||
|
core.warning(
|
||||||
|
`getting cache directory path failed: ${
|
||||||
|
(output as PromiseRejectedResult).reason
|
||||||
|
}`
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
const cachePaths = pathOutputs
|
||||||
|
.filter(
|
||||||
|
output =>
|
||||||
|
output.status === 'fulfilled' &&
|
||||||
|
(output as PromiseFulfilledResult<string>).value
|
||||||
|
)
|
||||||
|
.map(output => (output as PromiseFulfilledResult<string>).value);
|
||||||
|
|
||||||
if (!cachePaths.length) {
|
if (!cachePaths.length) {
|
||||||
throw new Error(`Could not get cache folder paths.`);
|
throw new Error(`Could not get cache folder paths.`);
|
||||||
|
|
Loading…
Add table
Reference in a new issue