forked from dotnet/wcf
-
Notifications
You must be signed in to change notification settings - Fork 0
/
netci.groovy
executable file
·280 lines (242 loc) · 11.6 KB
/
netci.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
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
// Import the utility functionality.
import jobs.generation.Utilities;
def project = GithubProject
// Globals
// Map of os -> osGroup.
def osGroupMap = ['Ubuntu':'Linux',
'Ubuntu14.04':'Linux',
'Ubuntu15.10':'Linux',
'Debian8.2':'Linux',
'OSX':'OSX',
'Windows_NT':'Windows_NT',
'CentOS7.1': 'Linux',
'OpenSUSE13.2': 'Linux',
'RHEL7.2': 'Linux']
// Map of os -> nuget runtime
def targetNugetRuntimeMap = ['OSX' : 'osx.10.10-x64',
'Ubuntu' : 'ubuntu.14.04-x64',
'Ubuntu15.10' : 'ubuntu.14.04-x64',
'Debian8.2' : 'ubuntu.14.04-x64',
'CentOS7.1' : 'centos.7-x64',
'OpenSUSE13.2' : 'ubuntu.14.04-x64',
'RHEL7.2': 'rhel.7-x64']
def branchList = ['master', 'pr', 'rc2']
def osShortName = ['Windows 10': 'win10',
'Windows 7' : 'win7',
'Windows_NT' : 'windows_nt',
'Ubuntu14.04' : 'ubuntu14.04',
'OSX' : 'osx',
'Windows Nano' : 'winnano',
'Ubuntu15.10' : 'ubuntu15.10',
'CentOS7.1' : 'centos7.1',
'OpenSUSE13.2' : 'opensuse13.2',
'RHEL7.2' : 'rhel7.2']
def static getFullBranchName(def branch) {
def branchMap = ['master':'*/master',
'rc2':'*/release/1.0.0-rc2',
'pr':'*/master']
def fullBranchName = branchMap.get(branch, null)
assert fullBranchName != null : "Could not find a full branch name for ${branch}"
return branchMap[branch]
}
def static getJobName(def name, def branchName) {
def baseName = name
if (branchName == 'rc2') {
baseName += "_rc2"
}
return baseName
}
def configurationGroupList = ['Debug', 'Release']
def branch = GithubBranchName
// **************************
// Utilities shared for WCF Core builds
// **************************
class WcfUtilities
{
def wcfPRServiceCount = 0
// Outerloop jobs for WCF Core require an external server reference
// This should be run
def addWcfOuterloopTestServiceSync(def job, String os, String branch, boolean isPR) {
// Exclude rc2 branch, since that branch will not have the sync scripts in
if (branch.toLowerCase().contains("rc2")) {
return
}
wcfPRServiceCount++
def operation = isPR ? "pr" : "branch"
job.with {
parameters {
stringParam('WcfServiceUri', "wcfcoresrv2.cloudapp.net/WcfService${wcfPRServiceCount}", 'Wcf OuterLoop Test Service Uri')
stringParam('WcfPRServiceUri', "http://wcfcoresrv2.cloudapp.net/PRServiceMaster/pr.ashx", 'Wcf OuterLoop Test PR Service Uri')
stringParam('WcfPRServiceId', "${wcfPRServiceCount}", 'Wcf OuterLoop Test PR Service Id')
}
}
if (os.toLowerCase().contains("windows")) {
job.with {
steps {
batchFile(".\\src\\System.Private.ServiceModel\\tools\\scripts\\sync-pr.cmd %WcfPRServiceId% ${operation} %WcfPRServiceUri%")
}
}
}
else {
job.with {
steps {
shell("HOME=\$WORKSPACE/tempHome ./src/System.Private.ServiceModel/tools/scripts/sync-pr.sh \$WcfPRServiceId ${operation} \$WcfPRServiceUri")
}
}
}
}
}
wcfUtilities = new WcfUtilities()
// **************************
// Define the code coverage jobs
// **************************
branchList.each { branchName ->
def isPR = (branchName == 'pr')
def os = "Windows_NT"
def configurationGroup = "Debug"
def newJobName = "code_coverage_${os.toLowerCase()}_${configurationGroup.toLowerCase()}"
// Create the new rolling job
def newJob = job(getJobName(Utilities.getFullJobName(project, newJobName, isPR), branchName))
wcfUtilities.addWcfOuterloopTestServiceSync(newJob, os, branchName, isPR)
newJob.with {
steps {
batchFile("build.cmd /p:ShouldCreatePackage=false /p:ShouldGenerateNuSpec=false /p:OSGroup=${osGroupMap[os]} /p:ConfigurationGroup=${configurationGroup} /p:Coverage=true /p:WithCategories=\"InnerLoop;OuterLoop\" /p:ServiceUri=%WcfServiceUri%")
}
}
// Set affinity for elevated machines
Utilities.setMachineAffinity(newJob, os, 'latest-or-auto-elevated')
// Set up standard options.
Utilities.standardJobSetup(newJob, project, isPR, getFullBranchName(branchName))
// Add code coverage report
Utilities.addHtmlPublisher(newJob, 'bin/tests/coverage', 'Code Coverage Report', 'index.htm')
// Archive results
Utilities.addArchival(newJob, '**/coverage/*,msbuild.log')
// Our outerloops rely on us calling WcfPRServiceUri to sync server code, after which the client
// will test against WcfServiceUri.
// The current design limitation means that if we allow concurrent builds, it becomes possible to pave over
// the server endpoint with mismatched code while another test is running.
// Due to this design limitation, we have to disable concurrent builds for outerloops
newJob.concurrentBuild(false)
// Set triggers
if (isPR)
{
Utilities.addGithubPRTrigger(newJob, "Code Coverage Windows_NT ${configurationGroup}", '(?i).*test\\W+code\\W*coverage.*')
}
else {
Utilities.addPeriodicTrigger(newJob, '@daily')
}
}
// **************************
// Define outerloop testing for OSes that can build and run. Run locally on each machine.
// **************************
def supportedFullCycleOuterloopPlatforms = ['Windows_NT', 'Ubuntu14.04', 'CentOS7.1', 'OSX']
branchList.each { branchName ->
configurationGroupList.each { configurationGroup ->
supportedFullCycleOuterloopPlatforms.each { os ->
def isPR = (branchName == 'pr')
def newJobName = "outerloop_${os.toLowerCase()}_${configurationGroup.toLowerCase()}"
def newJob = job(getJobName(Utilities.getFullJobName(project, newJobName, isPR), branchName))
wcfUtilities.addWcfOuterloopTestServiceSync(newJob, os, branchName, isPR)
if (osGroupMap[os] == 'Windows_NT') {
newJob.with {
steps {
batchFile("build.cmd /p:ConfigurationGroup=${configurationGroup} /p:OSGroup=${osGroupMap[os]} /p:WithCategories=OuterLoop /p:ServiceUri=%WcfServiceUri%")
}
}
}
else {
newJob.with {
steps {
shell("HOME=\$WORKSPACE/tempHome ./build.sh /p:ConfigurationGroup=${configurationGroup} /p:OSGroup=${osGroupMap[os]} /p:WithCategories=OuterLoop /p:TestWithLocalLibraries=true /p:ServiceUri=\$WcfServiceUri")
}
}
}
// Set the affinity. OS name matches the machine affinity.
if (os == 'Windows_NT') {
// Set affinity for elevated machines on Windows
Utilities.setMachineAffinity(newJob, os, 'latest-or-auto-elevated')
}
else if (os == 'Ubuntu14.04' || os == 'CentOS7.1') {
Utilities.setMachineAffinity(newJob, os, "outer-latest-or-auto")
}
else {
Utilities.setMachineAffinity(newJob, os, 'latest-or-auto')
}
// Set up standard options.
Utilities.standardJobSetup(newJob, project, isPR, getFullBranchName(branchName))
// Add the unit test results
Utilities.addXUnitDotNETResults(newJob, 'bin/tests/**/testResults.xml')
// Our outerloops rely on us calling WcfPRServiceUri to sync server code, after which the client
// will test against WcfServiceUri.
// The current design limitation means that if we allow concurrent builds, it becomes possible to pave over
// the server endpoint with mismatched code while another test is running.
// Due to this design limitation, we have to disable concurrent builds for outerloops
newJob.concurrentBuild(false)
// Skip outerloop testing on rc2 branch on non-WinNT platforms
// we are incapable of running outerloops in CI due to the dependency on the Bridge
if (branchName == 'rc2' && os != 'Windows_NT') {
newJob.disabled(true)
}
// Set up appropriate triggers. PR on demand, otherwise daily
if (isPR) {
// Set PR trigger.
Utilities.addGithubPRTrigger(newJob, "OuterLoop ${os} ${configurationGroup}", "(?i).*test\\W+outerloop\\W+${os}.*")
}
else {
// Set a periodic trigger
Utilities.addPeriodicTrigger(newJob, '@daily')
}
}
}
}
// **************************
// Define innerloop testing for OSes that can build and run. Run locally on each machine.
// **************************
def supportedFullCycleInnerloopPlatforms = ['Windows_NT', 'Ubuntu14.04', 'CentOS7.1', 'OSX']
branchList.each { branchName ->
configurationGroupList.each { configurationGroup ->
supportedFullCycleInnerloopPlatforms.each { os ->
def isPR = (branchName == 'pr')
def newJobName = "${os.toLowerCase()}_${configurationGroup.toLowerCase()}"
def newJob = job(getJobName(Utilities.getFullJobName(project, newJobName, isPR), branchName))
if (osGroupMap[os] == 'Windows_NT')
{
newJob.with {
steps {
batchFile("call \"C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\VC\\vcvarsall.bat\" x86 && build.cmd /p:ConfigurationGroup=${configurationGroup} /p:OSGroup=${osGroupMap[os]}")
batchFile("C:\\Packer\\Packer.exe .\\bin\\build.pack .\\bin")
}
}
}
else {
newJob.with {
steps {
shell("HOME=\$WORKSPACE/tempHome ./build.sh /p:ShouldCreatePackage=false /p:ShouldGenerateNuSpec=false /p:OSGroup=${osGroupMap[os]} /p:ConfigurationGroup=${configurationGroup}")
}
}
}
// Set the affinity. All of these run on Windows currently.
Utilities.setMachineAffinity(newJob, os, 'latest-or-auto')
// Set up standard options.
Utilities.standardJobSetup(newJob, project, isPR, getFullBranchName(branchName))
// Add the unit test results
Utilities.addXUnitDotNETResults(newJob, 'bin/tests/**/testResults.xml')
// Add archival for the built data
if (osGroupMap[os] == 'Windows_NT') {
Utilities.addArchival(newJob, "bin/build.pack,bin/${osGroupMap[os]}.AnyCPU.${configurationGroup}/**,bin/ref/**,bin/packages/**,msbuild.log")
}
else {
Utilities.addArchival(newJob, "bin/${osGroupMap[os]}.AnyCPU.${configurationGroup}/**,bin/ref/**,bin/packages/**,msbuild.log")
}
// Set up triggers
if (isPR) {
// Set PR trigger.
Utilities.addGithubPRTrigger(newJob, "Innerloop ${os} ${configurationGroup}")
}
else {
// Set a push trigger
Utilities.addGithubPushTrigger(newJob)
}
}
}
}