Skip to content

Commit 4d4de5a

Browse files
committed
add basic bump tests, update evergreen config, and review fixes
1 parent bb111a5 commit 4d4de5a

File tree

5 files changed

+76
-7
lines changed

5 files changed

+76
-7
lines changed

.evergreen.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4274,6 +4274,8 @@ functions:
42744274
source .evergreen/setup-env.sh
42754275
export PUPPETEER_SKIP_DOWNLOAD="true"
42764276
npm run evergreen-release draft
4277+
git add .
4278+
git commit --no-allow-empty -m "chore(release): bump to prepare for mongosh release"
42774279
}
42784280
42794281
release_publish_download_and_list_artifacts:

.github/workflows/bump-auxiliary-packages.yml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,10 @@ jobs:
3737
npm ci
3838
3939
- name: Bump packages
40-
env:
41-
LAST_BUMP_COMMIT_MESSAGE: "chore(release): bump auxiliary packages"
4240
run: |
4341
npm run bump-auxiliary
4442
git add .
45-
git commit --no-allow-empty -m "$LAST_BUMP_COMMIT_MESSAGE" || true
43+
git commit --no-allow-empty -m "chore(release): bump auxiliary packages" || true
4644
4745
- name: Create Pull Request
4846
uses: peter-evans/create-pull-request@5e914681df9dc83aa4e4905692ca88beb2f9e91f # 7.0.5

.github/workflows/publish-auxiliary-packages.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313
publish:
1414
if: |
1515
github.event_name == 'workflow_dispatch' ||
16-
startsWith(github.event.head_commit.message, 'chore(release): bump auxiliary package versions')
16+
startsWith(github.event.head_commit.message, 'chore(release): bump auxiliary packages')
1717
1818
runs-on: ubuntu-latest
1919

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
import { expect } from 'chai';
2+
import type { SinonStub } from 'sinon';
3+
import sinon from 'sinon';
4+
import {
5+
bumpMongoshReleasePackages,
6+
updateShellApiMongoshVersion,
7+
} from './bump';
8+
import { promises as fs } from 'fs';
9+
import path from 'path';
10+
import { PROJECT_ROOT } from './constants';
11+
import * as monorepoTools from '@mongodb-js/monorepo-tools';
12+
13+
describe('npm-packages bump', function () {
14+
let fsReadFile: SinonStub;
15+
let fsWriteFile: SinonStub;
16+
17+
beforeEach(function () {
18+
fsReadFile = sinon.stub(fs, 'readFile');
19+
20+
fsWriteFile = sinon.stub(fs, 'writeFile');
21+
fsWriteFile.resolves();
22+
});
23+
24+
afterEach(function () {
25+
sinon.restore();
26+
});
27+
28+
describe('bumpMongoshReleasePackages', function () {
29+
it('throws if MONGOSH_RELEASE_VERSION is not set', async function () {
30+
process.env.MONGOSH_RELEASE_VERSION = '';
31+
32+
try {
33+
await bumpMongoshReleasePackages();
34+
expect.fail('did not error');
35+
} catch (error) {
36+
expect(error).instanceOf(Error);
37+
expect((error as Error).message).equals(
38+
'MONGOSH_RELEASE_VERSION version not specified during mongosh bump'
39+
);
40+
}
41+
});
42+
});
43+
44+
describe('updateShellApiMongoshVersion', function () {
45+
it('updates the file to the set version', async function () {
46+
fsReadFile.resolves(`
47+
/** Current mongosh cli-repl version. */
48+
export const MONGOSH_VERSION = '2.3.8';`);
49+
50+
const newVersion = '3.0.0';
51+
await updateShellApiMongoshVersion(newVersion);
52+
53+
expect(fsWriteFile).calledWith(
54+
path.join(
55+
__dirname,
56+
PROJECT_ROOT,
57+
'packages',
58+
'shell-api',
59+
'src',
60+
'mongosh-version.ts'
61+
),
62+
`
63+
/** Current mongosh cli-repl version. */
64+
export const MONGOSH_VERSION = '${newVersion}';`,
65+
'utf-8'
66+
);
67+
});
68+
});
69+
});

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,11 +56,11 @@ export async function bumpMongoshReleasePackages(): Promise<void> {
5656
);
5757
}
5858

59-
await bumpShellApiMongoshVersion(version);
59+
await updateShellApiMongoshVersion(version);
6060
}
6161

62-
/** Sets the shell-api constant to match the mongosh version. */
63-
export async function bumpShellApiMongoshVersion(version: string) {
62+
/** Updates the shell-api constant to match the mongosh version. */
63+
export async function updateShellApiMongoshVersion(version: string) {
6464
const shellApiVersionFilePath = path.join(
6565
__dirname,
6666
PROJECT_ROOT,

0 commit comments

Comments
 (0)