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