Change hash to be a function that can use Features

This commit is contained in:
Michael B. Gale
2025-09-17 15:04:55 +01:00
parent 2a7680fca6
commit ab1c84236a
3 changed files with 29 additions and 25 deletions

15
lib/analyze-action.js generated
View File

@@ -91070,7 +91070,7 @@ function getJavaDependencyDirs() {
var defaultCacheConfigs = {
java: {
getDependencyPaths: getJavaDependencyDirs,
hash: [
getHashPatterns: async () => [
// Maven
"**/pom.xml",
// Gradle
@@ -91084,7 +91084,7 @@ var defaultCacheConfigs = {
},
csharp: {
getDependencyPaths: () => [(0, import_path.join)(os3.homedir(), ".nuget", "packages")],
hash: [
getHashPatterns: async () => [
// NuGet
"**/packages.lock.json",
// Paket
@@ -91093,7 +91093,7 @@ var defaultCacheConfigs = {
},
go: {
getDependencyPaths: () => [(0, import_path.join)(os3.homedir(), "go", "pkg", "mod")],
hash: ["**/go.sum"]
getHashPatterns: async () => ["**/go.sum"]
}
};
async function makeGlobber(patterns) {
@@ -91109,7 +91109,8 @@ async function uploadDependencyCaches(codeql, features, config, logger) {
);
continue;
}
const globber = await makeGlobber(cacheConfig.hash);
const patterns = await cacheConfig.getHashPatterns(codeql, features);
const globber = await makeGlobber(patterns);
if ((await globber.glob()).length === 0) {
status.push({ language, result: "no-hash" /* NoHash */ });
logger.info(
@@ -91129,7 +91130,7 @@ async function uploadDependencyCaches(codeql, features, config, logger) {
);
continue;
}
const key = await cacheKey2(codeql, features, language, cacheConfig);
const key = await cacheKey2(codeql, features, language, patterns);
logger.info(
`Uploading cache of size ${size} for ${language} with key ${key}...`
);
@@ -91157,8 +91158,8 @@ async function uploadDependencyCaches(codeql, features, config, logger) {
}
return status;
}
async function cacheKey2(codeql, features, language, cacheConfig) {
const hash2 = await glob.hashFiles(cacheConfig.hash.join("\n"));
async function cacheKey2(codeql, features, language, patterns) {
const hash2 = await glob.hashFiles(patterns.join("\n"));
return `${await cachePrefix2(codeql, features, language)}${hash2}`;
}
async function cachePrefix2(codeql, features, language) {

15
lib/init-action.js generated
View File

@@ -87257,7 +87257,7 @@ function getJavaDependencyDirs() {
var defaultCacheConfigs = {
java: {
getDependencyPaths: getJavaDependencyDirs,
hash: [
getHashPatterns: async () => [
// Maven
"**/pom.xml",
// Gradle
@@ -87271,7 +87271,7 @@ var defaultCacheConfigs = {
},
csharp: {
getDependencyPaths: () => [(0, import_path.join)(os2.homedir(), ".nuget", "packages")],
hash: [
getHashPatterns: async () => [
// NuGet
"**/packages.lock.json",
// Paket
@@ -87280,7 +87280,7 @@ var defaultCacheConfigs = {
},
go: {
getDependencyPaths: () => [(0, import_path.join)(os2.homedir(), "go", "pkg", "mod")],
hash: ["**/go.sum"]
getHashPatterns: async () => ["**/go.sum"]
}
};
async function makeGlobber(patterns) {
@@ -87296,7 +87296,8 @@ async function downloadDependencyCaches(codeql, features, languages, logger) {
);
continue;
}
const globber = await makeGlobber(cacheConfig.hash);
const patterns = await cacheConfig.getHashPatterns(codeql, features);
const globber = await makeGlobber(patterns);
if ((await globber.glob()).length === 0) {
status.push({ language, hit_kind: "no-hash" /* NoHash */ });
logger.info(
@@ -87304,7 +87305,7 @@ async function downloadDependencyCaches(codeql, features, languages, logger) {
);
continue;
}
const primaryKey = await cacheKey2(codeql, features, language, cacheConfig);
const primaryKey = await cacheKey2(codeql, features, language, patterns);
const restoreKeys = [
await cachePrefix2(codeql, features, language)
];
@@ -87331,8 +87332,8 @@ async function downloadDependencyCaches(codeql, features, languages, logger) {
}
return status;
}
async function cacheKey2(codeql, features, language, cacheConfig) {
const hash = await glob.hashFiles(cacheConfig.hash.join("\n"));
async function cacheKey2(codeql, features, language, patterns) {
const hash = await glob.hashFiles(patterns.join("\n"));
return `${await cachePrefix2(codeql, features, language)}${hash}`;
}
async function cachePrefix2(codeql, features, language) {