mirror of
https://github.com/astral-sh/setup-uv.git
synced 2025-02-08 01:56:10 +08:00
Prune cache before saving
This commit is contained in:
parent
6c37ad0dd4
commit
332ac35295
13
dist/save-cache/index.js
generated
vendored
13
dist/save-cache/index.js
generated
vendored
@ -82889,6 +82889,7 @@ Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|||||||
exports.run = void 0;
|
exports.run = 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 exec = __importStar(__nccwpck_require__(1514));
|
||||||
const restore_cache_1 = __nccwpck_require__(1898);
|
const restore_cache_1 = __nccwpck_require__(1898);
|
||||||
const inputs_1 = __nccwpck_require__(9378);
|
const inputs_1 = __nccwpck_require__(9378);
|
||||||
function run() {
|
function run() {
|
||||||
@ -82915,15 +82916,25 @@ function saveCache() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else if (matchedKey === cacheKey) {
|
else if (matchedKey === cacheKey) {
|
||||||
// no change in target directories
|
|
||||||
core.info(`Cache hit occurred on key ${cacheKey}, not saving cache.`);
|
core.info(`Cache hit occurred on key ${cacheKey}, not saving cache.`);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
yield pruneCache();
|
||||||
core.info(`Saving cache path: ${inputs_1.cacheLocalPath}`);
|
core.info(`Saving cache path: ${inputs_1.cacheLocalPath}`);
|
||||||
yield cache.saveCache([inputs_1.cacheLocalPath], cacheKey);
|
yield cache.saveCache([inputs_1.cacheLocalPath], cacheKey);
|
||||||
core.info(`cache saved with the key: ${cacheKey}`);
|
core.info(`cache saved with the key: ${cacheKey}`);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
function pruneCache() {
|
||||||
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
|
const options = {
|
||||||
|
silent: !core.isDebug()
|
||||||
|
};
|
||||||
|
const execArgs = ['cache', 'prune', '--ci'];
|
||||||
|
core.info('Pruning cache...');
|
||||||
|
yield exec.exec('uv', execArgs, options);
|
||||||
|
});
|
||||||
|
}
|
||||||
run();
|
run();
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
import * as cache from '@actions/cache'
|
import * as cache from '@actions/cache'
|
||||||
import * as core from '@actions/core'
|
import * as core from '@actions/core'
|
||||||
|
import * as exec from '@actions/exec'
|
||||||
import {STATE_CACHE_MATCHED_KEY, STATE_CACHE_KEY} from './cache/restore-cache'
|
import {STATE_CACHE_MATCHED_KEY, STATE_CACHE_KEY} from './cache/restore-cache'
|
||||||
import {cacheLocalPath, enableCache} from './utils/inputs'
|
import {cacheLocalPath, enableCache} from './utils/inputs'
|
||||||
|
|
||||||
@ -23,14 +24,26 @@ async function saveCache(): Promise<void> {
|
|||||||
core.warning('Error retrieving cache key from state.')
|
core.warning('Error retrieving cache key from state.')
|
||||||
return
|
return
|
||||||
} else if (matchedKey === cacheKey) {
|
} else if (matchedKey === cacheKey) {
|
||||||
// no change in target directories
|
|
||||||
core.info(`Cache hit occurred on key ${cacheKey}, not saving cache.`)
|
core.info(`Cache hit occurred on key ${cacheKey}, not saving cache.`)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
await pruneCache()
|
||||||
|
|
||||||
core.info(`Saving cache path: ${cacheLocalPath}`)
|
core.info(`Saving cache path: ${cacheLocalPath}`)
|
||||||
await cache.saveCache([cacheLocalPath], cacheKey)
|
await cache.saveCache([cacheLocalPath], cacheKey)
|
||||||
|
|
||||||
core.info(`cache saved with the key: ${cacheKey}`)
|
core.info(`cache saved with the key: ${cacheKey}`)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function pruneCache(): Promise<void> {
|
||||||
|
const options: exec.ExecOptions = {
|
||||||
|
silent: !core.isDebug()
|
||||||
|
}
|
||||||
|
const execArgs = ['cache', 'prune', '--ci']
|
||||||
|
|
||||||
|
core.info('Pruning cache...')
|
||||||
|
await exec.exec('uv', execArgs, options)
|
||||||
|
}
|
||||||
|
|
||||||
run()
|
run()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user