Skip to content

Commit b13f70e

Browse files
committed
Fail dispatch early
1 parent 393c88c commit b13f70e

File tree

1 file changed

+23
-17
lines changed

1 file changed

+23
-17
lines changed

packages/compass-smoke-tests/src/dispatch.ts

Lines changed: 23 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import assert from 'node:assert/strict';
12
import crypto from 'node:crypto';
23

34
import * as github from '@actions/github';
@@ -76,6 +77,7 @@ type DispatchOptions = {
7677
bucketName: string;
7778
bucketKeyPrefix: string;
7879
devVersion?: string;
80+
evergreenTaskUrl?: string;
7981

8082
/**
8183
* Delay in milliseconds to wait between requests when polling while watching the run.
@@ -89,6 +91,7 @@ export async function dispatchAndWait({
8991
devVersion,
9092
bucketName,
9193
bucketKeyPrefix,
94+
evergreenTaskUrl,
9295
watchPollDelayMs = 5000,
9396
}: DispatchOptions) {
9497
const octokit = github.getOctokit(githubToken);
@@ -103,6 +106,7 @@ export async function dispatchAndWait({
103106
dev_version: devVersion,
104107
bucket_name: bucketName,
105108
bucket_key_prefix: bucketKeyPrefix,
109+
evergreen_task_url: evergreenTaskUrl,
106110
nonce,
107111
},
108112
});
@@ -114,25 +118,27 @@ export async function dispatchAndWait({
114118
);
115119

116120
console.log(`Dispatched run #${run.run_number} (${run.html_url})`);
117-
for (
118-
const start = new Date();
119-
new Date().getTime() - start.getTime() < WATCH_POLL_TIMEOUT_MS;
121+
try {
122+
for (
123+
const start = new Date();
124+
new Date().getTime() - start.getTime() < WATCH_POLL_TIMEOUT_MS;
120125

121-
) {
122-
const {
123-
data: { status, conclusion },
124-
} = await octokit.rest.actions.getWorkflowRun({
125-
owner: GITHUB_OWNER,
126-
repo: GITHUB_REPO,
127-
run_id: run.id,
128-
});
129-
console.log(
130-
`Status = ${status || 'null'}, conclusion = ${conclusion || 'null'}`
131-
);
132-
if (status === 'completed' && conclusion === 'success') {
133-
return;
126+
) {
127+
const {
128+
data: { status, conclusion },
129+
} = await octokit.rest.actions.getWorkflowRun({
130+
owner: GITHUB_OWNER,
131+
repo: GITHUB_REPO,
132+
run_id: run.id,
133+
});
134+
console.log(`Status: ${status || 'null'}`);
135+
if (status === 'completed') {
136+
assert.equal(conclusion, 'success');
137+
}
138+
await new Promise((resolve) => setTimeout(resolve, watchPollDelayMs));
134139
}
135-
await new Promise((resolve) => setTimeout(resolve, watchPollDelayMs));
140+
} finally {
141+
console.log(`Run completed: ${run.html_url}`);
136142
}
137143
throw new Error(
138144
`Run did not complete successfully within ${WATCH_POLL_TIMEOUT_MS}ms: See ${run.html_url} for details.`

0 commit comments

Comments
 (0)