Address review comments from @henrymercer
This commit is contained in:
Родитель
8f867dcb21
Коммит
6df93613d7
|
@ -463,7 +463,7 @@ function shouldAddConfigFileQueries(queriesInput) {
|
|||
/**
|
||||
* Get the default config for when the user has not supplied one.
|
||||
*/
|
||||
async function getDefaultConfig(languagesInput, queriesInput, packsInput, dbLocation, trapCaching, debugMode, debugArtifactName, debugDatabaseName, repository, tempDir, codeQL, workspacePath, gitHubVersion, apiDetails, featureFlags, logger) {
|
||||
async function getDefaultConfig(languagesInput, queriesInput, packsInput, dbLocation, trapCachingEnabled, debugMode, debugArtifactName, debugDatabaseName, repository, tempDir, codeQL, workspacePath, gitHubVersion, apiDetails, featureFlags, logger) {
|
||||
var _a;
|
||||
const languages = await getLanguages(codeQL, languagesInput, repository, apiDetails, logger);
|
||||
const queries = {};
|
||||
|
@ -494,7 +494,7 @@ async function getDefaultConfig(languagesInput, queriesInput, packsInput, dbLoca
|
|||
debugArtifactName,
|
||||
debugDatabaseName,
|
||||
injectedMlQueries,
|
||||
trapCaches: trapCaching
|
||||
trapCaches: trapCachingEnabled
|
||||
? await (0, trap_caching_1.downloadTrapCaches)(codeQL, languages, logger)
|
||||
: {},
|
||||
};
|
||||
|
@ -503,7 +503,7 @@ exports.getDefaultConfig = getDefaultConfig;
|
|||
/**
|
||||
* Load the config from the given file.
|
||||
*/
|
||||
async function loadConfig(languagesInput, queriesInput, packsInput, configFile, dbLocation, trapCaching, debugMode, debugArtifactName, debugDatabaseName, repository, tempDir, codeQL, workspacePath, gitHubVersion, apiDetails, featureFlags, logger) {
|
||||
async function loadConfig(languagesInput, queriesInput, packsInput, configFile, dbLocation, trapCachingEnabled, debugMode, debugArtifactName, debugDatabaseName, repository, tempDir, codeQL, workspacePath, gitHubVersion, apiDetails, featureFlags, logger) {
|
||||
var _a;
|
||||
let parsedYAML;
|
||||
if (isLocal(configFile)) {
|
||||
|
@ -604,7 +604,7 @@ async function loadConfig(languagesInput, queriesInput, packsInput, configFile,
|
|||
debugArtifactName,
|
||||
debugDatabaseName,
|
||||
injectedMlQueries,
|
||||
trapCaches: trapCaching
|
||||
trapCaches: trapCachingEnabled
|
||||
? await (0, trap_caching_1.downloadTrapCaches)(codeQL, languages, logger)
|
||||
: {},
|
||||
};
|
||||
|
@ -788,16 +788,16 @@ function dbLocationOrDefault(dbLocation, tempDir) {
|
|||
* This will parse the config from the user input if present, or generate
|
||||
* a default config. The parsed config is then stored to a known location.
|
||||
*/
|
||||
async function initConfig(languagesInput, queriesInput, packsInput, configFile, dbLocation, trapCaching, debugMode, debugArtifactName, debugDatabaseName, repository, tempDir, codeQL, workspacePath, gitHubVersion, apiDetails, featureFlags, logger) {
|
||||
async function initConfig(languagesInput, queriesInput, packsInput, configFile, dbLocation, trapCachingEnabled, debugMode, debugArtifactName, debugDatabaseName, repository, tempDir, codeQL, workspacePath, gitHubVersion, apiDetails, featureFlags, logger) {
|
||||
var _a, _b, _c;
|
||||
let config;
|
||||
// If no config file was provided create an empty one
|
||||
if (!configFile) {
|
||||
logger.debug("No configuration file was provided");
|
||||
config = await getDefaultConfig(languagesInput, queriesInput, packsInput, dbLocation, trapCaching, debugMode, debugArtifactName, debugDatabaseName, repository, tempDir, codeQL, workspacePath, gitHubVersion, apiDetails, featureFlags, logger);
|
||||
config = await getDefaultConfig(languagesInput, queriesInput, packsInput, dbLocation, trapCachingEnabled, debugMode, debugArtifactName, debugDatabaseName, repository, tempDir, codeQL, workspacePath, gitHubVersion, apiDetails, featureFlags, logger);
|
||||
}
|
||||
else {
|
||||
config = await loadConfig(languagesInput, queriesInput, packsInput, configFile, dbLocation, trapCaching, debugMode, debugArtifactName, debugDatabaseName, repository, tempDir, codeQL, workspacePath, gitHubVersion, apiDetails, featureFlags, logger);
|
||||
config = await loadConfig(languagesInput, queriesInput, packsInput, configFile, dbLocation, trapCachingEnabled, debugMode, debugArtifactName, debugDatabaseName, repository, tempDir, codeQL, workspacePath, gitHubVersion, apiDetails, featureFlags, logger);
|
||||
}
|
||||
// The list of queries should not be empty for any language. If it is then
|
||||
// it is a user configuration error.
|
||||
|
|
Различия файлов скрыты, потому что одна или несколько строк слишком длинны
|
@ -153,11 +153,11 @@ async function run() {
|
|||
}
|
||||
await sendSuccessStatusReport(startedAt, config, toolsVersion);
|
||||
}
|
||||
function getTrapCachingEnabled(featureFlags) {
|
||||
async function getTrapCachingEnabled(featureFlags) {
|
||||
const trapCaching = (0, actions_util_1.getOptionalInput)("trap-caching");
|
||||
if (trapCaching !== undefined)
|
||||
return Promise.resolve(trapCaching.toLowerCase() === "true");
|
||||
return featureFlags.getValue(feature_flags_1.FeatureFlag.TrapCachingEnabled);
|
||||
return trapCaching === "true";
|
||||
return await featureFlags.getValue(feature_flags_1.FeatureFlag.TrapCachingEnabled);
|
||||
}
|
||||
async function runWrapper() {
|
||||
try {
|
||||
|
|
Различия файлов скрыты, потому что одна или несколько строк слишком длинны
|
@ -38,9 +38,9 @@ async function initCodeQL(codeqlURL, apiDetails, tempDir, variant, logger) {
|
|||
return { codeql, toolsVersion };
|
||||
}
|
||||
exports.initCodeQL = initCodeQL;
|
||||
async function initConfig(languagesInput, queriesInput, packsInput, configFile, dbLocation, trapCaching, debugMode, debugArtifactName, debugDatabaseName, repository, tempDir, codeQL, workspacePath, gitHubVersion, apiDetails, featureFlags, logger) {
|
||||
async function initConfig(languagesInput, queriesInput, packsInput, configFile, dbLocation, trapCachingEnabled, debugMode, debugArtifactName, debugDatabaseName, repository, tempDir, codeQL, workspacePath, gitHubVersion, apiDetails, featureFlags, logger) {
|
||||
logger.startGroup("Load language configuration");
|
||||
const config = await configUtils.initConfig(languagesInput, queriesInput, packsInput, configFile, dbLocation, trapCaching, debugMode, debugArtifactName, debugDatabaseName, repository, tempDir, codeQL, workspacePath, gitHubVersion, apiDetails, featureFlags, logger);
|
||||
const config = await configUtils.initConfig(languagesInput, queriesInput, packsInput, configFile, dbLocation, trapCachingEnabled, debugMode, debugArtifactName, debugDatabaseName, repository, tempDir, codeQL, workspacePath, gitHubVersion, apiDetails, featureFlags, logger);
|
||||
analysisPaths.printPathFiltersWarning(config, logger);
|
||||
logger.endGroup();
|
||||
return config;
|
||||
|
|
|
@ -1 +1 @@
|
|||
{"version":3,"file":"init.js","sourceRoot":"","sources":["../src/init.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAAA,uCAAyB;AACzB,2CAA6B;AAE7B,yEAA2D;AAC3D,kEAAoD;AAEpD,gEAAkD;AAElD,qCAA2E;AAC3E,4DAA8C;AAI9C,mDAAwE;AACxE,6CAA+B;AAC/B,iCAA4C;AAErC,KAAK,UAAU,UAAU,CAC9B,SAA6B,EAC7B,UAA4B,EAC5B,OAAe,EACf,OAA2B,EAC3B,MAAc;IAEd,MAAM,CAAC,UAAU,CAAC,oBAAoB,CAAC,CAAC;IACxC,MAAM,EAAE,MAAM,EAAE,YAAY,EAAE,GAAG,MAAM,IAAA,oBAAW,EAChD,SAAS,EACT,UAAU,EACV,OAAO,EACP,OAAO,EACP,MAAM,EACN,IAAI,CACL,CAAC;IACF,MAAM,MAAM,CAAC,YAAY,EAAE,CAAC;IAC5B,MAAM,CAAC,QAAQ,EAAE,CAAC;IAClB,OAAO,EAAE,MAAM,EAAE,YAAY,EAAE,CAAC;AAClC,CAAC;AAnBD,gCAmBC;AAEM,KAAK,UAAU,UAAU,CAC9B,cAAkC,EAClC,YAAgC,EAChC,UAA8B,EAC9B,UAA8B,EAC9B,UAA8B,EAC9B,WAAoB,EACpB,SAAkB,EAClB,iBAAyB,EACzB,iBAAyB,EACzB,UAAyB,EACzB,OAAe,EACf,MAAc,EACd,aAAqB,EACrB,aAAiC,EACjC,UAAoC,EACpC,YAA0B,EAC1B,MAAc;IAEd,MAAM,CAAC,UAAU,CAAC,6BAA6B,CAAC,CAAC;IACjD,MAAM,MAAM,GAAG,MAAM,WAAW,CAAC,UAAU,CACzC,cAAc,EACd,YAAY,EACZ,UAAU,EACV,UAAU,EACV,UAAU,EACV,WAAW,EACX,SAAS,EACT,iBAAiB,EACjB,iBA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AI,CAAC,aAAa,EAAE,MAAM,CAAC;gBAChC,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;aAC/B,CAAC,CAAC,IAAI,EAAE,CAAC;SACX;aAAM;YACL,MAAM,IAAI,UAAU,CAAC,UAAU,CAAC,MAAM,SAAS,CAAC,SAAS,CAAC,SAAS,CAAC,EAAE;gBACpE,IAAI;gBACJ,IAAI,CAAC,IAAI,CAAC,aAAa,EAAE,MAAM,CAAC;gBAChC,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;aAC/B,CAAC,CAAC,IAAI,EAAE,CAAC;SACX;KACF;IAAC,OAAO,CAAC,EAAE;QACV,MAAM,CAAC,QAAQ,EAAE,CAAC;QAClB,MAAM,CAAC,OAAO,CACZ,gFAAgF,CAAC,IAAI;YACnF,qGAAqG;YACrG,oGAAoG;YACpG,iDAAiD,CACpD,CAAC;QACF,OAAO;KACR;IACD,MAAM,CAAC,QAAQ,EAAE,CAAC;AACpB,CAAC;AAzCD,8CAyCC"}
|
|
@ -32,11 +32,13 @@ const util_1 = require("./util");
|
|||
// this for CLI/extractor changes, since the CLI version also
|
||||
// goes into the cache key.
|
||||
const CACHE_VERSION = 1;
|
||||
// This constant sets the size of each TRAP cache in megabytes.
|
||||
const CACHE_SIZE_MB = 1024;
|
||||
async function getTrapCachingExtractorConfigArgs(config) {
|
||||
const result = [];
|
||||
for (const language of config.languages)
|
||||
result.push(...(await getTrapCachingExtractorConfigArgsForLang(config, language)));
|
||||
return result;
|
||||
result.push(await getTrapCachingExtractorConfigArgsForLang(config, language));
|
||||
return result.flat();
|
||||
}
|
||||
exports.getTrapCachingExtractorConfigArgs = getTrapCachingExtractorConfigArgs;
|
||||
async function getTrapCachingExtractorConfigArgsForLang(config, language) {
|
||||
|
@ -46,11 +48,19 @@ async function getTrapCachingExtractorConfigArgsForLang(config, language) {
|
|||
const write = await actionsUtil.isAnalyzingDefaultBranch();
|
||||
return [
|
||||
`-O=${language}.trap.cache.dir=${cacheDir}`,
|
||||
`-O=${language}.trap.cache.bound=1024`,
|
||||
`-O=${language}.trap.cache.bound=${CACHE_SIZE_MB}`,
|
||||
`-O=${language}.trap.cache.write=${write}`,
|
||||
];
|
||||
}
|
||||
exports.getTrapCachingExtractorConfigArgsForLang = getTrapCachingExtractorConfigArgsForLang;
|
||||
/**
|
||||
* Download TRAP caches from the Actions cache.
|
||||
* @param codeql The CodeQL instance to use.
|
||||
* @param languages The languages being analyzed.
|
||||
* @param logger A logger to record some informational messages to.
|
||||
* @returns A partial map from languages to TRAP cache paths on disk, with
|
||||
* languages for which we shouldn't use TRAP caching omitted.
|
||||
*/
|
||||
async function downloadTrapCaches(codeql, languages, logger) {
|
||||
var _a, _b;
|
||||
const result = {};
|
||||
|
@ -70,22 +80,25 @@ async function downloadTrapCaches(codeql, languages, logger) {
|
|||
}
|
||||
let baseSha = "unknown";
|
||||
const eventPath = process.env.GITHUB_EVENT_PATH;
|
||||
if (eventPath !== undefined) {
|
||||
if (process.env.GITHUB_EVENT_NAME === "pull_request" &&
|
||||
eventPath !== undefined) {
|
||||
const event = JSON.parse(fs.readFileSync(path.resolve(eventPath), "utf-8"));
|
||||
baseSha = ((_b = (_a = event.pull_request) === null || _a === void 0 ? void 0 : _a.base) === null || _b === void 0 ? void 0 : _b.sha) || "unknown";
|
||||
baseSha = ((_b = (_a = event.pull_request) === null || _a === void 0 ? void 0 : _a.base) === null || _b === void 0 ? void 0 : _b.sha) || baseSha;
|
||||
}
|
||||
for (const language of languages) {
|
||||
const cacheDir = result[language];
|
||||
if (cacheDir === undefined)
|
||||
continue;
|
||||
// The SHA from the base of the PR is the most similar commit we might have a cache for
|
||||
const preferredKey = `codeql-trap-${CACHE_VERSION}-${await codeql.getVersion()}-${language}-${baseSha}`;
|
||||
const preferredKey = await cacheKey(codeql, language, baseSha);
|
||||
logger.info(`Looking in Actions cache for TRAP cache with key ${preferredKey}`);
|
||||
const found = await cache.restoreCache([cacheDir], preferredKey, [
|
||||
`codeql-trap-${CACHE_VERSION}-${await codeql.getVersion()}-${language}-`, // Fall back to any cache with the right key prefix
|
||||
await cachePrefix(codeql, language), // Fall back to any cache with the right key prefix
|
||||
]);
|
||||
if (found === undefined) {
|
||||
// Didn't find any cache, let's unset to avoid lookups in an empty directory
|
||||
// We didn't find a TRAP cache in the Actions cache, so the directory on disk is
|
||||
// still just an empty directory. There's no reason to tell the extractor to use it,
|
||||
// so let's unset the entry in the map so we don't set any extractor options.
|
||||
logger.info(`No TRAP cache found in Actions cache for ${language}`);
|
||||
result[language] = undefined;
|
||||
}
|
||||
|
@ -96,14 +109,16 @@ exports.downloadTrapCaches = downloadTrapCaches;
|
|||
async function uploadTrapCaches(codeql, config, logger) {
|
||||
if (!(await actionsUtil.isAnalyzingDefaultBranch()))
|
||||
return; // Only upload caches from the default branch
|
||||
const toAwait = [];
|
||||
for (const language of config.languages) {
|
||||
const cacheDir = config.trapCaches[language];
|
||||
if (cacheDir === undefined)
|
||||
continue;
|
||||
const key = `codeql-trap-${CACHE_VERSION}-${await codeql.getVersion()}-${language}-${process.env.GITHUB_SHA || "unknown"}`;
|
||||
const key = await cacheKey(codeql, language, process.env.GITHUB_SHA || "unknown");
|
||||
logger.info(`Uploading TRAP cache to Actions cache with key ${key}`);
|
||||
await cache.saveCache([cacheDir], key);
|
||||
toAwait.push(cache.saveCache([cacheDir], key));
|
||||
}
|
||||
await Promise.all(toAwait);
|
||||
}
|
||||
exports.uploadTrapCaches = uploadTrapCaches;
|
||||
async function getLanguagesSupportingCaching(codeql, languages, logger) {
|
||||
|
@ -113,6 +128,8 @@ async function getLanguagesSupportingCaching(codeql, languages, logger) {
|
|||
return result;
|
||||
const resolveResult = await codeql.betterResolveLanguages();
|
||||
outer: for (const lang of languages) {
|
||||
if (resolveResult.extractors[lang].length !== 1)
|
||||
continue;
|
||||
const extractor = resolveResult.extractors[lang][0];
|
||||
const trapCacheOptions = (_d = (_c = (_b = (_a = extractor.extractor_options) === null || _a === void 0 ? void 0 : _a.trap) === null || _b === void 0 ? void 0 : _b.properties) === null || _c === void 0 ? void 0 : _c.cache) === null || _d === void 0 ? void 0 : _d.properties;
|
||||
if (trapCacheOptions === undefined) {
|
||||
|
@ -130,4 +147,10 @@ async function getLanguagesSupportingCaching(codeql, languages, logger) {
|
|||
return result;
|
||||
}
|
||||
exports.getLanguagesSupportingCaching = getLanguagesSupportingCaching;
|
||||
async function cacheKey(codeql, language, baseSha) {
|
||||
return `${await cachePrefix(codeql, language)}-${baseSha}`;
|
||||
}
|
||||
async function cachePrefix(codeql, language) {
|
||||
return `codeql-trap-${CACHE_VERSION}-${await codeql.getVersion()}-${language}-`;
|
||||
}
|
||||
//# sourceMappingURL=trap-caching.js.map
|
|
@ -1 +1 @@
|
|||
{"version":3,"file":"trap-caching.js","sourceRoot":"","sources":["../src/trap-caching.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAAA,uCAAyB;AACzB,2CAA6B;AAE7B,sDAAwC;AAExC,4DAA8C;AAC9C,qCAA2E;AAI3E,iCAA4C;AAE5C,8DAA8D;AAC9D,+DAA+D;AAC/D,6DAA6D;AAC7D,6DAA6D;AAC7D,2BAA2B;AAC3B,MAAM,aAAa,GAAG,CAAC,CAAC;AAEjB,KAAK,UAAU,iCAAiC,CACrD,MAAc;IAEd,MAAM,MAAM,GAAa,EAAE,CAAC;IAC5B,KAAK,MAAM,QAAQ,IAAI,MAAM,CAAC,SAAS;QACrC,MAAM,CAAC,IAAI,CACT,GAAG,CAAC,MAAM,wCAAwC,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC,CACtE,CAAC;IACJ,OAAO,MAAM,CAAC;AAChB,CAAC;AATD,8EASC;AAEM,KAAK,UAAU,wCAAwC,CAC5D,MAAc,EACd,QAAkB;IAElB,MAAM,QAAQ,GAAG,MAAM,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC;IAC7C,IAAI,QAAQ,KAAK,SAAS;QAAE,OAAO,EAAE,CA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AAC;KACnB;IACD,OAAO,MAAM,CAAC;AAChB,CAAC;AAjCD,sEAiCC;AAED,KAAK,UAAU,QAAQ,CACrB,MAAc,EACd,QAAkB,EAClB,OAAe;IAEf,OAAO,GAAG,MAAM,WAAW,CAAC,MAAM,EAAE,QAAQ,CAAC,IAAI,OAAO,EAAE,CAAC;AAC7D,CAAC;AAED,KAAK,UAAU,WAAW,CACxB,MAAc,EACd,QAAkB;IAElB,OAAO,eAAe,aAAa,IAAI,MAAM,MAAM,CAAC,UAAU,EAAE,IAAI,QAAQ,GAAG,CAAC;AAClF,CAAC"}
|
|
@ -74,7 +74,7 @@ const stubCodeql = (0, codeql_1.setCodeQL)({
|
|||
};
|
||||
},
|
||||
});
|
||||
const stubConfig = {
|
||||
const testConfigWithoutTmpDir = {
|
||||
languages: [languages_1.Language.javascript, languages_1.Language.cpp],
|
||||
queries: {},
|
||||
pathsIgnore: [],
|
||||
|
@ -95,7 +95,7 @@ const stubConfig = {
|
|||
javascript: "/some/cache/dir",
|
||||
},
|
||||
};
|
||||
function getTestConfig(tmpDir) {
|
||||
function getTestConfigWithTempDir(tmpDir) {
|
||||
return {
|
||||
languages: [languages_1.Language.javascript, languages_1.Language.ruby],
|
||||
queries: {},
|
||||
|
@ -119,7 +119,7 @@ function getTestConfig(tmpDir) {
|
|||
}
|
||||
(0, ava_1.default)("check flags for JS, analyzing default branch", async (t) => {
|
||||
await util.withTmpDir(async (tmpDir) => {
|
||||
const config = getTestConfig(tmpDir);
|
||||
const config = getTestConfigWithTempDir(tmpDir);
|
||||
sinon.stub(actionsUtil, "isAnalyzingDefaultBranch").resolves(true);
|
||||
const result = await (0, trap_caching_1.getTrapCachingExtractorConfigArgsForLang)(config, languages_1.Language.javascript);
|
||||
t.deepEqual(result, [
|
||||
|
@ -131,7 +131,7 @@ function getTestConfig(tmpDir) {
|
|||
});
|
||||
(0, ava_1.default)("check flags for all, not analyzing default branch", async (t) => {
|
||||
await util.withTmpDir(async (tmpDir) => {
|
||||
const config = getTestConfig(tmpDir);
|
||||
const config = getTestConfigWithTempDir(tmpDir);
|
||||
sinon.stub(actionsUtil, "isAnalyzingDefaultBranch").resolves(false);
|
||||
const result = await (0, trap_caching_1.getTrapCachingExtractorConfigArgs)(config);
|
||||
t.deepEqual(result, [
|
||||
|
@ -156,7 +156,7 @@ function getTestConfig(tmpDir) {
|
|||
sinon.stub(actionsUtil, "isAnalyzingDefaultBranch").resolves(true);
|
||||
const stubSave = sinon.stub(cache, "saveCache");
|
||||
process.env.GITHUB_SHA = "somesha";
|
||||
await (0, trap_caching_1.uploadTrapCaches)(stubCodeql, stubConfig, logger);
|
||||
await (0, trap_caching_1.uploadTrapCaches)(stubCodeql, testConfigWithoutTmpDir, logger);
|
||||
t.assert(stubSave.calledOnceWith(sinon.match.array.contains(["/some/cache/dir"]), sinon
|
||||
.match("somesha")
|
||||
.and(sinon.match("2.10.3"))
|
||||
|
@ -170,6 +170,7 @@ function getTestConfig(tmpDir) {
|
|||
sinon.stub(actionsUtil, "isAnalyzingDefaultBranch").resolves(false);
|
||||
const stubRestore = sinon.stub(cache, "restoreCache").resolves("found");
|
||||
const eventFile = path.resolve(tmpDir, "event.json");
|
||||
process.env.GITHUB_EVENT_NAME = "pull_request";
|
||||
process.env.GITHUB_EVENT_PATH = eventFile;
|
||||
fs.writeFileSync(eventFile, JSON.stringify({
|
||||
pull_request: {
|
||||
|
|
Различия файлов скрыты, потому что одна или несколько строк слишком длинны
|
@ -151,7 +151,7 @@ export interface Config {
|
|||
injectedMlQueries: boolean;
|
||||
/**
|
||||
* Partial map from languages to locations of TRAP caches for that language.
|
||||
* A key being omitted means TRAP caching should not be used for that language.
|
||||
* If a key is omitted, then TRAP caching should not be used for that language.
|
||||
*/
|
||||
trapCaches: Partial<Record<Language, string>>;
|
||||
}
|
||||
|
@ -884,7 +884,7 @@ export async function getDefaultConfig(
|
|||
queriesInput: string | undefined,
|
||||
packsInput: string | undefined,
|
||||
dbLocation: string | undefined,
|
||||
trapCaching: boolean,
|
||||
trapCachingEnabled: boolean,
|
||||
debugMode: boolean,
|
||||
debugArtifactName: string,
|
||||
debugDatabaseName: string,
|
||||
|
@ -944,7 +944,7 @@ export async function getDefaultConfig(
|
|||
debugArtifactName,
|
||||
debugDatabaseName,
|
||||
injectedMlQueries,
|
||||
trapCaches: trapCaching
|
||||
trapCaches: trapCachingEnabled
|
||||
? await downloadTrapCaches(codeQL, languages, logger)
|
||||
: {},
|
||||
};
|
||||
|
@ -959,7 +959,7 @@ async function loadConfig(
|
|||
packsInput: string | undefined,
|
||||
configFile: string,
|
||||
dbLocation: string | undefined,
|
||||
trapCaching: boolean,
|
||||
trapCachingEnabled: boolean,
|
||||
debugMode: boolean,
|
||||
debugArtifactName: string,
|
||||
debugDatabaseName: string,
|
||||
|
@ -1128,7 +1128,7 @@ async function loadConfig(
|
|||
debugArtifactName,
|
||||
debugDatabaseName,
|
||||
injectedMlQueries,
|
||||
trapCaches: trapCaching
|
||||
trapCaches: trapCachingEnabled
|
||||
? await downloadTrapCaches(codeQL, languages, logger)
|
||||
: {},
|
||||
};
|
||||
|
@ -1372,7 +1372,7 @@ export async function initConfig(
|
|||
packsInput: string | undefined,
|
||||
configFile: string | undefined,
|
||||
dbLocation: string | undefined,
|
||||
trapCaching: boolean,
|
||||
trapCachingEnabled: boolean,
|
||||
debugMode: boolean,
|
||||
debugArtifactName: string,
|
||||
debugDatabaseName: string,
|
||||
|
@ -1395,7 +1395,7 @@ export async function initConfig(
|
|||
queriesInput,
|
||||
packsInput,
|
||||
dbLocation,
|
||||
trapCaching,
|
||||
trapCachingEnabled,
|
||||
debugMode,
|
||||
debugArtifactName,
|
||||
debugDatabaseName,
|
||||
|
@ -1415,7 +1415,7 @@ export async function initConfig(
|
|||
packsInput,
|
||||
configFile,
|
||||
dbLocation,
|
||||
trapCaching,
|
||||
trapCachingEnabled,
|
||||
debugMode,
|
||||
debugArtifactName,
|
||||
debugDatabaseName,
|
||||
|
|
|
@ -300,11 +300,12 @@ async function run() {
|
|||
await sendSuccessStatusReport(startedAt, config, toolsVersion);
|
||||
}
|
||||
|
||||
function getTrapCachingEnabled(featureFlags: FeatureFlags): Promise<boolean> {
|
||||
async function getTrapCachingEnabled(
|
||||
featureFlags: FeatureFlags
|
||||
): Promise<boolean> {
|
||||
const trapCaching = getOptionalInput("trap-caching");
|
||||
if (trapCaching !== undefined)
|
||||
return Promise.resolve(trapCaching.toLowerCase() === "true");
|
||||
return featureFlags.getValue(FeatureFlag.TrapCachingEnabled);
|
||||
if (trapCaching !== undefined) return trapCaching === "true";
|
||||
return await featureFlags.getValue(FeatureFlag.TrapCachingEnabled);
|
||||
}
|
||||
|
||||
async function runWrapper() {
|
||||
|
|
|
@ -42,7 +42,7 @@ export async function initConfig(
|
|||
packsInput: string | undefined,
|
||||
configFile: string | undefined,
|
||||
dbLocation: string | undefined,
|
||||
trapCaching: boolean,
|
||||
trapCachingEnabled: boolean,
|
||||
debugMode: boolean,
|
||||
debugArtifactName: string,
|
||||
debugDatabaseName: string,
|
||||
|
@ -62,7 +62,7 @@ export async function initConfig(
|
|||
packsInput,
|
||||
configFile,
|
||||
dbLocation,
|
||||
trapCaching,
|
||||
trapCachingEnabled,
|
||||
debugMode,
|
||||
debugArtifactName,
|
||||
debugDatabaseName,
|
||||
|
|
|
@ -63,7 +63,7 @@ const stubCodeql = setCodeQL({
|
|||
},
|
||||
});
|
||||
|
||||
const stubConfig: Config = {
|
||||
const testConfigWithoutTmpDir: Config = {
|
||||
languages: [Language.javascript, Language.cpp],
|
||||
queries: {},
|
||||
pathsIgnore: [],
|
||||
|
@ -85,7 +85,7 @@ const stubConfig: Config = {
|
|||
},
|
||||
};
|
||||
|
||||
function getTestConfig(tmpDir: string): configUtils.Config {
|
||||
function getTestConfigWithTempDir(tmpDir: string): configUtils.Config {
|
||||
return {
|
||||
languages: [Language.javascript, Language.ruby],
|
||||
queries: {},
|
||||
|
@ -110,7 +110,7 @@ function getTestConfig(tmpDir: string): configUtils.Config {
|
|||
|
||||
test("check flags for JS, analyzing default branch", async (t) => {
|
||||
await util.withTmpDir(async (tmpDir) => {
|
||||
const config = getTestConfig(tmpDir);
|
||||
const config = getTestConfigWithTempDir(tmpDir);
|
||||
sinon.stub(actionsUtil, "isAnalyzingDefaultBranch").resolves(true);
|
||||
const result = await getTrapCachingExtractorConfigArgsForLang(
|
||||
config,
|
||||
|
@ -126,7 +126,7 @@ test("check flags for JS, analyzing default branch", async (t) => {
|
|||
|
||||
test("check flags for all, not analyzing default branch", async (t) => {
|
||||
await util.withTmpDir(async (tmpDir) => {
|
||||
const config = getTestConfig(tmpDir);
|
||||
const config = getTestConfigWithTempDir(tmpDir);
|
||||
sinon.stub(actionsUtil, "isAnalyzingDefaultBranch").resolves(false);
|
||||
const result = await getTrapCachingExtractorConfigArgs(config);
|
||||
t.deepEqual(result, [
|
||||
|
@ -157,7 +157,7 @@ test("upload cache key contains right fields", async (t) => {
|
|||
sinon.stub(actionsUtil, "isAnalyzingDefaultBranch").resolves(true);
|
||||
const stubSave = sinon.stub(cache, "saveCache");
|
||||
process.env.GITHUB_SHA = "somesha";
|
||||
await uploadTrapCaches(stubCodeql, stubConfig, logger);
|
||||
await uploadTrapCaches(stubCodeql, testConfigWithoutTmpDir, logger);
|
||||
t.assert(
|
||||
stubSave.calledOnceWith(
|
||||
sinon.match.array.contains(["/some/cache/dir"]),
|
||||
|
@ -177,6 +177,7 @@ test("download cache looks for the right key and creates dir", async (t) => {
|
|||
sinon.stub(actionsUtil, "isAnalyzingDefaultBranch").resolves(false);
|
||||
const stubRestore = sinon.stub(cache, "restoreCache").resolves("found");
|
||||
const eventFile = path.resolve(tmpDir, "event.json");
|
||||
process.env.GITHUB_EVENT_NAME = "pull_request";
|
||||
process.env.GITHUB_EVENT_PATH = eventFile;
|
||||
fs.writeFileSync(
|
||||
eventFile,
|
||||
|
|
|
@ -17,15 +17,18 @@ import { codeQlVersionAbove } from "./util";
|
|||
// goes into the cache key.
|
||||
const CACHE_VERSION = 1;
|
||||
|
||||
// This constant sets the size of each TRAP cache in megabytes.
|
||||
const CACHE_SIZE_MB = 1024;
|
||||
|
||||
export async function getTrapCachingExtractorConfigArgs(
|
||||
config: Config
|
||||
): Promise<string[]> {
|
||||
const result: string[] = [];
|
||||
const result: string[][] = [];
|
||||
for (const language of config.languages)
|
||||
result.push(
|
||||
...(await getTrapCachingExtractorConfigArgsForLang(config, language))
|
||||
await getTrapCachingExtractorConfigArgsForLang(config, language)
|
||||
);
|
||||
return result;
|
||||
return result.flat();
|
||||
}
|
||||
|
||||
export async function getTrapCachingExtractorConfigArgsForLang(
|
||||
|
@ -37,11 +40,19 @@ export async function getTrapCachingExtractorConfigArgsForLang(
|
|||
const write = await actionsUtil.isAnalyzingDefaultBranch();
|
||||
return [
|
||||
`-O=${language}.trap.cache.dir=${cacheDir}`,
|
||||
`-O=${language}.trap.cache.bound=1024`,
|
||||
`-O=${language}.trap.cache.bound=${CACHE_SIZE_MB}`,
|
||||
`-O=${language}.trap.cache.write=${write}`,
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Download TRAP caches from the Actions cache.
|
||||
* @param codeql The CodeQL instance to use.
|
||||
* @param languages The languages being analyzed.
|
||||
* @param logger A logger to record some informational messages to.
|
||||
* @returns A partial map from languages to TRAP cache paths on disk, with
|
||||
* languages for which we shouldn't use TRAP caching omitted.
|
||||
*/
|
||||
export async function downloadTrapCaches(
|
||||
codeql: CodeQL,
|
||||
languages: Language[],
|
||||
|
@ -77,23 +88,28 @@ export async function downloadTrapCaches(
|
|||
|
||||
let baseSha = "unknown";
|
||||
const eventPath = process.env.GITHUB_EVENT_PATH;
|
||||
if (eventPath !== undefined) {
|
||||
if (
|
||||
process.env.GITHUB_EVENT_NAME === "pull_request" &&
|
||||
eventPath !== undefined
|
||||
) {
|
||||
const event = JSON.parse(fs.readFileSync(path.resolve(eventPath), "utf-8"));
|
||||
baseSha = event.pull_request?.base?.sha || "unknown";
|
||||
baseSha = event.pull_request?.base?.sha || baseSha;
|
||||
}
|
||||
for (const language of languages) {
|
||||
const cacheDir = result[language];
|
||||
if (cacheDir === undefined) continue;
|
||||
// The SHA from the base of the PR is the most similar commit we might have a cache for
|
||||
const preferredKey = `codeql-trap-${CACHE_VERSION}-${await codeql.getVersion()}-${language}-${baseSha}`;
|
||||
const preferredKey = await cacheKey(codeql, language, baseSha);
|
||||
logger.info(
|
||||
`Looking in Actions cache for TRAP cache with key ${preferredKey}`
|
||||
);
|
||||
const found = await cache.restoreCache([cacheDir], preferredKey, [
|
||||
`codeql-trap-${CACHE_VERSION}-${await codeql.getVersion()}-${language}-`, // Fall back to any cache with the right key prefix
|
||||
await cachePrefix(codeql, language), // Fall back to any cache with the right key prefix
|
||||
]);
|
||||
if (found === undefined) {
|
||||
// Didn't find any cache, let's unset to avoid lookups in an empty directory
|
||||
// We didn't find a TRAP cache in the Actions cache, so the directory on disk is
|
||||
// still just an empty directory. There's no reason to tell the extractor to use it,
|
||||
// so let's unset the entry in the map so we don't set any extractor options.
|
||||
logger.info(`No TRAP cache found in Actions cache for ${language}`);
|
||||
result[language] = undefined;
|
||||
}
|
||||
|
@ -109,15 +125,19 @@ export async function uploadTrapCaches(
|
|||
): Promise<void> {
|
||||
if (!(await actionsUtil.isAnalyzingDefaultBranch())) return; // Only upload caches from the default branch
|
||||
|
||||
const toAwait: Array<Promise<number>> = [];
|
||||
for (const language of config.languages) {
|
||||
const cacheDir = config.trapCaches[language];
|
||||
if (cacheDir === undefined) continue;
|
||||
const key = `codeql-trap-${CACHE_VERSION}-${await codeql.getVersion()}-${language}-${
|
||||
const key = await cacheKey(
|
||||
codeql,
|
||||
language,
|
||||
process.env.GITHUB_SHA || "unknown"
|
||||
}`;
|
||||
);
|
||||
logger.info(`Uploading TRAP cache to Actions cache with key ${key}`);
|
||||
await cache.saveCache([cacheDir], key);
|
||||
toAwait.push(cache.saveCache([cacheDir], key));
|
||||
}
|
||||
await Promise.all(toAwait);
|
||||
}
|
||||
|
||||
export async function getLanguagesSupportingCaching(
|
||||
|
@ -132,6 +152,7 @@ export async function getLanguagesSupportingCaching(
|
|||
return result;
|
||||
const resolveResult = await codeql.betterResolveLanguages();
|
||||
outer: for (const lang of languages) {
|
||||
if (resolveResult.extractors[lang].length !== 1) continue;
|
||||
const extractor = resolveResult.extractors[lang][0];
|
||||
const trapCacheOptions =
|
||||
extractor.extractor_options?.trap?.properties?.cache?.properties;
|
||||
|
@ -153,3 +174,18 @@ export async function getLanguagesSupportingCaching(
|
|||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
async function cacheKey(
|
||||
codeql: CodeQL,
|
||||
language: Language,
|
||||
baseSha: string
|
||||
): Promise<string> {
|
||||
return `${await cachePrefix(codeql, language)}-${baseSha}`;
|
||||
}
|
||||
|
||||
async function cachePrefix(
|
||||
codeql: CodeQL,
|
||||
language: Language
|
||||
): Promise<string> {
|
||||
return `codeql-trap-${CACHE_VERSION}-${await codeql.getVersion()}-${language}-`;
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче