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