aboutsummaryrefslogtreecommitdiff
path: root/ci-gen-index.sh
blob: 4de179c47148f7dca394742476e7a0e39745c96b (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#!/usr/bin/env bash
set -Eeuo pipefail
cd "$(dirname "${BASH_SOURCE[0]}")"

printf "Generating index.html of build logs... "
rm -f index.html

cat <<EOF >> index.html
<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport"  content="width=device-width, initial-scale=1" />

    <style>
      pre {
        display: inline;
      }
    </style>
  </head>
  <body>
    <h1>
      Build logs
    </h1>
EOF

PASS='✅'
FAIL='❌'
DUNNO='❔'

for dir in */; do
  d="${dir%/}"
  cat <<EOF >> index.html
    <h2 id="$d">
      <a href="#$d">
        $dir
      </a>
    </h2>
    <ul>
EOF
  for file in "$d"/*; do
    REPORT="$(grep '>>>' "$file" ||:)"
    if [[ -z "$REPORT" ]]; then
      STATUS="$DUNNO"
    elif grep '>>> exit status was 0' <(echo "$REPORT") > /dev/null; then
      STATUS="$PASS"
    else
      STATUS="$FAIL"
    fi
    cat <<EOF >> index.html
      <li>
        <a href="$file">
          $STATUS
          <pre>$file</pre>
        </a>
      </li>
EOF
  done

  cat <<EOF >> index.html
    </ul>
EOF
done

cat <<EOF >> index.html
  </body>
</html>
EOF

echo "done."