Jenkinsfile 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247
  1. @Library("cmsis")
  2. DOCKERINFO = [
  3. 'linux_staging': [
  4. 'registryUrl': 'mcu--docker-staging.eu-west-1.artifactory.aws.arm.com',
  5. 'registryCredentialsId': 'artifactory',
  6. 'k8sPullSecret': 'artifactory-mcu-docker-staging',
  7. 'namespace': 'mcu--docker-staging',
  8. 'image': 'cmsis_fusa/linux',
  9. 'label': "${JENKINS_ENV}-${JOB_BASE_NAME}-${BUILD_NUMBER}"
  10. ],
  11. 'linux_production': [
  12. 'registryUrl': 'mcu--docker.eu-west-1.artifactory.aws.arm.com',
  13. 'registryCredentialsId': 'artifactory',
  14. 'namespace': 'mcu--docker',
  15. 'k8sPullSecret': 'artifactory-mcu-docker',
  16. 'image': 'cmsis_fusa/linux',
  17. 'label': 'aws'
  18. ],
  19. 'windows_staging': [
  20. 'registryUrl': 'mcu--docker-staging.eu-west-1.artifactory.aws.arm.com',
  21. 'registryCredentialsId': 'artifactory',
  22. 'namespace': 'mcu--docker-staging',
  23. 'image': 'cmsis_fusa/windows',
  24. 'label': "${JENKINS_ENV}-${JOB_BASE_NAME}-${BUILD_NUMBER}"
  25. ],
  26. 'windows_production': [
  27. 'registryUrl': 'mcu--docker.eu-west-1.artifactory.aws.arm.com',
  28. 'registryCredentialsId': 'artifactory',
  29. 'namespace': 'mcu--docker',
  30. 'image': 'cmsis_fusa/windows',
  31. 'label': 'aws'
  32. ]
  33. ]
  34. dockerinfo_linux = DOCKERINFO['linux_production']
  35. dockerinfo_windows = DOCKERINFO['windows_production']
  36. isPrecommit = (JOB_BASE_NAME == 'pre_commit')
  37. isNightly = (JOB_BASE_NAME == 'nightly')
  38. patternGlobal = [
  39. '^Jenkinsfile'
  40. ]
  41. patternCoreM = [
  42. '^CMSIS/Core/Include/.*',
  43. '^Device/ARM/ARMCM.*'
  44. ]
  45. patternCoreA = [
  46. '^CMSIS/Core_A/Include/.*',
  47. '^Device/ARM/ARMCA.*'
  48. ]
  49. patternCoreValidation = [
  50. '^CMSIS/CoreValidation/.*'
  51. ]
  52. CONFIGURATIONS = [
  53. 'pre_commit': [
  54. 'mdevices': ['CM0', 'CM3', 'CM4FP', 'CM7DP', 'CM23', 'CM33NS', 'CM35PS'],
  55. 'adevices': ['CA7', 'CA9neon'],
  56. 'devices' : [],
  57. 'configs' : [
  58. 'AC6': ['low', 'tiny'],
  59. 'AC6LTM': ['low', 'tiny']
  60. ]
  61. ],
  62. 'nightly':[
  63. 'devices' : ['CM0', 'CM0plus', 'CM3', 'CM4', 'CM4FP', 'CM7', 'CM7SP', 'CM7DP',
  64. 'CM23', 'CM23S', 'CM23NS', 'CM33', 'CM33S', 'CM33NS',
  65. 'CM35P', 'CM35PS', 'CM35PNS',
  66. 'CA5', 'CA5neon', 'CA7', 'CA7neon', 'CA9', 'CA9neon'],
  67. 'configs' : [
  68. 'AC6': ['low', 'mid', 'high', 'size', 'tiny'],
  69. 'AC6LTM': ['low', 'mid', 'high', 'size', 'tiny']
  70. ]
  71. ]
  72. ]
  73. CONFIGURATION = CONFIGURATIONS[JOB_BASE_NAME]
  74. // ---- PIPELINE CODE ----
  75. def getChangeset() {
  76. def fileset = sh encoding: 'UTF-8', label: '', returnStdout: true, script: 'git diff --name-only HEAD~1..HEAD'
  77. return fileset.split('\n')
  78. }
  79. def fileSetMatches(fileset, patternset) {
  80. return patternset.any { p ->
  81. fileset.any{ f -> f ==~ p }
  82. }
  83. }
  84. FORCE_BUILD = false
  85. CORE_VALIDATION = true
  86. COMMIT = null
  87. VERSION = null
  88. pipeline {
  89. options {
  90. timestamps()
  91. timeout(time: 1, unit: 'HOURS')
  92. ansiColor('xterm')
  93. skipDefaultCheckout()
  94. }
  95. agent { label 'master' }
  96. stages {
  97. stage('Checkout') {
  98. steps {
  99. script {
  100. COMMIT = checkoutScmWithRetry(3)
  101. echo "COMMIT: ${COMMIT}"
  102. VERSION = (sh(returnStdout: true, script: 'git describe --always')).trim()
  103. echo "VERSION: '${VERSION}'"
  104. }
  105. }
  106. }
  107. stage('Analyse') {
  108. when {
  109. expression { return isPrecommit }
  110. beforeOptions true
  111. }
  112. steps {
  113. script {
  114. def fileset = changeset
  115. def hasGlobal = fileSetMatches(fileset, patternGlobal)
  116. def hasCoreM = fileSetMatches(fileset, patternCoreM)
  117. def hasCoreA = fileSetMatches(fileset, patternCoreA)
  118. def hasCoreValidation = fileSetMatches(fileset, patternCoreValidation)
  119. echo """Change analysis:
  120. - hasGlobal = ${hasGlobal}
  121. - hasCoreM = ${hasCoreM}
  122. - hasCoreA = ${hasCoreA}
  123. - hasCoreValidation = ${hasCoreValidation}
  124. """
  125. if (hasGlobal || hasCoreM || hasCoreValidation) {
  126. CONFIGURATION['devices'] += CONFIGURATION['mdevices']
  127. }
  128. if (hasGlobal || hasCoreA || hasCoreValidation) {
  129. CONFIGURATION['devices'] += CONFIGURATION['adevices']
  130. }
  131. CORE_VALIDATION &= hasGlobal || hasCoreM || hasCoreA || hasCoreValidation
  132. echo """Stage schedule:
  133. - CORE_VALIDATION = ${CORE_VALIDATION}
  134. """
  135. }
  136. }
  137. }
  138. stage('CoreValidation') {
  139. when {
  140. expression { return CORE_VALIDATION }
  141. beforeOptions true
  142. }
  143. matrix {
  144. axes {
  145. axis {
  146. name 'DEVICE'
  147. values 'CM0', 'CM0plus', 'CM3', 'CM4', 'CM4FP', 'CM7', 'CM7SP', 'CM7DP',
  148. 'CM23', 'CM23S', 'CM23NS', 'CM33', 'CM33S', 'CM33NS',
  149. 'CM35P', 'CM35PS', 'CM35PNS',
  150. 'CA5', 'CA5neon', 'CA7', 'CA7neon', 'CA9', 'CA9neon'
  151. }
  152. }
  153. stages {
  154. stage('Test') {
  155. when {
  156. expression { return DEVICE in CONFIGURATION['devices'] }
  157. beforeOptions true
  158. }
  159. agent {
  160. kubernetes {
  161. defaultContainer 'cmsis'
  162. slaveConnectTimeout 600
  163. yaml """\
  164. apiVersion: v1
  165. kind: Pod
  166. spec:
  167. imagePullSecrets:
  168. - name: ${dockerinfo_linux['k8sPullSecret']}
  169. securityContext:
  170. runAsUser: 1000
  171. runAsGroup: 1000
  172. containers:
  173. - name: cmsis
  174. image: ${dockerinfo_linux['registryUrl']}/${dockerinfo_linux['image']}:${dockerinfo_linux['label']}
  175. alwaysPullImage: true
  176. imagePullPolicy: Always
  177. command:
  178. - sleep
  179. args:
  180. - infinity
  181. resources:
  182. requests:
  183. cpu: 2
  184. memory: 2Gi
  185. """.stripIndent()
  186. }
  187. }
  188. steps {
  189. checkoutScmWithRetry(3)
  190. dir('CMSIS/CoreValidation/Tests') {
  191. script {
  192. CONFIGURATION['configs'].each { COMPILER, OPTS ->
  193. tee("CV_${COMPILER}_${DEVICE}.log") {
  194. sh "python3 build.py -d ${DEVICE} -c ${COMPILER} -o ${OPTS.join(' -o ')} build run"
  195. }
  196. }
  197. }
  198. archiveArtifacts artifacts: "CoreValidation_*.zip", allowEmptyArchive: true
  199. stash name: "CV_${DEVICE}", includes: '*.log, *.junit'
  200. }
  201. }
  202. }
  203. }
  204. }
  205. }
  206. stage('Results') {
  207. steps {
  208. dir('results') {
  209. deleteDir()
  210. script {
  211. CONFIGURATION['devices'].each { unstash "CV_${it}" }
  212. }
  213. recordIssues tools: [clang(id: 'AC6', name: 'Arm Compiler 6', pattern: 'CV_AC6_*.log'),
  214. clang(id: 'AC6LTM', name: 'Arm Compiler 6 LTM', pattern: 'CV_AC6LTM_*.log')],
  215. qualityGates: [[threshold: 1, type: 'DELTA', unstable: true]],
  216. referenceJobName: 'nightly', ignoreQualityGate: true
  217. xunit([
  218. JUnit(pattern: 'corevalidation_*.junit', failIfNotNew: false, skipNoTestFiles: true)
  219. ])
  220. }
  221. }
  222. }
  223. }
  224. }