Skip to content

Commit

Permalink
ci(NODE-4856): break apart ts tests into separate tasks and skip fail…
Browse files Browse the repository at this point in the history
…ing tasks on typescript next (#3474)
  • Loading branch information
baileympearson committed Dec 1, 2022
1 parent a57cd64 commit bb6683d
Show file tree
Hide file tree
Showing 4 changed files with 125 additions and 90 deletions.
26 changes: 7 additions & 19 deletions .evergreen/config.in.yml
Original file line number Diff line number Diff line change
Expand Up @@ -289,42 +289,30 @@ functions:
args:
- "${PROJECT_DIRECTORY}/.evergreen/run-unit-tests.sh"

"run typescript next":
"check types":
- command: subprocess.exec
type: test
params:
working_dir: "src"
timeout_secs: 60
env:
PROJECT_DIRECTORY: ${PROJECT_DIRECTORY}
TS_VERSION: "next"
TS_VERSION: ${TS_VERSION}
TS_CHECK: CHECK_TYPES
binary: bash
args:
- "${PROJECT_DIRECTORY}/.evergreen/run-typescript.sh"

"run typescript oldest":
"compile driver":
- command: subprocess.exec
type: test
params:
working_dir: "src"
timeout_secs: 60
env:
PROJECT_DIRECTORY: ${PROJECT_DIRECTORY}
TS_VERSION: "4.1.6"
TRY_COMPILING_DRIVER: "false" # 4.1.6 can consume the public API but not compile the driver
binary: bash
args:
- "${PROJECT_DIRECTORY}/.evergreen/run-typescript.sh"

"run typescript current":
- command: subprocess.exec
type: test
params:
working_dir: "src"
timeout_secs: 60
env:
PROJECT_DIRECTORY: ${PROJECT_DIRECTORY}
TS_VERSION: "" # leaving this empty will use the version in package-lock.json
TS_VERSION: ${TS_VERSION}
TS_CHECK: COMPILE_DRIVER
binary: bash
args:
- "${PROJECT_DIRECTORY}/.evergreen/run-typescript.sh"
Expand Down Expand Up @@ -886,7 +874,7 @@ functions:
local_file: src/coverage/coverage-final.json
optional: true
# Upload the coverage report for all tasks in a single build to the same directory.
# TODO NODE-4707 - change upload directory to ${UPLOAD_BUCKET}
# TODO NODE-4707 - change upload directory to ${UPLOAD_BUCKET}
# This change will require changing the `download and merge coverage` func as well
remote_file: mongo-node-driver/${revision}/${version_id}/coverage.${build_variant}.${task_name}.json
bucket: mciuploads
Expand Down
64 changes: 35 additions & 29 deletions .evergreen/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -255,40 +255,29 @@ functions:
binary: bash
args:
- ${PROJECT_DIRECTORY}/.evergreen/run-unit-tests.sh
run typescript next:
check types:
- command: subprocess.exec
type: test
params:
working_dir: src
timeout_secs: 60
env:
PROJECT_DIRECTORY: ${PROJECT_DIRECTORY}
TS_VERSION: next
binary: bash
args:
- ${PROJECT_DIRECTORY}/.evergreen/run-typescript.sh
run typescript oldest:
- command: subprocess.exec
type: test
params:
working_dir: src
timeout_secs: 60
env:
PROJECT_DIRECTORY: ${PROJECT_DIRECTORY}
TS_VERSION: 4.1.6
TRY_COMPILING_DRIVER: 'false'
TS_VERSION: ${TS_VERSION}
TS_CHECK: CHECK_TYPES
binary: bash
args:
- ${PROJECT_DIRECTORY}/.evergreen/run-typescript.sh
run typescript current:
compile driver:
- command: subprocess.exec
type: test
params:
working_dir: src
timeout_secs: 60
env:
PROJECT_DIRECTORY: ${PROJECT_DIRECTORY}
TS_VERSION: ''
TS_VERSION: ${TS_VERSION}
TS_CHECK: COMPILE_DRIVER
binary: bash
args:
- ${PROJECT_DIRECTORY}/.evergreen/run-typescript.sh
Expand Down Expand Up @@ -2090,30 +2079,46 @@ tasks:
vars:
NODE_LTS_NAME: erbium
- func: run lint checks
- name: run-typescript-next
- name: check-types-typescript-next
tags:
- run-typescript-next
- check-types-typescript-next
commands:
- func: install dependencies
vars:
NODE_LTS_NAME: erbium
- func: run typescript next
- name: run-typescript-current
- func: check types
vars:
TS_VERSION: next
- name: compile-driver-typescript-current
tags:
- run-typescript-current
- compile-driver-typescript-current
commands:
- func: install dependencies
vars:
NODE_LTS_NAME: erbium
- func: run typescript current
- name: run-typescript-oldest
- func: compile driver
vars:
TS_VERSION: current
- name: check-types-typescript-current
tags:
- run-typescript-oldest
- check-types-typescript-current
commands:
- func: install dependencies
vars:
NODE_LTS_NAME: erbium
- func: run typescript oldest
- func: check types
vars:
TS_VERSION: current
- name: check-types-typescript-4.1.6
tags:
- check-types-typescript-4.1.6
commands:
- func: install dependencies
vars:
NODE_LTS_NAME: erbium
- func: check types
vars:
TS_VERSION: 4.1.6
- name: run-mongosh-integration-tests
tags:
- run-mongosh-integration-tests
Expand Down Expand Up @@ -3084,9 +3089,10 @@ buildvariants:
tasks:
- run-unit-tests
- run-lint-checks
- run-typescript-current
- run-typescript-oldest
- run-typescript-next
- check-types-typescript-next
- compile-driver-typescript-current
- check-types-typescript-current
- check-types-typescript-4.1.6
- name: generate-combined-coverage
display_name: Generate Combined Coverage
run_on: rhel80-large
Expand Down
85 changes: 52 additions & 33 deletions .evergreen/generate_evergreen_tasks.js
Original file line number Diff line number Diff line change
Expand Up @@ -462,47 +462,68 @@ SINGLETON_TASKS.push(
{ func: 'run lint checks' }
]
},
{
name: 'run-typescript-next',
tags: ['run-typescript-next'],
commands: [
{
func: 'install dependencies',
vars: {
NODE_LTS_NAME: LOWEST_LTS
}
},
{ func: 'run typescript next' }
]
},
{
name: 'run-typescript-current',
tags: ['run-typescript-current'],
...Array.from(makeTypescriptTasks())
]
);

