Add check run ID

This commit is contained in:
Henry Mercer
2026-03-03 19:04:04 +01:00
parent a05f541a6e
commit 129d771399
4 changed files with 43 additions and 19 deletions

View File

@@ -159,6 +159,11 @@ inputs:
description: >-
Explicitly enable or disable caching of project build dependencies.
required: false
check-run-id:
description: >-
[Internal] The ID of the check run, as provided by the Actions runtime environment. Do not set this value manually.
default: ${{ job.check_run_id }}
required: false
outputs:
codeql-path:
description: The path of the CodeQL binary used for analysis

View File

@@ -166091,14 +166091,16 @@ function getStatusFilePath(languages) {
STATUS_FILE_NAME
);
}
function createOverlayStatus(attributes) {
function createOverlayStatus(attributes, checkRunId) {
const job = {
workflowRunId: getWorkflowRunID(),
workflowRunAttempt: getWorkflowRunAttempt(),
name: getRequiredEnvParam("GITHUB_JOB"),
...checkRunId !== void 0 && { checkRunId }
};
return {
...attributes,
job: {
workflowRunId: getWorkflowRunID(),
workflowRunAttempt: getWorkflowRunAttempt(),
name: getRequiredEnvParam("GITHUB_JOB")
}
job
};
}
async function saveOverlayStatus(codeql, languages, diskUsage, status, logger) {
@@ -170365,10 +170367,15 @@ async function recordOverlayStatus(codeql, config, features, logger) {
if (config.overlayDatabaseMode !== "overlay-base" /* OverlayBase */ || process.env["CODEQL_ACTION_ANALYZE_DID_COMPLETE_SUCCESSFULLY" /* ANALYZE_DID_COMPLETE_SUCCESSFULLY */] === "true" || !await features.getValue("overlay_analysis_status_save" /* OverlayAnalysisStatusSave */)) {
return;
}
const overlayStatus = createOverlayStatus({
attemptedToBuildOverlayBaseDatabase: true,
builtOverlayBaseDatabase: false
});
const checkRunIdInput = getOptionalInput("check-run-id");
const checkRunId = checkRunIdInput !== void 0 ? parseInt(checkRunIdInput, 10) : void 0;
const overlayStatus = createOverlayStatus(
{
attemptedToBuildOverlayBaseDatabase: true,
builtOverlayBaseDatabase: false
},
Number.isNaN(checkRunId) ? void 0 : checkRunId
);
const diskUsage = await checkDiskUsage(logger);
if (diskUsage === void 0) {
logger.warning(

View File

@@ -274,10 +274,17 @@ async function recordOverlayStatus(
return;
}
const overlayStatus: OverlayStatus = createOverlayStatus({
attemptedToBuildOverlayBaseDatabase: true,
builtOverlayBaseDatabase: false,
});
const checkRunIdInput = actionsUtil.getOptionalInput("check-run-id");
const checkRunId =
checkRunIdInput !== undefined ? parseInt(checkRunIdInput, 10) : undefined;
const overlayStatus: OverlayStatus = createOverlayStatus(
{
attemptedToBuildOverlayBaseDatabase: true,
builtOverlayBaseDatabase: false,
},
Number.isNaN(checkRunId) ? undefined : checkRunId,
);
const diskUsage = await checkDiskUsage(logger);
if (diskUsage === undefined) {

View File

@@ -45,6 +45,8 @@ function getStatusFilePath(languages: string[]): string {
/** Details of the job that recorded an overlay status. */
interface JobInfo {
/** The check run ID. This is optional since it is not always available. */
checkRunId?: number;
/** The workflow run ID. */
workflowRunId: number;
/** The workflow run attempt number. */
@@ -66,14 +68,17 @@ export interface OverlayStatus {
/** Creates an `OverlayStatus` populated with the details of the current job. */
export function createOverlayStatus(
attributes: Omit<OverlayStatus, "job">,
checkRunId?: number,
): OverlayStatus {
const job: JobInfo = {
workflowRunId: getWorkflowRunID(),
workflowRunAttempt: getWorkflowRunAttempt(),
name: getRequiredEnvParam("GITHUB_JOB"),
...(checkRunId !== undefined && { checkRunId }),
};
return {
...attributes,
job: {
workflowRunId: getWorkflowRunID(),
workflowRunAttempt: getWorkflowRunAttempt(),
name: getRequiredEnvParam("GITHUB_JOB"),
},
job,
};
}