1// Import the utility functionality.
2
3import jobs.generation.Utilities;
4import jobs.generation.JobReport;
5
6// The input project name (e.g. dotnet/coreclr)
7def project = GithubProject
8// The input branch name (e.g. master)
9def branch = GithubBranchName
10
11def imageVersionMap = ['Windows_NT':'latest-or-auto',
12                       'OSX10.12':'latest-or-auto',
13                       'Ubuntu':'20170118']
14
15// Innerloop build OS's
16def osList = ['Ubuntu', 'OSX10.12', 'Windows_NT']
17
18// Generate the builds for debug and release, commit and PRJob
19[true, false].each { isPR -> // Defines a closure over true and false, value assigned to isPR
20    ['Debug', 'Release'].each { configuration ->
21        osList.each { os ->
22
23            // Define build string
24            def lowercaseConfiguration = configuration.toLowerCase()
25
26            // Determine the name for the new job.  The first parameter is the project,
27            // the second parameter is the base name for the job, and the last parameter
28            // is a boolean indicating whether the job will be a PR job.  If true, the
29            // suffix _prtest will be appended.
30            def newJobName = Utilities.getFullJobName(project, lowercaseConfiguration + '_' + os.toLowerCase(), isPR)
31            def buildString = "";
32            def prJobDescription = "${os} ${configuration}";
33            if (configuration == 'Debug') {
34                prJobDescription += " and CoreCLR tests"
35            }
36
37            // Calculate the build commands
38            if (os == 'Windows_NT') {
39                buildString = "build.cmd ${lowercaseConfiguration}"
40                testScriptString = "tests\\runtest.cmd ${configuration} /coreclr "
41            }
42            else {
43                buildString = "./build.sh ${lowercaseConfiguration}"
44                testScriptString = "tests/runtest.sh ${configuration} -coredumps -coreclr "
45            }
46
47            // Create a new job with the specified name.  The brace opens a new closure
48            // and calls made within that closure apply to the newly created job.
49            def newJob = job(newJobName) {
50                // This opens the set of build steps that will be run.
51                steps {
52                    if (os == 'Windows_NT') {
53                        // Indicates that a batch script should be run with the build string (see above)
54                        batchFile(buildString)
55                        batchFile("tests\\runtest.cmd ${configuration} /multimodule")
56
57                        if (configuration == 'Debug') {
58                            if (isPR) {
59                                // Run a small set of BVTs during PR validation
60                                batchFile(testScriptString + "Top200")
61                            }
62                            else {
63                                // Run the full set of known passing tests in the post-commit job
64                                batchFile(testScriptString + "KnownGood /multimodule")
65                            }
66                        }
67                    }
68                    else {
69                        shell(buildString)
70
71                        if (configuration == 'Debug') {
72                            if (isPR) {
73                                // Run a small set of BVTs during PR validation
74                                shell(testScriptString + "top200")
75                            }
76                            else {
77                                // Run the full set of known passing tests in the post-commit job
78
79                                // Todo: Enable push test jobs once we establish a reasonable passing set of tests
80                                // shell(testScriptString + "KnownGood")
81                            }
82                        }
83                    }
84                }
85            }
86
87            // This call performs test run checks for the CI.
88            Utilities.addXUnitDotNETResults(newJob, '**/testResults.xml')
89            Utilities.setMachineAffinity(newJob, os, imageVersionMap[os])
90            Utilities.standardJobSetup(newJob, project, isPR, "*/${branch}")
91            if (isPR) {
92                Utilities.addGithubPRTriggerForBranch(newJob, branch, prJobDescription)
93            }
94            else {
95                // Set a large timeout since the default (2 hours) is insufficient
96                Utilities.setJobTimeout(newJob, 1440)
97                Utilities.addGithubPushTrigger(newJob)
98            }
99        }
100    }
101}
102
103JobReport.Report.generateJobReport(out)
104