netci.groovy 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182
  1. //-------------------------------------------------------------------------------------------------------
  2. // Copyright (C) Microsoft. All rights reserved.
  3. // Licensed under the MIT license. See LICENSE.txt file in the project root for full license information.
  4. //-------------------------------------------------------------------------------------------------------
  5. // Import the utility functionality.
  6. import jobs.generation.Utilities;
  7. // Grab the github project name passed in
  8. def project = GithubProject
  9. def branch = GithubBranchName
  10. def msbuildTypeMap = [
  11. 'debug':'chk',
  12. 'test':'test',
  13. 'release':'fre'
  14. ]
  15. // convert `machine` parameter to OS component of PR task name
  16. def machineTypeToOSTagMap = [
  17. 'Windows 7': 'Windows 7',
  18. 'Windows_NT': 'Windows'
  19. ]
  20. def dailyRegex = 'dailies'
  21. // ---------------
  22. // HELPER CLOSURES
  23. // ---------------
  24. def CreateBuildTasks = { machine, configTag, buildExtra, testExtra, runCodeAnalysis, excludeConfigIf, nonDefaultTaskSetup ->
  25. [true, false].each { isPR ->
  26. ['x86', 'x64', 'arm'].each { buildArch ->
  27. ['debug', 'test', 'release'].each { buildType ->
  28. if (excludeConfigIf && excludeConfigIf(isPR, buildArch, buildType)) {
  29. return // early exit: we don't want to create a job for this configuration
  30. }
  31. def config = "${buildArch}_${buildType}"
  32. config = (configTag == null) ? config : "${configTag}_${config}"
  33. // params: Project, BaseTaskName, IsPullRequest (appends '_prtest')
  34. def jobName = Utilities.getFullJobName(project, config, isPR)
  35. def testableConfig = buildType in ['debug', 'test'] && buildArch != 'arm'
  36. def analysisConfig = buildType in ['release'] && runCodeAnalysis
  37. def buildScript = "call .\\jenkins\\buildone.cmd ${buildArch} ${buildType}"
  38. buildScript += buildExtra ?: ''
  39. buildScript += analysisConfig ? ' "/p:runcodeanalysis=true"' : ''
  40. def testScript = "call .\\jenkins\\testone.cmd ${buildArch} ${buildType}"
  41. testScript += testExtra ?: ''
  42. def analysisScript = ".\\Build\\scripts\\check_prefast_error.ps1 . CodeAnalysis.err"
  43. def newJob = job(jobName) {
  44. // This opens the set of build steps that will be run.
  45. // This looks strange, but it is actually a method call, with a
  46. // closure as a param, since Groovy allows method calls without parens.
  47. // (Compare with '.each' method used above.)
  48. steps {
  49. batchFile(buildScript) // run the parameter as if it were a batch file
  50. if (testableConfig) {
  51. batchFile(testScript)
  52. }
  53. if (analysisConfig) {
  54. powerShell(analysisScript)
  55. }
  56. }
  57. }
  58. Utilities.setMachineAffinity(newJob, machine, 'latest-or-auto')
  59. def msbuildType = msbuildTypeMap.get(buildType)
  60. def msbuildFlavor = "build_${buildArch}${msbuildType}"
  61. def archivalString = "test/${msbuildFlavor}.*,test/logs/**"
  62. archivalString += analysisConfig ? ',CodeAnalysis.err' : ''
  63. Utilities.addArchival(newJob, archivalString,
  64. '', // no exclusions from archival
  65. false, // doNotFailIfNothingArchived=false ~= failIfNothingArchived
  66. false) // archiveOnlyIfSuccessful=false ~= archiveAlways
  67. if (nonDefaultTaskSetup == null)
  68. {
  69. Utilities.standardJobSetup(newJob, project, isPR, "*/${branch}")
  70. if (isPR) {
  71. // Set PR trigger.
  72. def osTag = machineTypeToOSTagMap.get(machine)
  73. Utilities.addGithubPRTrigger(newJob, "${osTag} ${config}")
  74. }
  75. else {
  76. // Set a push trigger
  77. Utilities.addGithubPushTrigger(newJob)
  78. }
  79. }
  80. else
  81. {
  82. Utilities.standardJobSetup(newJob, project, isPR, "*/${branch}")
  83. nonDefaultTaskSetup(newJob, isPR, config)
  84. }
  85. }
  86. }
  87. }
  88. }
  89. def DailyBuildTaskSetup = { newJob, isPR, triggerName, groupRegex ->
  90. // The addition of triggers makes the job non-default in GitHub.
  91. if (isPR) {
  92. def triggerRegex = "(${dailyRegex}|${groupRegex}|${triggerName})"
  93. Utilities.addGithubPRTrigger(newJob,
  94. triggerName, // GitHub task name
  95. "(?i).*test\\W+${triggerRegex}.*")
  96. } else {
  97. Utilities.addPeriodicTrigger(newJob, '@daily')
  98. }
  99. }
  100. def CreateStyleCheckTasks = { taskString, taskName, checkName ->
  101. [true, false].each { isPR ->
  102. def jobName = Utilities.getFullJobName(project, taskName, isPR)
  103. def newJob = job(jobName) {
  104. steps {
  105. shell(taskString)
  106. }
  107. }
  108. Utilities.standardJobSetup(newJob, project, isPR, "*/${branch}")
  109. if (isPR) {
  110. // Set PR trigger.
  111. Utilities.addGithubPRTrigger(newJob, checkName)
  112. }
  113. else {
  114. // Set a push trigger
  115. Utilities.addGithubPushTrigger(newJob)
  116. }
  117. Utilities.setMachineAffinity(newJob, 'Ubuntu14.04', 'latest-or-auto')
  118. }
  119. }
  120. // ----------------
  121. // INNER LOOP TASKS
  122. // ----------------
  123. CreateBuildTasks('Windows_NT', null, null, null, true, null, null)
  124. // -----------------
  125. // DAILY BUILD TASKS
  126. // -----------------
  127. // build and test on Windows 7 with VS 2013 (Dev12/MsBuild12)
  128. CreateBuildTasks('Windows 7', 'daily_dev12', ' msbuild12', ' -win7 -includeSlow', false,
  129. /* excludeConfigIf */ { isPR, buildArch, buildType -> (buildArch == 'arm') },
  130. /* nonDefaultTaskSetup */ { newJob, isPR, config ->
  131. DailyBuildTaskSetup(newJob, isPR,
  132. "Windows 7 ${config}",
  133. '(dev12|legacy)\\s+tests')})
  134. // build and test on the usual configuration (VS 2015) with -includeSlow
  135. CreateBuildTasks('Windows_NT', 'daily_slow', null, ' -includeSlow', false,
  136. /* excludeConfigIf */ null,
  137. /* nonDefaultTaskSetup */ { newJob, isPR, config ->
  138. DailyBuildTaskSetup(newJob, isPR,
  139. "Windows ${config}",
  140. 'slow\\s+tests')})
  141. // build and test on the usual configuration (VS 2015) with JIT disabled
  142. CreateBuildTasks('Windows_NT', 'daily_disablejit', ' "/p:BuildJIT=false"', ' -disablejit', true,
  143. /* excludeConfigIf */ null,
  144. /* nonDefaultTaskSetup */ { newJob, isPR, config ->
  145. DailyBuildTaskSetup(newJob, isPR,
  146. "Windows ${config}",
  147. '(disablejit|nojit)\\s+tests')})
  148. // ----------------
  149. // CODE STYLE TASKS
  150. // ----------------
  151. CreateStyleCheckTasks('./jenkins/check_eol.sh', 'ubuntu_check_eol', 'EOL Check')
  152. CreateStyleCheckTasks('./jenkins/check_copyright.sh', 'ubuntu_check_copyright', 'Copyright Check')