aboutsummaryrefslogtreecommitdiff
path: root/aux/ci/report.sh
diff options
context:
space:
mode:
authorEuAndreh <eu@euandre.org>2021-07-27 12:51:36 -0300
committerEuAndreh <eu@euandre.org>2021-07-27 12:51:36 -0300
commit3bceeb4da5ec953309bbc3e61d04f078198966d2 (patch)
treec30ba0fd9485a88f45bdd91d3784630f9e9fa950 /aux/ci/report.sh
parentTODOs.md: Dump links on Scratch (diff)
downloadgistatic-3bceeb4da5ec953309bbc3e61d04f078198966d2.tar.gz
gistatic-3bceeb4da5ec953309bbc3e61d04f078198966d2.tar.xz
aux/: Update, adjust Makefile
Diffstat (limited to 'aux/ci/report.sh')
-rwxr-xr-xaux/ci/report.sh52
1 files changed, 41 insertions, 11 deletions
diff --git a/aux/ci/report.sh b/aux/ci/report.sh
index 65d3335..7fa3d08 100755
--- a/aux/ci/report.sh
+++ b/aux/ci/report.sh
@@ -1,23 +1,48 @@
#!/bin/sh
set -eu
-PROJECT_UC="$1"
+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 public/ci-logs public/ci-data
+mkdir -p "$OUTDIR/ci-logs" "$OUTDIR/ci-data"
-OUT="$(mktemp)"
+OUT="$(mkstemp)"
chmod 644 "$OUT"
-git fetch origin refs/notes/*:refs/notes/* ||:
-
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" > "public/ci-data/$FILENAME"
- git notes --ref=refs/notes/ci-logs show "$c" > "public/ci-logs/$FILENAME"
+ echo "$DATA" > "$OUTDIR/ci-data/$FILENAME"
+ git notes --ref=refs/notes/ci-logs show "$c" \
+ > "$OUTDIR/ci-logs/$FILENAME"
done
cat <<EOF >> "$OUT"
@@ -25,8 +50,10 @@ cat <<EOF >> "$OUT"
<html lang="en">
<head>
<meta charset="UTF-8" />
- <meta name="viewport" content="width=device-width, initial-scale=1" />
+ <meta name="viewport"
+ content="width=device-width, initial-scale=1" />
<link rel="icon" type="image/svg+xml" href="favicon.svg" />
+ <title>CI logs for $PROJECT</title>
<style>
pre {
@@ -36,12 +63,15 @@ cat <<EOF >> "$OUT"
</head>
<body>
<h1>
- CI logs for $PROJECT_UC
+ CI logs for
+ <a href="https://$TLD/$PROJECT/en/">
+ $PROJECT
+ </a>
</h1>
<ul>
EOF
-for f in $(find public/ci-data/ -type f | LANG=C.UTF-8 sort -r); do
+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)"
@@ -67,4 +97,4 @@ cat <<EOF >> "$OUT"
</html>
EOF
-mv "$OUT" public/ci.html
+mv "$OUT" "$OUTDIR/ci.html"