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