-
Notifications
You must be signed in to change notification settings - Fork 166
/
Copy pathVersionSelectorScript.groovy
200 lines (177 loc) · 10.4 KB
/
VersionSelectorScript.groovy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
// https://wiki.jenkins.io/display/JENKINS/matrix+groovy+execution+strategy+plugin
// https://docs.oracle.com/javase/7/docs/api/java/util/regex/Pattern.html
// Helper closures to make our buildExclusions DSL terse and readable
def lt = { v -> { nodeVersion -> nodeVersion < v } }
def gte = { v -> { nodeVersion -> nodeVersion >= v } }
def gteLt = { vGte, vLt -> { nodeVersion -> gte(vGte)(nodeVersion) && lt(vLt)(nodeVersion) } }
def ltGte = { vLt, vGte -> { nodeVersion -> lt(vLt)(nodeVersion) || gte(vGte)(nodeVersion) } }
def allVer = { nodeVersion -> true }
def noVer = { nodeVersion -> false }
def releaseType = { buildType -> buildType == 'release' }
def testType = { buildType -> buildType == 'test' }
def anyType = { buildType -> true }
def buildExclusions = [
// Given a machine label, build type (release or !release) and a Node.js
// major version number, determine which ones to _exclude_ from a build
// -------------------------------------------------------
// Machine Label, Build Type, Node Version
// Linux -------------------------------------------------
[ /^centos6/, releaseType, lt(8) ],
[ /^centos6/, anyType, gte(12) ],
[ /^centos[67]-(arm)?(64|32)-gcc48/,anyType, gte(10) ],
[ /^centos[67]-(arm)?(64|32)-gcc6/, anyType, lt(10) ],
[ /^centos[67]-(arm)?(64|32)-gcc6/, anyType, gte(14) ], // 14.x: gcc6 builds stop
[ /^centos7-(arm)?(64)-gcc8/, anyType, lt(14) ], // 14.x: gcc8 builds start
[ /^centos7-(arm)?(64)-gcc8/, anyType, gte(18) ], // 18.x: centos7 builds stop
[ /^centos6-32-gcc6/, releaseType, gte(10) ], // 32-bit linux for <10 only
[ /^centos7-64/, releaseType, lt(12) ],
[ /^centos7-64/, anyType, gte(18) ],
[ /debian8-x86/, anyType, gte(10) ], // 32-bit linux for <10 only
[ /debian8/, anyType, gte(13) ],
[ /debian9/, anyType, gte(16) ],
[ /rhel7/, anyType, gte(18) ],
[ /rhel8/, releaseType, lt(18) ],
[ /rhel8/, anyType, lt(14) ],
[ /^ubuntu1804/, anyType, lt(10) ], // probably temporary
[ /^ubuntu1404-32/, anyType, gte(10) ], // 32-bit linux for <10 only
[ /^ubuntu1404-64/, anyType, gte(12) ],
[ /^ubuntu1604-32/, anyType, gte(10) ], // 32-bit linux for <10 only
[ /^ubuntu1604-64/, anyType, gte(16) ],
[ /^ubuntu2004/, anyType, lt(13) ], // Ubuntu 20 doesn't have Python 2
[ /^alpine-latest-x64$/, anyType, lt(13) ], // Alpine 3.12 doesn't have Python 2
// Linux PPC LE ------------------------------------------
[ /^centos7-ppcle/, anyType, lt(10) ],
[ /^centos7-ppcle/, anyType, gte(18) ],
// Linux S390X --------------------------------------------
[ /s390x/, anyType, lt(6) ],
[ /lto-s390x/, anyType, lt(16) ],
// ARM --------------------------------------------------
[ /^debian8-docker-armv7$/, releaseType, lt(10) ],
[ /^debian8-docker-armv7$/, anyType, gte(12) ],
[ /^debian9-docker-armv7$/, anyType, lt(10) ],
[ /^debian10-armv7l$/, anyType, gte(20) ], // gcc 10 requires newer libstdc++
[ /^pi1-docker$/, releaseType, gte(10) ],
[ /^cross-compiler-ubuntu1604-armv[67]-gcc-4.9/, anyType, gte(12) ],
[ /^cross-compiler-ubuntu1604-armv[67]-gcc-6/, anyType, lt(12) ],
[ /^cross-compiler-ubuntu1604-armv[67]-gcc-6/, anyType, gte(14) ],
[ /^cross-compiler-ubuntu1804-armv7-gcc-6/, anyType, lt(14) ],
[ /^cross-compiler-ubuntu1804-armv7-gcc-6/, anyType, gte(16) ],
[ /^cross-compiler-ubuntu1804-armv7-gcc-8/, anyType, lt(16) ],
[ /^cross-compiler-ubuntu1804-armv7-gcc-8/, anyType, gte(18) ],
[ /^cross-compiler-rhel8-armv7-gcc-8-glibc-2.28/,anyType, lt(18) ],
[ /^cross-compiler-rhel8-armv7-gcc-8-glibc-2.28/,anyType, gte(20) ],
[ /^cross-compiler-rhel8-armv7-gcc-10-glibc-2.28/,anyType, lt(20) ],
[ /^ubuntu1604-arm64/, anyType, gte(14) ],
// Windows -----------------------------------------------
// https://github.com/nodejs/build/blob/main/doc/windows-visualstudio-supported-versions.md
// Release Builders - should only match one VS version per Node.js version
[ /vs2013/, releaseType, gte(6) ],
[ /vs2015/, releaseType, ltGte(6, 10) ],
[ /vs2017/, releaseType, ltGte(10, 14) ],
[ /vs2019/, releaseType, lt(14) ],
[ /vs2019-arm64/, releaseType, lt(19) ],
// VS versions supported to compile Node.js - also matches labels used by test runners
[ /vs2013(-\w+)?$/, testType, gte(6) ],
[ /vs2015(-\w+)?$/, testType, gte(10) ],
[ /vcbt2015(-\w+)?$/, testType, gte(10) ],
[ /vs2017(-\w+)?$/, testType, ltGte(8, 15) ],
[ /vs2019(-\w+)?$/, testType, lt(13) ],
[ /vs2015-x86$/, testType, gte(10) ], // compile arm64/x86 only once
[ /vs2017-x86$/, testType, ltGte(10, 14) ],
[ /vs2019-x86$/, testType, lt(14) ],
[ /vs2019-arm64$/, testType, lt(14) ],
[ /COMPILED_BY-\w+-arm64$/, testType, lt(19) ], // run tests on arm64 for >=19
// VS versions supported to build add-ons
[ /vs2013-COMPILED_BY/, testType, gte(9) ],
[ /vs2015-COMPILED_BY/, testType, gte(19) ],
[ /vcbt2015-COMPILED_BY/, testType, gte(19) ],
[ /vs2017-COMPILED_BY/, testType, lt(8) ],
[ /vs2019-COMPILED_BY/, testType, lt(12) ],
// Exclude some redundant configurations
// https://github.com/nodejs/build/blob/main/doc/node-test-commit-matrix.md
[ /win10.*COMPILED_BY-vs2017/, testType, lt(10) ], // vcbt2015 runs on win10 for <10
[ /win10.*COMPILED_BY-vs2017/, testType, gte(13) ], // vs2019 runs on win10 for >=13
// SmartOS -----------------------------------------------
[ /^smartos17/, anyType, lt(10) ],
[ /^smartos17/, anyType, gte(12) ],
[ /^smartos18/, anyType, lt(12) ],
[ /^smartos18/, releaseType, gte(14) ],
[ /^smartos18/, anyType, gte(16) ],
// AIX PPC64 ---------------------------------------------
[ /aix71/, anyType, lt(10) ],
[ /aix71/, anyType, gte(15) ],
[ /aix72/, anyType, lt(15) ],
// Shared libs docker containers -------------------------
[ /ubi81_sharedlibs/, anyType, lt(13) ],
[ /sharedlibs_debug_x64/, anyType, gte(18) ],
[ /sharedlibs_openssl3/, anyType, lt(15) ],
[ /sharedlibs_openssl111/, anyType, lt(11) ],
[ /sharedlibs_openssl110/, anyType, lt(9) ],
[ /sharedlibs_openssl110/, anyType, gte(12) ],
[ /sharedlibs_openssl102/, anyType, gte(10) ],
[ /sharedlibs_fips20/, anyType, gte(10) ],
[ /sharedlibs_withoutintl/, anyType, lt(9) ],
[ /sharedlibs_withoutssl/, anyType, lt(10) ],
[ /sharedlibs_shared/, anyType, lt(9) ],
// OSX ---------------------------------------------------
[ /osx11-release-pkg/, releaseType, lt(16) ],
[ /osx11-release-tar/, releaseType, lt(16) ],
[ /osx1015-release-pkg/, releaseType, gte(16) ],
[ /^osx11/, testType, lt(15) ],
[ /osx1014/, anyType, gte(17) ],
// osx1015 enabled for all up, and builds all releases to support notarization
// osx11 only for 15+ and builds the fat binary
// This will need splitting into arm + x64 when the release machines move up from 10.15
// FreeBSD -----------------------------------------------
[ /^freebsd10/, anyType, gte(11) ],
// Source / headers / docs -------------------------------
[ /^centos7-release-sources$/, releaseType, lt(10) ],
[ /^centos7-release-sources$/, releaseType, gte(18) ],
[ /^rhel8-release-sources$/, releaseType, lt(18) ],
// -------------------------------------------------------
]
def canBuild = { nodeVersion, builderLabel, buildType ->
buildExclusions.findResult(true) { // this works like an array.contains(), returns true (default) or false
def match = it[0]
def type = it[1]
def version = it[2]
if (version(nodeVersion) && type(buildType) && builderLabel =~ match)
return false
return null
}
}
// setup for execution of the above rules
int nodeMajorVersion = -1
if (parameters['NODEJS_MAJOR_VERSION'])
if (parameters['NODEJS_MAJOR_VERSION'] instanceof Integer) {
nodeMajorVersion = parameters['NODEJS_MAJOR_VERSION']
} else {
nodeMajorVersion = (new String(parameters['NODEJS_MAJOR_VERSION'])).toInteger()
}
println "Node.js major version: $nodeMajorVersion"
if (parameters['NODEJS_VERSION'])
println "Node.js version: ${new String(parameters['NODEJS_VERSION'])}"
// NOTE: this assumes that the default "Slaves"->"Name" in the Configuration
// Matrix is left as "nodes", if it's changed then `it.nodes` below won't work
// and returning a result with a "nodes" property won't work.
result['nodes'] = []
// Before running this script, `def buildType = 'release'` or some other value
// to be able to use the appropriate `buildType` in the exclusions
def _buildType
try {
_buildType = buildType
} catch (groovy.lang.MissingPropertyException e) {
_buildType = 'test'
}
combinations.each{
def builderLabel = it.nodes
// Default to running all builders if nodeMajorVersion is still -1
// (i.e. the version check failed)
if (nodeMajorVersion >= 4) {
if (!canBuild(nodeMajorVersion, builderLabel, _buildType)) {
println "Skipping $builderLabel for Node.js $nodeMajorVersion"
return
}
}
result['nodes'].add(it)
}