Skip to content

chore: add TS/types version matrix to CI #4176

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .evergreen/config.in.yml
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,7 @@ functions:
PROJECT_DIRECTORY: ${PROJECT_DIRECTORY}
TS_VERSION: ${TS_VERSION}
TS_CHECK: CHECK_TYPES
TYPES_VERSION: ${TYPES_VERSION}
binary: bash
args:
- "${PROJECT_DIRECTORY}/.evergreen/run-typescript.sh"
Expand All @@ -362,6 +363,7 @@ functions:
PROJECT_DIRECTORY: ${PROJECT_DIRECTORY}
TS_VERSION: ${TS_VERSION}
TS_CHECK: COMPILE_DRIVER
TYPES_VERSION: ${TYPES_VERSION}
binary: bash
args:
- "${PROJECT_DIRECTORY}/.evergreen/run-typescript.sh"
Expand Down
63 changes: 57 additions & 6 deletions .evergreen/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,7 @@ functions:
PROJECT_DIRECTORY: ${PROJECT_DIRECTORY}
TS_VERSION: ${TS_VERSION}
TS_CHECK: CHECK_TYPES
TYPES_VERSION: ${TYPES_VERSION}
binary: bash
args:
- ${PROJECT_DIRECTORY}/.evergreen/run-typescript.sh
Expand All @@ -325,6 +326,7 @@ functions:
PROJECT_DIRECTORY: ${PROJECT_DIRECTORY}
TS_VERSION: ${TS_VERSION}
TS_CHECK: COMPILE_DRIVER
TYPES_VERSION: ${TYPES_VERSION}
binary: bash
args:
- ${PROJECT_DIRECTORY}/.evergreen/run-typescript.sh
Expand Down Expand Up @@ -3459,7 +3461,7 @@ tasks:
- {key: NPM_VERSION, value: '9'}
- func: install dependencies
- func: run lint checks
- name: check-types-typescript-next
- name: check-types-typescript-next-node-types-18.19.39
tags:
- check-types-typescript-next
- typescript-compilation
Expand All @@ -3471,11 +3473,12 @@ tasks:
- {key: NODE_LTS_VERSION, value: '16'}
- {key: NPM_VERSION, value: '9'}
- {key: TS_VERSION, value: next}
- {key: TYPES_VERSION, value: 18.19.39}
- func: install dependencies
- func: check types
- name: compile-driver-typescript-current
- name: check-types-typescript-current-node-types-18.19.39
tags:
- compile-driver-typescript-current
- check-types-typescript-current
- typescript-compilation
commands:
- command: expansions.update
Expand All @@ -3485,9 +3488,25 @@ tasks:
- {key: NODE_LTS_VERSION, value: '16'}
- {key: NPM_VERSION, value: '9'}
- {key: TS_VERSION, value: current}
- {key: TYPES_VERSION, value: 18.19.39}
- func: install dependencies
- func: compile driver
- name: check-types-typescript-current
- func: check types
- name: check-types-typescript-next-node-types-16.x
tags:
- check-types-typescript-next
- typescript-compilation
commands:
- command: expansions.update
type: setup
params:
updates:
- {key: NODE_LTS_VERSION, value: '16'}
- {key: NPM_VERSION, value: '9'}
- {key: TS_VERSION, value: next}
- {key: TYPES_VERSION, value: 16.x}
- func: install dependencies
- func: check types
- name: check-types-typescript-current-node-types-16.x
tags:
- check-types-typescript-current
- typescript-compilation
Expand All @@ -3499,9 +3518,10 @@ tasks:
- {key: NODE_LTS_VERSION, value: '16'}
- {key: NPM_VERSION, value: '9'}
- {key: TS_VERSION, value: current}
- {key: TYPES_VERSION, value: 16.x}
- func: install dependencies
- func: check types
- name: check-types-typescript-4.4
- name: check-types-typescript-4.4-node-types-18.11.9
tags:
- check-types-typescript-4.4
- typescript-compilation
Expand All @@ -3513,8 +3533,39 @@ tasks:
- {key: NODE_LTS_VERSION, value: '16'}
- {key: NPM_VERSION, value: '9'}
- {key: TS_VERSION, value: '4.4'}
- {key: TYPES_VERSION, value: 18.11.9}
- func: install dependencies
- func: check types
- name: compile-driver-typescript-current-node-types-18.19.39
tags:
- compile-driver-typescript-current
- typescript-compilation
commands:
- command: expansions.update
type: setup
params:
updates:
- {key: NODE_LTS_VERSION, value: '16'}
- {key: NPM_VERSION, value: '9'}
- {key: TS_VERSION, value: current}
- {key: TYPES_VERSION, value: 18.19.39}
- func: install dependencies
- func: compile driver
- name: compile-driver-typescript-current-node-types-16.x
tags:
- compile-driver-typescript-current
- typescript-compilation
commands:
- command: expansions.update
type: setup
params:
updates:
- {key: NODE_LTS_VERSION, value: '16'}
- {key: NPM_VERSION, value: '9'}
- {key: TS_VERSION, value: current}
- {key: TYPES_VERSION, value: 16.x}
- func: install dependencies
- func: compile driver
- name: download-and-merge-coverage
tags: []
commands:
Expand Down
68 changes: 34 additions & 34 deletions .evergreen/generate_evergreen_tasks.js
Original file line number Diff line number Diff line change
Expand Up @@ -497,51 +497,51 @@ SINGLETON_TASKS.push(
);

