blob: 00d4e86926c65700587143aa6b031594ed7c7caa [file] [log] [blame]
Leonardo Sandoval9dfdd1b2020-08-06 17:08:11 -05001#!/usr/bin/env bash
Fathi Boudra422bf772019-12-02 11:10:16 +02002#
Leonardo Sandoval579c7372020-10-23 15:23:32 -05003# Copyright (c) 2019-2020 Arm Limited. All rights reserved.
Fathi Boudra422bf772019-12-02 11:10:16 +02004#
5# SPDX-License-Identifier: BSD-3-Clause
6#
7
Saul Romero135468b2023-11-28 13:55:43 +00008set -e
9set -x
Fathi Boudra422bf772019-12-02 11:10:16 +020010
Paul Sokolovskybfa80ed2023-06-02 08:58:28 +030011# Jenkins Parameterized Trigger Plugin mangles job names as passed via
12# environment variables, replacing most non-alphanumeric chars with
13# underscore. The mangling is generally non-reversible, but we apply
14# "heuristics" based on our naming conventions.
15function unmangle_job_name() {
16 # Two numbers seperated by undescore was likely a version number originally,
17 # e.g. lts2.8 -> lts2_8.
18 s=$(python3 -c 'import sys, re; print(re.sub(r"(\d+)_(\d+)", r"\1.\2", sys.argv[1]))' "$1")
19 # Otherwise, we use hyphens as seperators.
20 s=$(echo $s | tr "_" "-")
21 echo $s
22}
23
Fathi Boudra422bf772019-12-02 11:10:16 +020024# Generate test report
25if [ "$CI_ROOT" ]; then
26 # Gather Coverity scan summary if it was performed as part of this job
27 if [ "$(find -maxdepth 1 -name '*coverity*.test' -type f | wc -l)" != 0 ]; then
28 if ! "$CI_ROOT/script/coverity_summary.py" "$BUILD_URL" > coverity.data; then
29 rm -f coverity.data
30 fi
31 fi
32
Leonardo Sandoval55d5c8c2021-01-20 10:51:18 -060033 # set proper jobs names for test generation report script
Gary Morrison999a9d72022-03-14 18:29:06 -050034 if echo "$JENKINS_URL" | grep -q "oss.arm.com"; then
Leonardo Sandoval55d5c8c2021-01-20 10:51:18 -060035 worker_job="${worker_job:-tf-worker}"
36 lava_job="${lava_job:-tf-build-for-lava}"
37 else
Paul Sokolovskybfa80ed2023-06-02 08:58:28 +030038 triggered_job=$(unmangle_job_name "${TRIGGERED_JOB_NAMES}")
Paul Sokolovsky71d78cc2021-12-20 17:44:10 +030039 worker_job="${worker_job:-${triggered_job}}"
40 lava_job="${lava_job:-${triggered_job}}"
Harrison Mutai4126dc72021-11-23 11:34:41 +000041 fi
42
43 # Generate UI for test results, only if this is a visualization job.
44 while getopts ":t" option; do
45 case $option in
46 t)
47 target_job="$(dirname $TARGET_BUILD)"
48 target=${target_job:-tf-a-main}
49 "$CI_ROOT/script/gen_results_report.py" \
50 --png "${target}-result.png" \
51 --csv "${WORKSPACE}/${target}-result.csv" \
52 -o "${WORKSPACE}/report.html" || true
53 exit;;
54 esac
55 done
Leonardo Sandoval55d5c8c2021-01-20 10:51:18 -060056
Fathi Boudra422bf772019-12-02 11:10:16 +020057 "$CI_ROOT/script/gen_test_report.py" \
Leonardo Sandoval55d5c8c2021-01-20 10:51:18 -060058 --job "${worker_job}" \
59 --build-job "${lava_job}" \
Fathi Boudra422bf772019-12-02 11:10:16 +020060 --meta-data clone.data \
61 --meta-data override.data \
62 --meta-data inject.data \
63 --meta-data html:coverity.data \
64 || true
Leonardo Sandoval5d9d2762021-02-02 10:06:33 -060065
Saul Romero135468b2023-11-28 13:55:43 +000066 # Only call to merge reports if the test groups are for code coverage
67 if [[ $TEST_GROUPS == *"code-coverage"* ]]; then
68 source $CI_ROOT/script/gen_merge_report.sh "${WORKSPACE}/report.json" \
69 "${WORKSPACE}/report.html"
70 fi
Fathi Boudra422bf772019-12-02 11:10:16 +020071fi