From 7400e108286a0fceacdac63b125fdc924c2dd50c Mon Sep 17 00:00:00 2001 From: EuAndreh Date: Sun, 25 Jul 2021 15:16:31 -0300 Subject: aux/: Update --- aux/assert-shellcheck.sh | 2 +- aux/ci/ci-build.sh | 23 +++++++---- aux/ci/git-post-receive.sh | 13 +++++-- aux/ci/git-pre-push.sh | 9 +++-- aux/ci/report.sh | 45 +++++++++++++++++----- aux/guix/with-container.sh | 2 +- aux/lib.sh | 30 +++++++++++++++ aux/workflow/TODOs.sh | 72 +++++++++++++++++++++++++--------- aux/workflow/assert-changelog.sh | 57 +++++++++++++++++++++++++-- aux/workflow/assert-readme.sh | 70 ++++++++++++++++++++++++++------- aux/workflow/assert-todos.sh | 4 +- aux/workflow/commonmark.sh | 50 +++++++++++++++++------- aux/workflow/dist.sh | 63 +++++++++++++++++++++++++++--- aux/workflow/preamble.md | 6 +-- aux/workflow/public.sh | 60 ++++++++++++++++++++++++----- aux/workflow/sign-tarballs.sh | 28 ++++++++++++-- aux/workflow/style.css | 83 +++++++++++++++++++--------------------- 17 files changed, 471 insertions(+), 146 deletions(-) create mode 100755 aux/lib.sh (limited to 'aux') diff --git a/aux/assert-shellcheck.sh b/aux/assert-shellcheck.sh index cc01f3a..1779ea8 100755 --- a/aux/assert-shellcheck.sh +++ b/aux/assert-shellcheck.sh @@ -1,5 +1,5 @@ #!/bin/sh -set -eux +set -eu git ls-files | \ xargs awk 'FNR==1 && /^#!\/bin\/sh$/ { print FILENAME }' | \ diff --git a/aux/ci/ci-build.sh b/aux/ci/ci-build.sh index b6769a9..17e9e37 100755 --- a/aux/ci/ci-build.sh +++ b/aux/ci/ci-build.sh @@ -1,12 +1,19 @@ #!/bin/sh set -eux -PACKAGE="$1" +PROJECT="$1" LOGS_DIR="$2" -read -r _ SHA _ # oldrev newrev refname +SHA="$3" FILENAME="$(date -Is)-$SHA.log" LOGFILE="$LOGS_DIR/$FILENAME" +mkdtemp() { + name="$(echo 'mkstemp(template)' | m4 -D template="${TMPDIR:-/tmp}/m4-tmpname.")" + rm -f "$name" + mkdir "$name" + echo "$name" +} + { echo "Starting CI job at: $(date -Is)" @@ -26,24 +33,24 @@ EOF git notes append -m "$NOTE" cd - - sh aux/ci/report.sh "$PACKAGE" - rsync -a public/ "/srv/http/$PACKAGE/" --delete + git fetch origin refs/notes/*:refs/notes/* + sh aux/ci/report.sh -n "$PROJECT" -o public + rsync -av public/ "/srv/http/$PROJECT/" --delete - printf "\n>>>\n>>> CI logs added as Git note.\n>>>\n>>> Run status was %s" "$STATUS" + printf "\n>>>\n>>> CI logs added as Git note.\n>>>\n>>> Run status was %s\n\n" "$STATUS" } trap finish EXIT unset GIT_DIR REMOTE="$PWD" - cd "$(mktemp -d)" + cd "$(mkdtemp)" 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/* git annex get ||: if [ -f aux/guix/with-container.sh ]; then - RUNNER='./aux/guix/with-container.sh' + RUNNER='sh aux/guix/with-container.sh' else RUNNER='sh -c' fi diff --git a/aux/ci/git-post-receive.sh b/aux/ci/git-post-receive.sh index ee8075f..426bff3 100755 --- a/aux/ci/git-post-receive.sh +++ b/aux/ci/git-post-receive.sh @@ -9,6 +9,13 @@ for n in $(seq 0 $((GIT_PUSH_OPTION_COUNT - 1))); do fi done -PACKAGE="$(basename "$PWD" | cut -d. -f1)" # remove .git suffix -LOGS_DIR="/opt/ci/$PACKAGE/logs" -"/opt/ci/$PACKAGE/ci-build.sh" "$PACKAGE" "$LOGS_DIR" +# shellcheck disable=2034 +read -r _oldrev SHA _refname + +PROJECT="$(basename "$PWD" | cut -d. -f1)" # remove .git suffix +LOGS_DIR="/opt/ci/$PROJECT/logs" +sh "/opt/ci/$PROJECT/ci-build.sh" "$PROJECT" "$LOGS_DIR" "$SHA" ||: + +echo 'To retrigger the build, run:' +echo "cd /srv/http/$PROJECT.git/" +echo "sh /opt/ci/$PROJECT/ci-build.sh" "$PROJECT" "$LOGS_DIR" "$SHA" diff --git a/aux/ci/git-pre-push.sh b/aux/ci/git-pre-push.sh index e73b9b8..eaaa7bd 100755 --- a/aux/ci/git-pre-push.sh +++ b/aux/ci/git-pre-push.sh @@ -2,12 +2,13 @@ set -eux TLD="$(cat aux/tld.txt)" +. aux/lib.sh -PACKAGE="$(basename "$PWD")" -LOGS_DIR="/opt/ci/$PACKAGE/logs" -REMOTE_GIT_DIR="/srv/git/$PACKAGE.git" +PROJECT="$(basename "$PWD")" +LOGS_DIR="/opt/ci/$PROJECT/logs" +REMOTE_GIT_DIR="/srv/http/$PROJECT.git" -DESCRIPTION="$(mktemp)" +DESCRIPTION="$(mkstemp)" if [ -f description ] then cp description "$DESCRIPTION" diff --git a/aux/ci/report.sh b/aux/ci/report.sh index 65d3335..1aa41a0 100755 --- a/aux/ci/report.sh +++ b/aux/ci/report.sh @@ -1,23 +1,47 @@ #!/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 <> "$OUT" @@ -27,6 +51,7 @@ cat <> "$OUT" + CI logs for $PROJECT -- cgit v1.2.3