Skip to content

Commit d1688c3

Browse files
authored
feat(ci): split compilation and packaging up MONGOSH-469 (#536)
- Split the `compile_and_upload_artifact` evergreen functions/tasks into two steps, named `compile_artifact` and `package_and_upload_artifact`. The former only compiles the binary, the latter creates the tarball/pkg/deb/zip from it and uploads it to S3. - On the build package level, the latter is also subdivided into creating the tarball and uploading it. This makes it easier to perform local testing, and replaces the “dry run” mode that we previously had. - Run the different tasks on appropriate machines: - On Windows and Linux, the build steps are moved to separate, more powerful machines that are intended for compilation steps. All other tasks remain on the same hosts. For Linux, this means compiling the executable once and packaging it three times, rather than compiling it three different times as well, and faster compilation times overall. - On macOS, the packaging step is kept on the codesign machine, while building takes place on regular macOS hosts. This helps us be nice to other evergreen consumers, because it reduces the amount of time that we’re hogging the single codesign host that evergreen provides. - In order to move executables from the compilation to the packaging steps, store them temporarily in S3 using evergreen’s built-in storage mechanism.
1 parent 837eb06 commit d1688c3

16 files changed

+231
-154
lines changed

.evergreen.yml

Lines changed: 143 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,15 @@ exec_timeout_secs: 7200
22

33
# Variables for common functions.
44
#
5-
# compile_and_upload_artifact: Runs the exec compile and release process.
5+
# compile_artifact: Compile the mongosh executable.
6+
# package_and_upload_artifact: Package the executable and upload the artifacts.
67
variables:
7-
- &compile_and_upload_artifact
8+
- &compile_artifact
89
command: shell.exec
910
params:
1011
working_dir: src
1112
shell: bash
1213
script: |
13-
set -e
14-
cat <<RELEASE_MONGOSH > ~/release_mongosh.sh
1514
set -e
1615
cd $(pwd)
1716
export NODE_JS_VERSION=${node_js_version}
@@ -27,31 +26,60 @@ variables:
2726
-e NODE_JS_VERSION \
2827
-e BUILD_VARIANT \
2928
--rm -v $PWD:/tmp/build --network host centos7-build \
30-
-c 'source /opt/rh/devtoolset-8/enable && cd /tmp/build && npm run evergreen-release package && dist/mongosh --version'
29+
-c 'source /opt/rh/devtoolset-8/enable && cd /tmp/build && npm run evergreen-release compile && dist/mongosh --version'
30+
else
31+
npm run evergreen-release compile
32+
fi
33+
dist/mongosh --version
34+
source .evergreen/.setup_env
35+
export MONGOSH_TEST_EXECUTABLE_PATH="$(pwd)/dist/mongosh"
36+
if [ x"$OS" == x"Windows_NT" ]; then
37+
export MONGOSH_TEST_EXECUTABLE_PATH="$(cygpath -w "$MONGOSH_TEST_EXECUTABLE_PATH")"
38+
fi
39+
echo "$MONGOSH_TEST_EXECUTABLE_PATH"
40+
npm run test-e2e-ci
41+
tar cvzf dist.tgz dist
42+
43+
- &package_and_upload_artifact
44+
command: shell.exec
45+
params:
46+
working_dir: src
47+
shell: bash
48+
script: |
49+
set -e
50+
cat <<RELEASE_MONGOSH > ~/release_mongosh.sh
51+
set -e
52+
cd $(pwd)
53+
export NODE_JS_VERSION=${node_js_version}
54+
source .evergreen/.setup_env
55+
tar xvzf dist.tgz
56+
dist/mongosh --version
57+
if [ `uname` == Linux ]; then
58+
mkdir -p tmp
59+
cp "$(pwd)/../tmp/expansions.yaml" tmp/expansions.yaml
60+
(cd scripts/docker && docker build -t centos7-package -f centos7-package.Dockerfile .)
61+
echo Starting Docker container packaging
62+
docker run -e PUPPETEER_SKIP_CHROMIUM_DOWNLOAD \
63+
-e EVERGREEN_EXPANSIONS_PATH=/tmp/build/tmp/expansions.yaml \
64+
-e NODE_JS_VERSION \
65+
-e BUILD_VARIANT \
66+
--rm -v $PWD:/tmp/build --network host centos7-package \
67+
-c 'cd /tmp/build && npm run evergreen-release package && npm run evergreen-release upload'
3168
else
3269
npm run evergreen-release package
3370
if [ `uname` == Darwin ]; then
3471
# Verify signing
3572
spctl -a -vvv -t install dist/mongosh
3673
fi
74+
npm run evergreen-release upload
3775
fi
3876
RELEASE_MONGOSH
39-
4077
if [ `uname` == Darwin ]; then
4178
ssh -v -p 2222 localhost "bash ~/release_mongosh.sh"
4279
else
4380
bash ~/release_mongosh.sh
4481
fi
4582
46-
export NODE_JS_VERSION=${node_js_version}
47-
source .evergreen/.setup_env
48-
export MONGOSH_TEST_EXECUTABLE_PATH="$(pwd)/dist/mongosh"
49-
if [ x"$OS" == x"Windows_NT" ]; then
50-
export MONGOSH_TEST_EXECUTABLE_PATH="$(cygpath -w "$MONGOSH_TEST_EXECUTABLE_PATH")"
51-
fi
52-
echo "$MONGOSH_TEST_EXECUTABLE_PATH"
53-
npm run test-e2e-ci
54-
5583
- &test_linux_artifact
5684
command: shell.exec
5785
params:
@@ -76,7 +104,8 @@ variables:
76104
# test - Runs all tests.
77105
# test_vscode - Clones the vscode extension repository and runs its tests.
78106
# test_connectivity - Runs extra connectivity tests.
79-
# compile_and_upload_artifact - Compile the release binary and upload it to S3.
107+
# compile_artifact - Compile the release binary.
108+
# package_and_upload_artifact - Upload the release binary to S3.
80109
# test_linux_artifact - Test that the built artifact works where we expect it to.
81110
# We use this to verify that e.g. the Ubuntu-built release
82111
# binary also works on RHEL and Debian.
@@ -142,12 +171,34 @@ functions:
142171
export NODE_JS_VERSION=${node_js_version}
143172
source .evergreen/.setup_env
144173
npm run test-connectivity
145-
compile_and_upload_artifact:
174+
compile_artifact:
175+
- command: expansions.write
176+
params:
177+
file: tmp/expansions.yaml
178+
redacted: true
179+
- <<: *compile_artifact
180+
- command: s3.put
181+
params:
182+
aws_key: ${aws_key}
183+
aws_secret: ${aws_secret}
184+
local_file: src/dist.tgz
185+
remote_file: mongosh/binaries/${revision}/${revision_order_id}/mongosh-${executable_os_id}.tgz
186+
bucket: mciuploads
187+
permissions: public-read
188+
content_type: application/x-gzip
189+
package_and_upload_artifact:
146190
- command: expansions.write
147191
params:
148192
file: tmp/expansions.yaml
149193
redacted: true
150-
- <<: *compile_and_upload_artifact
194+
- command: s3.get
195+
params:
196+
aws_key: ${aws_key}
197+
aws_secret: ${aws_secret}
198+
local_file: src/dist.tgz
199+
remote_file: mongosh/binaries/${revision}/${revision_order_id}/mongosh-${executable_os_id}.tgz
200+
bucket: mciuploads
201+
- <<: *package_and_upload_artifact
151202
test_linux_artifact:
152203
- command: expansions.write
153204
params:
@@ -178,7 +229,8 @@ functions:
178229
# test_{version} - Runs all tests, against a specified mongod version.
179230
# test_vscode - Run the vscode extension integration tests.
180231
# test_connectivity - Runs extra connectivity tests.
181-
# compile_and_upload_artifact - Compile the release binary and upload it to S3.
232+
# compile_artifact - Compile the release binary.
233+
# package_and_upload_artifact - Upload the release binary to S3.
182234
# test_linux_artifact - Test that the built artifact works where we expect it to.
183235
# release_publish - Publishes the npm packages and uploads the tarballs.
184236
tasks:
@@ -289,7 +341,16 @@ tasks:
289341
vars:
290342
node_js_version: "14.15.1"
291343
- func: test_connectivity
292-
- name: compile_and_upload_artifact_macos
344+
- name: compile_artifact
345+
commands:
346+
- func: checkout
347+
- func: install
348+
vars:
349+
node_js_version: "14.15.1"
350+
- func: compile_artifact
351+
vars:
352+
node_js_version: "14.15.1"
353+
- name: package_and_upload_artifact_macos
293354
depends_on:
294355
- name: check
295356
variant: darwin
@@ -309,17 +370,20 @@ tasks:
309370
variant: darwin
310371
- name: test_mlatest_n14
311372
variant: darwin
373+
- name: compile_artifact
374+
variant: darwin
312375
commands:
313376
- func: checkout
314377
- func: install
315378
vars:
316379
node_js_version: "14.15.1"
317-
- func: compile_and_upload_artifact
380+
- func: package_and_upload_artifact
318381
vars:
319382
node_js_version: "14.15.1"
320-
- name: compile_and_upload_artifact_linux
383+
- name: package_and_upload_artifact_linux
321384
depends_on:
322385
- name: check
386+
variant: linux
323387
- name: test_m40x_n12
324388
variant: linux
325389
- name: test_m42x_n12
@@ -336,36 +400,49 @@ tasks:
336400
variant: linux
337401
- name: test_mlatest_n14
338402
variant: linux
403+
- name: compile_artifact
404+
variant: linux_build
339405
commands:
340406
- func: checkout
341407
- func: install
342408
vars:
343409
node_js_version: "14.15.1"
344-
- func: compile_and_upload_artifact
410+
- func: package_and_upload_artifact
345411
vars:
346412
node_js_version: "14.15.1"
347-
- name: compile_and_upload_artifact_win
413+
- name: package_and_upload_artifact_win
348414
depends_on:
349415
- name: check
416+
variant: win32
350417
- name: test_m40x_n12
418+
variant: win32
351419
- name: test_m42x_n12
420+
variant: win32
352421
- name: test_m44x_n12
422+
variant: win32
353423
- name: test_mlatest_n12
424+
variant: win32
354425
- name: test_m40x_n14
426+
variant: win32
355427
- name: test_m42x_n14
428+
variant: win32
356429
- name: test_m44x_n14
430+
variant: win32
357431
- name: test_mlatest_n14
432+
variant: win32
433+
- name: compile_artifact
434+
variant: win32_build
358435
commands:
359436
- func: checkout
360437
- func: install
361438
vars:
362439
node_js_version: "14.15.1"
363-
- func: compile_and_upload_artifact
440+
- func: package_and_upload_artifact
364441
vars:
365442
node_js_version: "14.15.1"
366443
- name: test_linux_artifact
367444
depends_on:
368-
- name: compile_and_upload_artifact_linux
445+
- name: package_and_upload_artifact_linux
369446
variant: linux
370447
commands:
371448
- func: checkout
@@ -377,10 +454,12 @@ tasks:
377454
node_js_version: "14.15.1"
378455
- name: release_publish
379456
depends_on:
380-
- name: compile_and_upload_artifact_win
457+
- name: package_and_upload_artifact_win
381458
variant: win32
382-
- name: compile_and_upload_artifact_linux
459+
- name: package_and_upload_artifact_linux
383460
variant: linux
461+
- name: package_and_upload_artifact_macos
462+
variant: darwin_codesign
384463
- name: test_linux_artifact
385464
variant: rhel70
386465
- name: test_linux_artifact
@@ -391,8 +470,6 @@ tasks:
391470
variant: ubuntu1604
392471
- name: test_linux_artifact
393472
variant: ubuntu2004
394-
- name: compile_and_upload_artifact_macos
395-
variant: darwin_codesign
396473
- name: test_vscode
397474
variant: linux
398475
commands:
@@ -409,11 +486,15 @@ buildvariants:
409486
- name: darwin_codesign
410487
display_name: "MacOS Mojave (codesign)"
411488
run_on: macos-1014-codesign
489+
expansions:
490+
executable_os_id: darwin
412491
tasks:
413-
- name: compile_and_upload_artifact_macos
492+
- name: package_and_upload_artifact_macos
414493
- name: darwin
415494
display_name: "MacOS Mojave"
416495
run_on: macos-1014
496+
expansions:
497+
executable_os_id: darwin
417498
tasks:
418499
- name: check
419500
- name: test_m40x_n12
@@ -424,9 +505,12 @@ buildvariants:
424505
- name: test_m42x_n14
425506
- name: test_m44x_n14
426507
- name: test_mlatest_n14
508+
- name: compile_artifact
427509
- name: linux
428510
display_name: "Ubuntu 18.04"
429-
run_on: ubuntu1804-test
511+
run_on: ubuntu1804-small
512+
expansions:
513+
executable_os_id: linux
430514
tasks:
431515
- name: check
432516
- name: test_m40x_n12
@@ -439,19 +523,28 @@ buildvariants:
439523
- name: test_mlatest_n14
440524
- name: test_vscode
441525
- name: test_connectivity
442-
- name: compile_and_upload_artifact_linux
526+
- name: package_and_upload_artifact_linux
527+
- name: linux_build
528+
display_name: "Ubuntu 18.04 (build)"
529+
run_on: ubuntu1804-build
530+
expansions:
531+
executable_os_id: linux
532+
tasks:
533+
- name: compile_artifact
443534
- name: rhel
444535
display_name: "Ubuntu 18.04 (rpm target)"
445-
run_on: ubuntu1804-test
536+
run_on: ubuntu1804-small
537+
expansions:
538+
executable_os_id: linux
446539
tasks:
447-
- name: check
448-
- name: compile_and_upload_artifact_linux
540+
- name: package_and_upload_artifact_linux
449541
- name: debian
450542
display_name: "Ubuntu 18.04 (deb target)"
451-
run_on: ubuntu1804-test
543+
run_on: ubuntu1804-small
544+
expansions:
545+
executable_os_id: linux
452546
tasks:
453-
- name: check
454-
- name: compile_and_upload_artifact_linux
547+
- name: package_and_upload_artifact_linux
455548
- name: rhel70
456549
display_name: "RHEL 7.0"
457550
run_on: rhel70-small
@@ -479,7 +572,9 @@ buildvariants:
479572
- name: test_linux_artifact
480573
- name: win32
481574
display_name: "Windows VS 2019"
482-
run_on: windows-64-vs2019-test
575+
run_on: windows-64-vs2019-small
576+
expansions:
577+
executable_os_id: win32
483578
tasks:
484579
- name: check
485580
- name: test_m40x_n12
@@ -490,7 +585,14 @@ buildvariants:
490585
- name: test_m42x_n14
491586
- name: test_m44x_n14
492587
- name: test_mlatest_n14
493-
- name: compile_and_upload_artifact_win
588+
- name: package_and_upload_artifact_win
589+
- name: win32_build
590+
display_name: "Windows VS 2019 (build)"
591+
run_on: windows-64-vs2019-build
592+
expansions:
593+
executable_os_id: win32
594+
tasks:
595+
- name: compile_artifact
494596
- name: darwin_release_publish
495597
display_name: "Publish Release"
496598
run_on: macos-1014-codesign

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,4 @@ expansions.yaml
1919
tmp/expansions.yaml
2020
.evergreen/mongodb
2121
tmp/
22+
dist.tgz

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -167,11 +167,12 @@ npm run compile-exec
167167
Compile a specific package, e.g. the `.deb` for Debian:
168168

169169
```shell
170-
npm run evergreen-release package -- --dry --build-variant=Debian
170+
npm run compile-exec
171+
npm run evergreen-release package -- --build-variant=Debian
171172
```
172173

173174
## Contributing
174-
For issues, please create a ticket in our
175+
For issues, please create a ticket in our
175176
[JIRA Project](https://jira.mongodb.org/browse/MONGOSH).
176177

177178
For contributing, please refer to [CONTRIBUTING.md](./CONTRIBUTING.md).

config/build.conf.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,5 @@ module.exports = {
8484
repo: {
8585
owner: 'mongodb-js',
8686
repo: 'mongosh'
87-
},
88-
dryRun: false
87+
}
8988
};

package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,7 @@
4444
"compile-compass": "npm run compile-browser && lerna run --stream compile --scope @mongodb-js/compass-shell",
4545
"start-compass": "lerna run --stream start-compass --scope @mongodb-js/compass-shell",
4646
"start": "npm run start-cli",
47-
"precompile-exec": "npm run compile-ts",
48-
"compile-exec": "node scripts/compile-exec.js",
47+
"compile-exec": "npm run evergreen-release compile",
4948
"compile-all": "npm run compile-compass && npm run compile-exec",
5049
"preevergreen-release": "npm run compile-ts",
5150
"evergreen-release": "node scripts/evergreen-release.js",

0 commit comments

Comments
 (0)