Skip to content

Commit d8bbb55

Browse files
committed
test: lint the driver in a single evergreen task
This change speeds up evergreen runs by only linting the project once per build. The linting variant will also show up separately on PR builds, giving better signal about whether that is the cause of build failures
1 parent 08e89c0 commit d8bbb55

File tree

5 files changed

+108
-30
lines changed

5 files changed

+108
-30
lines changed

.evergreen/config.yml

Lines changed: 55 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,14 @@ functions:
112112
113113
AUTH=${AUTH} SSL=${SSL} UNIFIED=${UNIFIED} MONGODB_URI="${MONGODB_URI}" bash
114114
${PROJECT_DIRECTORY}/.evergreen/run-tests.sh
115+
run checks:
116+
- command: shell.exec
117+
type: test
118+
params:
119+
working_dir: src
120+
script: |
121+
${PREPARE_SHELL}
122+
bash ${PROJECT_DIRECTORY}/.evergreen/run-checks.sh
115123
cleanup:
116124
- command: shell.exec
117125
params:
@@ -744,14 +752,20 @@ tasks:
744752
commands:
745753
- func: install dependencies
746754
- func: run atlas tests
755+
- name: run-checks
756+
tags:
757+
- run-checks
758+
commands:
759+
- func: install dependencies
747760
vars:
748-
VERSION: latest
761+
NODE_LTS_NAME: erbium
762+
- func: run checks
749763
buildvariants:
750-
- name: macos-1014-dubnium
751-
display_name: macOS 10.14 Node Dubnium
764+
- name: macos-1014-erbium
765+
display_name: macOS 10.14 Node Erbium
752766
run_on: macos-1014
753767
expansions:
754-
NODE_LTS_NAME: dubnium
768+
NODE_LTS_NAME: erbium
755769
tasks: &ref_0
756770
- test-latest-server
757771
- test-latest-replica_set
@@ -802,6 +816,12 @@ buildvariants:
802816
- test-2.6-replica_set-unified
803817
- test-2.6-sharded_cluster-unified
804818
- test-atlas-connectivity
819+
- name: macos-1014-dubnium
820+
display_name: macOS 10.14 Node Dubnium
821+
run_on: macos-1014
822+
expansions:
823+
NODE_LTS_NAME: dubnium
824+
tasks: *ref_0
805825
- name: macos-1014-carbon
806826
display_name: macOS 10.14 Node Carbon
807827
run_on: macos-1014
@@ -820,6 +840,12 @@ buildvariants:
820840
expansions:
821841
NODE_LTS_NAME: argon
822842
tasks: *ref_0
843+
- name: rhel70-erbium
844+
display_name: RHEL 7.0 Node Erbium
845+
run_on: rhel70-small
846+
expansions:
847+
NODE_LTS_NAME: erbium
848+
tasks: *ref_0
823849
- name: rhel70-dubnium
824850
display_name: RHEL 7.0 Node Dubnium
825851
run_on: rhel70-small
@@ -844,11 +870,11 @@ buildvariants:
844870
expansions:
845871
NODE_LTS_NAME: argon
846872
tasks: *ref_0
847-
- name: ubuntu-14.04-dubnium
848-
display_name: Ubuntu 14.04 Node Dubnium
873+
- name: ubuntu-14.04-erbium
874+
display_name: Ubuntu 14.04 Node Erbium
849875
run_on: ubuntu1404-test
850876
expansions:
851-
NODE_LTS_NAME: dubnium
877+
NODE_LTS_NAME: erbium
852878
tasks: &ref_1
853879
- test-4.0-server
854880
- test-4.0-replica_set
@@ -886,6 +912,13 @@ buildvariants:
886912
- test-2.6-server-unified
887913
- test-2.6-replica_set-unified
888914
- test-2.6-sharded_cluster-unified
915+
- test-atlas-connectivity
916+
- name: ubuntu-14.04-dubnium
917+
display_name: Ubuntu 14.04 Node Dubnium
918+
run_on: ubuntu1404-test
919+
expansions:
920+
NODE_LTS_NAME: dubnium
921+
tasks: *ref_1
889922
- name: ubuntu-14.04-carbon
890923
display_name: Ubuntu 14.04 Node Carbon
891924
run_on: ubuntu1404-test
@@ -904,11 +937,11 @@ buildvariants:
904937
expansions:
905938
NODE_LTS_NAME: argon
906939
tasks: *ref_1
907-
- name: ubuntu-18.04-dubnium
908-
display_name: Ubuntu 18.04 Node Dubnium
940+
- name: ubuntu-18.04-erbium
941+
display_name: Ubuntu 18.04 Node Erbium
909942
run_on: ubuntu1804-test
910943
expansions:
911-
NODE_LTS_NAME: dubnium
944+
NODE_LTS_NAME: erbium
912945
CLIENT_ENCRYPTION: true
913946
tasks: &ref_2
914947
- test-latest-server
@@ -948,6 +981,13 @@ buildvariants:
948981
- test-3.2-replica_set-unified
949982
- test-3.2-sharded_cluster-unified
950983
- test-atlas-connectivity
984+
- name: ubuntu-18.04-dubnium
985+
display_name: Ubuntu 18.04 Node Dubnium
986+
run_on: ubuntu1804-test
987+
expansions:
988+
NODE_LTS_NAME: dubnium
989+
CLIENT_ENCRYPTION: true
990+
tasks: *ref_2
951991
- name: ubuntu-18.04-carbon
952992
display_name: Ubuntu 18.04 Node Carbon
953993
run_on: ubuntu1804-test
@@ -969,3 +1009,8 @@ buildvariants:
9691009
NODE_LTS_NAME: argon
9701010
CLIENT_ENCRYPTION: true
9711011
tasks: *ref_2
1012+
- name: lint
1013+
display_name: lint
1014+
run_on: rhel70
1015+
tasks:
1016+
- run-checks

