mirror of
https://github.com/github/codeql-action.git
synced 2025-12-31 19:50:32 +08:00
Ensure uniqueness of overlay-base database cache keys
This commit is contained in:
@@ -271,10 +271,12 @@ test("overlay-base database cache keys remain stable", async (t) => {
|
||||
|
||||
sinon.stub(apiClient, "getAutomationID").resolves("test-automation-id/");
|
||||
sinon.stub(gitUtils, "getCommitOid").resolves(commitOid);
|
||||
sinon.stub(actionsUtil, "getWorkflowRunID").returns(12345);
|
||||
sinon.stub(actionsUtil, "getWorkflowRunAttempt").returns(1);
|
||||
|
||||
const saveKey = await getCacheSaveKey(config, codeQlVersion, "checkout-path");
|
||||
const expectedSaveKey =
|
||||
"codeql-overlay-base-database-1-c5666c509a2d9895-javascript_python-2.23.0-abc123def456";
|
||||
"codeql-overlay-base-database-1-c5666c509a2d9895-javascript_python-2.23.0-12345-1-abc123def456";
|
||||
t.is(
|
||||
saveKey,
|
||||
expectedSaveKey,
|
||||
|
||||
@@ -4,7 +4,12 @@ import * as path from "path";
|
||||
|
||||
import * as actionsCache from "@actions/cache";
|
||||
|
||||
import { getRequiredInput, getTemporaryDirectory } from "./actions-util";
|
||||
import {
|
||||
getRequiredInput,
|
||||
getTemporaryDirectory,
|
||||
getWorkflowRunAttempt,
|
||||
getWorkflowRunID,
|
||||
} from "./actions-util";
|
||||
import { getAutomationID } from "./api-client";
|
||||
import { type CodeQL } from "./codeql";
|
||||
import { type Config } from "./config-utils";
|
||||
@@ -453,12 +458,14 @@ export async function getCacheSaveKey(
|
||||
codeQlVersion: string,
|
||||
checkoutPath: string,
|
||||
): Promise<string> {
|
||||
const runId = getWorkflowRunID();
|
||||
const attemptId = getWorkflowRunAttempt();
|
||||
const sha = await getCommitOid(checkoutPath);
|
||||
const restoreKeyPrefix = await getCacheRestoreKeyPrefix(
|
||||
config,
|
||||
codeQlVersion,
|
||||
);
|
||||
return `${restoreKeyPrefix}${sha}`;
|
||||
return `${restoreKeyPrefix}${runId}-${attemptId}-${sha}`;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user