Skip to content

Commit 7682e06

Browse files
authored
chore(smoke-test): Arm "test installers" GHA workflow (#6718)
* Add e2e tests as dep of smoke-tests * Arm workflow * Print debug messages * Fix and allow downgrade in auto-update-to tests * Cleanup on exit * Wait for update server to close * Add more debug messages and fix check
1 parent d0bb22b commit 7682e06

File tree

15 files changed

+371
-181
lines changed

15 files changed

+371
-181
lines changed

.github/workflows/test-installers.yml

Lines changed: 148 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,111 @@ on:
2121

2222
jobs:
2323
test:
24-
name: Dummy action
25-
runs-on: ubuntu-latest
24+
name: ${{ matrix.package }} test ${{ matrix.test }} (${{ matrix.hadron-distribution }})
25+
strategy:
26+
fail-fast: false
27+
matrix:
28+
test:
29+
- time-to-first-query
30+
- auto-update-from
31+
- auto-update-to
32+
package:
33+
- osx_dmg
34+
- osx_zip
35+
- windows_zip
36+
- windows_msi
37+
- windows_setup
38+
- linux_deb
39+
# TODO: Re-enable (see https://github.com/mongodb-js/compass/actions/runs/13281152689/job/37079619474)
40+
# - linux_tar
41+
# TODO: Enable (needs a docker container)
42+
# - linux_rpm
43+
hadron-distribution:
44+
- compass
45+
- compass-readonly
46+
- compass-isolated
47+
include:
48+
# MacOS
49+
- package: osx_dmg
50+
runs-on: macos-13
51+
arch: x64
52+
hadron-platform: darwin
53+
- package: osx_zip
54+
runs-on: macos-latest
55+
arch: arm64
56+
hadron-platform: darwin
57+
58+
# Windows
59+
- package: windows_zip
60+
runs-on: windows-latest
61+
arch: x64
62+
hadron-platform: windows
63+
- package: windows_msi
64+
runs-on: windows-latest
65+
arch: x64
66+
hadron-platform: windows
67+
- package: windows_setup
68+
runs-on: windows-latest
69+
arch: x64
70+
hadron-platform: windows
71+
72+
# Linux
73+
- package: linux_deb
74+
runs-on: ubuntu-latest
75+
arch: x64
76+
hadron-platform: linux
77+
# - package: linux_tar
78+
# runs-on: ubuntu-latest
79+
# arch: x64
80+
# hadron-platform: linux
81+
# - package: linux_rpm
82+
# runs-on: ubuntu-latest
83+
# arch: x64
84+
# hadron-platform: linux
85+
86+
# Install the update server for auto-update tests
87+
- test: auto-update-from
88+
install-update-server: true
89+
- test: auto-update-to
90+
install-update-server: true
91+
92+
exclude:
93+
# TODO: See https://github.com/mongodb-js/compass/actions/runs/13281152689/job/37079620322
94+
- package: osx_dmg
95+
test: auto-update-from
96+
# TODO: See https://github.com/mongodb-js/compass/actions/runs/13281152689/job/37079621700
97+
- package: windows_setup
98+
test: auto-update-from
99+
# Skip auto-update tests for isolated and readonly distributions for now
100+
# This is not supported by the update server we're using in the test harness
101+
- hadron-distribution: compass-isolated
102+
test: auto-update-from
103+
- hadron-distribution: compass-isolated
104+
test: auto-update-to
105+
- hadron-distribution: compass-readonly
106+
test: auto-update-from
107+
- hadron-distribution: compass-readonly
108+
test: auto-update-to
109+
# Temporary skip failing auto-update-to tests
110+
- test: auto-update-to
111+
package: osx_dmg
112+
- test: auto-update-to
113+
package: windows_zip
114+
- test: auto-update-to
115+
package: windows_msi
116+
- test: auto-update-to
117+
package: windows_setup
118+
- test: auto-update-to
119+
package: linux_deb
120+
121+
# Skip time-to-first-query tests for readonly because it doesn't have editable documents
122+
# See https://github.com/mongodb-js/compass/actions/runs/13286945911/job/37097791601
123+
- hadron-distribution: compass-readonly
124+
test: time-to-first-query
125+
126+
runs-on: ${{ matrix.runs-on }}
127+
env:
128+
DEBUG: compass:smoketests:*
26129
steps:
27130
- name: Checkout
28131
uses: actions/checkout@v2
@@ -31,6 +134,47 @@ jobs:
31134
with:
32135
node-version: 20
33136
cache: "npm"
34-
- name: Install dependencies
137+
- name: Cache downloads
138+
uses: actions/cache@v4
139+
with:
140+
key: smoke-tests-downloads-${{ inputs.version }}-${{ runner.os }}-${{ runner.arch }}-${{ matrix.package }}
141+
path: packages/compass-smoke-tests/.downloads
142+
- name: Install dependencies and build packages
35143
run: npm ci
36-
144+
- name: Bootstrap packages
145+
run: npx lerna run bootstrap --scope @mongodb-js/compass-smoke-tests --include-dependencies
146+
147+
- name: Create GitHub App Token
148+
if: matrix.install-update-server
149+
uses: actions/create-github-app-token@v1
150+
id: app-token
151+
with:
152+
app-id: ${{ vars.DEVTOOLS_BOT_APP_ID }}
153+
private-key: ${{ secrets.DEVTOOLS_BOT_PRIVATE_KEY }}
154+
owner: 10gen
155+
repositories: compass-mongodb-com
156+
- name: Checkout Compass Update server
157+
if: matrix.install-update-server
158+
uses: actions/checkout@v4
159+
with:
160+
repository: 10gen/compass-mongodb-com
161+
token: ${{ steps.app-token.outputs.token }}
162+
# Make sure the value of GITHUB_TOKEN will not be persisted in repo's config
163+
persist-credentials: false
164+
path: 'compass-mongodb-com'
165+
- name: Install Compass Update server
166+
if: matrix.install-update-server
167+
run: npm install --no-save --workspace packages/compass-smoke-tests ${{ github.workspace }}/compass-mongodb-com
168+
169+
- name: Run tests
170+
env:
171+
EVERGREEN_BUCKET_NAME: ${{ inputs.bucket_name }}
172+
EVERGREEN_BUCKET_KEY_PREFIX: ${{ inputs.bucket_key_prefix }}
173+
DEV_VERSION_IDENTIFIER: ${{ inputs.version }}
174+
HADRON_DISTRIBUTION: ${{ matrix.hadron-distribution }}
175+
PLATFORM: ${{ matrix.hadron-platform }}
176+
ARCH: ${{ matrix.arch }}
177+
# Exposing token to prevent update server from being rate limited
178+
GITHUB_TOKEN: ${{ github.token }}
179+
working-directory: packages/compass-smoke-tests
180+
run: npm start -- --package ${{ matrix.package }} --tests ${{ matrix.test }}

package-lock.json

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/compass-smoke-tests/.depcheckrc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,5 @@ ignores:
22
- '@mongodb-js/prettier-config-compass'
33
- '@mongodb-js/tsconfig-compass'
44
- compass-mongodb-com
5+
# Calling into the e2e tests via child processes
6+
- compass-e2e-tests

packages/compass-smoke-tests/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
"@mongodb-js/eslint-config-compass": "^1.3.1",
3535
"@mongodb-js/prettier-config-compass": "^1.2.1",
3636
"@mongodb-js/tsconfig-compass": "^1.2.1",
37+
"compass-e2e-tests": "^1.29.0",
3738
"depcheck": "^1.4.1",
3839
"debug": "^4.3.4",
3940
"eslint": "^7.25.0",

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

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import { SUPPORTED_PACKAGES } from './packages';
99
import { testTimeToFirstQuery } from './tests/time-to-first-query';
1010
import { testAutoUpdateFrom } from './tests/auto-update-from';
1111
import { testAutoUpdateTo } from './tests/auto-update-to';
12+
import { deleteSandboxesDirectory } from './directories';
1213

1314
const debug = createDebug('compass:smoketests');
1415

@@ -92,7 +93,7 @@ const argv = yargs(hideBin(process.argv))
9293
})
9394
.option('skipCleanup', {
9495
type: 'boolean',
95-
description: 'Do not delete the sandbox after a run',
96+
description: 'Do not delete the sandboxes after a run',
9697
default: false,
9798
})
9899
.option('tests', {
@@ -106,6 +107,27 @@ const argv = yargs(hideBin(process.argv))
106107
async function run() {
107108
const context: SmokeTestsContext = argv.parseSync();
108109

110+
function cleanupMaybe() {
111+
if (context.skipCleanup) {
112+
console.log('Skipped cleanup of sandboxes');
113+
} else {
114+
debug('Cleaning up sandboxes');
115+
try {
116+
deleteSandboxesDirectory();
117+
} catch (err) {
118+
if (err instanceof Error) {
119+
console.warn(`Failed cleaning sandboxes: ${err.message}`);
120+
} else {
121+
throw err;
122+
}
123+
}
124+
}
125+
}
126+
127+
process.once('SIGTERM', cleanupMaybe);
128+
process.once('SIGINT', cleanupMaybe);
129+
process.once('exit', cleanupMaybe);
130+
109131
debug(`Running tests`);
110132

111133
debug(

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

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,21 @@ import crypto from 'node:crypto';
33
import fs from 'node:fs';
44
import path from 'node:path';
55

6+
const SANDBOXES_PATH = path.resolve(__dirname, '../.sandboxes');
7+
8+
export function deleteSandboxesDirectory() {
9+
fs.rmSync(SANDBOXES_PATH, { recursive: true, force: true });
10+
}
11+
12+
export function sandboxesDirectoryExists() {
13+
return fs.existsSync(SANDBOXES_PATH);
14+
}
15+
616
function ensureSandboxesDirectory() {
7-
const sandboxesPath = path.resolve(__dirname, '../.sandboxes');
8-
if (!fs.existsSync(sandboxesPath)) {
9-
fs.mkdirSync(sandboxesPath, { recursive: true });
17+
if (!sandboxesDirectoryExists()) {
18+
fs.mkdirSync(SANDBOXES_PATH, { recursive: true });
1019
}
11-
return sandboxesPath;
20+
return SANDBOXES_PATH;
1221
}
1322

1423
export function createSandbox() {

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ export async function downloadFile({
1919
targetFilename,
2020
clearCache,
2121
}: DownloadFileOptions): Promise<string> {
22+
debug('Fetching', { url });
2223
const response = await fetch(url);
2324

2425
assert(
@@ -40,7 +41,7 @@ export async function downloadFile({
4041
if (clearCache) {
4142
fs.rmSync(cacheDirectoryPath, { recursive: true, force: true });
4243
} else {
43-
debug('Skipped downloading', url, '(cache existed)');
44+
debug('Skipped downloading (cache existed)', { url });
4445
return outputPath;
4546
}
4647
}
@@ -51,11 +52,11 @@ export async function downloadFile({
5152

5253
// Write the response to file
5354
assert(response.body, 'Expected a response body');
54-
debug('Downloading', url);
55+
debug('Downloading', { url, outputPath });
5556
await stream.promises.pipeline(
5657
response.body,
5758
fs.createWriteStream(outputPath)
5859
);
59-
60+
debug('Download completed', { url, outputPath });
6061
return outputPath;
6162
}

packages/compass-smoke-tests/src/installers/linux-deb.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
import assert from 'node:assert/strict';
22
import fs from 'node:fs';
33
import path from 'node:path';
4+
import createDebug from 'debug';
45

56
import type { InstalledAppInfo, InstallablePackage } from './types';
67
import { execute } from '../execute';
78
import * as apt from './apt';
89

10+
const debug = createDebug('compass:smoketests:linux-deb');
11+
912
export function installLinuxDeb({
1013
kind,
1114
filepath,
@@ -18,6 +21,7 @@ export function installLinuxDeb({
1821
const appPath = path.resolve(installPath, appName);
1922

2023
function uninstall() {
24+
debug('Uninstalling %s', filepath);
2125
execute('sudo', ['apt', 'remove', '--yes', '--purge', packageName]);
2226
}
2327

packages/compass-smoke-tests/src/installers/linux-rpm.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,13 @@ import assert from 'node:assert/strict';
22
import cp from 'node:child_process';
33
import path from 'node:path';
44
import fs from 'node:fs';
5+
import createDebug from 'debug';
56

67
import type { InstalledAppInfo, InstallablePackage } from './types';
78
import { execute } from '../execute';
9+
10+
const debug = createDebug('compass:smoketests:linux-rpm');
11+
812
/**
913
* Call dnf to get the package name
1014
*/
@@ -48,6 +52,7 @@ export function installLinuxRpm({
4852
const appPath = path.resolve(installPath, appName);
4953

5054
function uninstall() {
55+
debug('Uninstalling %s', filepath);
5156
execute('sudo', ['dnf', 'remove', '-y', packageName]);
5257
}
5358

packages/compass-smoke-tests/src/installers/windows-msi.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ export function installWindowsMSI({
2121
const appPath = path.resolve(installDirectory, `${appName}.exe`);
2222

2323
function uninstall() {
24+
debug('Uninstalling %s', filepath);
2425
execute('msiexec', ['/uninstall', filepath, '/passive']);
2526
}
2627

0 commit comments

Comments
 (0)