ZTS: Move zpool_import_hostid_changed* tests to Linux runfile
[zfs.git] / .github / workflows / scripts / generate-summary.sh
blobcd5ea3421c948317b68fbe40a5360c0505f80e94
1 #!/usr/bin/env bash
3 # for runtime reasons we split functional testings into N parts
4 # - use a define to check for missing tarfiles
5 FUNCTIONAL_PARTS="4"
7 ZTS_REPORT="tests/test-runner/bin/zts-report.py"
8 chmod +x $ZTS_REPORT
10 function output() {
11 echo -e $* >> Summary.md
14 function error() {
15 output ":bangbang: $* :bangbang:\n"
18 # this function generates the real summary
19 # - expects a logfile "log" in current directory
20 function generate() {
21 # we issued some error already
22 test ! -s log && return
24 # for overview and zts-report
25 cat log | grep '^Test' > list
27 # error details
28 awk '/\[FAIL\]|\[KILLED\]/{ show=1; print; next; }
29 /\[SKIP\]|\[PASS\]/{ show=0; } show' log > err
31 # summary of errors
32 if [ -s err ]; then
33 output "<pre>"
34 $ZTS_REPORT --no-maybes ./list >> Summary.md
35 output "</pre>"
37 # generate seperate error logfile
38 ERRLOGS=$((ERRLOGS+1))
39 errfile="err-$ERRLOGS.md"
40 echo -e "\n## $headline (debugging)\n" >> $errfile
41 echo "<details><summary>Error Listing - with dmesg and dbgmsg</summary><pre>" >> $errfile
42 dd if=err bs=999k count=1 >> $errfile
43 echo "</pre></details>" >> $errfile
44 else
45 output "All tests passed :thumbsup:"
48 output "<details><summary>Full Listing</summary><pre>"
49 cat list >> Summary.md
50 output "</pre></details>"
52 # remove tmp files
53 rm -f err list log
56 # check tarfiles and untar
57 function check_tarfile() {
58 if [ -f "$1" ]; then
59 tar xf "$1" || error "Tarfile $1 returns some error"
60 else
61 error "Tarfile $1 not found"
65 # check logfile and concatenate test results
66 function check_logfile() {
67 if [ -f "$1" ]; then
68 cat "$1" >> log
69 else
70 error "Logfile $1 not found"
74 # sanity
75 function summarize_s() {
76 headline="$1"
77 output "\n## $headline\n"
78 rm -rf testfiles
79 check_tarfile "$2/sanity.tar"
80 check_logfile "testfiles/log"
81 generate
84 # functional
85 function summarize_f() {
86 headline="$1"
87 output "\n## $headline\n"
88 rm -rf testfiles
89 for i in $(seq 1 $FUNCTIONAL_PARTS); do
90 tarfile="$2/part$i.tar"
91 check_tarfile "$tarfile"
92 check_logfile "testfiles/log"
93 done
94 generate
97 # https://docs.github.com/en/enterprise-server@3.6/actions/using-workflows/workflow-commands-for-github-actions#step-isolation-and-limits
98 # Job summaries are isolated between steps and each step is restricted to a maximum size of 1MiB.
99 # [ ] can not show all error findings here
100 # [x] split files into smaller ones and create additional steps
102 ERRLOGS=0
103 if [ ! -f Summary/Summary.md ]; then
104 # first call, we do the default summary (~500k)
105 echo -n > Summary.md
106 summarize_s "Sanity Tests Ubuntu 20.04" Logs-20.04-sanity
107 summarize_s "Sanity Tests Ubuntu 22.04" Logs-22.04-sanity
108 summarize_f "Functional Tests Ubuntu 20.04" Logs-20.04-functional
109 summarize_f "Functional Tests Ubuntu 22.04" Logs-22.04-functional
111 cat Summary.md >> $GITHUB_STEP_SUMMARY
112 mkdir -p Summary
113 mv *.md Summary
114 else
115 # here we get, when errors where returned in first call
116 test -f Summary/err-$1.md && cat Summary/err-$1.md >> $GITHUB_STEP_SUMMARY
119 exit 0