Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 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
1 change: 1 addition & 0 deletions .evergreen/functions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -667,6 +667,7 @@ functions:
<<: *compass-env
DEBUG: ${debug|}
GITHUB_TOKEN: ${generated_token}
EVERGREEN_TASK_URL: https://spruce.mongodb.com/task/${task_id}
script: |
set -e
# Load environment variables
Expand Down
9 changes: 9 additions & 0 deletions .github/workflows/test-installers.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,19 @@ on:
nonce:
type: string
description: 'A random string to track the run from dispatch to watching'
evergreen_task_url:
type: string
description: 'URL to the Evergreen job that triggered this run'

run-name: Test Installers ${{ github.event.inputs.dev_version || github.ref_name }} / (nonce = ${{ github.event.inputs.nonce || 'not set' }})

jobs:
summarize:
if: ${{ github.event.inputs.evergreen_task_url }}
runs-on: ubuntu-latest
steps:
- name: Add a summary to the job
run: echo "Triggered by ${{ github.event.inputs.evergreen_task_url }}" >> $GITHUB_STEP_SUMMARY
test:
name: ${{ matrix.package }} test ${{ matrix.test }} (${{ matrix.hadron-distribution }})
strategy:
Expand Down
2 changes: 2 additions & 0 deletions packages/compass-smoke-tests/src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ yargs(hideBin(process.argv))
.scriptName('smoke-tests')
.detectLocale(false)
.version(false)
.showHelpOnFail(false)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❤️

.strict()
.option('bucketName', {
type: 'string',
Expand Down Expand Up @@ -165,6 +166,7 @@ yargs(hideBin(process.argv))
})
: ref,
devVersion: process.env.DEV_VERSION_IDENTIFIER,
evergreenTaskUrl: process.env.EVERGREEN_TASK_URL,
bucketName,
bucketKeyPrefix,
});
Expand Down
79 changes: 57 additions & 22 deletions packages/compass-smoke-tests/src/dispatch.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import assert from 'node:assert/strict';
import crypto from 'node:crypto';

import * as github from '@actions/github';
Expand Down Expand Up @@ -70,12 +71,58 @@ export async function getRefFromGithubPr({
return ref;
}

type PollToCompletionOptions = {
octokit: ReturnType<typeof github.getOctokit>;
runId: number;
watchTimeoutMs: number;
watchPollDelayMs: number;
};

async function pollToCompletion({
octokit,
runId,
watchTimeoutMs,
watchPollDelayMs,
}: PollToCompletionOptions): Promise<string> {
for (
const start = new Date();
new Date().getTime() - start.getTime() < watchTimeoutMs;

) {
const {
data: { status, conclusion },
} = await octokit.rest.actions.getWorkflowRun({
owner: GITHUB_OWNER,
repo: GITHUB_REPO,
run_id: runId,
});
console.log(`Status: ${status || 'null'}`);
if (status === 'completed') {
assert(
typeof conclusion === 'string',
'Expected conclusion when completed'
);
return conclusion;
}
await new Promise((resolve) => setTimeout(resolve, watchPollDelayMs));
}

// Cancel the run before timing out
await octokit.rest.actions.cancelWorkflowRun({
owner: GITHUB_OWNER,
repo: GITHUB_REPO,
run_id: runId,
});
return 'timeout';
}

type DispatchOptions = {
githubToken: string;
ref: string;
bucketName: string;
bucketKeyPrefix: string;
devVersion?: string;
evergreenTaskUrl?: string;

/**
* Delay in milliseconds to wait between requests when polling while watching the run.
Expand All @@ -89,6 +136,7 @@ export async function dispatchAndWait({
devVersion,
bucketName,
bucketKeyPrefix,
evergreenTaskUrl,
watchPollDelayMs = 5000,
}: DispatchOptions) {
const octokit = github.getOctokit(githubToken);
Expand All @@ -103,6 +151,7 @@ export async function dispatchAndWait({
dev_version: devVersion,
bucket_name: bucketName,
bucket_key_prefix: bucketKeyPrefix,
evergreen_task_url: evergreenTaskUrl,
nonce,
},
});
Expand All @@ -114,27 +163,13 @@ export async function dispatchAndWait({
);

console.log(`Dispatched run #${run.run_number} (${run.html_url})`);
for (
const start = new Date();
new Date().getTime() - start.getTime() < WATCH_POLL_TIMEOUT_MS;
const status = await pollToCompletion({
octokit,
runId: run.id,
watchTimeoutMs: WATCH_POLL_TIMEOUT_MS,
watchPollDelayMs,
});

) {
const {
data: { status, conclusion },
} = await octokit.rest.actions.getWorkflowRun({
owner: GITHUB_OWNER,
repo: GITHUB_REPO,
run_id: run.id,
});
console.log(
`Status = ${status || 'null'}, conclusion = ${conclusion || 'null'}`
);
if (status === 'completed' && conclusion === 'success') {
return;
}
await new Promise((resolve) => setTimeout(resolve, watchPollDelayMs));
}
throw new Error(
`Run did not complete successfully within ${WATCH_POLL_TIMEOUT_MS}ms: See ${run.html_url} for details.`
);
console.log(`Run completed: ${run.html_url}`);
assert.equal(status, 'success', "Expected a 'success' conclusion");
}
Loading