diff --git a/init/action.yml b/init/action.yml index 57d5a9940..6c36f79bc 100644 --- a/init/action.yml +++ b/init/action.yml @@ -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 diff --git a/lib/init-action-post.js b/lib/init-action-post.js index 233ae9be0..e1b1f04e5 100644 --- a/lib/init-action-post.js +++ b/lib/init-action-post.js @@ -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( diff --git a/src/init-action-post-helper.ts b/src/init-action-post-helper.ts index 328c63951..b1fb968c0 100644 --- a/src/init-action-post-helper.ts +++ b/src/init-action-post-helper.ts @@ -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) { diff --git a/src/overlay/status.ts b/src/overlay/status.ts index 9e6d844ed..73f426059 100644 --- a/src/overlay/status.ts +++ b/src/overlay/status.ts @@ -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, + 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, }; }