Skip to content

Commit bb6683d

Browse files
ci(NODE-4856): break apart ts tests into separate tasks and skip failing tasks on typescript next (#3474)
1 parent a57cd64 commit bb6683d

File tree

4 files changed

+125
-90
lines changed

4 files changed

+125
-90
lines changed

.evergreen/config.in.yml

+7-19
Original file line numberDiff line numberDiff line change
@@ -289,42 +289,30 @@ functions:
289289
args:
290290
- "${PROJECT_DIRECTORY}/.evergreen/run-unit-tests.sh"
291291

292-
"run typescript next":
292+
"check types":
293293
- command: subprocess.exec
294294
type: test
295295
params:
296296
working_dir: "src"
297297
timeout_secs: 60
298298
env:
299299
PROJECT_DIRECTORY: ${PROJECT_DIRECTORY}
300-
TS_VERSION: "next"
300+
TS_VERSION: ${TS_VERSION}
301+
TS_CHECK: CHECK_TYPES
301302
binary: bash
302303
args:
303304
- "${PROJECT_DIRECTORY}/.evergreen/run-typescript.sh"
304305

305-
"run typescript oldest":
306+
"compile driver":
306307
- command: subprocess.exec
307308
type: test
308309
params:
309310
working_dir: "src"
310311
timeout_secs: 60
311312
env:
312313
PROJECT_DIRECTORY: ${PROJECT_DIRECTORY}
313-
TS_VERSION: "4.1.6"
314-
TRY_COMPILING_DRIVER: "false" # 4.1.6 can consume the public API but not compile the driver
315-
binary: bash
316-
args:
317-
- "${PROJECT_DIRECTORY}/.evergreen/run-typescript.sh"
318-
319-
"run typescript current":
320-
- command: subprocess.exec
321-
type: test
322-
params:
323-
working_dir: "src"
324-
timeout_secs: 60
325-
env:
326-
PROJECT_DIRECTORY: ${PROJECT_DIRECTORY}
327-
TS_VERSION: "" # leaving this empty will use the version in package-lock.json
314+
TS_VERSION: ${TS_VERSION}
315+
TS_CHECK: COMPILE_DRIVER
328316
binary: bash
329317
args:
330318
- "${PROJECT_DIRECTORY}/.evergreen/run-typescript.sh"
@@ -886,7 +874,7 @@ functions:
886874
local_file: src/coverage/coverage-final.json
887875
optional: true
888876
# Upload the coverage report for all tasks in a single build to the same directory.
889-
# TODO NODE-4707 - change upload directory to ${UPLOAD_BUCKET}
877+
# TODO NODE-4707 - change upload directory to ${UPLOAD_BUCKET}
890878
# This change will require changing the `download and merge coverage` func as well
891879
remote_file: mongo-node-driver/${revision}/${version_id}/coverage.${build_variant}.${task_name}.json
892880
bucket: mciuploads

.evergreen/config.yml

+35-29
Original file line numberDiff line numberDiff line change
@@ -255,40 +255,29 @@ functions:
255255
binary: bash
256256
args:
257257
- ${PROJECT_DIRECTORY}/.evergreen/run-unit-tests.sh
258-
run typescript next:
258+
check types:
259259
- command: subprocess.exec
260260
type: test
261261
params:
262262
working_dir: src
263263
timeout_secs: 60
264264
env:
265265
PROJECT_DIRECTORY: ${PROJECT_DIRECTORY}
266-
TS_VERSION: next
267-
binary: bash
268-
args:
269-
- ${PROJECT_DIRECTORY}/.evergreen/run-typescript.sh
270-
run typescript oldest:
271-
- command: subprocess.exec
272-
type: test
273-
params:
274-
working_dir: src
275-
timeout_secs: 60
276-
env:
277-
PROJECT_DIRECTORY: ${PROJECT_DIRECTORY}
278-
TS_VERSION: 4.1.6
279-
TRY_COMPILING_DRIVER: 'false'
266+
TS_VERSION: ${TS_VERSION}
267+
TS_CHECK: CHECK_TYPES
280268
binary: bash
281269
args:
282270
- ${PROJECT_DIRECTORY}/.evergreen/run-typescript.sh
283-
run typescript current:
271+
compile driver:
284272
- command: subprocess.exec
285273
type: test
286274
params:
287275
working_dir: src
288276
timeout_secs: 60
289277
env:
290278
PROJECT_DIRECTORY: ${PROJECT_DIRECTORY}
291-
TS_VERSION: ''
279+
TS_VERSION: ${TS_VERSION}
280+
TS_CHECK: COMPILE_DRIVER
292281
binary: bash
293282
args:
294283
- ${PROJECT_DIRECTORY}/.evergreen/run-typescript.sh
@@ -2090,30 +2079,46 @@ tasks:
20902079
vars:
20912080
NODE_LTS_NAME: erbium
20922081
- func: run lint checks
2093-
- name: run-typescript-next
2082+
- name: check-types-typescript-next
20942083
tags:
2095-
- run-typescript-next
2084+
- check-types-typescript-next
20962085
commands:
20972086
- func: install dependencies
20982087
vars:
20992088
NODE_LTS_NAME: erbium
2100-
- func: run typescript next
2101-
- name: run-typescript-current
2089+
- func: check types
2090+
vars:
2091+
TS_VERSION: next
2092+
- name: compile-driver-typescript-current
21022093
tags:
2103-
- run-typescript-current
2094+
- compile-driver-typescript-current
21042095
commands:
21052096
- func: install dependencies
21062097
vars:
21072098
NODE_LTS_NAME: erbium
2108-
- func: run typescript current
2109-
- name: run-typescript-oldest
2099+
- func: compile driver
2100+
vars:
2101+
TS_VERSION: current
2102+
- name: check-types-typescript-current
21102103
tags:
2111-
- run-typescript-oldest
2104+
- check-types-typescript-current
21122105
commands:
21132106
- func: install dependencies
21142107
vars:
21152108
NODE_LTS_NAME: erbium
2116-
- func: run typescript oldest
2109+
- func: check types
2110+
vars:
2111+
TS_VERSION: current
2112+
- name: check-types-typescript-4.1.6
2113+
tags:
2114+
- check-types-typescript-4.1.6
2115+
commands:
2116+
- func: install dependencies
2117+
vars:
2118+
NODE_LTS_NAME: erbium
2119+
- func: check types
2120+
vars:
2121+
TS_VERSION: 4.1.6
21172122
- name: run-mongosh-integration-tests
21182123
tags:
21192124
- run-mongosh-integration-tests
@@ -3084,9 +3089,10 @@ buildvariants:
30843089
tasks:
30853090
- run-unit-tests
30863091
- run-lint-checks
3087-
- run-typescript-current
3088-
- run-typescript-oldest
3089-
- run-typescript-next
3092+
- check-types-typescript-next
3093+
- compile-driver-typescript-current
3094+
- check-types-typescript-current
3095+
- check-types-typescript-4.1.6
30903096
- name: generate-combined-coverage
30913097
display_name: Generate Combined Coverage
30923098
run_on: rhel80-large

.evergreen/generate_evergreen_tasks.js

+52-33
Original file line numberDiff line numberDiff line change
@@ -462,47 +462,68 @@ SINGLETON_TASKS.push(
462462
{ func: 'run lint checks' }
463463
]
464464
},
465-
{
466-
name: 'run-typescript-next',
467-
tags: ['run-typescript-next'],
468-
commands: [
469-
{
470-
func: 'install dependencies',
471-
vars: {
472-
NODE_LTS_NAME: LOWEST_LTS
473-
}
474-
},
475-
{ func: 'run typescript next' }
476-
]
477-
},
478-
{
479-
name: 'run-typescript-current',
480-
tags: ['run-typescript-current'],
465+
...Array.from(makeTypescriptTasks())
466+
]
467+
);
468+
469+
function* makeTypescriptTasks() {
470+
for (const TS_VERSION of ["next", "current", "4.1.6"]) {
471+
// 4.1.6 can consume the public API but not compile the driver
472+
if (TS_VERSION !== '4.1.6'
473+
&& TS_VERSION !== 'next') {
474+
yield {
475+
name: `compile-driver-typescript-${TS_VERSION}`,
476+
tags: [`compile-driver-typescript-${TS_VERSION}`],
477+
commands: [
478+
{
479+
func: 'install dependencies',
480+
vars: {
481+
NODE_LTS_NAME: LOWEST_LTS
482+
}
483+
},
484+
{
485+
func: 'compile driver',
486+
vars: {
487+
TS_VERSION
488+
}
489+
}
490+
]
491+
}
492+
}
493+
494+
yield {
495+
name: `check-types-typescript-${TS_VERSION}`,
496+
tags: [`check-types-typescript-${TS_VERSION}`],
481497
commands: [
482498
{
483499
func: 'install dependencies',
484500
vars: {
485501
NODE_LTS_NAME: LOWEST_LTS
486502
}
487503
},
488-
{ func: 'run typescript current' }
489-
]
490-
},
491-
{
492-
name: 'run-typescript-oldest',
493-
tags: ['run-typescript-oldest'],
494-
commands: [
495504
{
496-
func: 'install dependencies',
505+
func: 'check types',
497506
vars: {
498-
NODE_LTS_NAME: LOWEST_LTS
507+
TS_VERSION
499508
}
500-
},
501-
{ func: 'run typescript oldest' }
509+
}
502510
]
503-
}
504-
]
505-
);
511+
}
512+
}
513+
return {
514+
name: 'run-typescript-next',
515+
tags: ['run-typescript-next'],
516+
commands: [
517+
{
518+
func: 'install dependencies',
519+
vars: {
520+
NODE_LTS_NAME: LOWEST_LTS
521+
}
522+
},
523+
{ func: 'run typescript next' }
524+
]
525+
}
526+
}
506527

