mirror of
https://github.com/github/codeql-action.git
synced 2025-12-26 09:10:07 +08:00
Add dependencyCachingEnabled to Config
This commit is contained in:
@@ -52,6 +52,7 @@ function createTestInitConfigInputs(
|
||||
configInput: undefined,
|
||||
buildModeInput: undefined,
|
||||
trapCachingEnabled: false,
|
||||
dependencyCachingEnabled: false,
|
||||
debugMode: false,
|
||||
debugArtifactName: "",
|
||||
debugDatabaseName: "",
|
||||
@@ -347,6 +348,7 @@ test("load non-empty input", async (t) => {
|
||||
augmentationProperties: configUtils.defaultAugmentationProperties,
|
||||
trapCaches: {},
|
||||
trapCacheDownloadTime: 0,
|
||||
dependencyCachingEnabled: false,
|
||||
};
|
||||
|
||||
const languagesInput = "javascript";
|
||||
|
||||
@@ -136,6 +136,9 @@ export interface Config {
|
||||
* Time taken to download TRAP caches. Used for status reporting.
|
||||
*/
|
||||
trapCacheDownloadTime: number;
|
||||
|
||||
/** A value indicating whether dependency caching is enabled. */
|
||||
dependencyCachingEnabled: boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -393,6 +396,7 @@ export interface InitConfigInputs {
|
||||
configInput: string | undefined;
|
||||
buildModeInput: string | undefined;
|
||||
trapCachingEnabled: boolean;
|
||||
dependencyCachingEnabled: boolean;
|
||||
debugMode: boolean;
|
||||
debugArtifactName: string;
|
||||
debugDatabaseName: string;
|
||||
@@ -425,6 +429,7 @@ export async function getDefaultConfig({
|
||||
buildModeInput,
|
||||
dbLocation,
|
||||
trapCachingEnabled,
|
||||
dependencyCachingEnabled,
|
||||
debugMode,
|
||||
debugArtifactName,
|
||||
debugDatabaseName,
|
||||
@@ -476,6 +481,7 @@ export async function getDefaultConfig({
|
||||
augmentationProperties,
|
||||
trapCaches,
|
||||
trapCacheDownloadTime,
|
||||
dependencyCachingEnabled,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -509,6 +515,7 @@ async function loadConfig({
|
||||
configFile,
|
||||
dbLocation,
|
||||
trapCachingEnabled,
|
||||
dependencyCachingEnabled,
|
||||
debugMode,
|
||||
debugArtifactName,
|
||||
debugDatabaseName,
|
||||
@@ -580,6 +587,7 @@ async function loadConfig({
|
||||
augmentationProperties,
|
||||
trapCaches,
|
||||
trapCacheDownloadTime,
|
||||
dependencyCachingEnabled,
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -339,6 +339,7 @@ async function run() {
|
||||
dbLocation: getOptionalInput("db-location"),
|
||||
configInput: 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),
|
||||
@@ -716,6 +717,29 @@ async function recordZstdAvailability(
|
||||
);
|
||||
}
|
||||
|
||||
/** Determines whether we are running in default setup. */
|
||||
function isDefaultSetup(): boolean {
|
||||
// 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(): boolean {
|
||||
// If the workflow specified something always respect that
|
||||
const dependencyCaching = getOptionalInput("dependency-caching");
|
||||
if (dependencyCaching !== undefined) return dependencyCaching === "true";
|
||||
|
||||
// On self-hosted runners which may have dependencies installed centrally, disable caching by default
|
||||
if (!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();
|
||||
|
||||
@@ -331,6 +331,7 @@ export function createTestConfig(overrides: Partial<Config>): Config {
|
||||
},
|
||||
trapCaches: {},
|
||||
trapCacheDownloadTime: 0,
|
||||
dependencyCachingEnabled: false,
|
||||
},
|
||||
overrides,
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user