Add CachingKind enum to control whether to restore or store caches
This commit is contained in:
parent
668531eca8
commit
79faaf1396
15 changed files with 195 additions and 57 deletions
21
lib/init-action.js
generated
21
lib/init-action.js
generated
|
|
@ -30,6 +30,7 @@ const safe_which_1 = require("@chrisgavin/safe-which");
|
|||
const uuid_1 = require("uuid");
|
||||
const actions_util_1 = require("./actions-util");
|
||||
const api_client_1 = require("./api-client");
|
||||
const caching_utils_1 = require("./caching-utils");
|
||||
const configUtils = __importStar(require("./config-utils"));
|
||||
const dependency_caching_1 = require("./dependency-caching");
|
||||
const diagnostics_1 = require("./diagnostics");
|
||||
|
|
@ -182,7 +183,7 @@ async function run() {
|
|||
dbLocation: (0, actions_util_1.getOptionalInput)("db-location"),
|
||||
configInput: (0, actions_util_1.getOptionalInput)("config"),
|
||||
trapCachingEnabled: getTrapCachingEnabled(),
|
||||
dependencyCachingEnabled: getDependencyCachingEnabled(),
|
||||
dependencyCachingEnabled: (0, caching_utils_1.getDependencyCachingEnabled)(),
|
||||
// Debug mode is enabled if:
|
||||
// - The `init` Action is passed `debug: true`.
|
||||
// - Actions step debugging is enabled (e.g. by [enabling debug logging for a rerun](https://docs.github.com/en/actions/managing-workflow-runs/re-running-workflows-and-jobs#re-running-all-the-jobs-in-a-workflow),
|
||||
|
|
@ -327,7 +328,7 @@ async function run() {
|
|||
core.exportVariable(bmnVar, value);
|
||||
}
|
||||
// Restore dependency cache(s), if they exist.
|
||||
if (config.dependencyCachingEnabled) {
|
||||
if ((0, caching_utils_1.shouldRestoreCache)(config.dependencyCachingEnabled)) {
|
||||
await (0, dependency_caching_1.downloadDependencyCaches)(config.languages, logger);
|
||||
}
|
||||
// For CLI versions <2.15.1, build tracing caused errors in MacOS ARM machines with
|
||||
|
|
@ -417,22 +418,6 @@ async function recordZstdAvailability(config, zstdAvailability) {
|
|||
},
|
||||
}));
|
||||
}
|
||||
/** Determines whether dependency caching is enabled. */
|
||||
function getDependencyCachingEnabled() {
|
||||
// If the workflow specified something always respect that
|
||||
const dependencyCaching = (0, actions_util_1.getOptionalInput)("dependency-caching") ||
|
||||
process.env[environment_1.EnvVar.DEPENDENCY_CACHING];
|
||||
if (dependencyCaching !== undefined)
|
||||
return dependencyCaching === "true";
|
||||
// On self-hosted runners which may have dependencies installed centrally, disable caching by default
|
||||
if (!(0, util_1.isHostedRunner)())
|
||||
return false;
|
||||
// Disable in advanced workflows by default.
|
||||
if (!(0, actions_util_1.isDefaultSetup)())
|
||||
return false;
|
||||
// On hosted runners, enable dependency caching by default
|
||||
return true;
|
||||
}
|
||||
async function runWrapper() {
|
||||
try {
|
||||
await run();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue