Remove OpenSuse13.2 from runtime section in all Project.Jsons
[platform/upstream/coreclr.git] / perf.groovy
1 // Import the utility functionality.
2
3 import jobs.generation.*;
4
5 def project = GithubProject
6 def branch = GithubBranchName
7 def projectName = Utilities.getFolderName(project)
8 def projectFolder = projectName + '/' + Utilities.getFolderName(branch)
9
10 def static getOSGroup(def os) {
11     def osGroupMap = ['Ubuntu14.04':'Linux',
12         'RHEL7.2': 'Linux',
13         'Ubuntu16.04': 'Linux',
14         'Debian8.4':'Linux',
15         'Fedora23':'Linux',
16         'OSX':'OSX',
17         'Windows_NT':'Windows_NT',
18         'FreeBSD':'FreeBSD',
19         'CentOS7.1': 'Linux',
20         'OpenSUSE13.2': 'Linux',
21         'OpenSUSE42.1': 'Linux',
22         'LinuxARMEmulator': 'Linux']
23     def osGroup = osGroupMap.get(os, null)
24     assert osGroup != null : "Could not find os group for ${os}"
25     return osGroupMap[os]
26 }
27 // Setup perflab tests runs
28 [true, false].each { isPR ->
29     ['Windows_NT'].each { os ->
30                 ['x64', 'x86'].each { architecture ->
31                         def newJob = job(Utilities.getFullJobName(project, "perf_perflab_${os}_${architecture}", isPR)) {
32                                 // Set the label.
33                                 label('windows_clr_perf')
34                                 wrappers {
35                                         credentialsBinding {
36                                                 string('BV_UPLOAD_SAS_TOKEN', 'CoreCLR Perf BenchView Sas')
37                                         }
38                                 }
39
40                         if (isPR)
41                         {
42                                 parameters
43                                 {
44                                         stringParam('BenchviewCommitName', '\${ghprbPullTitle}', 'The name that you will be used to build the full title of a run in Benchview.  The final name will be of the form <branch> private BenchviewCommitName')
45                                 }
46                         }
47                         def configuration = 'Release'
48                         def runType = isPR ? 'private' : 'rolling'
49                         def benchViewName = isPR ? 'coreclr private %BenchviewCommitName%' : 'coreclr rolling %GIT_BRANCH_WITHOUT_ORIGIN% %GIT_COMMIT%'
50                                 
51                                 steps {
52                                         // Batch
53
54                                         batchFile("if exist \"%WORKSPACE%\\Microsoft.BenchView.JSONFormat\" rmdir /s /q \"%WORKSPACE%\\Microsoft.BenchView.JSONFormat\"")
55                                         batchFile("C:\\Tools\\nuget.exe install Microsoft.BenchView.JSONFormat -Source http://benchviewtestfeed.azurewebsites.net/nuget -OutputDirectory \"%WORKSPACE%\" -Prerelease -ExcludeVersion")
56                                         //Do this here to remove the origin but at the front of the branch name as this is a problem for BenchView
57                                         //we have to do it all as one statement because cmd is called each time and we lose the set environment variable
58                                         batchFile("if [%GIT_BRANCH:~0,7%] == [origin/] (set GIT_BRANCH_WITHOUT_ORIGIN=%GIT_BRANCH:origin/=%) else (set GIT_BRANCH_WITHOUT_ORIGIN=%GIT_BRANCH%)\n" +
59                                         "py \"%WORKSPACE%\\Microsoft.BenchView.JSONFormat\\tools\\submission-metadata.py\" --name " + "\"" + benchViewName + "\"" + " --user " + "\"dotnet-bot@microsoft.com\"\n" +
60                                         "py \"%WORKSPACE%\\Microsoft.BenchView.JSONFormat\\tools\\build.py\" git --branch %GIT_BRANCH_WITHOUT_ORIGIN% --type " + runType)
61                                         batchFile("py \"%WORKSPACE%\\Microsoft.BenchView.JSONFormat\\tools\\machinedata.py\"")
62                                         batchFile("set __TestIntermediateDir=int&&build.cmd release ${architecture}")
63                                         batchFile("tests\\runtest.cmd release ${architecture} GenerateLayoutOnly")
64                                         batchFile("tests\\scripts\\run-xunit-perf.cmd -arch ${architecture} -configuration ${configuration} -testBinLoc bin\\tests\\Windows_NT.${architecture}.Release\\performance\\perflab\\Perflab -library -uploadToBenchview \"%WORKSPACE%\\Microsoft.Benchview.JSONFormat\\tools\" -runtype " + runType)
65                                         batchFile("tests\\scripts\\run-xunit-perf.cmd -arch ${architecture} -configuration ${configuration} -testBinLoc bin\\tests\\Windows_NT.${architecture}.Release\\Jit\\Performance\\CodeQuality -uploadToBenchview \"%WORKSPACE%\\Microsoft.Benchview.JSONFormat\\tools\" -runtype " + runType)
66                                 }
67                         }
68
69                         // Save machinedata.json to /artifact/bin/ Jenkins dir
70                         def archiveSettings = new ArchivalSettings()
71                         archiveSettings.addFiles('perf-*.xml')
72                         archiveSettings.addFiles('perf-*.etl')
73                         Utilities.addArchival(newJob, archiveSettings)
74
75                         Utilities.standardJobSetup(newJob, project, isPR, "*/${branch}")
76
77                         if (isPR) {
78                                 TriggerBuilder builder = TriggerBuilder.triggerOnPullRequest()
79                                 builder.setGithubContext("${os} ${architecture} CoreCLR Perf Tests")
80                                 builder.triggerOnlyOnComment()
81                                 builder.setCustomTriggerPhrase("(?i).*test\\W+${os}_${architecture}\\W+perf.*")
82                                 builder.triggerForBranch(branch)
83                                 builder.emitTrigger(newJob)
84                         }
85                         else {
86                                 // Set a push trigger
87                                 TriggerBuilder builder = TriggerBuilder.triggerOnCommit()
88                                 builder.emitTrigger(newJob)
89                         }
90                 }
91     }
92 }
93
94 // Create the Linux/OSX/CentOS coreclr test leg for debug and release and each scenario
95 [true, false].each { isPR ->
96     ['Ubuntu14.04'].each { os ->
97         def newJob = job(Utilities.getFullJobName(project, "perf_${os}", isPR)) {
98                         
99                         label('linux_clr_perf')
100                                 wrappers {
101                                         credentialsBinding {
102                                                 string('BV_UPLOAD_SAS_TOKEN', 'CoreCLR Perf BenchView Sas')
103                                         }
104                                 }
105                         
106                         if (isPR)
107                         {
108                                 parameters
109                                 {
110                                         stringParam('BenchviewCommitName', '\${ghprbPullTitle}', 'The name that you will be used to build the full title of a run in Benchview.  The final name will be of the form <branch> private BenchviewCommitName')
111                                 }
112                         }
113                         def osGroup = getOSGroup(os)
114                         def architecture = 'x64'
115                         def configuration = 'Release'
116                         def runType = isPR ? 'private' : 'rolling'
117                         def benchViewName = isPR ? 'coreclr private \$BenchviewCommitName' : 'coreclr rolling \$GIT_BRANCH_WITHOUT_ORIGIN \$GIT_COMMIT'
118                         
119             steps {
120                 shell("bash ./tests/scripts/perf-prep.sh")
121                 shell("./init-tools.sh")
122                                 shell("./build.sh ${architecture} ${configuration}")
123                                 shell("GIT_BRANCH_WITHOUT_ORIGIN=\$(echo \$GIT_BRANCH | sed \"s/[^/]*\\/\\(.*\\)/\\1 /\")\n" +
124                                 "python3.5 \"\${WORKSPACE}/tests/scripts/Microsoft.BenchView.JSONFormat/tools/submission-metadata.py\" --name " + "\"" + benchViewName + "\"" + " --user " + "\"dotnet-bot@microsoft.com\"\n" +
125                                 "python3.5 \"\${WORKSPACE}/tests/scripts/Microsoft.BenchView.JSONFormat/tools/build.py\" git --branch \$GIT_BRANCH_WITHOUT_ORIGIN --type " + runType)
126                 shell("""sudo -E bash ./tests/scripts/run-xunit-perf.sh \\
127                 --testRootDir=\"\${WORKSPACE}/bin/tests/Windows_NT.${architecture}.${configuration}\" \\
128                 --testNativeBinDir=\"\${WORKSPACE}/bin/obj/${osGroup}.${architecture}.${configuration}/tests\" \\
129                 --coreClrBinDir=\"\${WORKSPACE}/bin/Product/${osGroup}.${architecture}.${configuration}\" \\
130                 --mscorlibDir=\"\${WORKSPACE}/bin/Product/${osGroup}.${architecture}.${configuration}\" \\
131                 --coreFxBinDir=\"\${WORKSPACE}/corefx\" \\
132                                 --runType=\"${runType}\" \\
133                                 --benchViewOS=\"${os}\" \\
134                                 --uploadToBenchview""")
135             }
136         }
137
138         // Save machinedata.json to /artifact/bin/ Jenkins dir
139         def archiveSettings = new ArchivalSettings()
140         archiveSettings.addFiles('sandbox/perf-*.xml')
141         archiveSettings.addFiles('machinedata.json')
142         Utilities.addArchival(newJob, archiveSettings)
143
144         Utilities.standardJobSetup(newJob, project, isPR, "*/${branch}")
145
146         // For perf, we need to keep the run results longer
147         newJob.with {
148             // Enable the log rotator
149             logRotator {
150                 artifactDaysToKeep(7)
151                 daysToKeep(300)
152                 artifactNumToKeep(25)
153                 numToKeep(1000)
154             }
155         }
156         if (isPR) {
157             TriggerBuilder builder = TriggerBuilder.triggerOnPullRequest()
158             builder.setGithubContext("${os} Perf Tests")
159             builder.triggerOnlyOnComment()
160             builder.setCustomTriggerPhrase("(?i).*test\\W+${os}\\W+perf.*")
161             builder.triggerForBranch(branch)
162             builder.emitTrigger(newJob)
163         }
164         else {
165             // Set a push trigger
166             TriggerBuilder builder = TriggerBuilder.triggerOnCommit()
167             builder.emitTrigger(newJob)
168         }
169     } // os
170 } // isPR