forked from dotnet/msbuild
-
Notifications
You must be signed in to change notification settings - Fork 0
/
netci.groovy
168 lines (137 loc) · 6.19 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
// Import the utility functionality.
import jobs.generation.*;
// The input project name
project = GithubProject
// The input branch name (e.g. master)
branch = GithubBranchName
// What this repo is using for its machine images at the current time
imageVersionMap = ['Windows_NT':'latest-dev15-5',
'OSX10.13':'latest-or-auto',
'Ubuntu14.04':'latest-or-auto',
'Ubuntu16.04':'20170731',
'RHEL7.2' : 'latest']
def CreateJob(script, runtime, osName, isPR, machineAffinityOverride = null, shouldSkipTestsWhenResultsNotFound = false, isSourceBuild = false) {
def newJobName = Utilities.getFullJobName("innerloop_${osName}_${runtime}${isSourceBuild ? '_SourceBuild_' : ''}", isPR)
// Create a new job with the specified name. The brace opens a new closure
// and calls made within that closure apply to the newly created job.
def newJob = job(newJobName) {
description('')
}
newJob.with{
steps{
if(osName.contains("Windows") || osName.contains("windows")) {
batchFile(script)
} else {
shell(script)
}
}
skipTestsWhenResultsNotFound = shouldSkipTestsWhenResultsNotFound
}
// Add xunit result archiving. Skip if no results found.
Utilities.addXUnitDotNETResults(newJob, 'artifacts/**/TestResults/*.xml', skipTestsWhenResultsNotFound)
if (machineAffinityOverride == null) {
def imageVersion = imageVersionMap[osName];
Utilities.setMachineAffinity(newJob, osName, imageVersion)
}
else {
Utilities.setMachineAffinity(newJob, machineAffinityOverride)
}
Utilities.standardJobSetup(newJob, project, isPR, "*/${branch}")
// Add archiving of logs (even if the build failed)
Utilities.addArchival(newJob,
'artifacts/**/log/*.binlog,artifacts/**/log/*.log,artifacts/**/TestResults/*,artifacts/**/MSBuild_*.failure.txt', /* filesToArchive */
'', /* filesToExclude */
false, /* doNotFailIfNothingArchived */
false, /* archiveOnlyIfSuccessful */)
// Add trigger
if (isPR) {
TriggerBuilder prTrigger = TriggerBuilder.triggerOnPullRequest()
if (runtime == "MonoTest") {
// Until they're passing reliably, require opt in
// for Mono tests
prTrigger.setCustomTriggerPhrase("(?i).*test\\W+mono.*")
prTrigger.triggerOnlyOnComment()
}
prTrigger.triggerForBranch(branch)
// Set up what shows up in Github:
prTrigger.setGithubContext("${osName} Build for ${runtime}")
prTrigger.emitTrigger(newJob)
} else {
if (runtime != "Mono") {
Utilities.addGithubPushTrigger(newJob)
}
}
}
[true, false].each { isPR ->
['Windows_NT', 'OSX10.13', 'Ubuntu14.04', 'Ubuntu16.04'].each {osName ->
def runtimes = ['CoreCLR']
if (osName == 'Windows_NT') {
runtimes.add('Full')
}
// TODO: make this !windows once RHEL builds are working
if (osName.startsWith('Ubuntu') || osName.startsWith('OSX')) {
runtimes.add('Mono')
runtimes.add('MonoTest')
}
def script = "NA"
def machineAffinityOverride = null
def shouldSkipTestsWhenResultsNotFound = false
runtimes.each { runtime ->
switch(osName) {
case 'Windows_NT':
// Protect against VsDevCmd behaviour of changing the current working directory https://developercommunity.visualstudio.com/content/problem/26780/vsdevcmdbat-changes-the-current-working-directory.html
script = "set VSCMD_START_DIR=\"%CD%\" && call \"C:\\Program Files (x86)\\Microsoft Visual Studio\\2017\\Enterprise\\Common7\\Tools\\VsDevCmd.bat\""
if (runtime == "Full") {
script += " && build\\cibuild.cmd"
}
else if (runtime == "CoreCLR") {
script += " && build\\cibuild.cmd -hostType Core"
}
// this agent has VS 15.7 on it, which is a min requirement for our repo now.
machineAffinityOverride = 'Windows.10.Amd64.ClientRS3.DevEx.Open'
break;
case 'OSX10.13':
script = "./build/cibuild.sh"
if (runtime == "MonoTest" || runtime == "Mono") {
// default is to run tests!
script += " -hostType mono"
}
if (runtime == "Mono") {
// tests are failing on mono right now, so default to
// skipping tests
script += " -skipTests"
shouldSkipTestsWhenResultsNotFound = true
}
break;
case { it.startsWith('Ubuntu') }:
script = "./build/cibuild.sh"
if (runtime == "MonoTest" || runtime == "Mono") {
// default is to run tests!
script += " -hostType mono"
}
if (runtime == "Mono") {
// tests are failing on mono right now, so default to
// skipping tests
script += " -skipTests"
shouldSkipTestsWhenResultsNotFound = true
}
break;
}
CreateJob(script, runtime, osName, isPR, machineAffinityOverride, shouldSkipTestsWhenResultsNotFound)
}
}
}
// sourcebuild simulation
CreateJob(
"./build/build.sh build -dotnetBuildFromSource -bootstraponly -skiptests -pack -configuration Release",
"CoreCLR",
"RHEL7.2",
true,
null,
true,
true)
JobReport.Report.generateJobReport(out)
// Make the call to generate the help job
Utilities.createHelperJob(this, project, branch,
"Welcome to the ${project} Repository", // This is prepended to the help message
"Have a nice day!") // This is appended to the help message. You might put known issues here.