| #!/usr/bin/env groovy |
| //------------------------------------------------------------------------------- |
| // Copyright (c) 2020-2024, Arm Limited and Contributors. All rights reserved. |
| // |
| // SPDX-License-Identifier: BSD-3-Clause |
| // |
| //------------------------------------------------------------------------------- |
| |
| @Library('trustedfirmware') _ |
| |
| |
| @NonCPS |
| def isPerPatchJob() { |
| def upstream_job = manager.build.getAction(hudson.model.CauseAction.class).getCauses()[0] |
| if (upstream_job instanceof hudson.model.Cause.UpstreamCause) { |
| def gp_causes = upstream_job.getUpstreamCauses() |
| if (gp_causes.size() > 0 && gp_causes[0] instanceof hudson.model.Cause.UpstreamCause) { |
| print("Grand-parent project cause: ") |
| println(gp_causes[0].upstreamProject) |
| if (gp_causes[0].upstreamProject.endsWith("tf-m-static")) { |
| return true |
| } |
| } |
| } |
| return false |
| } |
| |
| def filterTestDevice() { |
| def device_type = env.DEVICE_FILTER |
| |
| if (env.DEVICE_FILTER != "") { |
| return device_type |
| } |
| // For AN521 builds running per-patch (started by the tf-m-static job), |
| // run tests only on FVP to improve turnaround/performance. |
| // Skip tests on MUSCA B1 in per-patch for better performance. |
| if (isPerPatchJob()) { |
| if (env.TFM_PLATFORM == "arm/mps2/an521" || env.TFM_PLATFORM == "arm/musca_b1") { |
| device_type = "--fvp-only " |
| print("Run test cases only on FVP in tf-m-static.") |
| } |
| } |
| |
| return device_type |
| } |
| |
| def submitJobs(device_type) { |
| dir("tf-m-ci-scripts") { |
| def res = sh(script: """./lava_helper/lava_create_jobs.py \ |
| --output-dir lava_jobs ${device_type} \ |
| --jenkins-build-url ${env.BUILD_URL} \ |
| --docker-prefix ${env.DOCKER_PREFIX} --license-variable "${env.LICENSE_VARIABLE}" \ |
| --enable-code-coverage "${env.CODE_COVERAGE_EN}" |
| """, returnStdout: true).trim() |
| print(res) |
| job_ids = sh(script: '''./lava_helper/lava_submit_jobs.py \ |
| --lava-url ${LAVA_URL} --job-dir lava_jobs \ |
| --lava-user ${LAVA_USER} --lava-token ${LAVA_TOKEN} | egrep "^JOBS" |
| ''', returnStdout: true).trim() |
| print("${job_ids}") |
| currentBuild.setDescription(job_ids) |
| } |
| } |
| |
| timestamps { |
| node("docker-amd64-tf-m-jammy") { |
| stage("Init") { |
| cleanWs() |
| dir("tf-m-ci-scripts") { |
| tfgit.checkout_ci_scripts() |
| withCredentials([string(credentialsId: 'TUXSUITE_TOKEN', variable: 'TUXSUITE_TOKEN')]) { |
| sh "jenkins/tuxsuite-setup.sh" |
| } |
| } |
| } |
| stage("LAVA") { |
| // Workaround for Groovy CPS idiosyncrasies. See e.g. |
| // https://blog.thesparktree.com/you-dont-know-jenkins-part-3#solutions |
| upstream_job = null |
| gp_causes = null |
| def device_type = filterTestDevice() |
| |
| withCredentials([usernamePassword(credentialsId: env.LAVA_CREDENTIALS, passwordVariable: 'LAVA_TOKEN', usernameVariable: 'LAVA_USER')]) { |
| print("Submitting LAVA jobs...") |
| def success = false |
| for (i = 0; i < 5; i++) { |
| try { |
| submitJobs(device_type) |
| success = true |
| break |
| } catch (Exception ex) { |
| print("LAVA-Submit failed! Exception: ${ex}") |
| print("Try to submit again...") |
| sleep(i * 10) |
| } |
| } |
| if (!success) { |
| throw new Exception("LAVA submission failed") |
| } |
| } |
| } |
| stage("Post") { |
| archiveArtifacts artifacts: 'tf-m-ci-scripts/lava_jobs/**', allowEmptyArchive: true |
| cleanWs() |
| } |
| } |
| } |