1#!/usr/bin/env bash 2 3# for runtime reasons we split functional testings into N parts 4# - use a define to check for missing tarfiles 5FUNCTIONAL_PARTS="4" 6 7ZTS_REPORT="tests/test-runner/bin/zts-report.py" 8chmod +x $ZTS_REPORT 9 10function output() { 11 echo -e $* >> Summary.md 12} 13 14function error() { 15 output ":bangbang: $* :bangbang:\n" 16} 17 18# this function generates the real summary 19# - expects a logfile "log" in current directory 20function generate() { 21 # we issued some error already 22 test ! -s log && return 23 24 # for overview and zts-report 25 cat log | grep '^Test' > list 26 27 # error details 28 awk '/\[FAIL\]|\[KILLED\]/{ show=1; print; next; } 29 /\[SKIP\]|\[PASS\]/{ show=0; } show' log > err 30 31 # summary of errors 32 if [ -s err ]; then 33 output "<pre>" 34 $ZTS_REPORT --no-maybes ./list >> Summary.md 35 output "</pre>" 36 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:" 46 fi 47 48 output "<details><summary>Full Listing</summary><pre>" 49 cat list >> Summary.md 50 output "</pre></details>" 51 52 # remove tmp files 53 rm -f err list log 54} 55 56# check tarfiles and untar 57function 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" 62 fi 63} 64 65# check logfile and concatenate test results 66function check_logfile() { 67 if [ -f "$1" ]; then 68 cat "$1" >> log 69 else 70 error "Logfile $1 not found" 71 fi 72} 73 74# sanity 75function 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 82} 83 84# functional 85function 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 95} 96 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 101 102ERRLOGS=0 103if [ ! -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 110 111 cat Summary.md >> $GITHUB_STEP_SUMMARY 112 mkdir -p Summary 113 mv *.md Summary 114else 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 117fi 118 119exit 0 120