Skip to content

Commit a6c7ab4

Browse files
authored
fix(ci): add a bump packages step to draft and publish tasks (#2339)
We did not have a bump for packages for draft builds and publishing which would lead to mongosh version discrepancies.
1 parent cc7bef6 commit a6c7ab4

File tree

8 files changed

+104
-35
lines changed

8 files changed

+104
-35
lines changed

packages/build/src/npm-packages/bump.spec.ts

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,16 +25,14 @@ describe('npm-packages bump', function () {
2525
});
2626

2727
describe('bumpMongoshReleasePackages', function () {
28-
it('throws if MONGOSH_RELEASE_VERSION is not set', async function () {
29-
process.env.MONGOSH_RELEASE_VERSION = '';
30-
28+
it('throws if version is not set', async function () {
3129
try {
32-
await bumpMongoshReleasePackages();
30+
await bumpMongoshReleasePackages('');
3331
expect.fail('did not error');
3432
} catch (error) {
3533
expect(error).instanceOf(Error);
3634
expect((error as Error).message).equals(
37-
'MONGOSH_RELEASE_VERSION version not specified during mongosh bump'
35+
'version not specified during mongosh bump'
3836
);
3937
}
4038
});
@@ -51,7 +49,6 @@ describe('npm-packages bump', function () {
5149

5250
expect(fsWriteFile).calledWith(
5351
path.join(
54-
__dirname,
5552
PROJECT_ROOT,
5653
'packages',
5754
'shell-api',

packages/build/src/npm-packages/bump.ts

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,14 @@ import path from 'path';
1010
import { getPackagesInTopologicalOrder } from '@mongodb-js/monorepo-tools';
1111

1212
/** Bumps only the main mongosh release packages to the set version. */
13-
export async function bumpMongoshReleasePackages(): Promise<void> {
14-
const version = process.env.MONGOSH_RELEASE_VERSION;
13+
export async function bumpMongoshReleasePackages(
14+
version: string
15+
): Promise<void> {
1516
if (!version) {
16-
throw new Error(
17-
'MONGOSH_RELEASE_VERSION version not specified during mongosh bump'
18-
);
17+
throw new Error('version not specified during mongosh bump');
1918
}
20-
console.info(`mongosh: Bumping package versions to ${version}`);
19+
20+
console.info(`mongosh: Bumping mongosh release packages to ${version}`);
2121
const monorepoRootPath = path.resolve(__dirname, '..', '..', '..', '..');
2222
const packages = await getPackagesInTopologicalOrder(monorepoRootPath);
2323

@@ -62,7 +62,6 @@ export async function bumpMongoshReleasePackages(): Promise<void> {
6262
/** Updates the shell-api constant to match the mongosh version. */
6363
export async function updateShellApiMongoshVersion(version: string) {
6464
const shellApiVersionFilePath = path.join(
65-
__dirname,
6665
PROJECT_ROOT,
6766
'packages',
6867
'shell-api',
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
export { bumpAuxiliaryPackages } from './bump';
1+
export { bumpAuxiliaryPackages, bumpMongoshReleasePackages } from './bump';
22
export { publishToNpm } from './publish';
33
export { pushTags } from './push-tags';

packages/build/src/publish-mongosh.spec.ts

Lines changed: 60 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,17 @@ import type {
99
import type { createAndPublishDownloadCenterConfig as createAndPublishDownloadCenterConfigFn } from './download-center';
1010
import { GithubRepo } from '@mongodb-js/devtools-github-repo';
1111
import type { publishToHomebrew as publishToHomebrewType } from './homebrew';
12+
import {
13+
type publishToNpm as publishToNpmType,
14+
type pushTags as pushTagsType,
15+
} from './npm-packages';
1216
import type {
13-
publishToNpm as publishToNpmType,
14-
pushTags as pushTagsType,
17+
bumpMongoshReleasePackages as bumpMongoshReleasePackagesFn,
18+
bumpAuxiliaryPackages as bumpAuxiliaryPackagesFn,
1519
} from './npm-packages';
1620
import { publishMongosh } from './publish-mongosh';
1721
import { dummyConfig } from '../test/helpers';
22+
import { getArtifactUrl } from './evergreen';
1823

1924
chai.use(require('sinon-chai'));
2025

@@ -36,11 +41,14 @@ describe('publishMongosh', function () {
3641
let writeBuildInfo: typeof writeBuildInfoType;
3742
let publishToHomebrew: typeof publishToHomebrewType;
3843
let shouldDoPublicRelease: typeof shouldDoPublicReleaseFn;
44+
let bumpMongoshReleasePackages: typeof bumpMongoshReleasePackagesFn;
45+
let bumpAuxiliaryPackages: typeof bumpAuxiliaryPackagesFn;
3946
let githubRepo: GithubRepo;
4047
let mongoHomebrewCoreForkRepo: GithubRepo;
4148
let homebrewCoreRepo: GithubRepo;
4249
let barque: Barque;
4350
let pushTags: typeof pushTagsType;
51+
const getEvergreenArtifactUrl = getArtifactUrl;
4452

4553
beforeEach(function () {
4654
config = { ...dummyConfig };
@@ -51,6 +59,8 @@ describe('publishMongosh', function () {
5159
publishToHomebrew = sinon.spy();
5260
shouldDoPublicRelease = sinon.spy();
5361
pushTags = sinon.spy();
62+
bumpMongoshReleasePackages = sinon.spy();
63+
bumpAuxiliaryPackages = sinon.spy();
5464

5565
githubRepo = createStubRepo();
5666
mongoHomebrewCoreForkRepo = createStubRepo();
@@ -95,7 +105,10 @@ describe('publishMongosh', function () {
95105
pushTags,
96106
writeBuildInfo,
97107
publishToHomebrew,
98-
shouldDoPublicRelease
108+
shouldDoPublicRelease,
109+
getEvergreenArtifactUrl,
110+
bumpMongoshReleasePackages,
111+
bumpAuxiliaryPackages
99112
);
100113
} catch (e: any) {
101114
return expect(e.message).to.contain('Could not find prior draft tag');
@@ -121,7 +134,10 @@ describe('publishMongosh', function () {
121134
pushTags,
122135
writeBuildInfo,
123136
publishToHomebrew,
124-
shouldDoPublicRelease
137+
shouldDoPublicRelease,
138+
getEvergreenArtifactUrl,
139+
bumpMongoshReleasePackages,
140+
bumpAuxiliaryPackages
125141
);
126142
} catch (e: any) {
127143
return expect(e.message).to.contain('Version mismatch');
@@ -142,7 +158,10 @@ describe('publishMongosh', function () {
142158
pushTags,
143159
writeBuildInfo,
144160
publishToHomebrew,
145-
shouldDoPublicRelease
161+
shouldDoPublicRelease,
162+
getEvergreenArtifactUrl,
163+
bumpMongoshReleasePackages,
164+
bumpAuxiliaryPackages
146165
);
147166

148167
expect(barque.releaseToBarque).to.have.been.callCount(26);
@@ -173,7 +192,10 @@ describe('publishMongosh', function () {
173192
pushTags,
174193
writeBuildInfo,
175194
publishToHomebrew,
176-
shouldDoPublicRelease
195+
shouldDoPublicRelease,
196+
getEvergreenArtifactUrl,
197+
bumpMongoshReleasePackages,
198+
bumpAuxiliaryPackages
177199
);
178200

179201
expect(createAndPublishDownloadCenterConfig).to.have.been.calledWith(
@@ -196,7 +218,10 @@ describe('publishMongosh', function () {
196218
pushTags,
197219
writeBuildInfo,
198220
publishToHomebrew,
199-
shouldDoPublicRelease
221+
shouldDoPublicRelease,
222+
getEvergreenArtifactUrl,
223+
bumpMongoshReleasePackages,
224+
bumpAuxiliaryPackages
200225
);
201226

202227
expect(githubRepo.promoteRelease).to.have.been.calledWith(config);
@@ -214,7 +239,10 @@ describe('publishMongosh', function () {
214239
pushTags,
215240
writeBuildInfo,
216241
publishToHomebrew,
217-
shouldDoPublicRelease
242+
shouldDoPublicRelease,
243+
getEvergreenArtifactUrl,
244+
bumpMongoshReleasePackages,
245+
bumpAuxiliaryPackages
218246
);
219247

220248
expect(writeBuildInfo).to.have.been.calledOnceWith(config);
@@ -233,7 +261,10 @@ describe('publishMongosh', function () {
233261
pushTags,
234262
writeBuildInfo,
235263
publishToHomebrew,
236-
shouldDoPublicRelease
264+
shouldDoPublicRelease,
265+
getEvergreenArtifactUrl,
266+
bumpMongoshReleasePackages,
267+
bumpAuxiliaryPackages
237268
);
238269

239270
expect(publishToHomebrew).to.have.been.calledWith(
@@ -264,7 +295,10 @@ describe('publishMongosh', function () {
264295
pushTags,
265296
writeBuildInfo,
266297
publishToHomebrew,
267-
shouldDoPublicRelease
298+
shouldDoPublicRelease,
299+
getEvergreenArtifactUrl,
300+
bumpMongoshReleasePackages,
301+
bumpAuxiliaryPackages
268302
);
269303

270304
expect(createAndPublishDownloadCenterConfig).not.to.have.been.called;
@@ -282,7 +316,10 @@ describe('publishMongosh', function () {
282316
pushTags,
283317
writeBuildInfo,
284318
publishToHomebrew,
285-
shouldDoPublicRelease
319+
shouldDoPublicRelease,
320+
getEvergreenArtifactUrl,
321+
bumpMongoshReleasePackages,
322+
bumpAuxiliaryPackages
286323
);
287324

288325
expect(githubRepo.promoteRelease).not.to.have.been.called;
@@ -300,7 +337,10 @@ describe('publishMongosh', function () {
300337
pushTags,
301338
writeBuildInfo,
302339
publishToHomebrew,
303-
shouldDoPublicRelease
340+
shouldDoPublicRelease,
341+
getEvergreenArtifactUrl,
342+
bumpMongoshReleasePackages,
343+
bumpAuxiliaryPackages
304344
);
305345

306346
expect(publishToNpm).not.to.have.been.called;
@@ -318,7 +358,10 @@ describe('publishMongosh', function () {
318358
pushTags,
319359
writeBuildInfo,
320360
publishToHomebrew,
321-
shouldDoPublicRelease
361+
shouldDoPublicRelease,
362+
getEvergreenArtifactUrl,
363+
bumpMongoshReleasePackages,
364+
bumpAuxiliaryPackages
322365
);
323366

324367
expect(publishToHomebrew).not.to.have.been.called;
@@ -336,7 +379,10 @@ describe('publishMongosh', function () {
336379
pushTags,
337380
writeBuildInfo,
338381
publishToHomebrew,
339-
shouldDoPublicRelease
382+
shouldDoPublicRelease,
383+
getEvergreenArtifactUrl,
384+
bumpMongoshReleasePackages,
385+
bumpAuxiliaryPackages
340386
);
341387

342388
expect(barque.releaseToBarque).not.to.have.been.called;

packages/build/src/publish-mongosh.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@ import type { pushTags as pushTagsType } from './npm-packages';
1414
import { type publishToNpm as publishToNpmType } from './npm-packages';
1515
import type { PackageInformationProvider } from './packaging';
1616
import { getPackageFile } from './packaging';
17+
import {
18+
bumpMongoshReleasePackages as bumpMongoshReleasePackagesFn,
19+
bumpAuxiliaryPackages as bumpAuxiliaryPackagesFn,
20+
} from './npm-packages';
1721

1822
export async function publishMongosh(
1923
config: Config,
@@ -27,7 +31,9 @@ export async function publishMongosh(
2731
writeBuildInfo: typeof writeBuildInfoType,
2832
publishToHomebrew: typeof publishToHomebrewType,
2933
shouldDoPublicRelease: typeof shouldDoPublicReleaseFn = shouldDoPublicReleaseFn,
30-
getEvergreenArtifactUrl: typeof getArtifactUrlFn = getArtifactUrlFn
34+
getEvergreenArtifactUrl: typeof getArtifactUrlFn = getArtifactUrlFn,
35+
bumpMongoshReleasePackages: typeof bumpMongoshReleasePackagesFn = bumpMongoshReleasePackagesFn,
36+
bumpAuxiliaryPackages: typeof bumpAuxiliaryPackagesFn = bumpAuxiliaryPackagesFn
3137
): Promise<void> {
3238
if (!shouldDoPublicRelease(config)) {
3339
console.warn(
@@ -59,6 +65,9 @@ export async function publishMongosh(
5965
latestDraftTag.name
6066
);
6167

68+
bumpAuxiliaryPackages();
69+
await bumpMongoshReleasePackages(releaseVersion);
70+
6271
await publishArtifactsToBarque(
6372
barque,
6473
config.project as string,

packages/build/src/release.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ export async function release(
5959
if (command === 'bump') {
6060
bumpAuxiliaryPackages();
6161
if (!config.useAuxiliaryPackagesOnly) {
62-
await bumpMongoshReleasePackages();
62+
await bumpMongoshReleasePackages(config.version);
6363
}
6464
return;
6565
}

packages/build/src/run-draft.spec.ts

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ describe('draft', function () {
3737
});
3838

3939
describe('runDraft', function () {
40+
const bumpMongoshReleasePackages = sinon.spy();
41+
const bumpMongoshAuxiliaryPackages = sinon.spy();
4042
let ensureGithubReleaseExistsAndUpdateChangelog: typeof ensureGithubReleaseExistsAndUpdateChangelogFn;
4143

4244
beforeEach(function () {
@@ -58,7 +60,9 @@ describe('draft', function () {
5860
githubRepo,
5961
uploadArtifactToDownloadCenter,
6062
downloadArtifactFromEvergreen,
61-
ensureGithubReleaseExistsAndUpdateChangelog
63+
ensureGithubReleaseExistsAndUpdateChangelog,
64+
bumpMongoshReleasePackages,
65+
bumpMongoshAuxiliaryPackages
6266
);
6367
});
6468

@@ -102,7 +106,9 @@ describe('draft', function () {
102106
githubRepo,
103107
uploadArtifactToDownloadCenter,
104108
downloadArtifactFromEvergreen,
105-
ensureGithubReleaseExistsAndUpdateChangelog
109+
ensureGithubReleaseExistsAndUpdateChangelog,
110+
bumpMongoshReleasePackages,
111+
bumpMongoshAuxiliaryPackages
106112
);
107113
expect(ensureGithubReleaseExistsAndUpdateChangelog).to.not.have.been
108114
.called;
@@ -125,7 +131,9 @@ describe('draft', function () {
125131
githubRepo,
126132
uploadArtifactToDownloadCenter,
127133
downloadArtifactFromEvergreen,
128-
ensureGithubReleaseExistsAndUpdateChangelog
134+
ensureGithubReleaseExistsAndUpdateChangelog,
135+
bumpMongoshReleasePackages,
136+
bumpMongoshAuxiliaryPackages
129137
);
130138
} catch (e: any) {
131139
expect(e.message).to.contain('Missing package information from config');

packages/build/src/run-draft.ts

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,23 @@ import { downloadArtifactFromEvergreen as downloadArtifactFromEvergreenFn } from
77
import { generateChangelog as generateChangelogFn } from './git';
88
import type { GithubRepo } from '@mongodb-js/devtools-github-repo';
99
import { getPackageFile } from './packaging';
10+
import {
11+
bumpAuxiliaryPackages as bumpAuxiliaryPackagesFn,
12+
bumpMongoshReleasePackages as bumpMongoshReleasePackagesFn,
13+
} from './npm-packages/bump';
1014

1115
export async function runDraft(
1216
config: Config,
1317
githubRepo: GithubRepo,
1418
uploadToDownloadCenter: typeof uploadArtifactToDownloadCenterFn = uploadArtifactToDownloadCenterFn,
1519
downloadArtifactFromEvergreen: typeof downloadArtifactFromEvergreenFn = downloadArtifactFromEvergreenFn,
16-
ensureGithubReleaseExistsAndUpdateChangelog: typeof ensureGithubReleaseExistsAndUpdateChangelogFn = ensureGithubReleaseExistsAndUpdateChangelogFn
20+
ensureGithubReleaseExistsAndUpdateChangelog: typeof ensureGithubReleaseExistsAndUpdateChangelogFn = ensureGithubReleaseExistsAndUpdateChangelogFn,
21+
bumpMongoshReleasePackages: typeof bumpMongoshReleasePackagesFn = bumpMongoshReleasePackagesFn,
22+
bumpAuxiliaryPackages: typeof bumpAuxiliaryPackagesFn = bumpAuxiliaryPackagesFn
1723
): Promise<void> {
1824
const { triggeringGitTag } = config;
19-
if (!triggeringGitTag || !getReleaseVersionFromTag(triggeringGitTag)) {
25+
const draftReleaseVersion = getReleaseVersionFromTag(triggeringGitTag);
26+
if (!triggeringGitTag || !draftReleaseVersion) {
2027
console.error(
2128
'mongosh: skipping draft as not triggered by a git tag that matches a draft/release tag'
2229
);
@@ -44,6 +51,9 @@ export async function runDraft(
4451
);
4552
await fs.mkdir(tmpDir, { recursive: true });
4653

54+
bumpAuxiliaryPackages();
55+
await bumpMongoshReleasePackages(draftReleaseVersion);
56+
4757
for await (const variant of ALL_PACKAGE_VARIANTS) {
4858
const tarballFile = getPackageFile(variant, config.packageInformation);
4959
console.info(

0 commit comments

Comments
 (0)