diff options
-rwxr-xr-x | aux/assert-terraform.sh | 8 | ||||
-rwxr-xr-x | aux/ci/ci-build.sh | 14 | ||||
-rwxr-xr-x | aux/ci/report.sh | 10 | ||||
-rw-r--r-- | aux/containers/guix/manifest.scm | 24 | ||||
-rwxr-xr-x | aux/containers/guix/with-container.sh | 19 | ||||
-rw-r--r-- | aux/guix/manifest.scm | 17 | ||||
-rw-r--r-- | aux/guix/pinned-channels.scm | 11 | ||||
-rwxr-xr-x | aux/guix/with-container.sh | 17 | ||||
-rwxr-xr-x | aux/lib.sh | 4 | ||||
l--------- | aux/with-container | 1 | ||||
-rwxr-xr-x | aux/workflow/TODOs.sh | 13 | ||||
-rwxr-xr-x | aux/workflow/assert-changelog.sh | 2 | ||||
-rwxr-xr-x | aux/workflow/assert-readme.sh | 6 | ||||
-rwxr-xr-x | aux/workflow/assert-todos.sh | 61 | ||||
-rwxr-xr-x | aux/workflow/commonmark.sh | 10 | ||||
-rwxr-xr-x | aux/workflow/dist.sh | 15 | ||||
-rw-r--r-- | aux/workflow/preamble.md | 2 | ||||
-rwxr-xr-x | aux/workflow/public.sh | 28 | ||||
-rw-r--r-- | aux/workflow/style.css | 115 |
19 files changed, 203 insertions, 174 deletions
diff --git a/aux/assert-terraform.sh b/aux/assert-terraform.sh deleted file mode 100755 index 5e2d8ab..0000000 --- a/aux/assert-terraform.sh +++ /dev/null @@ -1,8 +0,0 @@ -#!/bin/sh -set -eux - -terraform fmt -check=true -diff=true || { - echo "Terraform files are unformatted. To fix it, run:" - echo " terraform fmt" - exit 1 -} diff --git a/aux/ci/ci-build.sh b/aux/ci/ci-build.sh index 2ec0102..8d18252 100755 --- a/aux/ci/ci-build.sh +++ b/aux/ci/ci-build.sh @@ -36,12 +36,10 @@ EOF cd - git fetch origin refs/notes/*:refs/notes/* sh aux/ci/report.sh -n "$PROJECT" -o public - rsync -av public/ "/srv/http/$PROJECT/" --delete + rsync -av public/ "/srv/http/$PROJECT/" - if [ -f aux/guix/with-container.sh ]; then - cp "$(sh aux/guix/with-container.sh -C)" \ - "/srv/http/$PROJECT/docker.tar.gz" - fi + tar -C /srv/http -cf /srv/http/"$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" @@ -55,11 +53,11 @@ EOF git config --global user.email git@euandre.org git config --global user.name 'EuAndreh CI' - if [ -f aux/guix/with-container.sh ]; then - RUNNER='sh aux/guix/with-container.sh' + if [ -e aux/with-container ]; then + RUNNER='sh aux/with-container' else RUNNER='sh -c' fi - $RUNNER 'make clean public dev-check' + $RUNNER 'make clean dev-check' } 2>&1 | tee "$LOGFILE" diff --git a/aux/ci/report.sh b/aux/ci/report.sh index 6f18f0f..e900e26 100755 --- a/aux/ci/report.sh +++ b/aux/ci/report.sh @@ -45,7 +45,8 @@ for c in $(git notes list | cut -d\ -f2); do > "$OUTDIR/ci-logs/$FILENAME" done -cat <<EOF >> "$OUT" +{ + cat <<EOF <!DOCTYPE html> <html lang="en"> <head> @@ -55,6 +56,12 @@ cat <<EOF >> "$OUT" <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; @@ -72,6 +79,7 @@ cat <<EOF >> "$OUT" </h1> <ol> EOF +} > "$OUT" for f in $(find "$OUTDIR/ci-data/" -type f | LANG=C.UTF-8 sort -r); do DATA="$(cat "$f")" diff --git a/aux/containers/guix/manifest.scm b/aux/containers/guix/manifest.scm new file mode 100644 index 0000000..1870255 --- /dev/null +++ b/aux/containers/guix/manifest.scm @@ -0,0 +1,24 @@ +(specifications->manifest + (map symbol->string + '(bash + coreutils + findutils + diffutils + grep + sed + git + tar + gawk + make + makefile2graph + graphviz + shellcheck + pandoc + gettext + po4a-text + mdpo-patched + hunspell + hunspell-dict-en-utf8 + hunspell-dict-pt-utf8 + hunspell-dict-fr-utf8 + hunspell-dict-eo-utf8))) diff --git a/aux/containers/guix/with-container.sh b/aux/containers/guix/with-container.sh new file mode 100755 index 0000000..fcbb8b5 --- /dev/null +++ b/aux/containers/guix/with-container.sh @@ -0,0 +1,19 @@ +#!/bin/sh +set -eu + +CHANNEL_REMOTE='https://euandreh.xyz/package-repository.git' +CHANNEL_DIR="${XDG_CACHE_HOME:-$HOME/.cache}/euandreh-guix-channel" + +if [ ! -d "$CHANNEL_DIR" ]; then + git clone "$CHANNEL_REMOTE" "$CHANNEL_DIR" +fi + +git -C "$CHANNEL_DIR" pull + +ENV_CMD="guix environment -L $CHANNEL_DIR/src/ -m aux/containers/guix/manifest.scm" + +if [ -z "${1:-}" ]; then + $ENV_CMD +else + $ENV_CMD --pure -C -- sh -c "$@" +fi diff --git a/aux/guix/manifest.scm b/aux/guix/manifest.scm deleted file mode 100644 index 050024b..0000000 --- a/aux/guix/manifest.scm +++ /dev/null @@ -1,17 +0,0 @@ -(specifications->manifest - (map symbol->string - '(bash - coreutils - findutils - diffutils - grep - sed - git - make - shellcheck - gawk - direnv - git-crypt - ;; terraform - perl - pandoc))) diff --git a/aux/guix/pinned-channels.scm b/aux/guix/pinned-channels.scm deleted file mode 100644 index 504406f..0000000 --- a/aux/guix/pinned-channels.scm +++ /dev/null @@ -1,11 +0,0 @@ -(cons* - (channel - (name 'xyz-euandreh) - (url "git://euandreh.xyz/package-repository") - (branch "main") - (introduction - (make-channel-introduction - "d749e053e6db365069cb9b2ef47a78b06f9e7361" - (openpgp-fingerprint - "5BDA E9B8 B2F6 C6BC BB0D 6CE5 81F9 0EC3 CD35 6060")))) - %default-channels) diff --git a/aux/guix/with-container.sh b/aux/guix/with-container.sh deleted file mode 100755 index 6e19691..0000000 --- a/aux/guix/with-container.sh +++ /dev/null @@ -1,17 +0,0 @@ -#!/bin/sh -set -eu - -if [ -z "${1:-}" ]; then - guix time-machine --fallback -C aux/guix/pinned-channels.scm -- \ - environment --fallback -m aux/guix/manifest.scm -elif [ "$1" = '-p' ]; then - guix time-machine --fallback -C aux/guix/pinned-channels.scm -- \ - environment --fallback -m aux/guix/manifest.scm --pure -C -elif [ "$1" = '-C' ]; then - guix time-machine --fallback -C aux/guix/pinned-channels.scm -- \ - pack -f docker -S/bin=bin -m aux/guix/manifest.scm -v3 -else - guix time-machine --fallback -C aux/guix/pinned-channels.scm -- \ - environment --fallback -m aux/guix/manifest.scm --pure -C \ - -- sh -c "$@" -fi @@ -8,12 +8,12 @@ uuid() { # Taken from: # https://serverfault.com/a/799198 od -xN20 /dev/urandom | - head -1 | + head -n1 | awk '{OFS="-"; print $2$3,$4,$5,$6,$7$8$9}' } tmpname() { - echo 'mkstemp(template)' | m4 -D template="${TMPDIR:-/tmp}/m4-tmpname." + echo "${TMPDIR:-/tmp}/uuid-tmpname with spaces.$(uuid)" } mkstemp() { diff --git a/aux/with-container b/aux/with-container new file mode 120000 index 0000000..b96cf67 --- /dev/null +++ b/aux/with-container @@ -0,0 +1 @@ +containers/guix/with-container.sh
\ No newline at end of file diff --git a/aux/workflow/TODOs.sh b/aux/workflow/TODOs.sh index efc0b04..05cf3cb 100755 --- a/aux/workflow/TODOs.sh +++ b/aux/workflow/TODOs.sh @@ -40,20 +40,13 @@ if [ -z "${PROJECT_UC:-}" ]; then fi -# shellcheck disable=1004 -IDS_REGEX='s:^## \(TODO\|DOING\|WAITING\|MEETING\|INACTIVE\|NEXT\|CANCELLED\|DONE\|WONTFIX\) \(.*\) {#\(.*\)}\(.*\)$:## <a href="#\3"><span class="\1">\1</span> \2</a>\4\ -<pre class="header-anchor" id="\3">#\3</pre>\ -:g' -TAGS_REGEX='s|tag:\([a-z0-9-]*\)|<span class="tag">\1</span>|g' - -cat aux/workflow/preamble.md TODOs.md | +td -H | + cat aux/workflow/preamble.md - | sed \ -e "s:@PROJECT_UC@:$PROJECT_UC:g" \ -e "s:@PROJECT@:$PROJECT:g" \ -e "s:@MAILING_LIST@:$MAILING_LIST:g" \ - -e "s:@TLD@:$TLD:g" \ - -e "$IDS_REGEX" \ - -e "$TAGS_REGEX" | + -e "s:@TLD@:$TLD:g" | pandoc \ --toc \ --highlight-style pygments \ diff --git a/aux/workflow/assert-changelog.sh b/aux/workflow/assert-changelog.sh index 4acc81b..c58a600 100755 --- a/aux/workflow/assert-changelog.sh +++ b/aux/workflow/assert-changelog.sh @@ -44,7 +44,7 @@ assert() { VVERSION="$2" VERSION="${2#v}" CHANGELOG_ENTRY="$(printf \ - '# [%s](https://git.euandreh.xyz/%s/commit/?id=%s) - %s' \ + '# [%s](https://euandreh.xyz/%s.git/commit/?id=%s) - %s' \ "$VERSION" "$PROJECT" "$VVERSION" "$DATE")" if ! grep -qF "$CHANGELOG_ENTRY" CHANGELOG.md; then echo "Missing '$CHANGELOG_ENTRY' entry from CHANGELOG.md" >&2 diff --git a/aux/workflow/assert-readme.sh b/aux/workflow/assert-readme.sh index 1e49bfb..0a85221 100755 --- a/aux/workflow/assert-readme.sh +++ b/aux/workflow/assert-readme.sh @@ -55,7 +55,7 @@ Send contributions to the [mailing list] via ## Links - [homepage](https://$TLD/$PROJECT/en/) -- [source code](https://git.euandreh.xyz/$PROJECT/) +- [source code](https://euandreh.xyz/$PROJECT.git/) - [bug tracking](https://$TLD/$PROJECT/TODOs.html) - [mailing list] - [CI logs](https://$TLD/$PROJECT/ci.html) @@ -68,7 +68,7 @@ RELEASES_LIST="$(mkstemp)" add_release() { DATE="$1" VVERSION="$2" - echo "- [$VVERSION](https://git.euandreh.xyz/$PROJECT/commit/?id=$VVERSION) [$PROJECT-$VVERSION.tar.gz](https://git.euandreh.xyz/$PROJECT/snapshot/$PROJECT-$VVERSION.tar.gz) ([sig](https://git.euandreh.xyz/$PROJECT/snapshot/$PROJECT-$VVERSION.tar.gz.asc)) - $DATE" >> "$RELEASES_LIST" + echo "- [$VVERSION](https://euandreh.xyz/$PROJECT.git/commit/?id=$VVERSION) [$PROJECT-$VVERSION.tar.gz](https://euandreh.xyz/$PROJECT.git/snapshot/$PROJECT-$VVERSION.tar.gz) ([sig](https://euandreh.xyz/$PROJECT.git/snapshot/$PROJECT-$VVERSION.tar.gz.asc)) - $DATE" >> "$RELEASES_LIST" } for VVERSION in $(git tag); do @@ -98,7 +98,7 @@ The code is licensed under [GNU Affero General Public License v3.0 or later][AGPL-3.0-or-later] (AGPL-3.0-or-later). -[AGPL-3.0-or-later]: https://git.euandreh.xyz/$PROJECT/tree/COPYING +[AGPL-3.0-or-later]: https://euandreh.xyz/$PROJECT.git/tree/COPYING EOF if ! tail -n "$(wc -l < "$EXPECTED")" README.md | diff - "$EXPECTED"; then diff --git a/aux/workflow/assert-todos.sh b/aux/workflow/assert-todos.sh index bc4907d..f4fd965 100755 --- a/aux/workflow/assert-todos.sh +++ b/aux/workflow/assert-todos.sh @@ -1,58 +1,15 @@ #!/bin/sh set -eu -if [ -e .git ] && git grep FIXME | grep -v '^TODOs.md' | - grep -v '^aux/workflow/assert-todos.sh'; then - echo "Found dangling FIXME markers on the project." - echo "You should write them down properly on TODOs.md." +# shellcheck disable=2086 +if [ -e .git ] && + git grep FIXME ${1:-} | + grep -v '^TODOs.md:' | + grep -v '^aux/workflow/assert-todos.sh:' +then + echo "Found dangling FIXME markers on the project." >&2 + echo "You should write them down properly on TODOs.md." >&2 exit 1 fi -awk -F'{#' ' -BEGIN { - exitstatus = 0 - h2flag = 0 - h2status = "" - prevline = "" - idx = 0 - delete ids[0] -} -h2flag == 1 { - split($0, l, " ") - timelinestatus = l[2] - if (h2status != timelinestatus) { - print "h2/timeline status mismatch for line " NR-1 - print prevline - print $0 - exitstatus = 1 - } - h2status = "" - h2flag = 0 -} - -/^## (TODO|DOING|WAITING|MEETING|INACTIVE|NEXT|CANCELLED|DONE|WONTFIX)/ { - if (match($0, / \{#.*?\}.*$/) == 0) { - print "Missing ID for line " NR ":\n" $0 - exitstatus = 1 - } - id_with_prefix = substr($2, 0, length($2) - 1) - match(id_with_prefix, /^\w+-/) - id = substr(id_with_prefix, RLENGTH + 1) - if (id in arr) { - print "Duplicate ID: " id - exitstatus = 1 - } else { - arr[id] = 1 - } - - split($0, l, " ") - h2status = l[2] - h2flag = 1 - prevline = $0 -} - - -/^# Scratch$/ { - exit exitstatus -} -' TODOs.md +td -L diff --git a/aux/workflow/commonmark.sh b/aux/workflow/commonmark.sh index 6f5e59b..088d447 100755 --- a/aux/workflow/commonmark.sh +++ b/aux/workflow/commonmark.sh @@ -1,7 +1,7 @@ #!/bin/sh set -eu -while getopts 'N:t:l:' flag; do +while getopts 'N:t:l:H:' flag; do case "$flag" in N) PROJECT_UC="$OPTARG" @@ -12,6 +12,9 @@ while getopts 'N:t:l:' flag; do l) THE_LANG="$OPTARG" ;; + H) + ALTERNATES="$OPTARG" + ;; *) exit 2 ;; @@ -29,6 +32,7 @@ assert_arg() { assert_arg "${PROJECT_UC:-}" '-N PROJECT_UC' assert_arg "${TITLE:-}" '-t TITLE' assert_arg "${THE_LANG:-}" '-l THE_LANG' +assert_arg "${ALTERNATES:-}" '-H ALTERNATES' pandoc \ --toc \ @@ -39,4 +43,6 @@ pandoc \ --metadata "lang=$THE_LANG" \ -r commonmark \ -w html \ - -H aux/workflow/favicon.html + -H aux/workflow/favicon.html \ + -H aux/workflow/style.css \ + -H "$ALTERNATES" diff --git a/aux/workflow/dist.sh b/aux/workflow/dist.sh index a433478..68f8849 100755 --- a/aux/workflow/dist.sh +++ b/aux/workflow/dist.sh @@ -53,6 +53,12 @@ if git show "$VVERSION" 1>/dev/null 2>/dev/null; then exit 1 fi +if [ "v$(awk '/^VERSION *=/{print $3; exit}' Makefile)" != "$VVERSION" ]; then + echo "Version '$VVERSION' mismatch with \$(VERSION) in Makefile." >&2 + echo 'Make sure to invoke this script with "make dist".' >&2 + exit 1 +fi + if ! printf '%s\n%s\n' "$(git tag)" "$VVERSION" | sort -nct. -k1 -k2 -k3; then echo 'New tag is not bigger than existing ones.' >&2 exit 1 @@ -63,12 +69,19 @@ if [ "$DATE" != "$(git log -1 --format=%cd --date=short HEAD)" ]; then exit 1 fi +if [ "$(awk '/^DATE *=/{print $3; exit}' Makefile)" != "$DATE" ]; then + echo "Date '$DATE' mismatch with \$(DATE) in Makefile." >&2 + echo 'Make sure to invoke this script with "make dist".' >&2 + exit 1 +fi + if [ "Release $VVERSION" != "$(git log --format=%B -1 HEAD | head -n1)" ]; then echo "Commit message isn't 'Release $VVERSION'." >&2 exit 1 fi -make clean public dev-check EXTRA_VERSION="$VVERSION" +make clean +env ASSERT_NO_MISSING_TRANSLATIONS=1 make dev-check EXTRA_VERSION="$VVERSION" if ! (git diff --quiet && git diff --quiet --staged); then echo 'Dirty repository.' diff --git a/aux/workflow/preamble.md b/aux/workflow/preamble.md index ee32d58..a699d04 100644 --- a/aux/workflow/preamble.md +++ b/aux/workflow/preamble.md @@ -12,3 +12,5 @@ and see [existing discussions](https://lists.sr.ht/~euandreh/@MAILING_LIST@?sear *Vi povas ankaŭ skribi esperante*. +*Tu también puedes escribir en español*. + diff --git a/aux/workflow/public.sh b/aux/workflow/public.sh index 38613de..2c8c36a 100755 --- a/aux/workflow/public.sh +++ b/aux/workflow/public.sh @@ -1,6 +1,9 @@ #!/bin/sh set -eu +TLD="$(cat aux/tld.txt)" +. aux/lib.sh + PROJECT_UC= while getopts 'n:N:m:o:l:' flag; do case "$flag" in @@ -39,6 +42,23 @@ assert_arg "${OUTDIR:-}" '-o OUTDIR' assert_arg "${LANGS:-}" '-l LANGS' PROJECT_UC="${PROJECT_UC:-$PROJECT}" + +alternates_for() { + ALTERNATES="$(mkstemp)" + lang="$1" + OUTNAME="$2" + for l in $LANGS; do + if [ "$l" = "$lang" ]; then + continue + fi + cat <<EOF >> "$ALTERNATES" +<link rel="alternate" href="https://$TLD/$PROJECT/$l/$OUTNAME" hreflang="$l" /> +EOF + done + echo "$ALTERNATES" +} + + mkdir -p "$OUTDIR" sh aux/workflow/TODOs.sh \ @@ -46,9 +66,13 @@ sh aux/workflow/TODOs.sh \ for lang in $LANGS; do mkdir -p "$OUTDIR/$lang/" - sh aux/workflow/commonmark.sh -N "$PROJECT" -t README -l "$lang" \ + sh aux/workflow/commonmark.sh \ + -N "$PROJECT" -l "$lang" -t README \ + -H "$(alternates_for "$lang" '')" \ < "README.$lang.md" > "$OUTDIR/$lang/index.html" - sh aux/workflow/commonmark.sh -N "$PROJECT" -t CHANGELOG -l "$lang" \ + sh aux/workflow/commonmark.sh \ + -N "$PROJECT" -l "$lang" -t CHANGELOG \ + -H "$(alternates_for "$lang" 'CHANGELOG.html')" \ < "CHANGELOG.$lang.md" > "$OUTDIR/$lang/CHANGELOG.html" ln -fs ../favicon.svg "$OUTDIR/$lang" done diff --git a/aux/workflow/style.css b/aux/workflow/style.css index d72991e..99980aa 100644 --- a/aux/workflow/style.css +++ b/aux/workflow/style.css @@ -1,41 +1,78 @@ <style> - hr { - background-color: #ccc; - } - - .header-anchor { - opacity: 0.5; - } - - .tag { - font-family: monospace; - font-size: 70%; - background-color: lightgray; - padding: 3px; - border-radius: 5px; - } - - .TODO { - color: brown; - } - - .DOING { - color: yellowgreen; - } - - .WAITING, .MEETING { - color: orange; - } - - .INACTIVE { - color: gray; - } - - .NEXT { - color: red; - } - - .CANCELLED, .DONE, .WONTFIX { - color: green; - } + body { + max-width: 800px; + margin: 0 auto 0 auto; + } + + hr { + background-color: #ccc; + } + + .header-anchor { + opacity: 0.5; + display: inline-block; + } + + .tag { + font-family: monospace; + font-size: 70%; + background-color: lightgray; + color: black; + padding: 3px; + border-radius: 5px; + } + + .TODO { + color: brown; + } + + .DOING { + color: yellowgreen; + } + + .WAITING, .MEETING { + color: orange; + } + + .INACTIVE { + color: gray; + } + + .NEXT { + color: red; + } + + .CANCELLED, .DONE, .WONTFIX { + color: green; + } + + pre, code { + background-color: #ddd; + border-radius: 5px; + padding: 5px; + } + + pre > code { + overflow: auto; + white-space: pre; + } + + @media(prefers-color-scheme: dark) { + :root { + color: white; + background-color: black; + } + + a { + color: hsl(211, 100%, 60%); + } + + a:visited { + color: hsl(242, 100%, 80%); + } + + pre, code { + background-color: #222; + } + } </style> |