Skip to content

Commit

Permalink
Better debug info for pending jobs from the same workflow (#2776)
Browse files Browse the repository at this point in the history
  • Loading branch information
CatChen authored Jun 1, 2024
1 parent a1a86b8 commit 0ebe0fd
Show file tree
Hide file tree
Showing 4 changed files with 80 additions and 29 deletions.
33 changes: 25 additions & 8 deletions dist/index.js

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

2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

33 changes: 25 additions & 8 deletions lib/index.js

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

41 changes: 29 additions & 12 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -227,12 +227,40 @@ async function handlePullRequest(pullRequestNumber: number) {
pullRequest.head.sha,
octokit,
);

if (externalIds === undefined) {
// Two instances of the same job's execution share the same external id but not the same job id.
// We use external id to identify other instances of the job.
externalIds = checkRuns
.filter((checkRun) => {
if (checkRun.external_id === null) {
return false;
}
if (jobIds.includes(checkRun.id)) {
info(
`External ID associated with a job in current Workflow: ${checkRun.external_id} (job id: ${checkRun.id})`,
);
return true;
}
return false;
})
.map((checkRun) => checkRun.external_id);
}

info(`Checks:`);
for (const checkRun of checkRuns) {
info(` Check id: ${checkRun.id} (${checkRun.html_url})`);
info(` Check name: ${checkRun.name}`);
if (checkRun.status === COMPLETED) {
if (
if (jobIds.includes(checkRun.id)) {
info(` Check status/conclusion: ${checkRun.conclusion}`);
info(' This check is a job in the current Workflow.\n\n');
} else if (externalIds?.includes(checkRun.external_id)) {
info(` Check status/conclusion: ${checkRun.conclusion}`);
info(
' This check is a job in another instance of the same Workflow.\n\n',
);
} else if (
checkRun.conclusion !== null &&
[SUCCESS, NEUTRAL, SKIPPED].includes(checkRun.conclusion)
) {
Expand All @@ -245,17 +273,6 @@ async function handlePullRequest(pullRequestNumber: number) {
}
}

if (externalIds === undefined) {
// Two instances of the same job's execution share the same external id but not the same job id.
// We use external id to identify other instances of the job.
externalIds = checkRuns
.filter(
(checkRun) =>
jobIds.includes(checkRun.id) && checkRun.external_id !== null,
)
.map((checkRun) => checkRun.external_id);
}

const failedChecks = checkRuns.filter(
(checkRun) =>
!jobIds.includes(checkRun.id) &&
Expand Down

0 comments on commit 0ebe0fd

Please sign in to comment.