mirror of
https://github.com/actions/setup-go.git
synced 2025-05-04 14:14:34 +00:00
Enable caching by default with default input (#332)
This commit is contained in:
@ -23,7 +23,7 @@ export async function run() {
|
||||
if (typeof error === 'string') {
|
||||
message = error;
|
||||
}
|
||||
core.setFailed(message);
|
||||
core.warning(message);
|
||||
}
|
||||
}
|
||||
|
||||
@ -59,6 +59,13 @@ const cachePackages = async () => {
|
||||
);
|
||||
}
|
||||
|
||||
if (!primaryKey) {
|
||||
core.info(
|
||||
'Primary key was not generated. Please check the log messages above for more errors or information'
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
if (primaryKey === state) {
|
||||
core.info(
|
||||
`Cache hit occurred on the primary key ${primaryKey}, not saving cache.`
|
||||
|
@ -34,13 +34,23 @@ export const getPackageManagerInfo = async (packageManager: string) => {
|
||||
export const getCacheDirectoryPath = async (
|
||||
packageManagerInfo: PackageManagerInfo
|
||||
) => {
|
||||
const pathList = await Promise.all(
|
||||
const pathOutputs = await Promise.allSettled(
|
||||
packageManagerInfo.cacheFolderCommandList.map(async command =>
|
||||
getCommandOutput(command)
|
||||
)
|
||||
);
|
||||
|
||||
const cachePaths = pathList.filter(item => item);
|
||||
const results = pathOutputs.map(item => {
|
||||
if (item.status === 'fulfilled') {
|
||||
return item.value;
|
||||
} else {
|
||||
core.info(`[warning]getting cache directory path failed: ${item.reason}`);
|
||||
}
|
||||
|
||||
return '';
|
||||
});
|
||||
|
||||
const cachePaths = results.filter(item => item);
|
||||
|
||||
if (!cachePaths.length) {
|
||||
throw new Error(`Could not get cache folder paths.`);
|
||||
|
14
src/main.ts
14
src/main.ts
@ -62,11 +62,15 @@ export async function run() {
|
||||
if (cache && isCacheFeatureAvailable()) {
|
||||
const packageManager = 'default';
|
||||
const cacheDependencyPath = core.getInput('cache-dependency-path');
|
||||
await restoreCache(
|
||||
parseGoVersion(goVersion),
|
||||
packageManager,
|
||||
cacheDependencyPath
|
||||
);
|
||||
try {
|
||||
await restoreCache(
|
||||
parseGoVersion(goVersion),
|
||||
packageManager,
|
||||
cacheDependencyPath
|
||||
);
|
||||
} catch (error) {
|
||||
core.warning(`Restore cache failed: ${error.message}`);
|
||||
}
|
||||
}
|
||||
|
||||
// add problem matchers
|
||||
|
Reference in New Issue
Block a user