Skip to content

Commit 59860bc

Browse files
gha: Print all *.log files, in a separate action
Before this commit, we didn't print *_example.log files and test_suite.log. Printing is now handled in a separate action, which avoids code duplication and makes the ci.yml file more readable. This changes the folding/grouping of the log output in the GitHub Actions CI, but I think the new variant is as good as the old one. Furthermore, the condition for printing the logs is changed from "always()" to "!cancelled()". This ensures that logs will still be printed if previous steps such as the CI script failed, but that they won't be printed if the entire run is cancelled (e.g., by clicking a button in the UI or through a force-push to the PR). This is in line with a recommendation in the GHA docs: https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/evaluate-expressions-in-workflows-and-actions#always
1 parent 961ec25 commit 59860bc

File tree

2 files changed

+77
-221
lines changed

2 files changed

+77
-221
lines changed

.github/actions/print-logs/action.yml

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
name: "Print logs"
2+
description: "Print the log files produced by ci/ci.sh"
3+
runs:
4+
using: "composite"
5+
steps:
6+
- shell: bash
7+
run: |
8+
# Print the log files produced by ci/ci.sh
9+
10+
# Helper functions
11+
group() {
12+
title=$1
13+
echo "::group::$title"
14+
}
15+
endgroup() {
16+
echo "::endgroup::"
17+
}
18+
cat_file() {
19+
file=$1
20+
group "$file"
21+
cat "$file"
22+
endgroup
23+
}
24+
25+
# Print all *.log files
26+
shopt -s nullglob
27+
for file in *.log; do
28+
cat_file "$file"
29+
done
30+
31+
# Print environment
32+
group "CI env"
33+
env
34+
endgroup

.github/workflows/ci.yml

+43-221
Original file line numberDiff line numberDiff line change
@@ -107,23 +107,9 @@ jobs:
107107
dockerfile: ./ci/linux-debian.Dockerfile
108108
tag: linux-debian-image
109109

110-
- run: cat tests.log || true
111-
if: ${{ always() }}
112-
- run: cat noverify_tests.log || true
113-
if: ${{ always() }}
114-
- run: cat exhaustive_tests.log || true
115-
if: ${{ always() }}
116-
- run: cat ctime_tests.log || true
117-
if: ${{ always() }}
118-
- run: cat bench.log || true
119-
if: ${{ always() }}
120-
- run: cat config.log || true
121-
if: ${{ always() }}
122-
- run: cat test_env.log || true
123-
if: ${{ always() }}
124-
- name: CI env
125-
run: env
126-
if: ${{ always() }}
110+
- name: Print logs
111+
uses: ./.github/actions/print-logs
112+
if: ${{ !cancelled() }}
127113

128114
i686_debian:
129115
name: "i686: Linux (Debian stable)"
@@ -157,23 +143,9 @@ jobs:
157143
dockerfile: ./ci/linux-debian.Dockerfile
158144
tag: linux-debian-image
159145

160-
- run: cat tests.log || true
161-
if: ${{ always() }}
162-
- run: cat noverify_tests.log || true
163-
if: ${{ always() }}
164-
- run: cat exhaustive_tests.log || true
165-
if: ${{ always() }}
166-
- run: cat ctime_tests.log || true
167-
if: ${{ always() }}
168-
- run: cat bench.log || true
169-
if: ${{ always() }}
170-
- run: cat config.log || true
171-
if: ${{ always() }}
172-
- run: cat test_env.log || true
173-
if: ${{ always() }}
174-
- name: CI env
175-
run: env
176-
if: ${{ always() }}
146+
- name: Print logs
147+
uses: ./.github/actions/print-logs
148+
if: ${{ !cancelled() }}
177149

178150
s390x_debian:
179151
name: "s390x (big-endian): Linux (Debian stable, QEMU)"
@@ -203,23 +175,10 @@ jobs:
203175
dockerfile: ./ci/linux-debian.Dockerfile
204176
tag: linux-debian-image
205177

206-
- run: cat tests.log || true
207-
if: ${{ always() }}
208-
- run: cat noverify_tests.log || true
209-
if: ${{ always() }}
210-
- run: cat exhaustive_tests.log || true
211-
if: ${{ always() }}
212-
- run: cat ctime_tests.log || true
213-
if: ${{ always() }}
214-
- run: cat bench.log || true
215-
if: ${{ always() }}
216-
- run: cat config.log || true
217-
if: ${{ always() }}
218-
- run: cat test_env.log || true
219-
if: ${{ always() }}
220-
- name: CI env
221-
run: env
222-
if: ${{ always() }}
178+
- name: Print logs
179+
uses: ./.github/actions/print-logs
180+
if: ${{ !cancelled() }}
181+
223182

224183
arm32_debian:
225184
name: "ARM32: Linux (Debian stable, QEMU)"
@@ -257,23 +216,9 @@ jobs:
257216
dockerfile: ./ci/linux-debian.Dockerfile
258217
tag: linux-debian-image
259218