507528
BUILD_VARIANTS.push({
508529
name: 'lint',
@@ -511,9 +532,7 @@ BUILD_VARIANTS.push({
511532
tasks: [
512533
'run-unit-tests',
513534
'run-lint-checks',
514-
'run-typescript-current',
515-
'run-typescript-oldest',
516-
'run-typescript-next'
535+
...Array.from(makeTypescriptTasks()).map(({ name }) => name)
517536
]
518537
});
519538

.evergreen/run-typescript.sh

+31-9
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,31 @@ source "${PROJECT_DIRECTORY}/.evergreen/init-nvm.sh"
55

66
set -o xtrace
77

8-
function get_current_ts_version {
9-
node -e "console.log(require('./package-lock.json').dependencies.typescript.version)"
10-
}
8+
case $TS_CHECK in
9+
COMPILE_DRIVER|CHECK_TYPES) # Ok
10+
;;
11+
*)
12+
echo "TS_CHECK must be set to either COMPILE_DRIVER or CHECK_TYPES - received '$TS_CHECK'"
13+
exit 1
14+
esac
15+
16+
if [ -z "$TS_VERSION" ]; then echo "TS_VERSION must be set"; exit 1; fi
17+
18+
if [ ! -f "mongodb.d.ts" ]; then
19+
echo "mongodb.d.ts should always exist because of the installation in prior steps but in case it doesn't, build it"
20+
npm i
21+
fi
1122

