Skip to content

Commit

Permalink
Merge pull request #2197 from github/henrymercer/log-job-status
Browse files Browse the repository at this point in the history
Log job status in the "Post init" step
  • Loading branch information
henrymercer authored Mar 13, 2024
2 parents 0d680ab + e402144 commit f055b5e
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 3 deletions.
2 changes: 2 additions & 0 deletions lib/init-action-post.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lib/init-action-post.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 16 additions & 1 deletion lib/status-report.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lib/status-report.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions src/init-action-post.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import {
createStatusReportBase,
getActionsStatus,
ActionName,
getJobStatusDisplayName,
} from "./status-report";
import {
checkDiskUsage,
Expand Down Expand Up @@ -89,6 +90,9 @@ async function runWrapper() {
);
return;
}
const jobStatus = initActionPostHelper.getFinalJobStatus();
logger.info(`CodeQL job status was ${getJobStatusDisplayName(jobStatus)}.`);

const statusReportBase = await createStatusReportBase(
ActionName.InitPost,
"success",
Expand Down
16 changes: 16 additions & 0 deletions src/status-report.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import {
isInTestMode,
GITHUB_DOTCOM_URL,
DiskUsage,
assertNever,
} from "./util";

export enum ActionName {
Expand Down Expand Up @@ -171,6 +172,21 @@ export function getActionsStatus(
}
}

export function getJobStatusDisplayName(status: JobStatus): string {
switch (status) {
case JobStatus.SuccessStatus:
return "success";
case JobStatus.FailureStatus:
return "failure";
case JobStatus.ConfigErrorStatus:
return "configuration error";
case JobStatus.UnknownStatus:
return "unknown";
default:
assertNever(status);
}
}

/**
* Sets the overall job status environment variable to configuration error
* or failure, unless it's already been set to one of these values in a
Expand Down

0 comments on commit f055b5e

Please sign in to comment.