260-
- run: cat tests.log || true
261-
if: ${{ always() }}
262-
- run: cat noverify_tests.log || true
263-
if: ${{ always() }}
264-
- run: cat exhaustive_tests.log || true
265-
if: ${{ always() }}
266-
- run: cat ctime_tests.log || true
267-
if: ${{ always() }}
268-
- run: cat bench.log || true
269-
if: ${{ always() }}
270-
- run: cat config.log || true
271-
if: ${{ always() }}
272-
- run: cat test_env.log || true
273-
if: ${{ always() }}
274-
- name: CI env
275-
run: env
276-
if: ${{ always() }}
219+
- name: Print logs
220+
uses: ./.github/actions/print-logs
221+
if: ${{ !cancelled() }}
277222

278223
arm64_debian:
279224
name: "ARM64: Linux (Debian stable, QEMU)"
@@ -314,23 +259,9 @@ jobs:
314259
dockerfile: ./ci/linux-debian.Dockerfile
315260
tag: linux-debian-image
316261

317-
- run: cat tests.log || true
318-
if: ${{ always() }}
319-
- run: cat noverify_tests.log || true
320-
if: ${{ always() }}
321-
- run: cat exhaustive_tests.log || true
322-
if: ${{ always() }}
323-
- run: cat ctime_tests.log || true
324-
if: ${{ always() }}
325-
- run: cat bench.log || true
326-
if: ${{ always() }}
327-
- run: cat config.log || true
328-
if: ${{ always() }}
329-
- run: cat test_env.log || true
330-
if: ${{ always() }}
331-
- name: CI env
332-
run: env
333-
if: ${{ always() }}
262+
- name: Print logs
263+
uses: ./.github/actions/print-logs
264+
if: ${{ !cancelled() }}
334265

335266
ppc64le_debian:
336267
name: "ppc64le: Linux (Debian stable, QEMU)"
@@ -360,23 +291,10 @@ jobs:
360291
dockerfile: ./ci/linux-debian.Dockerfile
361292
tag: linux-debian-image
362293

363-
- run: cat tests.log || true
364-
if: ${{ always() }}
365-
- run: cat noverify_tests.log || true
366-
if: ${{ always() }}
367-
- run: cat exhaustive_tests.log || true
368-
if: ${{ always() }}
369-
- run: cat ctime_tests.log || true
370-
if: ${{ always() }}
371-
- run: cat bench.log || true
372-
if: ${{ always() }}
373-
- run: cat config.log || true
374-
if: ${{ always() }}
375-
- run: cat test_env.log || true
376-
if: ${{ always() }}
377-
- name: CI env
378-
run: env
379-
if: ${{ always() }}
294+
- name: Print logs
295+
uses: ./.github/actions/print-logs
296+
if: ${{ !cancelled() }}
297+
380298

381299
valgrind_debian:
382300
name: "Valgrind (memcheck)"
@@ -416,23 +334,9 @@ jobs:
416334
dockerfile: ./ci/linux-debian.Dockerfile
417335
tag: linux-debian-image
418336

419-
- run: cat tests.log || true
420-
if: ${{ always() }}
421-
- run: cat noverify_tests.log || true
422-
if: ${{ always() }}
423-
- run: cat exhaustive_tests.log || true
424-
if: ${{ always() }}
425-
- run: cat ctime_tests.log || true
426-
if: ${{ always() }}
427-
- run: cat bench.log || true
428-
if: ${{ always() }}
429-
- run: cat config.log || true
430-
if: ${{ always() }}
431-
- run: cat test_env.log || true
432-
if: ${{ always() }}
433-
- name: CI env
434-
run: env
435-
if: ${{ always() }}
337+
- name: Print logs
338+
uses: ./.github/actions/print-logs
339+
if: ${{ !cancelled() }}
436340

437341
sanitizers_debian:
438342
name: "UBSan, ASan, LSan"
@@ -473,23 +377,9 @@ jobs:
473377
dockerfile: ./ci/linux-debian.Dockerfile
474378
tag: linux-debian-image
475379

476-
- run: cat tests.log || true
477-
if: ${{ always() }}
478-
- run: cat noverify_tests.log || true
479-
if: ${{ always() }}
480-
- run: cat exhaustive_tests.log || true
481-
if: ${{ always() }}
482-
- run: cat ctime_tests.log || true
483-
if: ${{ always() }}
484-
- run: cat bench.log || true
485-
if: ${{ always() }}
486-
- run: cat config.log || true
487-
if: ${{ always() }}
488-
- run: cat test_env.log || true
489-
if: ${{ always() }}
490-
- name: CI env
491-
run: env
492-
if: ${{ always() }}
380+
- name: Print logs
381+
uses: ./.github/actions/print-logs
382+
if: ${{ !cancelled() }}
493383

494384
msan_debian:
495385
name: "MSan"
@@ -537,23 +427,10 @@ jobs:
537427
dockerfile: ./ci/linux-debian.Dockerfile
538428
tag: linux-debian-image
539429

540-
- run: cat tests.log || true
541-
if: ${{ always() }}
542-
- run: cat noverify_tests.log || true
543-
if: ${{ always() }}
544-
- run: cat exhaustive_tests.log || true
545-
if: ${{ always() }}
546-
- run: cat ctime_tests.log || true
547-
if: ${{ always() }}
548-
- run: cat bench.log || true
549-
if: ${{ always() }}
550-
- run: cat config.log || true
551-
if: ${{ always() }}
552-
- run: cat test_env.log || true
553-
if: ${{ always() }}
554-
- name: CI env
555-
run: env
556-
if: ${{ always() }}
430+
- name: Print logs
431+
uses: ./.github/actions/print-logs
432+
if: ${{ !cancelled() }}
433+
557434

558435
mingw_debian:
559436
name: ${{ matrix.configuration.job_name }}
@@ -593,23 +470,9 @@ jobs:
593470
dockerfile: ./ci/linux-debian.Dockerfile
594471
tag: linux-debian-image
595472

596-
- run: cat tests.log || true
597-
if: ${{ always() }}
598-
- run: cat noverify_tests.log || true
599-
if: ${{ always() }}
600-
- run: cat exhaustive_tests.log || true
601-
if: ${{ always() }}
602-
- run: cat ctime_tests.log || true
603-
if: ${{ always() }}
604-
- run: cat bench.log || true
605-
if: ${{ always() }}
606-
- run: cat config.log || true
607-
if: ${{ always() }}
608-
- run: cat test_env.log || true
609-
if: ${{ always() }}
610-
- name: CI env
611-
run: env
612-
if: ${{ always() }}
473+
- name: Print logs
474+
uses: ./.github/actions/print-logs
475+
if: ${{ !cancelled() }}
613476

614477
x86_64-macos-native:
615478
name: "x86_64: macOS Ventura, Valgrind"
@@ -652,23 +515,9 @@ jobs:
652515
env: ${{ matrix.env_vars }}
653516
run: ./ci/ci.sh
654517

655-
- run: cat tests.log || true
656-
if: ${{ always() }}
657-
- run: cat noverify_tests.log || true
658-
if: ${{ always() }}
659-
- run: cat exhaustive_tests.log || true
660-
if: ${{ always() }}
661-
- run: cat ctime_tests.log || true
662-
if: ${{ always() }}
663-
- run: cat bench.log || true
664-
if: ${{ always() }}
665-
- run: cat config.log || true
666-
if: ${{ always() }}
667-
- run: cat test_env.log || true
668-
if: ${{ always() }}
669-
- name: CI env
670-
run: env
671-
if: ${{ always() }}
518+
- name: Print logs
519+
uses: ./.github/actions/print-logs
520+
if: ${{ !cancelled() }}
672521

673522
arm64-macos-native:
674523
name: "ARM64: macOS Sonoma"
@@ -708,23 +557,10 @@ jobs:
708557
env: ${{ matrix.env_vars }}
709558
run: ./ci/ci.sh
710559

711-
- run: cat tests.log || true
712-
if: ${{ always() }}
713-
- run: cat noverify_tests.log || true
714-
if: ${{ always() }}
715-
- run: cat exhaustive_tests.log || true
716-
if: ${{ always() }}
717-
- run: cat ctime_tests.log || true
718-
if: ${{ always() }}
719-
- run: cat bench.log || true
720-
if: ${{ always() }}
721-
- run: cat config.log || true
722-
if: ${{ always() }}
723-
- run: cat test_env.log || true
724-
if: ${{ always() }}
725-
- name: CI env
726-
run: env
727-
if: ${{ always() }}
560+
- name: Print logs
561+
uses: ./.github/actions/print-logs
562+
if: ${{ !cancelled() }}
563+
728564

729565
win64-native:
730566
name: ${{ matrix.configuration.job_name }}
@@ -813,23 +649,9 @@ jobs:
813649
dockerfile: ./ci/linux-debian.Dockerfile
814650
tag: linux-debian-image
815651

816-
- run: cat tests.log || true
817-
if: ${{ always() }}
818-
- run: cat noverify_tests.log || true
819-
if: ${{ always() }}
820-
- run: cat exhaustive_tests.log || true
821-
if: ${{ always() }}
822-
- run: cat ctime_tests.log || true
823-
if: ${{ always() }}
824-
- run: cat bench.log || true
825-
if: ${{ always() }}
826-
- run: cat config.log || true
827-
if: ${{ always() }}
828-
- run: cat test_env.log || true
829-
if: ${{ always() }}
830-
- name: CI env
831-
run: env
832-
if: ${{ always() }}
652+
- name: Print logs
653+
uses: ./.github/actions/print-logs
654+
if: ${{ !cancelled() }}
833655

834656
cxx_headers_debian:
835657
name: "C++ (public headers)"

0 commit comments

Comments
 (0)