2
0

netci.groovy 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343
  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. 'Ubuntu14.04': 'Ubuntu14.04',
  20. 'Ubuntu16.04': 'Ubuntu',
  21. 'OSX': 'OSX'
  22. ]
  23. def dailyRegex = 'dailies'
  24. // ---------------
  25. // HELPER CLOSURES
  26. // ---------------
  27. def CreateBuildTask = { isPR, buildArch, buildType, machine, configTag, buildExtra, testExtra, runCodeAnalysis, excludeConfigIf, nonDefaultTaskSetup ->
  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. def msbuildType = msbuildTypeMap.get(buildType)
  59. def msbuildFlavor = "build_${buildArch}${msbuildType}"
  60. def archivalString = "test/${msbuildFlavor}.*,test/logs/**"
  61. archivalString += analysisConfig ? ',CodeAnalysis.err' : ''
  62. Utilities.addArchival(newJob, archivalString,
  63. '', // no exclusions from archival
  64. false, // doNotFailIfNothingArchived=false ~= failIfNothingArchived
  65. false) // archiveOnlyIfSuccessful=false ~= archiveAlways
  66. Utilities.setMachineAffinity(newJob, machine, 'latest-or-auto')
  67. Utilities.standardJobSetup(newJob, project, isPR, "*/${branch}")
  68. if (nonDefaultTaskSetup == null) {
  69. if (isPR) {
  70. def osTag = machineTypeToOSTagMap.get(machine)
  71. Utilities.addGithubPRTriggerForBranch(newJob, branch, "${osTag} ${config}")
  72. } else {
  73. Utilities.addGithubPushTrigger(newJob)
  74. }
  75. } else {
  76. // nonDefaultTaskSetup is e.g. DailyBuildTaskSetup (which sets up daily builds)
  77. // These jobs will only be configured for the branch specified below,
  78. // which is the name of the branch netci.groovy was processed for.
  79. // See list of such branches at:
  80. // https://github.com/dotnet/dotnet-ci/blob/master/jobs/data/repolist.txt
  81. nonDefaultTaskSetup(newJob, isPR, config)
  82. }
  83. }
  84. def CreateBuildTasks = { machine, configTag, buildExtra, testExtra, runCodeAnalysis, excludeConfigIf, nonDefaultTaskSetup ->
  85. [true, false].each { isPR ->
  86. ['x86', 'x64', 'arm'].each { buildArch ->
  87. ['debug', 'test', 'release'].each { buildType ->
  88. CreateBuildTask(isPR, buildArch, buildType, machine, configTag, buildExtra, testExtra, runCodeAnalysis, excludeConfigIf, nonDefaultTaskSetup)
  89. }
  90. }
  91. }
  92. }
  93. def CreateXPlatBuildTask = { isPR, buildType, staticBuild, machine, platform, configTag,
  94. xplatBranch, nonDefaultTaskSetup, customOption, testVariant ->
  95. def config = (platform == "osx" ? "osx_${buildType}" : "linux_${buildType}")
  96. def numConcurrentCommand = (platform == "osx" ? "sysctl -n hw.logicalcpu" : "nproc")
  97. config = (configTag == null) ? config : "${configTag}_${config}"
  98. config = staticBuild ? "${config}_static" : config
  99. // params: Project, BaseTaskName, IsPullRequest (appends '_prtest')
  100. def jobName = Utilities.getFullJobName(project, config, isPR) + customOption.replaceAll(/[-]+/, "_")
  101. def infoScript = "bash jenkins/get_system_info.sh --${platform}"
  102. def buildFlag = buildType == "release" ? "" : (buildType == "debug" ? "--debug" : "--test-build")
  103. def staticFlag = staticBuild ? "--static" : ""
  104. def icuFlag = (platform == "osx" ? "--icu=/usr/local/opt/icu4c/include" : "")
  105. def compilerPaths = (platform == "osx") ? "" : "--cxx=/usr/bin/clang++-3.8 --cc=/usr/bin/clang-3.8"
  106. def buildScript = "bash ./build.sh ${staticFlag} -j=`${numConcurrentCommand}` ${buildFlag} ${compilerPaths} ${icuFlag} ${customOption}"
  107. def testScript = "bash test/runtests.sh \"${testVariant}\""
  108. def newJob = job(jobName) {
  109. steps {
  110. shell(infoScript)
  111. shell(buildScript)
  112. shell(testScript)
  113. }
  114. }
  115. def archivalString = "BuildLinux/build.log"
  116. Utilities.addArchival(newJob, archivalString,
  117. '', // no exclusions from archival
  118. true, // doNotFailIfNothingArchived=false ~= failIfNothingArchived (true ~= doNotFail)
  119. false) // archiveOnlyIfSuccessful=false ~= archiveAlways
  120. Utilities.setMachineAffinity(newJob, machine, 'latest-or-auto')
  121. Utilities.standardJobSetup(newJob, project, isPR, "*/${branch}")
  122. if (nonDefaultTaskSetup == null) {
  123. if (isPR) {
  124. def osTag = machineTypeToOSTagMap.get(machine)
  125. Utilities.addGithubPRTriggerForBranch(newJob, xplatBranch, "${osTag} ${config}")
  126. } else {
  127. Utilities.addGithubPushTrigger(newJob)
  128. }
  129. } else {
  130. // nonDefaultTaskSetup is e.g. DailyBuildTaskSetup (which sets up daily builds)
  131. // These jobs will only be configured for the branch specified below,
  132. // which is the name of the branch netci.groovy was processed for.
  133. // See list of such branches at:
  134. // https://github.com/dotnet/dotnet-ci/blob/master/jobs/data/repolist.txt
  135. nonDefaultTaskSetup(newJob, isPR, config)
  136. }
  137. }
  138. // Generic task to trigger clang-based cross-plat build tasks
  139. def CreateXPlatBuildTasks = { machine, platform, configTag, xplatBranch, nonDefaultTaskSetup ->
  140. [true, false].each { isPR ->
  141. CreateXPlatBuildTask(isPR, "test", "", machine, platform,
  142. configTag, xplatBranch, nonDefaultTaskSetup, "--no-jit", "--variants disable_jit")
  143. ['debug', 'test', 'release'].each { buildType ->
  144. def staticBuildConfigs = [true, false]
  145. if (platform == "osx") {
  146. staticBuildConfigs = [true]
  147. }
  148. staticBuildConfigs.each { staticBuild ->
  149. CreateXPlatBuildTask(isPR, buildType, staticBuild, machine, platform,
  150. configTag, xplatBranch, nonDefaultTaskSetup, "", "")
  151. }
  152. }
  153. }
  154. }
  155. def DailyBuildTaskSetup = { newJob, isPR, triggerName, groupRegex ->
  156. // The addition of triggers makes the job non-default in GitHub.
  157. if (isPR) {
  158. def triggerRegex = "(${dailyRegex}|${groupRegex}|${triggerName})"
  159. Utilities.addGithubPRTriggerForBranch(newJob, branch,
  160. triggerName, // GitHub task name
  161. "(?i).*test\\W+${triggerRegex}.*")
  162. } else {
  163. Utilities.addPeriodicTrigger(newJob, '@daily')
  164. }
  165. }
  166. def CreateStyleCheckTasks = { taskString, taskName, checkName ->
  167. [true, false].each { isPR ->
  168. def jobName = Utilities.getFullJobName(project, taskName, isPR)
  169. def newJob = job(jobName) {
  170. steps {
  171. shell(taskString)
  172. }
  173. }
  174. Utilities.standardJobSetup(newJob, project, isPR, "*/${branch}")
  175. if (isPR) {
  176. // Set PR trigger.
  177. Utilities.addGithubPRTriggerForBranch(newJob, branch, checkName)
  178. } else {
  179. // Set a push trigger
  180. Utilities.addGithubPushTrigger(newJob)
  181. }
  182. Utilities.setMachineAffinity(newJob, 'Ubuntu14.04', 'latest-or-auto')
  183. }
  184. }
  185. // ----------------
  186. // INNER LOOP TASKS
  187. // ----------------
  188. CreateBuildTasks('Windows_NT', null, null, null, true, null, null)
  189. // Add some additional daily configs to trigger per-PR as a quality gate:
  190. // x64_debug Slow Tests
  191. CreateBuildTask(true, 'x64', 'debug',
  192. 'Windows_NT', 'ci_slow', null, '-includeSlow', false, null, null)
  193. // x64_debug DisableJIT
  194. CreateBuildTask(true, 'x64', 'debug',
  195. 'Windows_NT', 'ci_disablejit', '"/p:BuildJIT=false"', '-disablejit', false, null, null)
  196. // x64_debug Legacy
  197. CreateBuildTask(true, 'x64', 'debug',
  198. 'Windows 7', 'ci_dev12', 'msbuild12', '-win7 -includeSlow', false, null, null)
  199. // -----------------
  200. // DAILY BUILD TASKS
  201. // -----------------
  202. if (!branch.endsWith('-ci')) {
  203. // build and test on Windows 7 with VS 2013 (Dev12/MsBuild12)
  204. CreateBuildTasks('Windows 7', 'daily_dev12', 'msbuild12', '-win7 -includeSlow', false,
  205. /* excludeConfigIf */ { isPR, buildArch, buildType -> (buildArch == 'arm') },
  206. /* nonDefaultTaskSetup */ { newJob, isPR, config ->
  207. DailyBuildTaskSetup(newJob, isPR,
  208. "Windows 7 ${config}",
  209. '(dev12|legacy)\\s+tests')})
  210. // build and test on the usual configuration (VS 2015) with -includeSlow
  211. CreateBuildTasks('Windows_NT', 'daily_slow', null, '-includeSlow', false,
  212. /* excludeConfigIf */ null,
  213. /* nonDefaultTaskSetup */ { newJob, isPR, config ->
  214. DailyBuildTaskSetup(newJob, isPR,
  215. "Windows ${config}",
  216. 'slow\\s+tests')})
  217. // build and test on the usual configuration (VS 2015) with JIT disabled
  218. CreateBuildTasks('Windows_NT', 'daily_disablejit', '"/p:BuildJIT=false"', '-disablejit', true,
  219. /* excludeConfigIf */ null,
  220. /* nonDefaultTaskSetup */ { newJob, isPR, config ->
  221. DailyBuildTaskSetup(newJob, isPR,
  222. "Windows ${config}",
  223. '(disablejit|nojit)\\s+tests')})
  224. }
  225. // ----------------
  226. // CODE STYLE TASKS
  227. // ----------------
  228. CreateStyleCheckTasks('./jenkins/check_copyright.sh', 'ubuntu_check_copyright', 'Copyright Check')
  229. CreateStyleCheckTasks('./jenkins/check_eol.sh', 'ubuntu_check_eol', 'EOL Check')
  230. CreateStyleCheckTasks('./jenkins/check_tabs.sh', 'ubuntu_check_tabs', 'Tab Check')
  231. // --------------
  232. // XPLAT BRANCHES
  233. // --------------
  234. // Explicitly enumerate xplat-incompatible branches, because we don't anticipate any future incompatible branches
  235. def isXPlatCompatibleBranch = !(branch in ['release/1.1', 'release/1.1-ci', 'release/1.2', 'release/1.2-ci'])
  236. // Include these explicitly-named branches
  237. def isXPlatDailyBranch = branch in ['master', 'linux', 'xplat']
  238. // Include some release/* branches (ignore branches ending in '-ci')
  239. if (branch.startsWith('release') && !branch.endsWith('-ci')) {
  240. // Allows all current and future release/* branches on which we should run daily builds of XPlat configs.
  241. // RegEx matches branch names we should ignore (e.g. release/1.1, release/1.2, release/1.2-pre)
  242. includeReleaseBranch = !(branch =~ /^release\/(1\.[12](\D.*)?)$/)
  243. isXPlatDailyBranch |= includeReleaseBranch
  244. }
  245. // -----------------
  246. // LINUX BUILD TASKS
  247. // -----------------
  248. if (isXPlatCompatibleBranch) {
  249. def osString = 'Ubuntu16.04'
  250. // PR and CI checks
  251. CreateXPlatBuildTasks(osString, "linux", "ubuntu", branch, null)
  252. // daily builds
  253. if (isXPlatDailyBranch) {
  254. CreateXPlatBuildTasks(osString, "linux", "daily_ubuntu", branch,
  255. /* nonDefaultTaskSetup */ { newJob, isPR, config ->
  256. DailyBuildTaskSetup(newJob, isPR,
  257. "Ubuntu ${config}",
  258. 'linux\\s+tests')})
  259. }
  260. }
  261. // ---------------
  262. // OSX BUILD TASKS
  263. // ---------------
  264. if (isXPlatCompatibleBranch) {
  265. def osString = 'OSX'
  266. // PR and CI checks
  267. CreateXPlatBuildTasks(osString, "osx", "osx", branch, null)
  268. // daily builds
  269. if (isXPlatDailyBranch) {
  270. CreateXPlatBuildTasks(osString, "osx", "daily_osx", branch,
  271. /* nonDefaultTaskSetup */ { newJob, isPR, config ->
  272. DailyBuildTaskSetup(newJob, isPR,
  273. "OSX ${config}",
  274. 'linux\\s+tests')})
  275. }
  276. }
  277. // ------------
  278. // HELP MESSAGE
  279. // ------------
  280. Utilities.createHelperJob(this, project, branch,
  281. "Welcome to the ${project} Repository", // This is prepended to the help message
  282. "For additional documentation on ChakraCore CI checks, please see:\n" +
  283. "\n" +
  284. "* https://github.com/Microsoft/ChakraCore/wiki/Jenkins-CI-Checks\n" +
  285. "* https://github.com/Microsoft/ChakraCore/wiki/Jenkins-Build-Triggers\n" +
  286. "* https://github.com/Microsoft/ChakraCore/wiki/Jenkins-Repro-Steps\n" +
  287. "\n" +
  288. "Have a nice day!") // This is appended to the help message. You might put known issues here.