-
Notifications
You must be signed in to change notification settings - Fork 445
Record the job that published an overlay status #3537
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -12,7 +12,11 @@ import { EnvVar } from "./environment"; | |
| import { Feature, FeatureEnablement } from "./feature-flags"; | ||
| import { Logger } from "./logging"; | ||
| import { OverlayDatabaseMode } from "./overlay"; | ||
| import { OverlayStatus, saveOverlayStatus } from "./overlay/status"; | ||
| import { | ||
| createOverlayStatus, | ||
| OverlayStatus, | ||
| saveOverlayStatus, | ||
| } from "./overlay/status"; | ||
| import { RepositoryNwo, getRepositoryNwo } from "./repository"; | ||
| import { JobStatus } from "./status-report"; | ||
| import * as uploadLib from "./upload-lib"; | ||
|
|
@@ -270,10 +274,17 @@ async function recordOverlayStatus( | |
| return; | ||
| } | ||
|
|
||
| const overlayStatus: OverlayStatus = { | ||
| 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, | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should we also check that this is |
||
| ); | ||
|
|
||
| const diskUsage = await checkDiskUsage(logger); | ||
| if (diskUsage === undefined) { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -13,12 +13,17 @@ import * as path from "path"; | |
|
|
||
| import * as actionsCache from "@actions/cache"; | ||
|
|
||
| import { getTemporaryDirectory } from "../actions-util"; | ||
| import { | ||
| getTemporaryDirectory, | ||
| getWorkflowRunAttempt, | ||
| getWorkflowRunID, | ||
| } from "../actions-util"; | ||
| import { type CodeQL } from "../codeql"; | ||
| import { Logger } from "../logging"; | ||
| import { | ||
| DiskUsage, | ||
| getErrorMessage, | ||
| getRequiredEnvParam, | ||
| waitForResultWithTimeLimit, | ||
| } from "../util"; | ||
|
|
||
|
|
@@ -38,12 +43,43 @@ 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. */ | ||
| workflowRunAttempt: number; | ||
| /** The name of the job (from GITHUB_JOB). */ | ||
| name: string; | ||
| } | ||
|
|
||
| /** Status of an overlay analysis for a group of languages. */ | ||
| export interface OverlayStatus { | ||
| /** Whether the job attempted to build an overlay base database. */ | ||
| attemptedToBuildOverlayBaseDatabase: boolean; | ||
| /** Whether the job successfully built an overlay base database. */ | ||
| builtOverlayBaseDatabase: boolean; | ||
| /** Details of the job that recorded this status. */ | ||
| job?: JobInfo; | ||
| } | ||
|
|
||
| /** 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 }), | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we had a similar point on another PR recently: this is mostly equivalent to just |
||
| }; | ||
| return { | ||
| ...attributes, | ||
| job, | ||
| }; | ||
| } | ||
|
|
||
| /** | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor: It might be nice to extend
setupActionsVarswith all environment variables that we'd typically expect in an Actions environment and modify it to accept an argument with a (partial) mapping of specific environment variables we want to set. Not necessarily something for this PR.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good idea. I'll take a look at this in a separate PR.