aboutsummaryrefslogtreecommitdiff
path: root/share/aux-repo/aux/ci
diff options
context:
space:
mode:
Diffstat (limited to '')
-rwxr-xr-xshare/aux-repo/aux/ci/ci-build.sh66
-rwxr-xr-xshare/aux-repo/aux/ci/git-post-receive.sh22
-rwxr-xr-xshare/aux-repo/aux/ci/git-pre-push.sh22
-rwxr-xr-xshare/aux-repo/aux/ci/report.sh158
4 files changed, 0 insertions, 268 deletions
diff --git a/share/aux-repo/aux/ci/ci-build.sh b/share/aux-repo/aux/ci/ci-build.sh
deleted file mode 100755
index 8d49779a..00000000
--- a/share/aux-repo/aux/ci/ci-build.sh
+++ /dev/null
@@ -1,66 +0,0 @@
-#!/bin/sh
-set -eux
-
-PROJECT="$1"
-LOGS_DIR="$2"
-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)"
-
- finish() {
- STATUS="$?"
- printf "\n\n>>> exit status was %s\n" "$STATUS"
- echo "Finishing CI job at: $(date -Is)"
- cd -
- NOTE=$(cat <<EOF
-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 -
- git fetch origin refs/notes/*:refs/notes/*
- sh aux/ci/report.sh -n "$PROJECT" -o public
- rsync -av public/ "/opt/www/$TLD/static/$PROJECT/"
-
- tar \
- -C "/opt/www/$TLD/git/repos" \
- -c \
- -f "/opt/www/$TLD/static/$PROJECT/repo.tar.gz" \
- "$PROJECT".git
-
- printf '\n>>>\n>>> CI logs added as Git note.\n>>>\n>>> Run status was %s\n>>>\n\n' \
- "$STATUS"
- }
- trap finish EXIT
-
- unset GIT_DIR
- REMOTE="$PWD"
- cd "$(mkdtemp)"
- git clone "$REMOTE" .
- git config --global user.email git@euandre.org
- git config --global user.name 'EuAndreh CI'
-
- if [ -e aux/with-container ]; then
- RUNNER='sh aux/with-container'
- else
- RUNNER='sh -c'
- fi
-
- $RUNNER 'make clean dev-check'
-} 2>&1 | tee "$LOGFILE"
diff --git a/share/aux-repo/aux/ci/git-post-receive.sh b/share/aux-repo/aux/ci/git-post-receive.sh
deleted file mode 100755
index f8132590..00000000
--- a/share/aux-repo/aux/ci/git-post-receive.sh
+++ /dev/null
@@ -1,22 +0,0 @@
-#!/bin/sh
-set -eu
-
-for n in $(seq 0 $((GIT_PUSH_OPTION_COUNT - 1))); do
- opt="$(eval "echo \$GIT_PUSH_OPTION_$n")"
- if [ "$opt" = skip-ci ] || [ "$opt" = ci-skip ]; then
- printf "\n'%s' option detected, not running ci-build.sh\n\n" \
- "$opt"
- exit 0
- fi
-done
-
-# 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 /opt/www/$TLD/git/repos/$PROJECT.git/"
-echo "sh /opt/www/$TLD/git/ci/$PROJECT/ci-build.sh" "$PROJECT" "$LOGS_DIR" "$SHA"
diff --git a/share/aux-repo/aux/ci/git-pre-push.sh b/share/aux-repo/aux/ci/git-pre-push.sh
deleted file mode 100755
index 98837693..00000000
--- a/share/aux-repo/aux/ci/git-pre-push.sh
+++ /dev/null
@@ -1,22 +0,0 @@
-#!/bin/sh
-set -eux
-
-TLD="$(cat aux/tld.txt)"
-. aux/lib.sh
-
-PROJECT="$(basename "$PWD")"
-LOGS_DIR="/opt/www/$TLD/git/ci/$PROJECT/logs"
-REMOTE_GIT_DIR="/opt/www/$TLD/git/repos/$PROJECT.git"
-
-DESCRIPTION="$(mkstemp)"
-if [ -f description ]
-then
- cp description "$DESCRIPTION"
-else
- git config euandreh.description > "$DESCRIPTION"
-fi
-
-scp "$DESCRIPTION" "$TLD:$REMOTE_GIT_DIR/description"
-ssh "$TLD" mkdir -p "$LOGS_DIR"
-scp aux/ci/ci-build.sh "$TLD:$(dirname "$LOGS_DIR")/ci-build.sh"
-scp aux/ci/git-post-receive.sh "$TLD:$REMOTE_GIT_DIR/hooks/post-receive"
diff --git a/share/aux-repo/aux/ci/report.sh b/share/aux-repo/aux/ci/report.sh
deleted file mode 100755
index 21cc54e3..00000000
--- a/share/aux-repo/aux/ci/report.sh
+++ /dev/null
@@ -1,158 +0,0 @@
-#!/bin/sh
-set -eu
-
-TLD="$(cat aux/tld.txt)"
-. aux/lib.sh
-
-
-usage() {
- cat <<-'EOF'
- Usage:
- aux/ci/report.sh -n NAME -o OUTDIR
- aux/ci/report.sh -h
- EOF
-}
-
-help() {
- cat <<-'EOF'
-
-
- Options:
- -n NAME the lowercase name of the project
- -o OUTDIR directory where to write the files
- -h, --help show this message
-
-
- Generate static HTML files CI report from data stored in git
- notes. The metadata about the CI runs are stored in the ref
- "refs/notes/ci-data", in the format described by
- "aux/ci/run.sh", and the raw logs are stored under the ref
- "refs/notes/ci-logs".
-
-
- Examples:
-
- Generate report for project "myapp" in "public/ci/":
-
- $ sh aux/ci/report.sh -n myapp -o public/ci
- EOF
-}
-
-
-for flag in "$@"; do
- case "$flag" in
- --)
- break
- ;;
- --help)
- usage
- help
- exit
- ;;
- *)
- ;;
- esac
-done
-
-while getopts 'n:o:h' flag; do
- case "$flag" in
- n)
- NAME="$OPTARG"
- ;;
- o)
- OUTDIR="$OPTARG"
- ;;
- h)
- usage
- help
- exit
- ;;
- *)
- usage >&2
- exit 2
- ;;
- esac
-done
-shift $((OPTIND - 1))
-
-
-eval "$(assert_arg "${NAME:-}" '-n NAME')"
-eval "$(assert_arg "${OUTDIR:-}" '-o OUTDIR')"
-
-PASS='✅'
-FAIL='❌'
-
-mkdir -p "$OUTDIR"/logs "$OUTDIR"/data
-
-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/data/$FILENAME"
- git notes --ref=refs/notes/ci-logs show "$c" \
- > "$OUTDIR/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 $NAME" />
- <link rel="icon" type="image/svg+xml" href="favicon.svg" />
- <title>$NAME - CI logs</title>
-
- <style>
- EOF
-
- cat aux/workflow/style.css | sed 's|^| |'
-
- cat <<-EOF
- </style>
-
- <style>
- pre {
- display: inline;
- }
- ol {
- list-style-type: disc;
- }
- </style>
- </head>
- <body>
- <main>
- <h1>
- CI logs for
- <a href="https://$TLD/$NAME/en/">$NAME</a>
- </h1>
- <ol>
- EOF
-
- for f in $(find "$OUTDIR/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
- <li>
- <a href="logs/$FILENAME">$STATUS_MARKER <pre>$FILENAME</pre></a>
- </li>
- EOF
- done
-
- cat <<-EOF
- </ol>
- </main>
- </body>
- </html>
- EOF
-} > "$OUTDIR"/index.html.tmp
-
-mv "$OUTDIR"/index.html.tmp "$OUTDIR"/index.html