Skip to content

Commit 24c1462

Browse files
committed
Use hadron build info to determine the version
1 parent 8d10c17 commit 24c1462

File tree

2 files changed

+38
-21
lines changed

2 files changed

+38
-21
lines changed

packages/compass-smoke-tests/src/build-info.ts

Lines changed: 34 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,16 @@ import assert from 'node:assert/strict';
22
import fs from 'node:fs';
33
import path from 'node:path';
44
import createDebug from 'debug';
5+
import { pick } from 'lodash';
56

67
import { handler as writeBuildInfo } from 'hadron-build/commands/info';
78

89
import { type PackageKind } from './packages';
910
import { type SmokeTestsContextWithSandbox } from './context';
10-
import { pick } from 'lodash';
11+
import { createSandbox } from './directories';
1112

1213
const debug = createDebug('compass:smoketests:build-info');
14+
const COMPASS_PATH = path.resolve(__dirname, '../../compass');
1315

1416
const SUPPORTED_CHANNELS = ['dev', 'beta', 'stable'] as const;
1517

@@ -229,16 +231,18 @@ export function readPackageDetails(
229231
return getPackageDetails(kind, result);
230232
}
231233

232-
export function writeAndReadPackageDetails(
233-
context: SmokeTestsContextWithSandbox
234-
): PackageDetails {
235-
const compassDir = path.resolve(__dirname, '../../compass');
234+
export function writeAndReadPackageDetails({
235+
package: packageKind,
236+
platform,
237+
arch,
238+
sandboxPath,
239+
}: SmokeTestsContextWithSandbox): PackageDetails {
236240
const infoArgs = {
237241
format: 'json',
238-
dir: compassDir,
239-
platform: context.platform,
240-
arch: context.arch,
241-
out: path.resolve(context.sandboxPath, 'target.json'),
242+
dir: COMPASS_PATH,
243+
platform,
244+
arch,
245+
out: path.resolve(sandboxPath, 'target.json'),
242246
};
243247
debug({ infoArgs });
244248

@@ -258,5 +262,25 @@ export function writeAndReadPackageDetails(
258262
])
259263
);
260264
writeBuildInfo(infoArgs);
261-
return readPackageDetails(context.package, infoArgs.out);
265+
return readPackageDetails(packageKind, infoArgs.out);
266+
}
267+
268+
export function getCompassVersionFromBuildInfo(): string {
269+
const out = path.resolve(createSandbox(), 'target.json');
270+
writeBuildInfo({
271+
format: 'json',
272+
dir: COMPASS_PATH,
273+
platform: 'linux',
274+
arch: 'x64',
275+
out,
276+
});
277+
const result = readJson(out);
278+
assert(typeof result === 'object', 'Expected hadron to write an object');
279+
assert(
280+
'version' in result,
281+
'Expected hadron to write an object with a version'
282+
);
283+
const { version } = result;
284+
assert(typeof version === 'string', 'Expected version to be a string');
285+
return version;
262286
}

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

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import { testAutoUpdateFrom } from './tests/auto-update-from';
1414
import { testAutoUpdateTo } from './tests/auto-update-to';
1515
import { deleteSandboxesDirectory } from './directories';
1616
import { dispatchAndWait, getRefFromGithubPr } from './dispatch';
17+
import { getCompassVersionFromBuildInfo } from './build-info';
1718

1819
const debug = createDebug('compass:smoketests');
1920

@@ -143,26 +144,18 @@ yargs(hideBin(process.argv))
143144
type: 'string',
144145
description: 'Git reference to dispatch the workflow from',
145146
default: getDefaultRef(),
146-
})
147-
.option('version', {
148-
type: 'string',
149-
description: 'Compass version to run tests for',
150-
default: process.env.DEV_VERSION_IDENTIFIER,
151147
}),
152-
async ({ version, bucketName, bucketKeyPrefix, ref, githubPrNumber }) => {
148+
async ({ bucketName, bucketKeyPrefix, ref, githubPrNumber }) => {
153149
const { GITHUB_TOKEN } = process.env;
154150
assert(
155151
typeof GITHUB_TOKEN === 'string',
156152
'Expected a GITHUB_TOKEN environment variable'
157153
);
158-
assert(
159-
typeof version === 'string',
160-
'Expected a version to dispatch tests for'
161-
);
162154
assert(
163155
typeof bucketName === 'string' && typeof bucketKeyPrefix === 'string',
164156
'Bucket name and key prefix are needed to download'
165157
);
158+
166159
await dispatchAndWait({
167160
githubToken: GITHUB_TOKEN,
168161
ref:
@@ -172,7 +165,7 @@ yargs(hideBin(process.argv))
172165
githubPrNumber,
173166
})
174167
: ref,
175-
version,
168+
version: getCompassVersionFromBuildInfo(),
176169
bucketName,
177170
bucketKeyPrefix,
178171
});

0 commit comments

Comments
 (0)