Dean Birch | 62c4f08 | 2020-01-17 16:13:26 +0000 | [diff] [blame] | 1 | #!/usr/bin/env groovy |
| 2 | //------------------------------------------------------------------------------- |
| 3 | // Copyright (c) 2020, Arm Limited and Contributors. All rights reserved. |
| 4 | // |
| 5 | // SPDX-License-Identifier: BSD-3-Clause |
| 6 | // |
| 7 | //------------------------------------------------------------------------------- |
| 8 | |
Dean Birch | d0f9f8c | 2020-03-26 11:10:33 +0000 | [diff] [blame] | 9 | @Library('trustedfirmware') _ |
| 10 | import org.trustedfirmware.Gerrit |
| 11 | import org.trustedfirmware.Summary |
Dean Birch | a6ede7e | 2020-03-13 14:00:33 +0000 | [diff] [blame] | 12 | |
Mark Horvath | 8d281cd | 2020-12-07 15:20:26 +0100 | [diff] [blame^] | 13 | mapPlatform = ["cypress/psoc64": "psoc64", |
| 14 | "mps2/an519": "AN519", |
| 15 | "mps2/an521": "AN521", |
| 16 | "mps2/an539": "AN539", |
| 17 | "mps2/sse-200_aws": "SSE-200_AWS", |
| 18 | "mps3/an524": "AN524", |
| 19 | "musca_a": "MUSCA_A", |
| 20 | "musca_b1/sse_200": "MUSCA_B1", |
| 21 | "musca_b1/secure_enclave": "MUSCA_B1_SE", |
| 22 | "musca_s1": "MUSCA_S1"] |
Xinyu Zhang | 5c4bbca | 2020-09-24 16:36:03 +0800 | [diff] [blame] | 23 | |
| 24 | mapCompiler = ["toolchain_GNUARM.cmake": "GNUARM", |
| 25 | "toolchain_ARMCLANG.cmake": "ARMCLANG"] |
| 26 | |
| 27 | mapBL2 = ["True": "--bl2", |
| 28 | "False": ""] |
| 29 | |
| 30 | mapTestPsaApi = ["OFF": "", |
| 31 | "INTERNAL_TRUSTED_STORAGE": "ITS", |
| 32 | "PROTECTED_STORAGE": "PS", |
| 33 | "CRYPTO": "Crypto", |
| 34 | "INITIAL_ATTESTATION": "Attest", |
| 35 | "IPC": "FF"] |
| 36 | |
Xinyu Zhang | dbfadae | 2020-12-07 14:42:59 +0800 | [diff] [blame] | 37 | // BL2, NS, PSA_API, ISOLATION_LEVEL, TEST_REG, TEST_PSA_API, PROFILE, CONFIG_NAME |
Xinyu Zhang | 4f2ef5a | 2020-11-09 18:11:43 +0800 | [diff] [blame] | 38 | mapConfigs = [ |
| 39 | ["True", "True", "False", "1", "False", "OFF", "N.A", "Default"], |
| 40 | ["True", "True", "True", "1", "False", "OFF", "N.A", "CoreIPC"], |
| 41 | ["True", "True", "True", "2", "False", "OFF", "N.A", "CoreIPCTfmLevel2"], |
| 42 | ["True", "True", "True", "3", "False", "OFF", "N.A", "CoreIPCTfmLevel3"], |
| 43 | ["True", "True", "False", "1", "False", "OFF", "profile_small", "DefaultProfileS"], |
| 44 | ["True", "True", "True", "2", "False", "OFF", "profile_medium", "DefaultProfileM"], |
| 45 | ["True", "True", "False", "1", "True", "OFF", "N.A", "Regression"], |
| 46 | ["True", "True", "True", "1", "True", "OFF", "N.A", "RegressionIPC"], |
| 47 | ["True", "True", "True", "2", "True", "OFF", "N.A", "RegressionIPCTfmLevel2"], |
| 48 | ["True", "True", "True", "3", "True", "OFF", "N.A", "RegressionIPCTfmLevel3"], |
| 49 | ["True", "True", "False", "1", "True", "OFF", "profile_small", "RegressionProfileS"], |
| 50 | ["True", "True", "True", "2", "True", "OFF", "profile_medium", "RegressionProfileM"], |
| 51 | ["True", "True", "False", "1", "False", "INTERNAL_TRUSTED_STORAGE", "N.A", "PsaApiTest (ITS)"], |
| 52 | ["True", "True", "False", "1", "False", "PROTECTED_STORAGE", "N.A", "PsaApiTest (PS)"], |
| 53 | ["True", "True", "False", "1", "False", "CRYPTO", "N.A", "PsaApiTest (Crypto)"], |
| 54 | ["True", "True", "False", "1", "False", "INITIAL_ATTESTATION", "N.A", "PsaApiTest (Attest)"], |
| 55 | ["True", "True", "False", "1", "False", "IPC", "N.A", "PsaApiTest (FF)"], |
| 56 | ["True", "True", "True", "1", "False", "INTERNAL_TRUSTED_STORAGE", "N.A", "PsaApiTestIPC (ITS)"], |
| 57 | ["True", "True", "True", "1", "False", "PROTECTED_STORAGE", "N.A", "PsaApiTestIPC (PS)"], |
| 58 | ["True", "True", "True", "1", "False", "CRYPTO", "N.A", "PsaApiTestIPC (Crypto)"], |
| 59 | ["True", "True", "True", "1", "False", "INITIAL_ATTESTATION", "N.A", "PsaApiTestIPC (Attest)"], |
| 60 | ["True", "True", "True", "1", "False", "IPC", "N.A", "PsaApiTestIPC (FF)"], |
| 61 | ["True", "True", "True", "2", "False", "INTERNAL_TRUSTED_STORAGE", "N.A", "PsaApiTestIPCTfmLevel2 (ITS)"], |
| 62 | ["True", "True", "True", "2", "False", "PROTECTED_STORAGE", "N.A", "PsaApiTestIPCTfmLevel2 (PS)"], |
| 63 | ["True", "True", "True", "2", "False", "CRYPTO", "N.A", "PsaApiTestIPCTfmLevel2 (Crypto)"], |
| 64 | ["True", "True", "True", "2", "False", "INITIAL_ATTESTATION", "N.A", "PsaApiTestIPCTfmLevel2 (Attest)"], |
| 65 | ["True", "True", "True", "2", "False", "IPC", "N.A", "PsaApiTestIPCTfmLevel2 (FF)"], |
| 66 | ["True", "True", "True", "3", "False", "INTERNAL_TRUSTED_STORAGE", "N.A", "PsaApiTestIPCTfmLevel3 (ITS)"], |
| 67 | ["True", "True", "True", "3", "False", "PROTECTED_STORAGE", "N.A", "PsaApiTestIPCTfmLevel3 (PS)"], |
| 68 | ["True", "True", "True", "3", "False", "CRYPTO", "N.A", "PsaApiTestIPCTfmLevel3 (Crypto)"], |
| 69 | ["True", "True", "True", "3", "False", "INITIAL_ATTESTATION", "N.A", "PsaApiTestIPCTfmLevel3 (Attest)"], |
| 70 | ["True", "True", "True", "3", "False", "IPC", "N.A", "PsaApiTestIPCTfmLevel3 (FF)"], |
| 71 | ] |
| 72 | |
| 73 | cfgs = ["Default", "CoreIPC", "CoreIPCTfmLevel2", "CoreIPCTfmLevel3", |
| 74 | "Regression", "RegressionIPC", |
| 75 | "RegressionIPCTfmLevel2", "RegressionIPCTfmLevel3", |
| 76 | "DefaultProfileS", "RegressionProfileS", |
| 77 | "DefaultProfileM", "RegressionProfileM", "RegressionProfileM PSOFF", |
| 78 | "PsaApiTest (Attest)", "PsaApiTestIPC (Attest)", |
| 79 | "PsaApiTestIPCTfmLevel2 (Attest)", |
| 80 | "PsaApiTest (Crypto)", "PsaApiTestIPC (Crypto)", |
| 81 | "PsaApiTestIPCTfmLevel2 (Crypto)", |
| 82 | "PsaApiTest (PS)", "PsaApiTestIPC (PS)", |
| 83 | "PsaApiTestIPCTfmLevel2 (PS)", |
| 84 | "PsaApiTest (ITS)", "PsaApiTestIPC (ITS)", |
| 85 | "PsaApiTestIPCTfmLevel2 (ITS)", |
| 86 | "PsaApiTestIPC (FF)", |
| 87 | "PsaApiTestIPCTfmLevel2 (FF)", |
| 88 | "PsaApiTestIPCTfmLevel3 (ITS)", "PsaApiTestIPCTfmLevel3 (PS)", |
| 89 | "PsaApiTestIPCTfmLevel3 (Crypto)", "PsaApiTestIPCTfmLevel3 (Attest)", |
| 90 | "PsaApiTestIPCTfmLevel3 (FF)"] |
| 91 | |
Xinyu Zhang | 5c4bbca | 2020-09-24 16:36:03 +0800 | [diff] [blame] | 92 | def generateLavaParam(build_params) { |
| 93 | def params = [] |
| 94 | params += string(name: "TARGET_PLATFORM", \ |
| 95 | value: mapPlatform[build_params["TFM_PLATFORM"]]) |
| 96 | params += string(name: "COMPILER", \ |
| 97 | value: mapCompiler[build_params["TOOLCHAIN_FILE"]]) |
| 98 | params += string(name: "PSA_API_SUITE", \ |
| 99 | value: mapTestPsaApi[build_params["TEST_PSA_API"]]) |
| 100 | |
Xinyu Zhang | dbfadae | 2020-12-07 14:42:59 +0800 | [diff] [blame] | 101 | configName = "Config" |
| 102 | config_params = [build_params["BL2"], build_params["NS"], \ |
| 103 | build_params["PSA_API"], build_params["ISOLATION_LEVEL"], \ |
| 104 | build_params["TEST_REGRESSION"], build_params["TEST_PSA_API"], \ |
| 105 | build_params["PROFILE"]] |
| 106 | for (config in mapConfigs) { |
| 107 | if (config_params == config[0..6]) { |
| 108 | configName += config[7].split(' ')[0] |
| 109 | break |
| 110 | } |
Xinyu Zhang | 5c4bbca | 2020-09-24 16:36:03 +0800 | [diff] [blame] | 111 | } |
Xinyu Zhang | dbfadae | 2020-12-07 14:42:59 +0800 | [diff] [blame] | 112 | if (configName == "Config") { |
| 113 | configName = "ConfigDefault" |
| 114 | } |
| 115 | params += string(name: "PROJ_CONFIG", value: configName) |
| 116 | |
Xinyu Zhang | 5c4bbca | 2020-09-24 16:36:03 +0800 | [diff] [blame] | 117 | return params |
| 118 | } |
| 119 | |
Dean Birch | 62c4f08 | 2020-01-17 16:13:26 +0000 | [diff] [blame] | 120 | def listConfigs(ci_scripts_dir, config_list, filter_group) { |
| 121 | dir(ci_scripts_dir) { |
| 122 | echo "Obtaining list of configs." |
Matthew Hart | fb6fd36 | 2020-03-04 21:03:59 +0000 | [diff] [blame] | 123 | echo "Running: python3 ./configs.py -g ${filter_group.replace(" ", " -g ")}" |
Dean Birch | 62c4f08 | 2020-01-17 16:13:26 +0000 | [diff] [blame] | 124 | def build_config_list_raw = sh(script: """\ |
Matthew Hart | fb6fd36 | 2020-03-04 21:03:59 +0000 | [diff] [blame] | 125 | python3 ./configs.py -g ${filter_group.replace(" ", " -g ")} |
Dean Birch | 62c4f08 | 2020-01-17 16:13:26 +0000 | [diff] [blame] | 126 | """, returnStdout: true).trim() |
| 127 | def build_config_list = build_config_list_raw.tokenize('\n') |
| 128 | config_list.addAll(build_config_list) |
| 129 | } |
| 130 | } |
| 131 | |
Matthew Hart | fb6fd36 | 2020-03-04 21:03:59 +0000 | [diff] [blame] | 132 | def buildConfig(ci_scripts_dir, config, filter_group, results) { |
Dean Birch | 62c4f08 | 2020-01-17 16:13:26 +0000 | [diff] [blame] | 133 | def params = [] |
Matthew Hart | fb6fd36 | 2020-03-04 21:03:59 +0000 | [diff] [blame] | 134 | def params_collection = [:] |
Dean Birch | 62c4f08 | 2020-01-17 16:13:26 +0000 | [diff] [blame] | 135 | def build_config_params |
| 136 | dir(ci_scripts_dir) { |
| 137 | echo "Obtaining build configuration for config ${config}" |
Matthew Hart | fb6fd36 | 2020-03-04 21:03:59 +0000 | [diff] [blame] | 138 | echo "Running: python3 ./configs.py -g ${filter_group.replace(" ", " -g ")} ${config}" |
Dean Birch | 62c4f08 | 2020-01-17 16:13:26 +0000 | [diff] [blame] | 139 | build_config_params = sh(script: """\ |
Matthew Hart | fb6fd36 | 2020-03-04 21:03:59 +0000 | [diff] [blame] | 140 | python3 ./configs.py -g ${filter_group.replace(" ", " -g ")} ${config} |
Dean Birch | 62c4f08 | 2020-01-17 16:13:26 +0000 | [diff] [blame] | 141 | """, returnStdout: true).trim() |
| 142 | } |
| 143 | def lines = build_config_params.tokenize('\n') |
| 144 | for (String line : lines) { |
| 145 | def key, value |
| 146 | (key, value) = line.tokenize('=') |
| 147 | params += string(name: key, value: value) |
Matthew Hart | fb6fd36 | 2020-03-04 21:03:59 +0000 | [diff] [blame] | 148 | params_collection[key] = value |
Dean Birch | 62c4f08 | 2020-01-17 16:13:26 +0000 | [diff] [blame] | 149 | } |
| 150 | params += string(name: 'GERRIT_BRANCH', value: env.GERRIT_BRANCH) |
Dean Birch | d0f9f8c | 2020-03-26 11:10:33 +0000 | [diff] [blame] | 151 | params += string(name: 'GERRIT_HOST', value: env.GERRIT_HOST) |
| 152 | params += string(name: 'GERRIT_CHANGE_NUMBER', value: env.GERRIT_CHANGE_NUMBER) |
| 153 | params += string(name: 'GERRIT_PATCHSET_REVISION', value: env.GERRIT_PATCHSET_REVISION) |
Dean Birch | 62c4f08 | 2020-01-17 16:13:26 +0000 | [diff] [blame] | 154 | params += string(name: 'GERRIT_REFSPEC', value: env.GERRIT_REFSPEC) |
Karl Zhang | 02d3035 | 2020-08-20 13:48:52 +0800 | [diff] [blame] | 155 | params += string(name: 'MBEDTLS_VERSION', value: env.MBEDTLS_VERSION) |
Dean Birch | 62c4f08 | 2020-01-17 16:13:26 +0000 | [diff] [blame] | 156 | params += string(name: 'CODE_REPO', value: env.CODE_REPO) |
Karl Zhang | f6f467e | 2020-07-10 16:24:45 +0800 | [diff] [blame] | 157 | params += string(name: 'CODE_COVERAGE_EN', value: env.CODE_COVERAGE_EN) |
Colin Thorbinson | 58703db | 2020-11-24 12:02:19 +0000 | [diff] [blame] | 158 | params += string(name: 'CI_SCRIPTS_BRANCH', value: env.CI_SCRIPTS_BRANCH) |
Dean Birch | a6ede7e | 2020-03-13 14:00:33 +0000 | [diff] [blame] | 159 | return { -> results |
| 160 | def build_res = build(job: 'tf-m-build-config', parameters: params, propagate: false) |
| 161 | def build_info = [build_res, config, params_collection] |
| 162 | results['builds'][build_res.number] = build_info |
| 163 | def build_url = build_res.getAbsoluteUrl() |
| 164 | print("${build_res.number}: ${config} ${build_res.result} ${build_url}") |
| 165 | failure_states = ["FAILURE", "ABORTED", "UNSTABLE", "NOT_BUILT"] |
| 166 | if (build_res.result in failure_states) { |
| 167 | error("Build failed at ${build_url}") |
| 168 | } |
Karl Zhang | 2b10b34 | 2020-11-09 14:50:11 +0800 | [diff] [blame] | 169 | else if (params_collection["NS"] == "False" || \ |
| 170 | (params_collection["PROFILE"] == "profile_medium" && \ |
| 171 | params_collection["PARTITION_PS"] == "OFF")) { |
Xinyu Zhang | 5c4bbca | 2020-09-24 16:36:03 +0800 | [diff] [blame] | 172 | print("LAVA is not needed for ${build_url}") |
| 173 | } |
Dean Birch | a6ede7e | 2020-03-13 14:00:33 +0000 | [diff] [blame] | 174 | else { |
| 175 | print("Doing LAVA stuff for ${build_url}") |
Xinyu Zhang | 5c4bbca | 2020-09-24 16:36:03 +0800 | [diff] [blame] | 176 | params += generateLavaParam(params_collection) |
Dean Birch | a6ede7e | 2020-03-13 14:00:33 +0000 | [diff] [blame] | 177 | params += string(name: 'BUILD_NUMBER', value: "${build_res.number}") |
| 178 | params += string(name: 'BUILD_URL', value: build_url) |
Matthew Hart | fb6fd36 | 2020-03-04 21:03:59 +0000 | [diff] [blame] | 179 | params += string(name: 'LAVA_URL', value: env.LAVA_URL) |
Dean Birch | 956416f | 2020-08-12 10:36:16 +0100 | [diff] [blame] | 180 | params += string(name: 'CI_SCRIPTS_BRANCH', value: env.CI_SCRIPTS_BRANCH) |
| 181 | params += string(name: 'LAVA_CREDENTIALS', value: env.LAVA_CREDENTIALS) |
Dean Birch | a6ede7e | 2020-03-13 14:00:33 +0000 | [diff] [blame] | 182 | def lava_res = build(job: 'tf-m-lava-submit', parameters: params, propagate: false) |
Matthew Hart | fb6fd36 | 2020-03-04 21:03:59 +0000 | [diff] [blame] | 183 | if (lava_res.result in failure_states) { |
| 184 | error("LAVA Create and Submit failed at ${lava_res.getAbsoluteUrl()}") |
| 185 | } |
| 186 | else { |
| 187 | results['lava_jobs'] += lava_res.getDescription() |
| 188 | } |
Dean Birch | 62c4f08 | 2020-01-17 16:13:26 +0000 | [diff] [blame] | 189 | } |
| 190 | } |
| 191 | } |
| 192 | |
Matthew Hart | 06340d7 | 2020-06-15 16:08:20 +0100 | [diff] [blame] | 193 | def buildDocs(results) { |
Dean Birch | 62c4f08 | 2020-01-17 16:13:26 +0000 | [diff] [blame] | 194 | def params = [] |
| 195 | params += string(name: 'GERRIT_BRANCH', value: env.GERRIT_BRANCH) |
Dean Birch | d0f9f8c | 2020-03-26 11:10:33 +0000 | [diff] [blame] | 196 | params += string(name: 'GERRIT_HOST', value: env.GERRIT_HOST) |
| 197 | params += string(name: 'GERRIT_CHANGE_NUMBER', value: env.GERRIT_CHANGE_NUMBER) |
| 198 | params += string(name: 'GERRIT_PATCHSET_REVISION', value: env.GERRIT_PATCHSET_REVISION) |
Dean Birch | 62c4f08 | 2020-01-17 16:13:26 +0000 | [diff] [blame] | 199 | params += string(name: 'GERRIT_REFSPEC', value: env.GERRIT_REFSPEC) |
Karl Zhang | 02d3035 | 2020-08-20 13:48:52 +0800 | [diff] [blame] | 200 | params += string(name: 'MBEDTLS_VERSION', value: env.MBEDTLS_VERSION) |
Dean Birch | 62c4f08 | 2020-01-17 16:13:26 +0000 | [diff] [blame] | 201 | params += string(name: 'CODE_REPO', value: env.CODE_REPO) |
Colin Thorbinson | 58703db | 2020-11-24 12:02:19 +0000 | [diff] [blame] | 202 | params += string(name: 'CI_SCRIPTS_BRANCH', value: env.CI_SCRIPTS_BRANCH) |
Matthew Hart | 06340d7 | 2020-06-15 16:08:20 +0100 | [diff] [blame] | 203 | return { -> results |
Dean Birch | 62c4f08 | 2020-01-17 16:13:26 +0000 | [diff] [blame] | 204 | def res = build(job: 'tf-m-build-docs', parameters: params, propagate:false) |
| 205 | print("${res.number}: Docs ${res.result} ${res.getAbsoluteUrl()}") |
Matthew Hart | 06340d7 | 2020-06-15 16:08:20 +0100 | [diff] [blame] | 206 | results['docs'] = [res.number, res.result, params] |
Dean Birch | a6ede7e | 2020-03-13 14:00:33 +0000 | [diff] [blame] | 207 | if (res.result in ["FAILURE", "ABORTED", "UNSTABLE", "NOT_BUILT"]) { |
Dean Birch | 62c4f08 | 2020-01-17 16:13:26 +0000 | [diff] [blame] | 208 | error("Build failed at ${res.getAbsoluteUrl()}") |
| 209 | } |
| 210 | } |
| 211 | } |
| 212 | |
Xinyu Zhang | 38a1887 | 2020-11-23 16:45:28 +0800 | [diff] [blame] | 213 | def generateEmailBody(stage, failed_jobs) { |
| 214 | body = "Check console output at ${env.BUILD_URL} \n\n" |
| 215 | |
| 216 | body += "Failed Jobs:\n" |
| 217 | failed_jobs.each { job -> |
| 218 | body += "${job.key} ${job.value}\n" |
| 219 | } |
| 220 | |
| 221 | body += "\nFor detailed ${stage} results please refer to \ |
| 222 | ${env.BUILD_URL}artifact/${stage}_results.csv \n" |
| 223 | return body |
| 224 | } |
| 225 | |
| 226 | def emailNotification(results, stage, failed_jobs) { |
Karl Zhang | 0413e97 | 2020-09-18 17:59:26 +0800 | [diff] [blame] | 227 | script { |
| 228 | if (env.JOB_NAME.equals("tf-m-nightly") && !env.EMAIL_NOTIFICATION.equals('')) { |
| 229 | def result = "Fail." |
Karl Zhang | 182ecdf | 2020-10-10 09:52:12 +0800 | [diff] [blame] | 230 | if (results == true) { |
Karl Zhang | 0413e97 | 2020-09-18 17:59:26 +0800 | [diff] [blame] | 231 | result = "Success." |
Karl Zhang | 182ecdf | 2020-10-10 09:52:12 +0800 | [diff] [blame] | 232 | print("Skip sending as ${result} for ${stage}") |
| 233 | } |
| 234 | else { |
| 235 | emailext ( |
| 236 | subject: ("Job ${env.JOB_NAME} ${stage} ${env.BUILD_NUMBER} ${result}"), |
Xinyu Zhang | 38a1887 | 2020-11-23 16:45:28 +0800 | [diff] [blame] | 237 | body: generateEmailBody(stage, failed_jobs), |
Karl Zhang | 182ecdf | 2020-10-10 09:52:12 +0800 | [diff] [blame] | 238 | to: "${EMAIL_NOTIFICATION}" |
| 239 | ) |
| 240 | } |
Karl Zhang | 0413e97 | 2020-09-18 17:59:26 +0800 | [diff] [blame] | 241 | } |
| 242 | } /* script */ |
| 243 | } |
| 244 | |
Xinyu Zhang | 38a1887 | 2020-11-23 16:45:28 +0800 | [diff] [blame] | 245 | def filterFailedBuild(results) { |
| 246 | def failed_builds = [:] |
| 247 | results.each { result -> |
| 248 | if (result.value[0].getResult() == "FAILURE") { |
| 249 | failed_builds[result.value[1]] = result.value[0].getAbsoluteUrl() |
| 250 | } |
| 251 | } |
| 252 | return failed_builds |
| 253 | } |
| 254 | |
| 255 | def filterFailedTest(string) { |
| 256 | def failed_tests = [:] |
| 257 | line = lineInString(string, "FAILURE_TESTS:") |
| 258 | a = line.split(' ') |
| 259 | if (a.size() > 1) { |
| 260 | a = line.split(' ')[1..-1] |
| 261 | a.each { fail_test -> |
| 262 | config_link = fail_test.split(':') |
| 263 | failed_tests[config_link[0]] = config_link[1..-1].join(':') |
| 264 | } |
| 265 | } |
| 266 | return failed_tests |
| 267 | } |
| 268 | |
xinyu-tfm | b4fc041 | 2020-08-19 10:49:51 +0800 | [diff] [blame] | 269 | @NonCPS |
| 270 | def generateCsvContent(results) { |
| 271 | def resultsParam = [] |
| 272 | results.each { result -> |
Xinyu Zhang | 4f2ef5a | 2020-11-09 18:11:43 +0800 | [diff] [blame] | 273 | if (result.value[2]['BL2'] == "True") { |
| 274 | resultsParam.add([result.value[1], \ |
| 275 | result.value[0].getResult(), \ |
| 276 | result.value[2]['TFM_PLATFORM'], \ |
| 277 | result.value[2]['TOOLCHAIN_FILE'], \ |
| 278 | result.value[2]['CMAKE_BUILD_TYPE'], \ |
| 279 | result.value[2]['BL2'], \ |
| 280 | result.value[2]['NS'], \ |
| 281 | result.value[2]['PSA_API'], \ |
| 282 | result.value[2]['ISOLATION_LEVEL'], \ |
| 283 | result.value[2]['TEST_REGRESSION'], \ |
| 284 | result.value[2]['TEST_PSA_API'], \ |
| 285 | result.value[2]['PROFILE'], \ |
| 286 | result.value[2]['PARTITION_PS'], \ |
| 287 | result.value[2]['OTP']]) |
| 288 | } |
xinyu-tfm | b4fc041 | 2020-08-19 10:49:51 +0800 | [diff] [blame] | 289 | } |
xinyu-tfm | b4fc041 | 2020-08-19 10:49:51 +0800 | [diff] [blame] | 290 | resultsParam.each { result -> |
Xinyu Zhang | 4f2ef5a | 2020-11-09 18:11:43 +0800 | [diff] [blame] | 291 | if (result[2] == 'musca_b1') { |
| 292 | if (result[13] != 'off') { |
| 293 | result[2] = 'musca_b1_OTP' |
xinyu-tfm | b4fc041 | 2020-08-19 10:49:51 +0800 | [diff] [blame] | 294 | } |
| 295 | } |
Xinyu Zhang | 4f2ef5a | 2020-11-09 18:11:43 +0800 | [diff] [blame] | 296 | result[3] = mapCompiler[result[3]] |
| 297 | build_params = result[5..12] |
| 298 | configName = "" |
| 299 | for (map_cfg in mapConfigs) { |
| 300 | if (build_params[0..6] == map_cfg[0..6]) { |
| 301 | configName = map_cfg[7] |
| 302 | break |
| 303 | } |
xinyu-tfm | b4fc041 | 2020-08-19 10:49:51 +0800 | [diff] [blame] | 304 | } |
Xinyu Zhang | 4f2ef5a | 2020-11-09 18:11:43 +0800 | [diff] [blame] | 305 | if (configName == "") { |
| 306 | configName = "Default" |
xinyu-tfm | b4fc041 | 2020-08-19 10:49:51 +0800 | [diff] [blame] | 307 | } |
Xinyu Zhang | 4f2ef5a | 2020-11-09 18:11:43 +0800 | [diff] [blame] | 308 | else if (configName == "RegressionProfileM") { |
| 309 | if (build_params[7] == "OFF") { |
| 310 | configName = "RegressionProfileM PSOFF" |
| 311 | } |
xinyu-tfm | b4fc041 | 2020-08-19 10:49:51 +0800 | [diff] [blame] | 312 | } |
Xinyu Zhang | 4f2ef5a | 2020-11-09 18:11:43 +0800 | [diff] [blame] | 313 | result.add(configName) |
xinyu-tfm | b4fc041 | 2020-08-19 10:49:51 +0800 | [diff] [blame] | 314 | } |
xinyu-tfm | b4fc041 | 2020-08-19 10:49:51 +0800 | [diff] [blame] | 315 | def csvContent = [] |
| 316 | resultsParam.each { result -> |
Xinyu Zhang | 4f2ef5a | 2020-11-09 18:11:43 +0800 | [diff] [blame] | 317 | current_row = result[2..4] |
| 318 | cfgs.each {cfg -> |
| 319 | if (cfg == result[14]) { |
| 320 | current_row.add(cfg) |
| 321 | current_row.add(result[1]) |
| 322 | } |
| 323 | } |
| 324 | csvContent.add(current_row) |
| 325 | } |
| 326 | csvContent.sort{a,b -> a[0] <=> b[0] ?: a[1] <=> b[1] ?: a[2] <=> b[2]} |
| 327 | build_summary = [] |
| 328 | current_platform = "" |
| 329 | current_compiler = "" |
| 330 | current_build_type = "" |
| 331 | csvContent.each { build_cfg -> |
| 332 | if (current_platform != build_cfg[0] || \ |
| 333 | current_compiler != build_cfg[1] || \ |
| 334 | current_build_type != build_cfg[2]) { |
| 335 | current_platform = build_cfg[0] |
| 336 | current_compiler = build_cfg[1] |
| 337 | current_build_type = build_cfg[2] |
| 338 | csv_line = [current_platform, current_compiler, current_build_type] |
| 339 | cfgs.each { |
| 340 | csv_line.add("N.A.") |
xinyu-tfm | b4fc041 | 2020-08-19 10:49:51 +0800 | [diff] [blame] | 341 | } |
Xinyu Zhang | 4f2ef5a | 2020-11-09 18:11:43 +0800 | [diff] [blame] | 342 | build_summary.add(csv_line) |
| 343 | } |
| 344 | i = 0 |
| 345 | cfgs.each { cfg -> |
| 346 | if (cfg == build_cfg[3]) { |
| 347 | build_summary[-1][3+i] = build_cfg[4] |
| 348 | } |
| 349 | i += 1 |
xinyu-tfm | b4fc041 | 2020-08-19 10:49:51 +0800 | [diff] [blame] | 350 | } |
| 351 | } |
Xinyu Zhang | 4f2ef5a | 2020-11-09 18:11:43 +0800 | [diff] [blame] | 352 | build_summary.add(0, ['Platform', 'Compiler', 'Cmake Build Type']) |
| 353 | build_summary[0] += cfgs |
| 354 | return build_summary |
xinyu-tfm | b4fc041 | 2020-08-19 10:49:51 +0800 | [diff] [blame] | 355 | } |
| 356 | |
| 357 | def generateBuildCsv(results) { |
| 358 | def csvContent = generateCsvContent(results) |
| 359 | node("master") { |
| 360 | writeCSV file: 'build_results.csv', records: csvContent, format: CSVFormat.EXCEL |
| 361 | archiveArtifacts 'build_results.csv' |
| 362 | } |
| 363 | } |
Dean Birch | a6ede7e | 2020-03-13 14:00:33 +0000 | [diff] [blame] | 364 | |
| 365 | def buildCsv(results) { |
Dean Birch | d0f9f8c | 2020-03-26 11:10:33 +0000 | [diff] [blame] | 366 | def summary = new Summary(); |
Dean Birch | a6ede7e | 2020-03-13 14:00:33 +0000 | [diff] [blame] | 367 | def csvContent = summary.getBuildCsv(results) |
| 368 | node("master") { |
| 369 | writeCSV file: 'build_results.csv', records: csvContent, format: CSVFormat.EXCEL |
| 370 | archiveArtifacts 'build_results.csv' |
| 371 | } |
| 372 | } |
| 373 | |
| 374 | def writeSummary(results) { |
Dean Birch | d0f9f8c | 2020-03-26 11:10:33 +0000 | [diff] [blame] | 375 | def summary = new Summary(); |
Dean Birch | a6ede7e | 2020-03-13 14:00:33 +0000 | [diff] [blame] | 376 | def buildLinks = summary.getLinks(results) |
| 377 | node("master") { |
| 378 | writeFile file: "build_links.html", text: buildLinks |
| 379 | archiveArtifacts 'build_links.html' |
| 380 | } |
| 381 | } |
| 382 | |
Matthew Hart | fb6fd36 | 2020-03-04 21:03:59 +0000 | [diff] [blame] | 383 | def lineInString(string, match) { |
| 384 | def lines = string.split("\n") |
| 385 | def result = lines.findAll { it.contains(match) } |
| 386 | return result[0] |
| 387 | } |
| 388 | |
| 389 | def getResult(string, match) { |
| 390 | line = lineInString(string, match) |
Dean Birch | 1d545c0 | 2020-05-29 14:09:21 +0100 | [diff] [blame] | 391 | a = line.split(match)[1].split(' ') |
| 392 | score = a[0] |
| 393 | if (a.size() > 1) |
| 394 | { |
| 395 | fail_text = a[1..-1].join(" ") |
| 396 | return [score, fail_text] |
| 397 | } |
| 398 | return [score, ""] |
Matthew Hart | fb6fd36 | 2020-03-04 21:03:59 +0000 | [diff] [blame] | 399 | } |
| 400 | |
| 401 | def submitJobsToList(results) { |
| 402 | def all_jobs = [] |
| 403 | for (String result : results){ |
| 404 | jobs_s = result.split('JOBS: ') |
| 405 | if (jobs_s.size() > 1) { |
| 406 | all_jobs += jobs_s[1] |
| 407 | } |
| 408 | } |
| 409 | return(all_jobs) |
| 410 | } |
| 411 | |
Dean Birch | 62c4f08 | 2020-01-17 16:13:26 +0000 | [diff] [blame] | 412 | def configs = [] |
| 413 | def builds = [:] |
Matthew Hart | fb6fd36 | 2020-03-04 21:03:59 +0000 | [diff] [blame] | 414 | def results = [:] |
Dean Birch | 62c4f08 | 2020-01-17 16:13:26 +0000 | [diff] [blame] | 415 | |
Benjamin Copeland | be53b03 | 2020-10-30 19:57:59 +0000 | [diff] [blame] | 416 | node("docker-amd64-tf-m-bionic") { |
Dean Birch | 62c4f08 | 2020-01-17 16:13:26 +0000 | [diff] [blame] | 417 | stage("Init") { |
| 418 | cleanWs() |
| 419 | dir("tf-m-ci-scripts") { |
Colin Thorbinson | 58703db | 2020-11-24 12:02:19 +0000 | [diff] [blame] | 420 | checkout([$class: 'GitSCM', branches: [[name: '$CI_SCRIPTS_BRANCH']], userRemoteConfigs: [[credentialsId: 'GIT_SSH_KEY', url: '$CI_SCRIPTS_REPO']]]) |
Dean Birch | 62c4f08 | 2020-01-17 16:13:26 +0000 | [diff] [blame] | 421 | } |
| 422 | } |
| 423 | stage("Configs") { |
| 424 | // Populate configs |
| 425 | listConfigs('tf-m-ci-scripts', configs, env.FILTER_GROUP) |
Dean Birch | a6ede7e | 2020-03-13 14:00:33 +0000 | [diff] [blame] | 426 | results['builds'] = [:] |
| 427 | results['lava_jobs'] = [] |
Dean Birch | 62c4f08 | 2020-01-17 16:13:26 +0000 | [diff] [blame] | 428 | for (config in configs) { |
Matthew Hart | fb6fd36 | 2020-03-04 21:03:59 +0000 | [diff] [blame] | 429 | builds[config] = buildConfig("tf-m-ci-scripts", config, env.FILTER_GROUP, results) |
Dean Birch | 62c4f08 | 2020-01-17 16:13:26 +0000 | [diff] [blame] | 430 | } |
Matthew Hart | 06340d7 | 2020-06-15 16:08:20 +0100 | [diff] [blame] | 431 | builds["docs"] = buildDocs(results) |
Dean Birch | 62c4f08 | 2020-01-17 16:13:26 +0000 | [diff] [blame] | 432 | } |
| 433 | } |
Karl Zhang | fec8410 | 2020-06-24 09:56:36 +0800 | [diff] [blame] | 434 | |
Dean Birch | 62c4f08 | 2020-01-17 16:13:26 +0000 | [diff] [blame] | 435 | stage("Builds") { |
| 436 | def verify = 1 |
Karl Zhang | 182ecdf | 2020-10-10 09:52:12 +0800 | [diff] [blame] | 437 | def success = true |
Dean Birch | 62c4f08 | 2020-01-17 16:13:26 +0000 | [diff] [blame] | 438 | try { |
| 439 | parallel(builds) |
| 440 | } catch (Exception e) { |
Dean Birch | a6ede7e | 2020-03-13 14:00:33 +0000 | [diff] [blame] | 441 | print(e) |
Dean Birch | 62c4f08 | 2020-01-17 16:13:26 +0000 | [diff] [blame] | 442 | manager.buildFailure() |
| 443 | verify = -1 |
Karl Zhang | 182ecdf | 2020-10-10 09:52:12 +0800 | [diff] [blame] | 444 | success = false |
Dean Birch | 62c4f08 | 2020-01-17 16:13:26 +0000 | [diff] [blame] | 445 | } finally { |
Dean Birch | a6ede7e | 2020-03-13 14:00:33 +0000 | [diff] [blame] | 446 | print("Verifying status") |
Xinyu Zhang | 38a1887 | 2020-11-23 16:45:28 +0800 | [diff] [blame] | 447 | def failed_builds = filterFailedBuild(results['builds']) |
| 448 | emailNotification(success, 'build', failed_builds) |
Dean Birch | d0f9f8c | 2020-03-26 11:10:33 +0000 | [diff] [blame] | 449 | g = new Gerrit() |
| 450 | g.verifyStatus(verify, 'tf-m-build', 'build') |
Dean Birch | a6ede7e | 2020-03-13 14:00:33 +0000 | [diff] [blame] | 451 | print("Building CSV") |
xinyu-tfm | b4fc041 | 2020-08-19 10:49:51 +0800 | [diff] [blame] | 452 | generateBuildCsv(results['builds']) |
Dean Birch | a6ede7e | 2020-03-13 14:00:33 +0000 | [diff] [blame] | 453 | writeSummary(results['builds']) |
Dean Birch | 62c4f08 | 2020-01-17 16:13:26 +0000 | [diff] [blame] | 454 | } |
| 455 | } |
Matthew Hart | 06340d7 | 2020-06-15 16:08:20 +0100 | [diff] [blame] | 456 | |
Benjamin Copeland | be53b03 | 2020-10-30 19:57:59 +0000 | [diff] [blame] | 457 | node("docker-amd64-tf-m-bionic") { |
Matthew Hart | 06340d7 | 2020-06-15 16:08:20 +0100 | [diff] [blame] | 458 | stage("Copy Docs") { |
Karl Zhang | 3249797 | 2020-09-21 14:38:29 +0800 | [diff] [blame] | 459 | if (env.JOB_NAME.equals("tf-m-build-and-test")) { |
| 460 | step([$class: 'CopyArtifact', projectName: 'tf-m-build-docs', |
| 461 | selector: specific("${results['docs'][0]}"), target: './docs/', |
| 462 | optional: true]) |
| 463 | archiveArtifacts artifacts: 'docs/**', allowEmptyArchive: true |
| 464 | } |
| 465 | else { |
| 466 | print("No doc copy for job: ${env.JOB_NAME}") |
| 467 | } |
Matthew Hart | 06340d7 | 2020-06-15 16:08:20 +0100 | [diff] [blame] | 468 | } |
Dean Birch | a6ede7e | 2020-03-13 14:00:33 +0000 | [diff] [blame] | 469 | stage("Tests") { |
| 470 | dir("tf-m-ci-scripts") { |
Colin Thorbinson | 58703db | 2020-11-24 12:02:19 +0000 | [diff] [blame] | 471 | checkout([$class: 'GitSCM', branches: [[name: '$CI_SCRIPTS_BRANCH']], userRemoteConfigs: [[credentialsId: 'GIT_SSH_KEY', url: '$CI_SCRIPTS_REPO']]]) |
Dean Birch | a6ede7e | 2020-03-13 14:00:33 +0000 | [diff] [blame] | 472 | } |
Matthew Hart | fb6fd36 | 2020-03-04 21:03:59 +0000 | [diff] [blame] | 473 | def all_jobs = [] |
| 474 | def success = true |
Dean Birch | a6ede7e | 2020-03-13 14:00:33 +0000 | [diff] [blame] | 475 | print("Wait for LAVA results here...") |
Matthew Hart | fb6fd36 | 2020-03-04 21:03:59 +0000 | [diff] [blame] | 476 | try { |
| 477 | all_jobs = submitJobsToList(results['lava_jobs']) |
| 478 | if (all_jobs.size() > 0) { |
| 479 | dir("tf-m-ci-scripts") { |
Dean Birch | 956416f | 2020-08-12 10:36:16 +0100 | [diff] [blame] | 480 | withCredentials([usernamePassword(credentialsId: env.LAVA_CREDENTIALS, passwordVariable: 'LAVA_TOKEN', usernameVariable: 'LAVA_USER')]) { |
Matthew Hart | fb6fd36 | 2020-03-04 21:03:59 +0000 | [diff] [blame] | 481 | output = sh(script: """./lava_helper/lava_wait_jobs.py --job-ids ${all_jobs.join(",")} \ |
| 482 | --lava-url ${env.LAVA_URL} --lava-user ${LAVA_USER} --lava-token ${LAVA_TOKEN} \ |
Matthew Hart | 05a59b5 | 2020-05-27 17:54:51 +0100 | [diff] [blame] | 483 | --artifacts-path lava_artifacts --lava-timeout 7200 \ |
Matthew Hart | fb6fd36 | 2020-03-04 21:03:59 +0000 | [diff] [blame] | 484 | """, returnStdout: true).trim() |
| 485 | archiveArtifacts artifacts: 'test_summary.*', allowEmptyArchive: true |
Xinyu Zhang | 1b8f515 | 2020-11-13 16:10:58 +0800 | [diff] [blame] | 486 | archiveArtifacts artifacts: 'test_results.csv', allowEmptyArchive: true |
Matthew Hart | fb6fd36 | 2020-03-04 21:03:59 +0000 | [diff] [blame] | 487 | g = new Gerrit() |
Dean Birch | 1d545c0 | 2020-05-29 14:09:21 +0100 | [diff] [blame] | 488 | def (boot_result, boot_output) = getResult(output, 'BOOT_RESULT: ') |
Matthew Hart | fb6fd36 | 2020-03-04 21:03:59 +0000 | [diff] [blame] | 489 | if (boot_result) { |
| 490 | g.verifyStatus(boot_result, "lava_boot", "test") |
| 491 | } |
Dean Birch | 1d545c0 | 2020-05-29 14:09:21 +0100 | [diff] [blame] | 492 | def (test_result, test_output) = getResult(output, 'TEST_RESULT: ') |
Matthew Hart | fb6fd36 | 2020-03-04 21:03:59 +0000 | [diff] [blame] | 493 | if (test_result) { |
| 494 | g.verifyStatus(test_result, "lava_test", "test") |
| 495 | } |
| 496 | if (boot_result.toInteger() < 1 || test_result.toInteger() < 1) { |
Dean Birch | 1d545c0 | 2020-05-29 14:09:21 +0100 | [diff] [blame] | 497 | error("Marking job as failed due to failed boots: ${boot_output} or tests: ${test_output}") |
Matthew Hart | fb6fd36 | 2020-03-04 21:03:59 +0000 | [diff] [blame] | 498 | } |
| 499 | } |
| 500 | } |
| 501 | } |
| 502 | else { |
| 503 | print("There were no LAVA jobs to test.") |
| 504 | } |
| 505 | } |
| 506 | catch (Exception e) { |
| 507 | print("ERROR: ${e}") |
| 508 | success = false |
| 509 | } finally { |
| 510 | archiveArtifacts artifacts: 'tf-m-ci-scripts/lava_artifacts/**', allowEmptyArchive: true |
Xinyu Zhang | 9160901 | 2020-12-09 17:35:49 +0800 | [diff] [blame] | 511 | if (all_jobs.size() > 0) { |
| 512 | emailNotification(success, 'test', filterFailedTest(output)) |
| 513 | } |
Matthew Hart | fb6fd36 | 2020-03-04 21:03:59 +0000 | [diff] [blame] | 514 | cleanWs() |
| 515 | if (!success) { |
| 516 | error("There was an Error waiting for LAVA jobs") |
| 517 | } |
Dean Birch | a6ede7e | 2020-03-13 14:00:33 +0000 | [diff] [blame] | 518 | } |
| 519 | } |
Dean Birch | a6ede7e | 2020-03-13 14:00:33 +0000 | [diff] [blame] | 520 | } |