Add dependencyCachingEnabled to Config

This commit is contained in:
Michael B. Gale 2024-07-22 13:51:33 +01:00
parent 1a7989f395
commit 1922a489a8
No known key found for this signature in database
GPG key ID: FF5E2765BD00628F
12 changed files with 68 additions and 6 deletions

22
lib/init-action.js generated
View file

@ -181,6 +181,7 @@ async function run() {
dbLocation: (0, actions_util_1.getOptionalInput)("db-location"),
configInput: (0, actions_util_1.getOptionalInput)("config"),
trapCachingEnabled: getTrapCachingEnabled(),
dependencyCachingEnabled: 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),
@ -411,6 +412,27 @@ async function recordZstdAvailability(config, zstdAvailability) {
},
}));
}
/** Determines whether we are running in default setup. */
function isDefaultSetup() {
// This is set to something in default setup runs.
// TODO: replace with something better, if there's something.
return process.env["CODE_SCANNING_WORKFLOW_FILE"] !== undefined;
}
/** 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");
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 (!isDefaultSetup())
return false;
// On hosted runners, enable dependency caching by default
return true;
}
async function runWrapper() {
try {
await run();