12-
CURRENT_TS_VERSION=$(get_current_ts_version)
23+
function get_ts_version() {
24+
if [ "$TS_VERSION" == "current" ]; then
25+
echo $(node -e "console.log(require('./package-lock.json').dependencies.typescript.version)")
26+
else
27+
echo $TS_VERSION
28+
fi
29+
}
1330

1431
export TSC="./node_modules/typescript/bin/tsc"
15-
export TS_VERSION=${TS_VERSION:=$CURRENT_TS_VERSION}
32+
export TS_VERSION=$(get_ts_version)
1633

1734
npm install --no-save --force typescript@"$TS_VERSION"
1835

@@ -21,9 +38,14 @@ echo "Typescript $($TSC -v)"
2138
# check resolution uses the default latest types
2239
echo "import * as mdb from '.'" > file.ts && node $TSC --noEmit --traceResolution file.ts | grep 'mongodb.d.ts' && rm file.ts
2340

24-
# check compilation
25-
node $TSC mongodb.d.ts
26-
27-
if [[ $TRY_COMPILING_DRIVER != "false" ]]; then
41+
if [ "$TS_CHECK" == "COMPILE_DRIVER" ]; then
42+
echo "compiling driver"
2843
npm run build:ts
44+
elif [ "$TS_CHECK" == "CHECK_TYPES" ]; then
45+
echo "checking driver types"
46+
# check compilation
47+
node $TSC mongodb.d.ts
48+
else
49+
"Invalid value $TS_CHECK for TS_CHECK environment variable."
50+
exit 1
2951
fi

0 commit comments

Comments
 (0)