Fix cross component builderror - CMakeLists.txt for PAL (#9819)
[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', 'x86jit32'].each { arch ->
31             architecture = arch
32             testEnv = ''
33
34             if (arch == 'x86jit32')
35             {
36                 architecture = 'x86'
37                 testEnv = '-testEnv %WORKSPACE%\\tests\\x86\\compatjit_x86_testenv.cmd'
38             }
39             else if (arch == 'x86')
40             {
41                 testEnv = '-testEnv %WORKSPACE%\\tests\\x86\\ryujit_x86_testenv.cmd'
42             }
43
44                         def newJob = job(Utilities.getFullJobName(project, "perf_perflab_${os}_${arch}", isPR)) {
45                                 // Set the label.
46                                 label('windows_clr_perf')
47                                 wrappers {
48                                         credentialsBinding {
49                                                 string('BV_UPLOAD_SAS_TOKEN', 'CoreCLR Perf BenchView Sas')
50                                         }
51                                 }
52
53                         if (isPR)
54                         {
55                                 parameters
56                                 {
57                                         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')
58                                 }
59                         }
60                         def configuration = 'Release'
61                         def runType = isPR ? 'private' : 'rolling'
62                         def benchViewName = isPR ? 'coreclr private %BenchviewCommitName%' : 'coreclr rolling %GIT_BRANCH_WITHOUT_ORIGIN% %GIT_COMMIT%'
63                                 
64                                 steps {
65                                         // Batch
66
67                                         batchFile("if exist \"%WORKSPACE%\\Microsoft.BenchView.JSONFormat\" rmdir /s /q \"%WORKSPACE%\\Microsoft.BenchView.JSONFormat\"")
68                                         batchFile("C:\\Tools\\nuget.exe install Microsoft.BenchView.JSONFormat -Source http://benchviewtestfeed.azurewebsites.net/nuget -OutputDirectory \"%WORKSPACE%\" -Prerelease -ExcludeVersion")
69                                         //Do this here to remove the origin but at the front of the branch name as this is a problem for BenchView
70                                         //we have to do it all as one statement because cmd is called each time and we lose the set environment variable
71                                         batchFile("if [%GIT_BRANCH:~0,7%] == [origin/] (set GIT_BRANCH_WITHOUT_ORIGIN=%GIT_BRANCH:origin/=%) else (set GIT_BRANCH_WITHOUT_ORIGIN=%GIT_BRANCH%)\n" +
72                                         "py \"%WORKSPACE%\\Microsoft.BenchView.JSONFormat\\tools\\submission-metadata.py\" --name " + "\"" + benchViewName + "\"" + " --user " + "\"dotnet-bot@microsoft.com\"\n" +
73                                         "py \"%WORKSPACE%\\Microsoft.BenchView.JSONFormat\\tools\\build.py\" git --branch %GIT_BRANCH_WITHOUT_ORIGIN% --type " + runType)
74                                         batchFile("py \"%WORKSPACE%\\Microsoft.BenchView.JSONFormat\\tools\\machinedata.py\"")
75                                         batchFile("set __TestIntermediateDir=int&&build.cmd ${configuration} ${architecture}")
76                                         batchFile("tests\\runtest.cmd ${configuration} ${architecture} GenerateLayoutOnly")
77                                         batchFile("tests\\scripts\\run-xunit-perf.cmd -arch ${arch} -configuration ${configuration} ${testEnv} -testBinLoc bin\\tests\\Windows_NT.${architecture}.${configuration}\\performance\\perflab\\Perflab -library -uploadToBenchview \"%WORKSPACE%\\Microsoft.Benchview.JSONFormat\\tools\" -runtype ${runType}")
78                                         batchFile("tests\\scripts\\run-xunit-perf.cmd -arch ${arch} -configuration ${configuration} ${testEnv} -testBinLoc bin\\tests\\Windows_NT.${architecture}.${configuration}\\Jit\\Performance\\CodeQuality -uploadToBenchview \"%WORKSPACE%\\Microsoft.Benchview.JSONFormat\\tools\" -runtype ${runType}")
79                                 }
80                         }
81
82                         // Save machinedata.json to /artifact/bin/ Jenkins dir
83                         def archiveSettings = new ArchivalSettings()
84                         archiveSettings.addFiles('perf-*.xml')
85                         archiveSettings.addFiles('perf-*.etl')
86                         Utilities.addArchival(newJob, archiveSettings)
87
88                         Utilities.standardJobSetup(newJob, project, isPR, "*/${branch}")
89
90                         if (isPR) {
91                                 TriggerBuilder builder = TriggerBuilder.triggerOnPullRequest()
92                                 builder.setGithubContext("${os} ${arch} CoreCLR Perf Tests")
93                                 builder.triggerOnlyOnComment()
94                                 builder.setCustomTriggerPhrase("(?i).*test\\W+${os}_${arch}\\W+perf.*")
95                                 builder.triggerForBranch(branch)
96                                 builder.emitTrigger(newJob)
97                         }
98                         else {
99                                 // Set a push trigger
100                                 TriggerBuilder builder = TriggerBuilder.triggerOnCommit()
101                                 builder.emitTrigger(newJob)
102                         }
103                 }
104     }
105 }
106
107 // Create the Linux/OSX/CentOS coreclr test leg for debug and release and each scenario
108 [true, false].each { isPR ->
109     ['Ubuntu14.04'].each { os ->
110         def newJob = job(Utilities.getFullJobName(project, "perf_${os}", isPR)) {
111                         
112                         label('linux_clr_perf')
113                                 wrappers {
114                                         credentialsBinding {
115                                                 string('BV_UPLOAD_SAS_TOKEN', 'CoreCLR Perf BenchView Sas')
116                                         }
117                                 }
118                         
119                         if (isPR)
120                         {
121                                 parameters
122                                 {
123                                         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')
124                                 }
125                         }
126                         def osGroup = getOSGroup(os)
127                         def architecture = 'x64'
128                         def configuration = 'Release'
129                         def runType = isPR ? 'private' : 'rolling'
130                         def benchViewName = isPR ? 'coreclr private \$BenchviewCommitName' : 'coreclr rolling \$GIT_BRANCH_WITHOUT_ORIGIN \$GIT_COMMIT'
131                         
132             steps {
133                 shell("bash ./tests/scripts/perf-prep.sh")
134                 shell("./init-tools.sh")
135                                 shell("./build.sh ${architecture} ${configuration}")
136                                 shell("GIT_BRANCH_WITHOUT_ORIGIN=\$(echo \$GIT_BRANCH | sed \"s/[^/]*\\/\\(.*\\)/\\1 /\")\n" +
137                                 "python3.5 \"\${WORKSPACE}/tests/scripts/Microsoft.BenchView.JSONFormat/tools/submission-metadata.py\" --name " + "\"" + benchViewName + "\"" + " --user " + "\"dotnet-bot@microsoft.com\"\n" +
138                                 "python3.5 \"\${WORKSPACE}/tests/scripts/Microsoft.BenchView.JSONFormat/tools/build.py\" git --branch \$GIT_BRANCH_WITHOUT_ORIGIN --type " + runType)
139                 shell("""sudo -E bash ./tests/scripts/run-xunit-perf.sh \\
140                 --testRootDir=\"\${WORKSPACE}/bin/tests/Windows_NT.${architecture}.${configuration}\" \\
141                 --testNativeBinDir=\"\${WORKSPACE}/bin/obj/${osGroup}.${architecture}.${configuration}/tests\" \\
142                 --coreClrBinDir=\"\${WORKSPACE}/bin/Product/${osGroup}.${architecture}.${configuration}\" \\
143                 --mscorlibDir=\"\${WORKSPACE}/bin/Product/${osGroup}.${architecture}.${configuration}\" \\
144                 --coreFxBinDir=\"\${WORKSPACE}/corefx\" \\
145                                 --runType=\"${runType}\" \\
146                                 --benchViewOS=\"${os}\" \\
147                                 --uploadToBenchview""")
148             }
149         }
150
151         // Save machinedata.json to /artifact/bin/ Jenkins dir
152         def archiveSettings = new ArchivalSettings()
153         archiveSettings.addFiles('sandbox/perf-*.xml')
154         archiveSettings.addFiles('machinedata.json')
155         Utilities.addArchival(newJob, archiveSettings)
156
157         Utilities.standardJobSetup(newJob, project, isPR, "*/${branch}")
158
159         // For perf, we need to keep the run results longer
160         newJob.with {
161             // Enable the log rotator
162             logRotator {
163                 artifactDaysToKeep(7)
164                 daysToKeep(300)
165                 artifactNumToKeep(25)
166                 numToKeep(1000)
167             }
168         }
169         if (isPR) {
170             TriggerBuilder builder = TriggerBuilder.triggerOnPullRequest()
171             builder.setGithubContext("${os} Perf Tests")
172             builder.triggerOnlyOnComment()
173             builder.setCustomTriggerPhrase("(?i).*test\\W+${os}\\W+perf.*")
174             builder.triggerForBranch(branch)
175             builder.emitTrigger(newJob)
176         }
177         else {
178             // Set a push trigger
179             TriggerBuilder builder = TriggerBuilder.triggerOnCommit()
180             builder.emitTrigger(newJob)
181         }
182     } // os
183 } // isPR