aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEuAndreh <eu@euandre.org>2021-02-19 17:27:42 -0300
committerEuAndreh <eu@euandre.org>2021-02-19 17:27:42 -0300
commita5d36570344337568595d9cf3bedc08576b8f5f1 (patch)
tree516b57136f9ebf3f68899ea76ea7b13328626c3f
parent9ebe31929152f7fe1e29e78a2696ca7affd95dc4 (diff)
downloadboneco-a5d36570344337568595d9cf3bedc08576b8f5f1.tar.gz
Add aux/ci/report.sh
Notes
Notes: See CI logs with: git notes --ref=refs/notes/ci-logs show a5d36570344337568595d9cf3bedc08576b8f5f1 git notes --ref=refs/notes/ci-data show a5d36570344337568595d9cf3bedc08576b8f5f1
-rwxr-xr-xaux/assert-shellcheck.sh6
-rwxr-xr-xaux/ci/ci-build.sh22
-rwxr-xr-xaux/ci/report.sh69
3 files changed, 90 insertions, 7 deletions
diff --git a/aux/assert-shellcheck.sh b/aux/assert-shellcheck.sh
new file mode 100755
index 0000000..334a875
--- /dev/null
+++ b/aux/assert-shellcheck.sh
@@ -0,0 +1,6 @@
+#!/bin/sh
+set -eux
+
+git ls-files -z | \
+ xargs -0 awk 'FNR==1 && /^#!\/bin\/sh$/ { print FILENAME }' | \
+ xargs shellcheck
diff --git a/aux/ci/ci-build.sh b/aux/ci/ci-build.sh
index bff1216..1159204 100755
--- a/aux/ci/ci-build.sh
+++ b/aux/ci/ci-build.sh
@@ -20,20 +20,28 @@ See CI logs with:
git notes --ref=refs/notes/ci-logs show $SHA
git notes --ref=refs/notes/ci-data show $SHA
EOF
- )
+)
git notes --ref=refs/notes/ci-data add -f -m "$STATUS $FILENAME"
git notes --ref=refs/notes/ci-logs add -f -F "$LOGFILE"
git notes append -m "$NOTE"
+
+ cd -
+ if [ -f ./aux/ci/report.sh ]; then
+ sh aux/ci/report.sh "$PACKAGE"
+ rsync -avzzP public/ "/srv/http/$PACKAGE/" --delete
+ fi
+
printf "\n>>>\n>>> CI logs added as Git note.\n>>>\n>>> Run status was %s" "$STATUS"
}
trap finish EXIT
unset GIT_DIR
- CLONE="$(mktemp -d)"
- git clone . "$CLONE"
- cd "$CLONE"
+ REMOTE="$PWD"
+ cd "$(mktemp -d)"
+ git clone "$REMOTE" .
git config --global user.email git@euandre.org
git config --global user.name 'EuAndreh CI'
+ git fetch origin refs/notes/*:refs/notes/*
if [ -f aux/guix/with-container.sh ]; then
RUNNER='./aux/guix/with-container.sh'
@@ -41,10 +49,10 @@ EOF
RUNNER='sh -c'
fi
- if [ -f ./bootstrap ]; then
- COMMAND='./bootstrap && ./configure && make clean all check distcheck public'
+ if [ -f ./configure ]; then
+ COMMAND='./configure && make CC=cc clean check public'
else
- COMMAND='make clean check public'
+ COMMAND='make CC=cc clean check public'
fi
$RUNNER "$COMMAND"
diff --git a/aux/ci/report.sh b/aux/ci/report.sh
new file mode 100755
index 0000000..b82c061
--- /dev/null
+++ b/aux/ci/report.sh
@@ -0,0 +1,69 @@
+#!/bin/sh
+set -eu
+
+PROJECT_UC="$1"
+
+PASS='✅'
+FAIL='❌'
+
+mkdir -p public/ci-logs public/ci-data
+
+OUT="$(mktemp)"
+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"
+done
+
+cat <<EOF >> "$OUT"
+<!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>
+ CI logs for $PROJECT_UC
+ </h1>
+ <ul>
+EOF
+
+for f in $(find public/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"
+ </ul>
+ </body>
+</html>
+EOF
+
+mv "$OUT" public/ci.html