@@ -13,12 +13,17 @@ import * as path from "path";
1313
1414import * as actionsCache from "@actions/cache" ;
1515
16- import { getTemporaryDirectory } from "../actions-util" ;
16+ import {
17+ getTemporaryDirectory ,
18+ getWorkflowRunAttempt ,
19+ getWorkflowRunID ,
20+ } from "../actions-util" ;
1721import { type CodeQL } from "../codeql" ;
1822import { Logger } from "../logging" ;
1923import {
2024 DiskUsage ,
2125 getErrorMessage ,
26+ getRequiredEnvParam ,
2227 waitForResultWithTimeLimit ,
2328} from "../util" ;
2429
@@ -38,12 +43,43 @@ function getStatusFilePath(languages: string[]): string {
3843 ) ;
3944}
4045
46+ /** Details of the job that recorded an overlay status. */
47+ interface JobInfo {
48+ /** The check run ID. This is optional since it is not always available. */
49+ checkRunId ?: number ;
50+ /** The workflow run ID. */
51+ workflowRunId : number ;
52+ /** The workflow run attempt number. */
53+ workflowRunAttempt : number ;
54+ /** The name of the job (from GITHUB_JOB). */
55+ name : string ;
56+ }
57+
4158/** Status of an overlay analysis for a group of languages. */
4259export interface OverlayStatus {
4360 /** Whether the job attempted to build an overlay base database. */
4461 attemptedToBuildOverlayBaseDatabase : boolean ;
4562 /** Whether the job successfully built an overlay base database. */
4663 builtOverlayBaseDatabase : boolean ;
64+ /** Details of the job that recorded this status. */
65+ job ?: JobInfo ;
66+ }
67+
68+ /** Creates an `OverlayStatus` populated with the details of the current job. */
69+ export function createOverlayStatus (
70+ attributes : Omit < OverlayStatus , "job" > ,
71+ checkRunId ?: number ,
72+ ) : OverlayStatus {
73+ const job : JobInfo = {
74+ workflowRunId : getWorkflowRunID ( ) ,
75+ workflowRunAttempt : getWorkflowRunAttempt ( ) ,
76+ name : getRequiredEnvParam ( "GITHUB_JOB" ) ,
77+ checkRunId,
78+ } ;
79+ return {
80+ ...attributes ,
81+ job,
82+ } ;
4783}
4884
4985/**
0 commit comments