From 85cb2ae5593ac530c7ca78d42577876d725c78d1 Mon Sep 17 00:00:00 2001 From: Amaury Pouly Date: Sun, 8 Dec 2024 16:50:52 +0100 Subject: [PATCH] [ci] Create GitHub groups in log outputs for FPGA tests The log are quite long and GitHub provides a feature where the output group can split lines into groups. This is achieved by using the --run_under command of bazel test. This allows to run a script that then invokes the test runner. This only thing this script does is print the grouping commands. Signed-off-by: Amaury Pouly --- ci/scripts/BUILD | 8 ++++++++ ci/scripts/run-fpga-tests.sh | 1 + ci/scripts/run_test.sh | 20 ++++++++++++++++++++ 3 files changed, 29 insertions(+) create mode 100644 ci/scripts/BUILD create mode 100755 ci/scripts/run_test.sh diff --git a/ci/scripts/BUILD b/ci/scripts/BUILD new file mode 100644 index 00000000000000..3d165499d5efd5 --- /dev/null +++ b/ci/scripts/BUILD @@ -0,0 +1,8 @@ +# Copyright lowRISC contributors (OpenTitan project). +# Licensed under the Apache License, Version 2.0, see LICENSE for details. +# SPDX-License-Identifier: Apache-2.0 + +sh_binary( + name = "run_test", + srcs = ["run_test.sh"], +) diff --git a/ci/scripts/run-fpga-tests.sh b/ci/scripts/run-fpga-tests.sh index 26ca1d779713ec..030370c83c7601 100755 --- a/ci/scripts/run-fpga-tests.sh +++ b/ci/scripts/run-fpga-tests.sh @@ -47,6 +47,7 @@ ci/bazelisk.sh run //sw/host/opentitantool -- --rcfile= --interface="$fpga" fpga ci/bazelisk.sh run //sw/host/opentitantool -- --rcfile= --interface="$fpga" fpga get-sam3x-fw-version || true ci/bazelisk.sh test \ + --run_under=//ci/scripts:run_test \ --define DISABLE_VERILATOR_BUILD=true \ --nokeep_going \ --test_timeout_filters=short,moderate \ diff --git a/ci/scripts/run_test.sh b/ci/scripts/run_test.sh new file mode 100755 index 00000000000000..228078a2367af9 --- /dev/null +++ b/ci/scripts/run_test.sh @@ -0,0 +1,20 @@ +#!/bin/bash +# Copyright lowRISC contributors (OpenTitan project). +# Licensed under the Apache License, Version 2.0, see LICENSE for details. +# SPDX-License-Identifier: Apache-2.0 + +# Print a special GitHub command to create a group in the log's output: +# https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/workflow-commands-for-github-actions#grouping-log-lines +# +# Test variables are documented here: +# https://bazel.build/reference/test-encyclopedia +if [ -z "$TEST_RUN_NUMBER" ]; then + RUN_NR="" +else + RUN_NR="(Run $TEST_RUN_NUMBER)" +fi +echo "::group::$TEST_TARGET $RUN_NR" +# NOTE Even if the command fails, we still want to continue to print +# the endgroup command. +exec $@ +echo "::endgroup::"