xref: /freebsd/sys/contrib/openzfs/.github/workflows/scripts/qemu-9-summary-page.sh (revision b64c5a0ace59af62eff52bfe110a521dc73c937b)
1#!/usr/bin/env bash
2
3######################################################################
4# 9) generate github summary page of all the testings
5######################################################################
6
7set -eu
8
9function output() {
10  echo -e $* >> "out-$logfile.md"
11}
12
13function outfile() {
14  cat "$1" >> "out-$logfile.md"
15}
16
17function outfile_plain() {
18  output "<pre>"
19  cat "$1" >> "out-$logfile.md"
20  output "</pre>"
21}
22
23function send2github() {
24  test -f "$1" || exit 0
25  dd if="$1" bs=1023k count=1 >> $GITHUB_STEP_SUMMARY
26}
27
28# https://docs.github.com/en/enterprise-server@3.6/actions/using-workflows/workflow-commands-for-github-actions#step-isolation-and-limits
29# Job summaries are isolated between steps and each step is restricted to a maximum size of 1MiB.
30# [ ] can not show all error findings here
31# [x] split files into smaller ones and create additional steps
32
33# first call, generate all summaries
34if [ ! -f out-1.md ]; then
35  logfile="1"
36  for tarfile in Logs-functional-*/qemu-*.tar; do
37    rm -rf vm* *.txt
38    if [ ! -s "$tarfile" ]; then
39      output "\n## Functional Tests: unknown\n"
40      output ":exclamation: Tarfile $tarfile is empty :exclamation:"
41      continue
42    fi
43    tar xf "$tarfile"
44    test -s env.txt || continue
45    source env.txt
46    # when uname.txt is there, the other files are also ok
47    test -s uname.txt || continue
48    output "\n## Functional Tests: $OSNAME\n"
49    outfile_plain uname.txt
50    outfile_plain summary.txt
51    outfile failed.txt
52    logfile=$((logfile+1))
53  done
54  send2github out-1.md
55else
56  send2github out-$1.md
57fi
58