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