Skip to content
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

Log job status in the "Post init" step #2197

Merged
merged 1 commit into from
Mar 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading