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 <[email protected]>
  • Loading branch information
pamaury committed Dec 8, 2024
1 parent 7ed46b1 commit 85cb2ae
Show file tree
Hide file tree
Showing 3 changed files with 29 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 @@ 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 \
Expand Down
20 changes: 20 additions & 0 deletions ci/scripts/run_test.sh
Original file line number Diff line number Diff line change
@@ -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::"

0 comments on commit 85cb2ae

Please sign in to comment.