.evergreen/config.yml.in

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,15 @@ functions:
130130

131131
AUTH=${AUTH} SSL=${SSL} UNIFIED=${UNIFIED} MONGODB_URI="${MONGODB_URI}" bash ${PROJECT_DIRECTORY}/.evergreen/run-tests.sh
132132

133+
"run checks":
134+
- command: shell.exec
135+
type: test
136+
params:
137+
working_dir: "src"
138+
script: |
139+
${PREPARE_SHELL}
140+
bash ${PROJECT_DIRECTORY}/.evergreen/run-checks.sh
141+
133142
"cleanup":
134143
- command: shell.exec
135144
params:

.evergreen/generate_evergreen_tasks.js

Lines changed: 34 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ const yaml = require('js-yaml');
66

77
const LATEST_EFFECTIVE_VERSION = '5.0';
88
const MONGODB_VERSIONS = ['latest', '4.2', '4.0', '3.6', '3.4', '3.2', '3.0', '2.6'];
9-
const NODE_VERSIONS = ['dubnium', 'carbon', 'boron', 'argon'];
9+
const NODE_VERSIONS = ['erbium', 'dubnium', 'carbon', 'boron', 'argon'];
1010
const TOPOLOGIES = ['server', 'replica_set', 'sharded_cluster'].concat([
1111
'server-unified',
1212
'replica_set-unified',
@@ -37,7 +37,7 @@ const OPERATING_SYSTEMS = [
3737
run_on: 'ubuntu1804-test',
3838
mongoVersion: '>=3.2',
3939
clientEncryption: true
40-
},
40+
}
4141

4242
// Windows. reenable this when nvm supports windows, or we settle on an alternative tool
4343
// {
@@ -67,6 +67,7 @@ const OPERATING_SYSTEMS = [
6767
);
6868

6969
const TASKS = [];
70+
const SINGLETON_TASKS = [];
7071

7172
function makeTask({ mongoVersion, topology }) {
7273
let topologyForTest = topology;
@@ -80,9 +81,7 @@ function makeTask({ mongoVersion, topology }) {
8081
name: `test-${mongoVersion}-${topology}`,
8182
tags: [mongoVersion, topology],
8283
commands: [
83-
{
84-
func: 'install dependencies'
85-
},
84+
{ func: 'install dependencies' },
8685
{
8786
func: 'bootstrap mongo-orchestration',
8887
vars: {
@@ -101,20 +100,11 @@ MONGODB_VERSIONS.forEach(mongoVersion => {
101100
});
102101
});
103102

103+
// singleton task for connectivity tests
104104
TASKS.push({
105105
name: 'test-atlas-connectivity',
106106
tags: ['atlas-connect'],
107-
commands: [
108-
{
109-
func: 'install dependencies'
110-
},
111-
{
112-
func: 'run atlas tests',
113-
vars: {
114-
VERSION: 'latest'
115-
}
116-
}
117-
]
107+
commands: [{ func: 'install dependencies' }, { func: 'run atlas tests' }]
118108
});
119109

120110
const BUILD_VARIANTS = [];
@@ -129,8 +119,12 @@ const getTaskList = (() => {
129119
}
130120

131121
const ret = TASKS.filter(task => {
132-
const { VERSION } = task.commands.filter(task => !!task.vars)[0].vars;
122+
const tasksWithVars = task.commands.filter(task => !!task.vars);
123+
if (!tasksWithVars.length) {
124+
return true;
125+
}
133126

127+
const { VERSION } = tasksWithVars[0].vars || {};
134128
if (VERSION === 'latest') {
135129
return semver.satisfies(semver.coerce(LATEST_EFFECTIVE_VERSION), mongoVersion);
136130
}
@@ -170,9 +164,30 @@ OPERATING_SYSTEMS.forEach(
170164
}
171165
);
172166

173-
const fileData = yaml.safeLoad(fs.readFileSync(`${__dirname}/config.yml.in`, 'utf8'));
167+
// singleton build variant for linting
168+
SINGLETON_TASKS.push({
169+
name: 'run-checks',
170+
tags: ['run-checks'],
171+
commands: [
172+
{
173+
func: 'install dependencies',
174+
vars: {
175+
NODE_LTS_NAME: 'erbium'
176+
}
177+
},
178+
{ func: 'run checks' }
179+
]
180+
});
174181

175-
fileData.tasks = (fileData.tasks || []).concat(TASKS);
182+
BUILD_VARIANTS.push({
183+
name: 'lint',
184+
display_name: 'lint',
185+
run_on: 'rhel70',
186+
tasks: ['run-checks']
187+
});
188+
189+
const fileData = yaml.safeLoad(fs.readFileSync(`${__dirname}/config.yml.in`, 'utf8'));
190+
fileData.tasks = (fileData.tasks || []).concat(TASKS).concat(SINGLETON_TASKS);
176191
fileData.buildvariants = (fileData.buildvariants || []).concat(BUILD_VARIANTS);
177192

178193
fs.writeFileSync(`${__dirname}/config.yml`, yaml.safeDump(fileData, { lineWidth: 120 }), 'utf8');

.evergreen/run-checks.sh

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#!/bin/bash
2+
set -o errexit # Exit the script with error if any of the commands fail
3+
4+
export PROJECT_DIRECTORY="$(pwd)"
5+
NODE_ARTIFACTS_PATH="${PROJECT_DIRECTORY}/node-artifacts"
6+
export NVM_DIR="${NODE_ARTIFACTS_PATH}/nvm"
7+
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
8+
9+
npm run lint

.evergreen/run-tests.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,4 @@ else
3030
npm install mongodb-client-encryption
3131
fi
3232

33-
MONGODB_UNIFIED_TOPOLOGY=${UNIFIED} MONGODB_URI=${MONGODB_URI} npm test
33+
MONGODB_UNIFIED_TOPOLOGY=${UNIFIED} MONGODB_URI=${MONGODB_URI} npm run test-nolint

0 commit comments

Comments
 (0)