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