Skip to content

Commit dab73ae

Browse files
dschogitster
authored andcommitted
ci/run-build-and-tests: add some structure to the GitHub workflow output
The current output of Git's GitHub workflow can be quite confusing, especially for contributors new to the project. To make it more helpful, let's introduce some collapsible grouping. Initially, readers will see the high-level view of what actually happened (did the build fail, or the test suite?). To drill down, the respective group can be expanded. Note: sadly, workflow output currently cannot contain any nested groups (see actions/runner#802 for details), therefore we take pains to ensure to end any previous group before starting a new one. Signed-off-by: Johannes Schindelin <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 08dccc8 commit dab73ae

File tree

3 files changed

+52
-10
lines changed

3 files changed

+52
-10
lines changed

ci/lib.sh

Lines changed: 49 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,50 @@
11
# Library of functions shared by all CI scripts
22

3+
if test true != "$GITHUB_ACTIONS"
4+
then
5+
begin_group () { :; }
6+
end_group () { :; }
7+
8+
group () {
9+
shift
10+
"$@"
11+
}
12+
set -x
13+
else
14+
begin_group () {
15+
need_to_end_group=t
16+
echo "::group::$1" >&2
17+
set -x
18+
}
19+
20+
end_group () {
21+
test -n "$need_to_end_group" || return 0
22+
set +x
23+
need_to_end_group=
24+
echo '::endgroup::' >&2
25+
}
26+
trap end_group EXIT
27+
28+
group () {
29+
set +x
30+
begin_group "$1"
31+
shift
32+
"$@"
33+
res=$?
34+
end_group
35+
return $res
36+
}
37+
38+
begin_group "CI setup"
39+
fi
40+
41+
# Set 'exit on error' for all CI scripts to let the caller know that
42+
# something went wrong.
43+
#
44+
# We already enabled tracing executed commands earlier. This helps by showing
45+
# how # environment variables are set and and dependencies are installed.
46+
set -e
47+
348
skip_branch_tip_with_tag () {
449
# Sometimes, a branch is pushed at the same time the tag that points
550
# at the same commit as the tip of the branch is pushed, and building
@@ -88,12 +133,6 @@ export TERM=${TERM:-dumb}
88133
# Clear MAKEFLAGS that may come from the outside world.
89134
export MAKEFLAGS=
90135

91-
# Set 'exit on error' for all CI scripts to let the caller know that
92-
# something went wrong.
93-
# Set tracing executed commands, primarily setting environment variables
94-
# and installing dependencies.
95-
set -ex
96-
97136
if test -n "$SYSTEM_COLLECTIONURI" || test -n "$SYSTEM_TASKDEFINITIONSURI"
98137
then
99138
CI_TYPE=azure-pipelines
@@ -138,7 +177,7 @@ then
138177
test_name="${test_exit%.exit}"
139178
test_name="${test_name##*/}"
140179
printf "\\e[33m\\e[1m=== Failed test: ${test_name} ===\\e[m\\n"
141-
cat "t/test-results/$test_name.out"
180+
group "Failed test: $test_name" cat "t/test-results/$test_name.out"
142181

143182
trash_dir="t/trash directory.$test_name"
144183
cp "t/test-results/$test_name.out" t/failed-test-artifacts/
@@ -233,3 +272,6 @@ linux-leaks)
233272
esac
234273

235274
MAKEFLAGS="$MAKEFLAGS CC=${CC:-cc}"
275+
276+
end_group
277+
set -x

ci/run-build-and-tests.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,10 @@ pedantic)
4545
;;
4646
esac
4747

48-
make
48+
group Build make
4949
if test -n "$run_tests"
5050
then
51-
make test ||
51+
group "Run tests" make test ||
5252
handle_failed_tests
5353
fi
5454
check_unignored_build_artifacts

ci/run-test-slice.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ windows*) cmd //c mklink //j t\\.prove "$(cygpath -aw "$cache_dir/.prove")";;
1010
*) ln -s "$cache_dir/.prove" t/.prove;;
1111
esac
1212

13-
make --quiet -C t T="$(cd t &&
13+
group "Run tests" make --quiet -C t T="$(cd t &&
1414
./helper/test-tool path-utils slice-tests "$1" "$2" t[0-9]*.sh |
1515
tr '\n' ' ')" ||
1616
handle_failed_tests

0 commit comments

Comments
 (0)