function* makeTypescriptTasks() {
for (const TS_VERSION of ['next', 'current', '4.4']) {
// We don't compile on next, because compilation errors are likely. We do expect
// that the drivers types continue to work with next though.
if (TS_VERSION !== '4.4' && TS_VERSION !== 'next') {
yield {
name: `compile-driver-typescript-${TS_VERSION}`,
tags: [`compile-driver-typescript-${TS_VERSION}`, 'typescript-compilation'],
commands: [
updateExpansions({
NODE_LTS_VERSION: LOWEST_LTS,
NPM_VERSION: 9,
TS_VERSION
}),
{ func: 'install dependencies' },
{ func: 'compile driver' }
]
};
function makeCompileTask(TS_VERSION, TYPES_VERSION) {
return {
name: `compile-driver-typescript-${TS_VERSION}-node-types-${TYPES_VERSION}`,
tags: [`compile-driver-typescript-${TS_VERSION}`, 'typescript-compilation'],
commands: [
updateExpansions({
NODE_LTS_VERSION: LOWEST_LTS,
NPM_VERSION: 9,
TS_VERSION,
TYPES_VERSION
}),
{ func: 'install dependencies' },
{ func: 'compile driver' }
]
}

yield {
name: `check-types-typescript-${TS_VERSION}`,
}
function makeCheckTypesTask(TS_VERSION, TYPES_VERSION) {
return {
name: `check-types-typescript-${TS_VERSION}-node-types-${TYPES_VERSION}`,
tags: [`check-types-typescript-${TS_VERSION}`, 'typescript-compilation'],
commands: [
updateExpansions({
NODE_LTS_VERSION: LOWEST_LTS,
NPM_VERSION: 9,
TS_VERSION
TS_VERSION,
TYPES_VERSION
}),
{ func: 'install dependencies' },
{ func: 'check types' }
]
};
}
}
return {
name: 'run-typescript-next',
tags: ['run-typescript-next', 'typescript-compilation'],
commands: [
updateExpansions({
NODE_LTS_VERSION: LOWEST_LTS,
NPM_VERSION: 9
}),
{ func: 'install dependencies' },
{ func: 'run typescript next' }
]
};

const typesVersion = require('../package.json').devDependencies['@types/node'].slice(1)
yield makeCheckTypesTask('next', typesVersion);
yield makeCheckTypesTask('current', typesVersion);

yield makeCheckTypesTask('next', '16.x');
yield makeCheckTypesTask('current', '16.x');

// typescript 4.4 only compiles our types with this particular version
yield makeCheckTypesTask('4.4', '18.11.9');

yield makeCompileTask('current', typesVersion);
yield makeCompileTask('current', '16.x');
}

BUILD_VARIANTS.push({
Expand Down
8 changes: 4 additions & 4 deletions .evergreen/run-typescript.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ set -o errexit # Exit the script with error if any of the commands fail

source "${PROJECT_DIRECTORY}/.evergreen/init-node-and-npm-env.sh"

set -o xtrace

case $TS_CHECK in
COMPILE_DRIVER|CHECK_TYPES) # Ok
;;
Expand All @@ -14,6 +12,7 @@ case $TS_CHECK in
esac

if [ -z "$TS_VERSION" ]; then echo "TS_VERSION must be set"; exit 1; fi
if [ -z "$TYPES_VERSION" ]; then echo "TYPES_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"
Expand All @@ -31,10 +30,11 @@ function get_ts_version() {
export TSC="./node_modules/typescript/bin/tsc"
export TS_VERSION=$(get_ts_version)

# On old versions of TS we need to put the node types back to 18.11.19
npm install --no-save --force typescript@"$TS_VERSION" "$(if [[ $TS_VERSION == '4.4' ]]; then echo "@types/[email protected]"; else echo ""; fi)"
npm install --no-save --force "typescript@$TS_VERSION" "@types/node@$TYPES_VERSION"

echo "Typescript $($TSC -v)"
echo "Types: $(cat node_modules/@types/node/package.json | jq -r .version)"
echo "Nodejs: $(node -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
Expand Down