netci.groovy 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421
  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', // 'latest-or-auto' -> Windows Server 2008 R2 ~= Windows 7
  18. 'Windows_NT': 'Windows 8.1', // 'latest-or-auto' -> Windows Server 2012 R2 ~= Windows 8.1 aka Blue
  19. 'windows.10.amd64.clientrs4.devex.open': 'Windows 10', // = Windows 10 RS4 with Dev 15.7
  20. 'Ubuntu16.04': 'Ubuntu',
  21. 'OSX10.12': 'OSX'
  22. ]
  23. def defaultMachineTag = 'latest-or-auto'
  24. def legacyWindows7Machine = 'Windows 7'
  25. def legacyWindows7MachineTag = defaultMachineTag
  26. def legacyWindows8Machine = 'Windows_NT'
  27. def legacyWindows8MachineTag = defaultMachineTag
  28. def latestWindowsMachine = 'windows.10.amd64.clientrs4.devex.open' // Windows 10 RS4 with Dev 15.7
  29. def latestWindowsMachineTag = null // all information is included in the machine name above
  30. def dailyRegex = 'dailies'
  31. // ---------------
  32. // HELPER CLOSURES
  33. // ---------------
  34. def CreateBuildTask = { isPR, buildArch, buildType, machine, machineTag, configTag, buildExtra, testExtra, runCodeAnalysis, excludeConfigIf, nonDefaultTaskSetup ->
  35. if (excludeConfigIf && excludeConfigIf(isPR, buildArch, buildType)) {
  36. return // early exit: we don't want to create a job for this configuration
  37. }
  38. def config = "${buildArch}_${buildType}"
  39. config = (configTag == null) ? config : "${configTag}_${config}"
  40. // params: Project, BaseTaskName, IsPullRequest (appends '_prtest')
  41. def jobName = Utilities.getFullJobName(project, config, isPR)
  42. def testableConfig = buildType in ['debug', 'test'] && buildArch != 'arm'
  43. def analysisConfig = buildType in ['release'] && runCodeAnalysis
  44. def buildScript = "call .\\jenkins\\buildone.cmd ${buildArch} ${buildType} "
  45. buildScript += buildExtra ?: ''
  46. buildScript += analysisConfig ? ' "/p:runcodeanalysis=true"' : ''
  47. def testScript = "call .\\jenkins\\testone.cmd ${buildArch} ${buildType} "
  48. testScript += testExtra ?: ''
  49. def analysisScript = '.\\Build\\scripts\\check_prefast_error.ps1 . CodeAnalysis.err'
  50. def newJob = job(jobName) {
  51. // This opens the set of build steps that will be run.
  52. // This looks strange, but it is actually a method call, with a
  53. // closure as a param, since Groovy allows method calls without parens.
  54. // (Compare with '.each' method used above.)
  55. steps {
  56. batchFile(buildScript) // run the parameter as if it were a batch file
  57. if (testableConfig) {
  58. batchFile(testScript)
  59. }
  60. if (analysisConfig) {
  61. powerShell(analysisScript)
  62. }
  63. }
  64. }
  65. def msbuildType = msbuildTypeMap.get(buildType)
  66. def msbuildFlavor = "build_${buildArch}${msbuildType}"
  67. def archivalString = "test/${msbuildFlavor}.*,test/logs/**"
  68. archivalString += analysisConfig ? ',CodeAnalysis.err' : ''
  69. Utilities.addArchival(newJob, archivalString,
  70. '', // no exclusions from archival
  71. false, // doNotFailIfNothingArchived=false ~= failIfNothingArchived
  72. false) // archiveOnlyIfSuccessful=false ~= archiveAlways
  73. if (machineTag == null) {
  74. // note: this is a different overload and not equivalent to calling setMachineAffinity(_,_,null)
  75. Utilities.setMachineAffinity(newJob, machine)
  76. } else {
  77. Utilities.setMachineAffinity(newJob, machine, machineTag)
  78. }
  79. Utilities.standardJobSetup(newJob, project, isPR, "*/${branch}")
  80. if (nonDefaultTaskSetup == null) {
  81. if (isPR) {
  82. def osTag = machineTypeToOSTagMap.get(machine)
  83. Utilities.addGithubPRTriggerForBranch(newJob, branch, "${osTag} ${config}")
  84. } else {
  85. Utilities.addGithubPushTrigger(newJob)
  86. }
  87. } else {
  88. // nonDefaultTaskSetup is e.g. DailyBuildTaskSetup (which sets up daily builds)
  89. // These jobs will only be configured for the branch specified below,
  90. // which is the name of the branch netci.groovy was processed for.
  91. // See list of such branches at:
  92. // https://github.com/dotnet/dotnet-ci/blob/master/jobs/data/repolist.txt
  93. nonDefaultTaskSetup(newJob, isPR, config)
  94. }
  95. }
  96. def CreateBuildTasks = { machine, machineTag, configTag, buildExtra, testExtra, runCodeAnalysis, excludeConfigIf, nonDefaultTaskSetup ->
  97. [true, false].each { isPR ->
  98. ['x86', 'x64', 'arm'].each { buildArch ->
  99. ['debug', 'test', 'release'].each { buildType ->
  100. CreateBuildTask(isPR, buildArch, buildType, machine, machineTag, configTag, buildExtra, testExtra, runCodeAnalysis, excludeConfigIf, nonDefaultTaskSetup)
  101. }
  102. }
  103. }
  104. }
  105. def CreateXPlatBuildTask = { isPR, buildType, staticBuild, machine, platform, configTag,
  106. xplatBranch, nonDefaultTaskSetup, customOption, testVariant, extraBuildParams ->
  107. def config = (platform == "osx" ? "osx_${buildType}" : "linux_${buildType}")
  108. def numConcurrentCommand = (platform == "osx" ? "sysctl -n hw.logicalcpu" : "nproc")
  109. config = (configTag == null) ? config : "${configTag}_${config}"
  110. config = staticBuild ? "static_${config}" : "shared_${config}"
  111. config = customOption ? customOption.replaceAll(/[-]+/, "_") + "_" + config : config
  112. // params: Project, BaseTaskName, IsPullRequest (appends '_prtest')
  113. def jobName = Utilities.getFullJobName(project, config, isPR)
  114. def infoScript = "bash jenkins/get_system_info.sh --${platform}"
  115. def buildFlag = buildType == "release" ? "" : (buildType == "debug" ? "--debug" : "--test-build")
  116. def staticFlag = staticBuild ? "--static" : ""
  117. def swbCheckFlag = (platform == "linux" && buildType == "debug" && !staticBuild) ? "--wb-check" : "";
  118. def icuFlag = (platform == "osx" ? "--icu=/usr/local/opt/icu4c/include" : "")
  119. def compilerPaths = (platform == "osx") ? "" : "--cxx=/usr/bin/clang++-3.9 --cc=/usr/bin/clang-3.9"
  120. def buildScript = "bash ./build.sh ${staticFlag} -j=`${numConcurrentCommand}` ${buildFlag} " +
  121. "${swbCheckFlag} ${compilerPaths} ${icuFlag} ${customOption} ${extraBuildParams}"
  122. def testScript = "bash test/runtests.sh \"${testVariant}\""
  123. def newJob = job(jobName) {
  124. steps {
  125. shell(infoScript)
  126. shell(buildScript)
  127. shell(testScript)
  128. }
  129. }
  130. def archivalString = "out/build.log"
  131. Utilities.addArchival(newJob, archivalString,
  132. '', // no exclusions from archival
  133. true, // doNotFailIfNothingArchived=false ~= failIfNothingArchived (true ~= doNotFail)
  134. false) // archiveOnlyIfSuccessful=false ~= archiveAlways
  135. Utilities.setMachineAffinity(newJob, machine, defaultMachineTag)
  136. Utilities.standardJobSetup(newJob, project, isPR, "*/${branch}")
  137. if (nonDefaultTaskSetup == null) {
  138. if (isPR) {
  139. def osTag = machineTypeToOSTagMap.get(machine)
  140. Utilities.addGithubPRTriggerForBranch(newJob, xplatBranch, "${osTag} ${config}")
  141. } else {
  142. Utilities.addGithubPushTrigger(newJob)
  143. }
  144. } else {
  145. // nonDefaultTaskSetup is e.g. DailyBuildTaskSetup (which sets up daily builds)
  146. // These jobs will only be configured for the branch specified below,
  147. // which is the name of the branch netci.groovy was processed for.
  148. // See list of such branches at:
  149. // https://github.com/dotnet/dotnet-ci/blob/master/jobs/data/repolist.txt
  150. nonDefaultTaskSetup(newJob, isPR, config)
  151. }
  152. }
  153. // Generic task to trigger clang-based cross-plat build tasks
  154. def CreateXPlatBuildTasks = { machine, platform, configTag, xplatBranch, nonDefaultTaskSetup, extraBuildParams ->
  155. [true, false].each { isPR ->
  156. CreateXPlatBuildTask(isPR, "test", "", machine, platform,
  157. configTag, xplatBranch, nonDefaultTaskSetup, "--no-jit", "--variants disable_jit", extraBuildParams)
  158. ['debug', 'test', 'release'].each { buildType ->
  159. def staticBuildConfigs = [true, false]
  160. if (platform == "osx") {
  161. staticBuildConfigs = [true]
  162. }
  163. staticBuildConfigs.each { staticBuild ->
  164. CreateXPlatBuildTask(isPR, buildType, staticBuild, machine, platform,
  165. configTag, xplatBranch, nonDefaultTaskSetup, "", "", extraBuildParams)
  166. }
  167. }
  168. }
  169. }
  170. def DailyBuildTaskSetup = { newJob, isPR, triggerName, groupRegex ->
  171. // The addition of triggers makes the job non-default in GitHub.
  172. if (isPR) {
  173. def triggerRegex = "(${dailyRegex}|${groupRegex}|${triggerName})"
  174. Utilities.addGithubPRTriggerForBranch(newJob, branch,
  175. triggerName, // GitHub task name
  176. "(?i).*test\\W+${triggerRegex}.*")
  177. } else {
  178. Utilities.addPeriodicTrigger(newJob, '@daily')
  179. }
  180. }
  181. def CreateStyleCheckTasks = { taskString, taskName, checkName ->
  182. [true, false].each { isPR ->
  183. def jobName = Utilities.getFullJobName(project, taskName, isPR)
  184. def newJob = job(jobName) {
  185. steps {
  186. shell(taskString)
  187. }
  188. }
  189. Utilities.standardJobSetup(newJob, project, isPR, "*/${branch}")
  190. if (isPR) {
  191. // Set PR trigger.
  192. Utilities.addGithubPRTriggerForBranch(newJob, branch, checkName)
  193. } else {
  194. // Set a push trigger
  195. Utilities.addGithubPushTrigger(newJob)
  196. }
  197. Utilities.setMachineAffinity(newJob, 'Ubuntu16.04', defaultMachineTag)
  198. }
  199. }
  200. // ----------------
  201. // INNER LOOP TASKS
  202. // ----------------
  203. // The latest machine seems to have a configuration problem preventing us from building ARM.
  204. // For now, build ARM on the LKG config, Legacy Windows 8.1 (Blue) config.
  205. // TODO When the Windows 10 configuration is updated to fix ARM builds, unify this config split.
  206. CreateBuildTasks(latestWindowsMachine, latestWindowsMachineTag, null, null, "-win10", true,
  207. /* excludeConfigIf */ { isPR, buildArch, buildType -> (buildArch == 'arm') }, null) // configures everything except ARM
  208. CreateBuildTasks(legacyWindows8Machine, legacyWindows8MachineTag, null, null, "-winBlue", true,
  209. /* excludeConfigIf */ { isPR, buildArch, buildType -> (buildArch != 'arm') }, null) // configures ARM
  210. // Add some additional daily configs to trigger per-PR as a quality gate:
  211. // x64_debug Slow Tests
  212. CreateBuildTask(true, 'x64', 'debug',
  213. latestWindowsMachine, latestWindowsMachineTag, 'ci_slow', null, '-win10 -includeSlow', false, null, null)
  214. // x64_debug DisableJIT
  215. CreateBuildTask(true, 'x64', 'debug',
  216. latestWindowsMachine, latestWindowsMachineTag, 'ci_disablejit', '"/p:BuildJIT=false"', '-win10 -disablejit', false, null, null)
  217. // x64_debug Lite
  218. CreateBuildTask(true, 'x64', 'debug',
  219. latestWindowsMachine, latestWindowsMachineTag, 'ci_lite', '"/p:BuildLite=true"', '-win10 -lite', false, null, null)
  220. // x64_debug Legacy (Windows 7)
  221. CreateBuildTask(true, 'x64', 'debug',
  222. legacyWindows7Machine, legacyWindows7MachineTag, 'ci_legacy7', 'msbuild14', '-win7 -includeSlow', false, null, null)
  223. // x64_debug Legacy (Windows 8.1 (Blue))
  224. CreateBuildTask(true, 'x64', 'debug',
  225. legacyWindows8Machine, legacyWindows8MachineTag, 'ci_legacy8', 'msbuild14', '-winBlue -includeSlow', false, null, null)
  226. // -----------------
  227. // DAILY BUILD TASKS
  228. // -----------------
  229. if (!branch.endsWith('-ci')) {
  230. // build and test on the legacy configuration (Windows 7 + VS 2015 (Dev14))
  231. CreateBuildTasks(legacyWindows7Machine, legacyWindows7MachineTag, 'daily_legacy7', 'msbuild14', '-win7 -includeSlow', false,
  232. /* excludeConfigIf */ { isPR, buildArch, buildType -> (buildArch == 'arm') }, // excludes ARM
  233. /* nonDefaultTaskSetup */ { newJob, isPR, config ->
  234. DailyBuildTaskSetup(newJob, isPR,
  235. "Windows 7 ${config}",
  236. 'legacy7?\\s+tests)')})
  237. // build and test on the legacy configuration (Windows 8.1 (Blue) + VS 2015 (Dev14))
  238. CreateBuildTasks(legacyWindows8Machine, legacyWindows8MachineTag, 'daily_legacy8', 'msbuild14', '-winBlue -includeSlow', false,
  239. /* excludeConfigIf */ null, // ARM builds previously worked on this configuration, so don't exclude them unless we explicitly drop support
  240. /* nonDefaultTaskSetup */ { newJob, isPR, config ->
  241. DailyBuildTaskSetup(newJob, isPR,
  242. "Windows 8 ${config}",
  243. 'legacy8?\\s+tests')})
  244. // build and test on the latest configuration (RS4 + VS 2017 Dev 15.7) with -includeSlow
  245. // TODO When the Windows 10 configuration is updated to fix ARM builds, unify this config split.
  246. CreateBuildTasks(latestWindowsMachine, latestWindowsMachineTag, 'daily_slow', null, '-win10 -includeSlow', false,
  247. /* excludeConfigIf */ { isPR, buildArch, buildType -> (buildArch == 'arm') }, // configures everything except ARM
  248. /* nonDefaultTaskSetup */ { newJob, isPR, config ->
  249. DailyBuildTaskSetup(newJob, isPR,
  250. "Windows ${config}",
  251. 'slow\\s+tests')})
  252. CreateBuildTasks(legacyWindows8Machine, legacyWindows8MachineTag, 'daily_slow', null, '-winBlue -includeSlow', false,
  253. /* excludeConfigIf */ { isPR, buildArch, buildType -> (buildArch != 'arm') }, // configures ARM
  254. /* nonDefaultTaskSetup */ { newJob, isPR, config ->
  255. DailyBuildTaskSetup(newJob, isPR,
  256. "Windows ${config}",
  257. 'slow\\s+tests')})
  258. // build and test on the latest configuration (RS4 + VS 2017 Dev 15.7) with JIT disabled
  259. // TODO When the Windows 10 configuration is updated to fix ARM builds, unify this config split.
  260. CreateBuildTasks(latestWindowsMachine, latestWindowsMachineTag, 'daily_disablejit', '"/p:BuildJIT=false"', '-win10 -disablejit', true,
  261. /* excludeConfigIf */ { isPR, buildArch, buildType -> (buildArch == 'arm') }, // configures everything except ARM
  262. /* nonDefaultTaskSetup */ { newJob, isPR, config ->
  263. DailyBuildTaskSetup(newJob, isPR,
  264. "Windows ${config}",
  265. '(disablejit|nojit)\\s+tests')})
  266. CreateBuildTasks(legacyWindows8Machine, legacyWindows8MachineTag, 'daily_disablejit', '"/p:BuildJIT=false"', '-winBlue -disablejit', true,
  267. /* excludeConfigIf */ { isPR, buildArch, buildType -> (buildArch != 'arm') }, // configures ARM
  268. /* nonDefaultTaskSetup */ { newJob, isPR, config ->
  269. DailyBuildTaskSetup(newJob, isPR,
  270. "Windows ${config}",
  271. '(disablejit|nojit)\\s+tests')})
  272. // build and test on the latest configuration (RS4 + VS 2017 Dev 15.7) with Lite build
  273. // TODO When the Windows 10 configuration is updated to fix ARM builds, unify this config split.
  274. CreateBuildTasks(latestWindowsMachine, latestWindowsMachineTag, 'daily_lite', '"/p:BuildLite=true"', '-win10 -lite', true,
  275. /* excludeConfigIf */ { isPR, buildArch, buildType -> (buildArch == 'arm') }, // configures everything except ARM
  276. /* nonDefaultTaskSetup */ { newJob, isPR, config ->
  277. DailyBuildTaskSetup(newJob, isPR,
  278. "Windows ${config}",
  279. 'lite\\s+tests')})
  280. CreateBuildTasks(legacyWindows8Machine, legacyWindows8MachineTag, 'daily_lite', '"/p:BuildLite=true"', '-winBlue -lite', true,
  281. /* excludeConfigIf */ { isPR, buildArch, buildType -> (buildArch != 'arm') }, // configures ARM
  282. /* nonDefaultTaskSetup */ { newJob, isPR, config ->
  283. DailyBuildTaskSetup(newJob, isPR,
  284. "Windows ${config}",
  285. 'lite\\s+tests')})
  286. }
  287. // ----------------
  288. // CODE STYLE TASKS
  289. // ----------------
  290. CreateStyleCheckTasks('./jenkins/check_copyright.sh', 'ubuntu_check_copyright', 'Copyright Check')
  291. CreateStyleCheckTasks('./jenkins/check_eol.sh', 'ubuntu_check_eol', 'EOL Check')
  292. CreateStyleCheckTasks('./jenkins/check_tabs.sh', 'ubuntu_check_tabs', 'Tab Check')
  293. CreateStyleCheckTasks('./jenkins/check_ascii.sh', 'ubuntu_check_ascii', 'ASCII Check')
  294. // --------------
  295. // XPLAT BRANCHES
  296. // --------------
  297. // Explicitly enumerate xplat-incompatible branches, because we don't anticipate any future incompatible branches
  298. def isXPlatCompatibleBranch = !(branch in ['release/1.1', 'release/1.1-ci', 'release/1.2', 'release/1.2-ci'])
  299. // Include these explicitly-named branches
  300. def isXPlatDailyBranch = branch in ['master', 'linux', 'xplat']
  301. // Include some release/* branches (ignore branches ending in '-ci')
  302. if (branch.startsWith('release') && !branch.endsWith('-ci')) {
  303. // Allows all current and future release/* branches on which we should run daily builds of XPlat configs.
  304. // RegEx matches branch names we should ignore (e.g. release/1.1, release/1.2, release/1.2-pre)
  305. includeReleaseBranch = !(branch =~ /^release\/(1\.[12](\D.*)?)$/)
  306. isXPlatDailyBranch |= includeReleaseBranch
  307. }
  308. // -----------------
  309. // LINUX BUILD TASKS
  310. // -----------------
  311. if (isXPlatCompatibleBranch) {
  312. def osString = 'Ubuntu16.04'
  313. // PR and CI checks
  314. CreateXPlatBuildTasks(osString, "linux", "ubuntu", branch, null, "")
  315. // Create a PR/continuous task to check ubuntu/static/debug/no-icu
  316. [true, false].each { isPR ->
  317. CreateXPlatBuildTask(isPR, "debug", true, osString, "linux",
  318. "ubuntu", branch, null, "--no-icu", "--not-tag exclude_noicu", "")
  319. }
  320. // daily builds
  321. if (isXPlatDailyBranch) {
  322. CreateXPlatBuildTasks(osString, "linux", "daily_ubuntu", branch,
  323. /* nonDefaultTaskSetup */ { newJob, isPR, config ->
  324. DailyBuildTaskSetup(newJob, isPR,
  325. "Ubuntu ${config}",
  326. 'linux\\s+tests')},
  327. /* extraBuildParams */ "--extra-defines=PERFMAP_TRACE_ENABLED=1")
  328. }
  329. }
  330. // ---------------
  331. // OSX BUILD TASKS
  332. // ---------------
  333. if (isXPlatCompatibleBranch) {
  334. def osString = 'OSX10.12'
  335. // PR and CI checks
  336. CreateXPlatBuildTasks(osString, "osx", "osx", branch, null, "")
  337. // daily builds
  338. if (isXPlatDailyBranch) {
  339. CreateXPlatBuildTasks(osString, "osx", "daily_osx", branch,
  340. /* nonDefaultTaskSetup */ { newJob, isPR, config ->
  341. DailyBuildTaskSetup(newJob, isPR,
  342. "OSX ${config}",
  343. 'linux\\s+tests')},
  344. /* extraBuildParams */ "")
  345. }
  346. }
  347. // ------------
  348. // HELP MESSAGE
  349. // ------------
  350. Utilities.createHelperJob(this, project, branch,
  351. "Welcome to the ${project} Repository", // This is prepended to the help message
  352. "For additional documentation on ChakraCore CI checks, please see:\n" +
  353. "\n" +
  354. "* https://github.com/Microsoft/ChakraCore/wiki/Jenkins-CI-Checks\n" +
  355. "* https://github.com/Microsoft/ChakraCore/wiki/Jenkins-Build-Triggers\n" +
  356. "* https://github.com/Microsoft/ChakraCore/wiki/Jenkins-Repro-Steps\n" +
  357. "\n" +
  358. "Have a nice day!") // This is appended to the help message. You might put known issues here.