aboutsummaryrefslogtreecommitdiff
path: root/aux/ci/report.sh
diff options
context:
space:
mode:
authorEuAndreh <eu@euandre.org>2022-04-13 14:32:04 -0300
committerEuAndreh <eu@euandre.org>2022-04-13 14:32:04 -0300
commit0c214c0cfb1f0e750deec0c411f180c2ab561cec (patch)
treeaff0e3184ffa4ec9c7e94e685045af5eede8cf64 /aux/ci/report.sh
parentTODOs.md: Add #td-dba2ff82-59b3-dd17-06a9-edbc9cffb264 (diff)
downloadeuandre.org-0c214c0cfb1f0e750deec0c411f180c2ab561cec.tar.gz
euandre.org-0c214c0cfb1f0e750deec0c411f180c2ab561cec.tar.xz
aux/ci/: Add
Diffstat (limited to '')
-rwxr-xr-xaux/ci/report.sh109
1 files changed, 109 insertions, 0 deletions
diff --git a/aux/ci/report.sh b/aux/ci/report.sh
new file mode 100755
index 0000000..e900e26
--- /dev/null
+++ b/aux/ci/report.sh
@@ -0,0 +1,109 @@
+#!/bin/sh
+set -eu
+
+TLD="$(cat aux/tld.txt)"
+. aux/lib.sh
+
+while getopts 'n:o:' flag; do
+ case "$flag" in
+ n)
+ PROJECT="$OPTARG"
+ ;;
+ o)
+ OUTDIR="$OPTARG"
+ ;;
+ *)
+ exit 2
+ ;;
+ esac
+done
+shift $((OPTIND - 1))
+
+assert_arg() {
+ if [ -z "$1" ]; then
+ echo "Missing $2" >&2
+ exit 2
+ fi
+}
+
+assert_arg "${PROJECT:-}" '-n PROJECT'
+assert_arg "${OUTDIR:-}" '-o OUTDIR'
+
+PASS='✅'
+FAIL='❌'
+
+mkdir -p "$OUTDIR/ci-logs" "$OUTDIR/ci-data"
+
+OUT="$(mkstemp)"
+chmod 644 "$OUT"
+
+for c in $(git notes list | cut -d\ -f2); do
+ DATA="$(git notes --ref=refs/notes/ci-data show "$c")"
+ FILENAME="$(echo "$DATA" | cut -d\ -f2)"
+ echo "$DATA" > "$OUTDIR/ci-data/$FILENAME"
+ git notes --ref=refs/notes/ci-logs show "$c" \
+ > "$OUTDIR/ci-logs/$FILENAME"
+done
+
+{
+ cat <<EOF
+<!DOCTYPE html>
+<html lang="en">
+ <head>
+ <meta charset="UTF-8" />
+ <meta name="viewport" content="width=device-width, initial-scale=1" />
+ <meta name="description" content="CI logs for $PROJECT" />
+ <link rel="icon" type="image/svg+xml" href="favicon.svg" />
+ <title>$PROJECT - CI logs</title>
+
+EOF
+
+ cat aux/workflow/style.css
+
+ cat <<EOF
+
+ <style>
+ pre {
+ display: inline;
+ }
+ ol {
+ list-style-type: disc;
+ }
+ </style>
+ </head>
+ <body>
+ <main>
+ <h1>
+ CI logs for
+ <a href="https://$TLD/$PROJECT/en/">$PROJECT</a>
+ </h1>
+ <ol>
+EOF
+} > "$OUT"
+
+for f in $(find "$OUTDIR/ci-data/" -type f | LANG=C.UTF-8 sort -r); do
+ DATA="$(cat "$f")"
+ STATUS="$(echo "$DATA" | cut -d\ -f1)"
+ FILENAME="$(echo "$DATA" | cut -d\ -f2)"
+
+ if [ "$STATUS" = 0 ]; then
+ STATUS_MARKER="$PASS"
+ else
+ STATUS_MARKER="$FAIL"
+ fi
+
+ cat <<EOF >> "$OUT"
+ <li>
+ <a href="ci-logs/$FILENAME">$STATUS_MARKER <pre>$FILENAME</pre></a>
+ </li>
+EOF
+done
+
+cat <<EOF >> "$OUT"
+ </ol>
+ </main>
+ </body>
+</html>
+EOF
+
+mv "$OUT" "$OUTDIR/ci.html"