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 https://github.com/actions/runner/issues/802 for details), therefore we take pains to ensure to end any previous group before starting a new one. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Johannes Schindelin committed
May 21, 2022 at 22:18 UTC
dab73aebd85acf6441769370f380f50619c3ebae
3 files changed
+52
-10
ci/lib.sh
+49
-7
@@ -1,5 +1,50 @@
1
# Library of functions shared by all CI scripts
2
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
+
48
skip_branch_tip_with_tag () {
49
# Sometimes, a branch is pushed at the same time the tag that points
50
# at the same commit as the tip of the branch is pushed, and building
@@ -88,12 +133,6 @@ export TERM=${TERM:-dumb}
133
# Clear MAKEFLAGS that may come from the outside world.
134
export MAKEFLAGS=
135
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
-
136
if test -n "$SYSTEM_COLLECTIONURI" || test -n "$SYSTEM_TASKDEFINITIONSURI"
137
then
138
CI_TYPE=azure-pipelines
@@ -138,7 +177,7 @@ then
177
test_name="${test_exit%.exit}"
178
test_name="${test_name##*/}"
179
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"
181
182
trash_dir="t/trash directory.$test_name"
183
cp "t/test-results/$test_name.out" t/failed-test-artifacts/
@@ -233,3 +272,6 @@ linux-leaks)
272
esac
273
274
MAKEFLAGS="$MAKEFLAGS CC=${CC:-cc}"
275
+
276
+end_group
277
+set -x
ci/run-build-and-tests.sh
+2
-2
@@ -45,10 +45,10 @@ pedantic)
45
;;
46
esac
47
48
-make
48
+group Build make
49
if test -n "$run_tests"
50
then
51
- make test ||
51
+ group "Run tests" make test ||
52
handle_failed_tests
53
fi
54
check_unignored_build_artifacts
ci/run-test-slice.sh
+1
-1
@@ -10,7 +10,7 @@ windows*) cmd //c mklink //j t\\.prove "$(cygpath -aw "$cache_dir/.prove")";;
10
*) ln -s "$cache_dir/.prove" t/.prove;;
11
esac
12
13
-make --quiet -C t T="$(cd t &&
13
+group "Run tests" make --quiet -C t T="$(cd t &&
14
./helper/test-tool path-utils slice-tests "$1" "$2" t[0-9]*.sh |
15
tr '\n' ' ')" ||
16
handle_failed_tests