Add environment variable for custom dependency cache prefix
This commit is contained in:
parent
1338dbce25
commit
8f657e857d
6 changed files with 29 additions and 4 deletions
|
|
@ -9,6 +9,7 @@ import { Config } from "./config-utils";
|
|||
import { Language } from "./languages";
|
||||
import { Logger } from "./logging";
|
||||
import { getRequiredEnvParam } from "./util";
|
||||
import { EnvVar } from "./environment";
|
||||
|
||||
/**
|
||||
* Caching configuration for a particular language.
|
||||
|
|
@ -197,5 +198,12 @@ async function cacheKey(
|
|||
*/
|
||||
async function cachePrefix(language: Language): Promise<string> {
|
||||
const runnerOs = getRequiredEnvParam("RUNNER_OS");
|
||||
return `${CODEQL_DEPENDENCY_CACHE_PREFIX}-${CODEQL_DEPENDENCY_CACHE_VERSION}-${runnerOs}-${language}-`;
|
||||
const customPrefix = process.env[EnvVar.DEPENDENCY_CACHING_PREFIX];
|
||||
let prefix = CODEQL_DEPENDENCY_CACHE_PREFIX;
|
||||
|
||||
if (customPrefix !== undefined && customPrefix.length > 0) {
|
||||
prefix = `${prefix}-${customPrefix}`;
|
||||
}
|
||||
|
||||
return `${prefix}-${CODEQL_DEPENDENCY_CACHE_VERSION}-${runnerOs}-${language}-`;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -105,4 +105,10 @@ export enum EnvVar {
|
|||
* change the inputs to the Action.
|
||||
*/
|
||||
DEPENDENCY_CACHING = "CODEQL_ACTION_DEPENDENCY_CACHING",
|
||||
|
||||
/**
|
||||
* An optional string to add into the cache key used by dependency caching.
|
||||
* Useful for testing purposes where multiple caches may be stored in the same repository.
|
||||
*/
|
||||
DEPENDENCY_CACHING_PREFIX = "CODEQL_ACTION_DEPENDENCY_CACHE_PREFIX",
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue