mirror of
https://code.forgejo.org/actions/setup-go
synced 2025-06-15 14:54:09 +02:00
Remove toolchain directories from the cache
This commit is contained in:
parent
bfd2fb341f
commit
75d73b8577
13 changed files with 893 additions and 301 deletions
|
@ -2,7 +2,11 @@ import * as core from '@actions/core';
|
|||
import * as cache from '@actions/cache';
|
||||
import fs from 'fs';
|
||||
import {State} from './constants';
|
||||
import {getCacheDirectoryPath, getPackageManagerInfo} from './cache-utils';
|
||||
import {
|
||||
getCacheDirectoryPath,
|
||||
getPackageManagerInfo,
|
||||
getToolchainDirectoriesFromCachedDirectories
|
||||
} from './cache-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
|
||||
|
@ -73,6 +77,21 @@ const cachePackages = async () => {
|
|||
return;
|
||||
}
|
||||
|
||||
const toolchainVersion = core.getState(State.ToolchainVersion);
|
||||
// toolchainVersion is always null for self-hosted runners
|
||||
if (toolchainVersion) {
|
||||
const toolchainDirectories = getToolchainDirectoriesFromCachedDirectories(
|
||||
toolchainVersion,
|
||||
cachePaths
|
||||
);
|
||||
toolchainDirectories.forEach(toolchainDirectory => {
|
||||
core.warning(
|
||||
`Toolchain version ${toolchainVersion} will be removed from cache: ${toolchainDirectory}`
|
||||
);
|
||||
fs.rmSync(toolchainDirectory, {recursive: true});
|
||||
});
|
||||
}
|
||||
|
||||
const cacheId = await cache.saveCache(cachePaths, primaryKey);
|
||||
if (cacheId === -1) {
|
||||
return;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue