mirror of
https://github.com/github/codeql-action.git
synced 2025-12-24 08:10:06 +08:00
Add dependencyCachingEnabled to Config
This commit is contained in:
6
lib/config-utils.js
generated
6
lib/config-utils.js
generated
@@ -213,7 +213,7 @@ async function getRawLanguages(languagesInput, repository, logger) {
|
|||||||
/**
|
/**
|
||||||
* Get the default config for when the user has not supplied one.
|
* Get the default config for when the user has not supplied one.
|
||||||
*/
|
*/
|
||||||
async function getDefaultConfig({ languagesInput, queriesInput, packsInput, buildModeInput, dbLocation, trapCachingEnabled, debugMode, debugArtifactName, debugDatabaseName, repository, tempDir, codeql, githubVersion, features, logger, }) {
|
async function getDefaultConfig({ languagesInput, queriesInput, packsInput, buildModeInput, dbLocation, trapCachingEnabled, dependencyCachingEnabled, debugMode, debugArtifactName, debugDatabaseName, repository, tempDir, codeql, githubVersion, features, logger, }) {
|
||||||
const languages = await getLanguages(codeql, languagesInput, repository, logger);
|
const languages = await getLanguages(codeql, languagesInput, repository, logger);
|
||||||
const buildMode = await parseBuildModeInput(buildModeInput, languages, features, logger);
|
const buildMode = await parseBuildModeInput(buildModeInput, languages, features, logger);
|
||||||
const augmentationProperties = calculateAugmentation(packsInput, queriesInput, languages);
|
const augmentationProperties = calculateAugmentation(packsInput, queriesInput, languages);
|
||||||
@@ -232,6 +232,7 @@ async function getDefaultConfig({ languagesInput, queriesInput, packsInput, buil
|
|||||||
augmentationProperties,
|
augmentationProperties,
|
||||||
trapCaches,
|
trapCaches,
|
||||||
trapCacheDownloadTime,
|
trapCacheDownloadTime,
|
||||||
|
dependencyCachingEnabled,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
async function downloadCacheWithTime(trapCachingEnabled, codeQL, languages, logger) {
|
async function downloadCacheWithTime(trapCachingEnabled, codeQL, languages, logger) {
|
||||||
@@ -247,7 +248,7 @@ async function downloadCacheWithTime(trapCachingEnabled, codeQL, languages, logg
|
|||||||
/**
|
/**
|
||||||
* Load the config from the given file.
|
* Load the config from the given file.
|
||||||
*/
|
*/
|
||||||
async function loadConfig({ languagesInput, queriesInput, packsInput, buildModeInput, configFile, dbLocation, trapCachingEnabled, debugMode, debugArtifactName, debugDatabaseName, repository, tempDir, codeql, workspacePath, githubVersion, apiDetails, features, logger, }) {
|
async function loadConfig({ languagesInput, queriesInput, packsInput, buildModeInput, configFile, dbLocation, trapCachingEnabled, dependencyCachingEnabled, debugMode, debugArtifactName, debugDatabaseName, repository, tempDir, codeql, workspacePath, githubVersion, apiDetails, features, logger, }) {
|
||||||
let parsedYAML;
|
let parsedYAML;
|
||||||
if (isLocal(configFile)) {
|
if (isLocal(configFile)) {
|
||||||
if (configFile !== userConfigFromActionPath(tempDir)) {
|
if (configFile !== userConfigFromActionPath(tempDir)) {
|
||||||
@@ -281,6 +282,7 @@ async function loadConfig({ languagesInput, queriesInput, packsInput, buildModeI
|
|||||||
augmentationProperties,
|
augmentationProperties,
|
||||||
trapCaches,
|
trapCaches,
|
||||||
trapCacheDownloadTime,
|
trapCacheDownloadTime,
|
||||||
|
dependencyCachingEnabled,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
2
lib/config-utils.test.js
generated
2
lib/config-utils.test.js
generated
@@ -53,6 +53,7 @@ function createTestInitConfigInputs(overrides) {
|
|||||||
configInput: undefined,
|
configInput: undefined,
|
||||||
buildModeInput: undefined,
|
buildModeInput: undefined,
|
||||||
trapCachingEnabled: false,
|
trapCachingEnabled: false,
|
||||||
|
dependencyCachingEnabled: false,
|
||||||
debugMode: false,
|
debugMode: false,
|
||||||
debugArtifactName: "",
|
debugArtifactName: "",
|
||||||
debugDatabaseName: "",
|
debugDatabaseName: "",
|
||||||
@@ -286,6 +287,7 @@ function mockListLanguages(languages) {
|
|||||||
augmentationProperties: configUtils.defaultAugmentationProperties,
|
augmentationProperties: configUtils.defaultAugmentationProperties,
|
||||||
trapCaches: {},
|
trapCaches: {},
|
||||||
trapCacheDownloadTime: 0,
|
trapCacheDownloadTime: 0,
|
||||||
|
dependencyCachingEnabled: false,
|
||||||
};
|
};
|
||||||
const languagesInput = "javascript";
|
const languagesInput = "javascript";
|
||||||
const configFilePath = createConfigFile(inputFileContents, tempDir);
|
const configFilePath = createConfigFile(inputFileContents, tempDir);
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
22
lib/init-action.js
generated
22
lib/init-action.js
generated
@@ -181,6 +181,7 @@ async function run() {
|
|||||||
dbLocation: (0, actions_util_1.getOptionalInput)("db-location"),
|
dbLocation: (0, actions_util_1.getOptionalInput)("db-location"),
|
||||||
configInput: (0, actions_util_1.getOptionalInput)("config"),
|
configInput: (0, actions_util_1.getOptionalInput)("config"),
|
||||||
trapCachingEnabled: getTrapCachingEnabled(),
|
trapCachingEnabled: getTrapCachingEnabled(),
|
||||||
|
dependencyCachingEnabled: getDependencyCachingEnabled(),
|
||||||
// Debug mode is enabled if:
|
// Debug mode is enabled if:
|
||||||
// - The `init` Action is passed `debug: true`.
|
// - 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),
|
// - 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() {
|
async function runWrapper() {
|
||||||
try {
|
try {
|
||||||
await run();
|
await run();
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
1
lib/testing-utils.js
generated
1
lib/testing-utils.js
generated
@@ -271,6 +271,7 @@ function createTestConfig(overrides) {
|
|||||||
},
|
},
|
||||||
trapCaches: {},
|
trapCaches: {},
|
||||||
trapCacheDownloadTime: 0,
|
trapCacheDownloadTime: 0,
|
||||||
|
dependencyCachingEnabled: false,
|
||||||
}, overrides);
|
}, overrides);
|
||||||
}
|
}
|
||||||
//# sourceMappingURL=testing-utils.js.map
|
//# sourceMappingURL=testing-utils.js.map
|
||||||
File diff suppressed because one or more lines are too long
@@ -52,6 +52,7 @@ function createTestInitConfigInputs(
|
|||||||
configInput: undefined,
|
configInput: undefined,
|
||||||
buildModeInput: undefined,
|
buildModeInput: undefined,
|
||||||
trapCachingEnabled: false,
|
trapCachingEnabled: false,
|
||||||
|
dependencyCachingEnabled: false,
|
||||||
debugMode: false,
|
debugMode: false,
|
||||||
debugArtifactName: "",
|
debugArtifactName: "",
|
||||||
debugDatabaseName: "",
|
debugDatabaseName: "",
|
||||||
@@ -347,6 +348,7 @@ test("load non-empty input", async (t) => {
|
|||||||
augmentationProperties: configUtils.defaultAugmentationProperties,
|
augmentationProperties: configUtils.defaultAugmentationProperties,
|
||||||
trapCaches: {},
|
trapCaches: {},
|
||||||
trapCacheDownloadTime: 0,
|
trapCacheDownloadTime: 0,
|
||||||
|
dependencyCachingEnabled: false,
|
||||||
};
|
};
|
||||||
|
|
||||||
const languagesInput = "javascript";
|
const languagesInput = "javascript";
|
||||||
|
|||||||
@@ -136,6 +136,9 @@ export interface Config {
|
|||||||
* Time taken to download TRAP caches. Used for status reporting.
|
* Time taken to download TRAP caches. Used for status reporting.
|
||||||
*/
|
*/
|
||||||
trapCacheDownloadTime: number;
|
trapCacheDownloadTime: number;
|
||||||
|
|
||||||
|
/** A value indicating whether dependency caching is enabled. */
|
||||||
|
dependencyCachingEnabled: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -393,6 +396,7 @@ export interface InitConfigInputs {
|
|||||||
configInput: string | undefined;
|
configInput: string | undefined;
|
||||||
buildModeInput: string | undefined;
|
buildModeInput: string | undefined;
|
||||||
trapCachingEnabled: boolean;
|
trapCachingEnabled: boolean;
|
||||||
|
dependencyCachingEnabled: boolean;
|
||||||
debugMode: boolean;
|
debugMode: boolean;
|
||||||
debugArtifactName: string;
|
debugArtifactName: string;
|
||||||
debugDatabaseName: string;
|
debugDatabaseName: string;
|
||||||
@@ -425,6 +429,7 @@ export async function getDefaultConfig({
|
|||||||
buildModeInput,
|
buildModeInput,
|
||||||
dbLocation,
|
dbLocation,
|
||||||
trapCachingEnabled,
|
trapCachingEnabled,
|
||||||
|
dependencyCachingEnabled,
|
||||||
debugMode,
|
debugMode,
|
||||||
debugArtifactName,
|
debugArtifactName,
|
||||||
debugDatabaseName,
|
debugDatabaseName,
|
||||||
@@ -476,6 +481,7 @@ export async function getDefaultConfig({
|
|||||||
augmentationProperties,
|
augmentationProperties,
|
||||||
trapCaches,
|
trapCaches,
|
||||||
trapCacheDownloadTime,
|
trapCacheDownloadTime,
|
||||||
|
dependencyCachingEnabled,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -509,6 +515,7 @@ async function loadConfig({
|
|||||||
configFile,
|
configFile,
|
||||||
dbLocation,
|
dbLocation,
|
||||||
trapCachingEnabled,
|
trapCachingEnabled,
|
||||||
|
dependencyCachingEnabled,
|
||||||
debugMode,
|
debugMode,
|
||||||
debugArtifactName,
|
debugArtifactName,
|
||||||
debugDatabaseName,
|
debugDatabaseName,
|
||||||
@@ -580,6 +587,7 @@ async function loadConfig({
|
|||||||
augmentationProperties,
|
augmentationProperties,
|
||||||
trapCaches,
|
trapCaches,
|
||||||
trapCacheDownloadTime,
|
trapCacheDownloadTime,
|
||||||
|
dependencyCachingEnabled,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -339,6 +339,7 @@ async function run() {
|
|||||||
dbLocation: getOptionalInput("db-location"),
|
dbLocation: getOptionalInput("db-location"),
|
||||||
configInput: getOptionalInput("config"),
|
configInput: getOptionalInput("config"),
|
||||||
trapCachingEnabled: getTrapCachingEnabled(),
|
trapCachingEnabled: getTrapCachingEnabled(),
|
||||||
|
dependencyCachingEnabled: getDependencyCachingEnabled(),
|
||||||
// Debug mode is enabled if:
|
// Debug mode is enabled if:
|
||||||
// - The `init` Action is passed `debug: true`.
|
// - 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),
|
// - 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() {
|
async function runWrapper() {
|
||||||
try {
|
try {
|
||||||
await run();
|
await run();
|
||||||
|
|||||||
@@ -331,6 +331,7 @@ export function createTestConfig(overrides: Partial<Config>): Config {
|
|||||||
},
|
},
|
||||||
trapCaches: {},
|
trapCaches: {},
|
||||||
trapCacheDownloadTime: 0,
|
trapCacheDownloadTime: 0,
|
||||||
|
dependencyCachingEnabled: false,
|
||||||
},
|
},
|
||||||
overrides,
|
overrides,
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user