mirror of
https://github.com/Swatinem/rust-cache.git
synced 2025-07-19 07:11:24 +03:00
Slightly improve docs
This commit is contained in:
59
dist/restore/index.js
vendored
59
dist/restore/index.js
vendored
@ -66788,8 +66788,6 @@ var external_path_ = __nccwpck_require__(1017);
|
||||
var external_path_default = /*#__PURE__*/__nccwpck_require__.n(external_path_);
|
||||
// EXTERNAL MODULE: ./node_modules/@actions/glob/lib/glob.js
|
||||
var glob = __nccwpck_require__(8090);
|
||||
// EXTERNAL MODULE: ./node_modules/toml/index.js
|
||||
var toml = __nccwpck_require__(4920);
|
||||
// EXTERNAL MODULE: external "crypto"
|
||||
var external_crypto_ = __nccwpck_require__(6113);
|
||||
var external_crypto_default = /*#__PURE__*/__nccwpck_require__.n(external_crypto_);
|
||||
@ -66799,12 +66797,14 @@ var promises_default = /*#__PURE__*/__nccwpck_require__.n(promises_);
|
||||
// EXTERNAL MODULE: external "os"
|
||||
var external_os_ = __nccwpck_require__(2037);
|
||||
var external_os_default = /*#__PURE__*/__nccwpck_require__.n(external_os_);
|
||||
// EXTERNAL MODULE: ./node_modules/@actions/buildjet-cache/lib/cache.js
|
||||
var cache = __nccwpck_require__(7551);
|
||||
// EXTERNAL MODULE: ./node_modules/@actions/cache/lib/cache.js
|
||||
var lib_cache = __nccwpck_require__(7799);
|
||||
// EXTERNAL MODULE: ./node_modules/toml/index.js
|
||||
var toml = __nccwpck_require__(4920);
|
||||
// EXTERNAL MODULE: ./node_modules/@actions/exec/lib/exec.js
|
||||
var exec = __nccwpck_require__(1514);
|
||||
// EXTERNAL MODULE: ./node_modules/@actions/buildjet-cache/lib/cache.js
|
||||
var lib_cache = __nccwpck_require__(7551);
|
||||
// EXTERNAL MODULE: ./node_modules/@actions/cache/lib/cache.js
|
||||
var cache_lib_cache = __nccwpck_require__(7799);
|
||||
;// CONCATENATED MODULE: ./src/utils.ts
|
||||
|
||||
|
||||
@ -66846,18 +66846,16 @@ async function getCmdOutput(cmd, args = [], options = {}) {
|
||||
}
|
||||
return stdout;
|
||||
}
|
||||
function getCacheHandler() {
|
||||
function getCacheProvider() {
|
||||
const cacheProvider = lib_core.getInput("cache-provider");
|
||||
switch (cacheProvider) {
|
||||
case "github":
|
||||
lib_core.info("Using Github Cache.");
|
||||
return lib_cache;
|
||||
case "buildjet":
|
||||
lib_core.info("Using Buildjet Cache.");
|
||||
return cache;
|
||||
default:
|
||||
throw new Error("Only currently support github and buildjet caches");
|
||||
const cache = cacheProvider === "github" ? cache_lib_cache : cacheProvider === "buildjet" ? lib_cache : undefined;
|
||||
if (!cache) {
|
||||
throw new Error(`The \`cache-provider\` \`{cacheProvider}\` is not valid.`);
|
||||
}
|
||||
return {
|
||||
name: cacheProvider,
|
||||
cache: cache,
|
||||
};
|
||||
}
|
||||
|
||||
;// CONCATENATED MODULE: ./src/workspace.ts
|
||||
@ -67007,7 +67005,7 @@ class CacheConfig {
|
||||
const cargo_manifests = sort_and_uniq(await globFiles(`${root}/**/Cargo.toml`));
|
||||
for (const cargo_manifest of cargo_manifests) {
|
||||
try {
|
||||
const content = await promises_default().readFile(cargo_manifest, { encoding: 'utf8' });
|
||||
const content = await promises_default().readFile(cargo_manifest, { encoding: "utf8" });
|
||||
const parsed = toml.parse(content);
|
||||
if ("package" in parsed) {
|
||||
const pack = parsed.package;
|
||||
@ -67024,21 +67022,22 @@ class CacheConfig {
|
||||
for (const key of Object.keys(deps)) {
|
||||
const dep = deps[key];
|
||||
if ("path" in dep) {
|
||||
dep.version = '0.0.0';
|
||||
dep.version = "0.0.0";
|
||||
}
|
||||
}
|
||||
}
|
||||
hasher.update(JSON.stringify(parsed));
|
||||
parsedKeyFiles.push(cargo_manifest);
|
||||
}
|
||||
catch (_e) { // Fallback to caching them as regular file
|
||||
catch (_e) {
|
||||
// Fallback to caching them as regular file
|
||||
keyFiles.push(cargo_manifest);
|
||||
}
|
||||
}
|
||||
const cargo_locks = sort_and_uniq(await globFiles(`${root}/**/Cargo.lock`));
|
||||
for (const cargo_lock of cargo_locks) {
|
||||
try {
|
||||
const content = await promises_default().readFile(cargo_lock, { encoding: 'utf8' });
|
||||
const content = await promises_default().readFile(cargo_lock, { encoding: "utf8" });
|
||||
const parsed = toml.parse(content);
|
||||
if (parsed.version !== 3 || !("package" in parsed)) {
|
||||
// Fallback to caching them as regular file since this action
|
||||
@ -67054,7 +67053,8 @@ class CacheConfig {
|
||||
hasher.update(JSON.stringify(packages));
|
||||
parsedKeyFiles.push(cargo_lock);
|
||||
}
|
||||
catch (_e) { // Fallback to caching them as regular file
|
||||
catch (_e) {
|
||||
// Fallback to caching them as regular file
|
||||
keyFiles.push(cargo_lock);
|
||||
}
|
||||
}
|
||||
@ -67098,15 +67098,16 @@ class CacheConfig {
|
||||
}
|
||||
const self = new CacheConfig();
|
||||
Object.assign(self, JSON.parse(source));
|
||||
self.workspaces = self.workspaces
|
||||
.map((w) => new Workspace(w.root, w.target));
|
||||
self.workspaces = self.workspaces.map((w) => new Workspace(w.root, w.target));
|
||||
return self;
|
||||
}
|
||||
/**
|
||||
* Prints the configuration to the action log.
|
||||
*/
|
||||
printInfo() {
|
||||
printInfo(cacheProvider) {
|
||||
lib_core.startGroup("Cache Configuration");
|
||||
lib_core.info(`Cache Provider:`);
|
||||
lib_core.info(` ${cacheProvider.name}`);
|
||||
lib_core.info(`Workspaces:`);
|
||||
for (const workspace of this.workspaces) {
|
||||
lib_core.info(` ${workspace.root}`);
|
||||
@ -67173,7 +67174,7 @@ async function globFiles(pattern) {
|
||||
// fs.statSync resolve the symbolic link and returns stat for the
|
||||
// file it pointed to, so isFile would make sure the resolved
|
||||
// file is actually a regular file.
|
||||
return (await globber.glob()).filter(file => external_fs_default().statSync(file).isFile());
|
||||
return (await globber.glob()).filter((file) => external_fs_default().statSync(file).isFile());
|
||||
}
|
||||
function sort_and_uniq(a) {
|
||||
return a
|
||||
@ -67475,8 +67476,8 @@ process.on("uncaughtException", (e) => {
|
||||
}
|
||||
});
|
||||
async function run() {
|
||||
const cache = getCacheHandler();
|
||||
if (!cache.isFeatureAvailable()) {
|
||||
const cacheProvider = getCacheProvider();
|
||||
if (!cacheProvider.cache.isFeatureAvailable()) {
|
||||
setCacheHitOutput(false);
|
||||
return;
|
||||
}
|
||||
@ -67488,14 +67489,14 @@ async function run() {
|
||||
lib_core.exportVariable("CACHE_ON_FAILURE", cacheOnFailure);
|
||||
lib_core.exportVariable("CARGO_INCREMENTAL", 0);
|
||||
const config = await CacheConfig["new"]();
|
||||
config.printInfo();
|
||||
config.printInfo(cacheProvider);
|
||||
lib_core.info("");
|
||||
lib_core.info(`... Restoring cache ...`);
|
||||
const key = config.cacheKey;
|
||||
// Pass a copy of cachePaths to avoid mutating the original array as reported by:
|
||||
// https://github.com/actions/toolkit/pull/1378
|
||||
// TODO: remove this once the underlying bug is fixed.
|
||||
const restoreKey = await cache.restoreCache(config.cachePaths.slice(), key, [config.restoreKey]);
|
||||
const restoreKey = await cacheProvider.cache.restoreCache(config.cachePaths.slice(), key, [config.restoreKey]);
|
||||
if (restoreKey) {
|
||||
const match = restoreKey === key;
|
||||
lib_core.info(`Restored from cache key "${restoreKey}" full match: ${match}.`);
|
||||
|
Reference in New Issue
Block a user