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 f5265d9f9fe4a7..dee05a5a8c2f9a 100755 --- a/ci/scripts/run-fpga-tests.sh +++ b/ci/scripts/run-fpga-tests.sh @@ -47,6 +47,7 @@ trap './bazelisk.sh run //sw/host/opentitantool -- --rcfile= --interface=${fpga} ./bazelisk.sh run //sw/host/opentitantool -- --rcfile= --interface="$fpga" fpga get-sam3x-fw-version || true ./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..1810971aac5dd9 --- /dev/null +++ b/ci/scripts/run_test.sh @@ -0,0 +1,25 @@ +#!/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 + +function cleanup { + echo "::endgroup::" +} + +echo "::group::$TEST_TARGET $RUN_NR" +# NOTE Even if the command fails, we still want to continue to print +# the endgroup command. +trap cleanup SIGINT SIGTERM EXIT +$@