forked from nodejs/build
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathVersionSelectorScript.groovy
164 lines (142 loc) · 8 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
// 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 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) ],
[ /centos6-32-gcc6/, releaseType, gte(10) ], // 32-bit linux for <10 only
[ /^centos7-64/, releaseType, lt(12) ],
[ /^centos7-ppcle/, anyType, lt(10) ],
[ /^ppcle-ubuntu/, releaseType, gte(10) ],
[ /debian8-x86/, anyType, gte(10) ], // 32-bit linux for <10 only
[ /debian8/, anyType, gte(13) ],
[ /^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
// ARM --------------------------------------------------
[ /^debian8-docker-armv7$/, releaseType, lt(10) ],
[ /^debian8-docker-armv7$/, anyType, gte(12) ],
[ /^debian9-docker-armv7$/, anyType, lt(10) ],
[ /^pi1-docker$/, releaseType, gte(10) ],
[ /^cross-compiler-armv[67]-gcc-4.8$/, anyType, gte(10) ],
[ /^cross-compiler-armv[67]-gcc-4.9/, anyType, lt(10) ],
[ /^cross-compiler-armv[67]-gcc-4.9/, anyType, gte(12) ],
[ /^cross-compiler-armv[67]-gcc-6/, anyType, lt(12) ],
// Windows -----------------------------------------------
// https://github.com/nodejs/build/blob/master/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) ],
// 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, lt(8) ],
[ /vs2019(-\w+)?$/, testType, lt(13) ],
[ /vs2015-x86$/, testType, gte(10) ], // compile x86 only once
[ /vs2017-x86$/, testType, ltGte(10, 14) ],
[ /vs2019-x86$/, testType, lt(14) ],
// VS versions supported to build add-ons
[ /vs2013-COMPILED_BY/, testType, gte(9) ],
[ /vs2015-COMPILED_BY/, testType, noVer ],
[ /vcbt2015-COMPILED_BY/, testType, noVer ],
[ /vs2017-COMPILED_BY/, testType, lt(8) ],
[ /vs2019-COMPILED_BY/, testType, lt(12) ],
// Exclude some redundant configurations
// https://github.com/nodejs/build/blob/master/doc/node-test-commit-matrix.md
[ /win2008r2.*COMPILED_BY-vs2017/, testType, lt(10) ], // vs2015 runs on win2008 for <10
[ /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 -----------------------------------------------
[ /^smartos15/, anyType, lt(8) ],
[ /^smartos15/, anyType, gte(10) ],
[ /^smartos16/, anyType, lt(8) ],
[ /^smartos16/, anyType, gte(12) ],
[ /^smartos17/, anyType, lt(10) ],
[ /^smartos17/, anyType, gte(12) ],
[ /^smartos18/, anyType, lt(12) ],
// PPC BE ------------------------------------------------
[ /^ppcbe-ubuntu/, anyType, gte(8) ],
// s390x -------------------------------------------------
[ /s390x/, anyType, lt(6) ],
// AIX61 -------------------------------------------------
[ /aix61/, anyType, lt(6) ],
// Shared libs docker containers -------------------------
[ /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 ---------------------------------------------------
[ /^osx1010/, anyType, gte(11) ],
[ /^osx1011/, releaseType, lt(11) ],
// FreeBSD -----------------------------------------------
[ /^freebsd10/, anyType, gte(11) ],
// Source / headers / docs -------------------------------
[ /^osx1010-release-sources$/, releaseType, gte(11) ],
[ /^osx1011-release-sources$/, releaseType, lt(11) ],
[ /^osx1011-release-sources$/, releaseType, gte(12) ],
[ /^centos7-release-sources$/, releaseType, lt(12) ],
// -------------------------------------------------------
]
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'])
nodeMajorVersion = parameters['NODEJS_MAJOR_VERSION'].toString().toInteger()
println "Node.js major version: $nodeMajorVersion"
println "Node.js version: ${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)
}