function* makeTypescriptTasks() {
for (const TS_VERSION of ["next", "current", "4.1.6"]) {
// 4.1.6 can consume the public API but not compile the driver
if (TS_VERSION !== '4.1.6'
&& TS_VERSION !== 'next') {
yield {
name: `compile-driver-typescript-${TS_VERSION}`,
tags: [`compile-driver-typescript-${TS_VERSION}`],
commands: [
{
func: 'install dependencies',
vars: {
NODE_LTS_NAME: LOWEST_LTS
}
},
{
func: 'compile driver',
vars: {
TS_VERSION
}
}
]
}
}

yield {
name: `check-types-typescript-${TS_VERSION}`,
tags: [`check-types-typescript-${TS_VERSION}`],
commands: [
{
func: 'install dependencies',
vars: {
NODE_LTS_NAME: LOWEST_LTS
}
},
{ func: 'run typescript current' }
]
},
{
name: 'run-typescript-oldest',
tags: ['run-typescript-oldest'],
commands: [
{
func: 'install dependencies',
func: 'check types',
vars: {
NODE_LTS_NAME: LOWEST_LTS
TS_VERSION
}
},
{ func: 'run typescript oldest' }
}
]
}
]
);
}
}
return {
name: 'run-typescript-next',
tags: ['run-typescript-next'],
commands: [
{
func: 'install dependencies',
vars: {
NODE_LTS_NAME: LOWEST_LTS
}
},
{ func: 'run typescript next' }
]
}
}

BUILD_VARIANTS.push({
name: 'lint',
Expand All @@ -511,9 +532,7 @@ BUILD_VARIANTS.push({
tasks: [
'run-unit-tests',
'run-lint-checks',
'run-typescript-current',
'run-typescript-oldest',
'run-typescript-next'
...Array.from(makeTypescriptTasks()).map(({ name }) => name)
]
});

Expand Down
40 changes: 31 additions & 9 deletions .evergreen/run-typescript.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,31 @@ source "${PROJECT_DIRECTORY}/.evergreen/init-nvm.sh"

set -o xtrace

function get_current_ts_version {
node -e "console.log(require('./package-lock.json').dependencies.typescript.version)"
}
case $TS_CHECK in
COMPILE_DRIVER|CHECK_TYPES) # Ok
;;
*)
echo "TS_CHECK must be set to either COMPILE_DRIVER or CHECK_TYPES - received '$TS_CHECK'"
exit 1
esac

if [ -z "$TS_VERSION" ]; then echo "TS_VERSION must be set"; exit 1; fi

if [ ! -f "mongodb.d.ts" ]; then
echo "mongodb.d.ts should always exist because of the installation in prior steps but in case it doesn't, build it"
npm i
fi

CURRENT_TS_VERSION=$(get_current_ts_version)
function get_ts_version() {
if [ "$TS_VERSION" == "current" ]; then
echo $(node -e "console.log(require('./package-lock.json').dependencies.typescript.version)")
else
echo $TS_VERSION
fi
}

export TSC="./node_modules/typescript/bin/tsc"
export TS_VERSION=${TS_VERSION:=$CURRENT_TS_VERSION}
export TS_VERSION=$(get_ts_version)

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

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

# check compilation
node $TSC mongodb.d.ts

if [[ $TRY_COMPILING_DRIVER != "false" ]]; then
if [ "$TS_CHECK" == "COMPILE_DRIVER" ]; then
echo "compiling driver"
npm run build:ts
elif [ "$TS_CHECK" == "CHECK_TYPES" ]; then
echo "checking driver types"
# check compilation
node $TSC mongodb.d.ts
else
"Invalid value $TS_CHECK for TS_CHECK environment variable."
exit 1
fi

0 comments on commit bb6683d

Please sign in to comment.