Skip to content

Commit

Permalink
[ci] Create GitHub groups in log outputs for FPGA tests
Browse files Browse the repository at this point in the history
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 <amaury.pouly@lowrisc.org>
  • Loading branch information
pamaury committed Dec 20, 2024
1 parent ebff68b commit c3911ca
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 0 deletions.
8 changes: 8 additions & 0 deletions ci/scripts/BUILD
Original file line number Diff line number Diff line change
@@ -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"],
)
1 change: 1 addition & 0 deletions ci/scripts/run-fpga-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand Down
25 changes: 25 additions & 0 deletions ci/scripts/run_test.sh
Original file line number Diff line number Diff line change
@@ -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
"$@"

0 comments on commit c3911ca

Please sign in to comment.