aboutsummaryrefslogtreecommitdiff
path: root/aux/checks
diff options
context:
space:
mode:
Diffstat (limited to 'aux/checks')
-rwxr-xr-xaux/checks/changelog.sh54
-rwxr-xr-xaux/checks/manpages.sh21
-rw-r--r--aux/checks/manpages/footer.en.0.in30
-rw-r--r--aux/checks/manpages/footer.eo.0.in13
-rw-r--r--aux/checks/manpages/footer.es.0.in13
-rw-r--r--aux/checks/manpages/footer.fr.0.in13
-rw-r--r--aux/checks/manpages/footer.pt.0.in13
-rwxr-xr-xaux/checks/readme.sh82
-rwxr-xr-xaux/checks/repo.sh188
-rwxr-xr-xaux/checks/shellcheck.sh6
-rwxr-xr-xaux/checks/spelling.sh5
-rwxr-xr-xaux/checks/todos.sh62
12 files changed, 500 insertions, 0 deletions
diff --git a/aux/checks/changelog.sh b/aux/checks/changelog.sh
new file mode 100755
index 0000000..ee10549
--- /dev/null
+++ b/aux/checks/changelog.sh
@@ -0,0 +1,54 @@
+#!/bin/sh
+set -eu
+
+
+while getopts 'h' flag; do
+ case "$flag" in
+ h)
+ usage
+ help
+ exit
+ ;;
+ *)
+ usage >&2
+ exit 2
+ ;;
+ esac
+done
+shift $((OPTIND - 1))
+
+. aux/lib.sh
+
+
+HOMEPAGE_LINK="Changelog for [$NAME](https://$TLD/$NAME/en/)."
+
+if ! grep -qF "$HOMEPAGE_LINK" CHANGELOG.md; then
+ echo "Missing link to homepage in CHANGELOG.md:" >&2
+ echo "$HOMEPAGE_LINK"
+ exit 1
+fi
+
+assert() {
+ DATE="$1"
+ VVERSION="$2"
+ VERSION="${2#v}"
+ CHANGELOG_ENTRY="$(printf \
+ '# [%s](https://%s/git/%s/commit/?id=%s) - %s' \
+ "$VERSION" "$TLD" "$NAME" "$VVERSION" "$DATE")"
+ if ! grep -qF "$CHANGELOG_ENTRY" CHANGELOG.md; then
+ echo "Missing '$CHANGELOG_ENTRY' entry from CHANGELOG.md" >&2
+ exit 1
+ fi
+}
+
+for VVERSION in $(git tag); do
+ DATE="$(git log -1 --format=%ad --date=short "$VVERSION")"
+ assert "$DATE" "$VVERSION"
+done
+
+# FIXME
+# "$@" represents a list of tags to be also included in the verification.
+for VVERSION in "$@"; do
+ DATE="$(date '+%Y-%m-%d')"
+ assert "$DATE" "$VVERSION"
+done
diff --git a/aux/checks/manpages.sh b/aux/checks/manpages.sh
new file mode 100755
index 0000000..204d960
--- /dev/null
+++ b/aux/checks/manpages.sh
@@ -0,0 +1,21 @@
+#!/bin/sh
+set -eu
+
+while getopts 'h' flag; do
+ case "$flag" in
+ h)
+ usage
+ help
+ exit
+ ;;
+ *)
+ exit 2
+ ;;
+ esac
+done
+shift $((OPTIND - 1))
+
+. aux/lib.sh
+
+
+# FIXME
diff --git a/aux/checks/manpages/footer.en.0.in b/aux/checks/manpages/footer.en.0.in
new file mode 100644
index 0000000..8db378b
--- /dev/null
+++ b/aux/checks/manpages/footer.en.0.in
@@ -0,0 +1,30 @@
+.SH AUTHORS
+
+.MT eu@euandre.org
+EuAndreh
+.ME
+and contributors.
+
+
+.SH BUGS
+
+.IP \(bu
+Report bugs to the
+.MT ~euandreh/@MAILING_LIST@@lists.sr.ht
+mailing list
+.ME .
+Use the subject "\f(CR[@NAME@] BUG or TASK:
+<description>\fR".
+.IP \(bu
+Browse bugs
+.UR https://@TLD@/@NAME@/TODOs.html
+online
+.UE .
+.IP \(bu
+.UR https://@TLD@/@NAME@/en/
+Homepage
+.UE .
+.IP \(bu
+.UR https://lists.sr.ht/~euandreh/@MAILING_LIST@?search=%5B@NAME@%5D
+Comments and discussions
+.UE .
diff --git a/aux/checks/manpages/footer.eo.0.in b/aux/checks/manpages/footer.eo.0.in
new file mode 100644
index 0000000..bb319ca
--- /dev/null
+++ b/aux/checks/manpages/footer.eo.0.in
@@ -0,0 +1,13 @@
+.SH AUTHORS
+
+.MT eu@euandre.org EuAndreh .ME and contributors.
+
+
+.SH BUGS
+
+.IP \(bu Report bugs to the .MT ~euandreh/@MAILING_LIST@@lists.sr.ht mailing
+list .ME . Use the subject "\f(CR[@NAME@] BUG or TASK: <description>\fR".
+.IP \(bu Browse bugs .UR https://@TLD@/@NAME@/TODOs.html online .UE . .IP
+\(bu .UR https://@TLD@/@NAME@/en/ Homepage .UE . .IP \(bu .UR
+https://lists.sr.ht/~euandreh/@MAILING_LIST@?search=%5B@NAME@%5D Comments
+and discussions .UE .
diff --git a/aux/checks/manpages/footer.es.0.in b/aux/checks/manpages/footer.es.0.in
new file mode 100644
index 0000000..bb319ca
--- /dev/null
+++ b/aux/checks/manpages/footer.es.0.in
@@ -0,0 +1,13 @@
+.SH AUTHORS
+
+.MT eu@euandre.org EuAndreh .ME and contributors.
+
+
+.SH BUGS
+
+.IP \(bu Report bugs to the .MT ~euandreh/@MAILING_LIST@@lists.sr.ht mailing
+list .ME . Use the subject "\f(CR[@NAME@] BUG or TASK: <description>\fR".
+.IP \(bu Browse bugs .UR https://@TLD@/@NAME@/TODOs.html online .UE . .IP
+\(bu .UR https://@TLD@/@NAME@/en/ Homepage .UE . .IP \(bu .UR
+https://lists.sr.ht/~euandreh/@MAILING_LIST@?search=%5B@NAME@%5D Comments
+and discussions .UE .
diff --git a/aux/checks/manpages/footer.fr.0.in b/aux/checks/manpages/footer.fr.0.in
new file mode 100644
index 0000000..bb319ca
--- /dev/null
+++ b/aux/checks/manpages/footer.fr.0.in
@@ -0,0 +1,13 @@
+.SH AUTHORS
+
+.MT eu@euandre.org EuAndreh .ME and contributors.
+
+
+.SH BUGS
+
+.IP \(bu Report bugs to the .MT ~euandreh/@MAILING_LIST@@lists.sr.ht mailing
+list .ME . Use the subject "\f(CR[@NAME@] BUG or TASK: <description>\fR".
+.IP \(bu Browse bugs .UR https://@TLD@/@NAME@/TODOs.html online .UE . .IP
+\(bu .UR https://@TLD@/@NAME@/en/ Homepage .UE . .IP \(bu .UR
+https://lists.sr.ht/~euandreh/@MAILING_LIST@?search=%5B@NAME@%5D Comments
+and discussions .UE .
diff --git a/aux/checks/manpages/footer.pt.0.in b/aux/checks/manpages/footer.pt.0.in
new file mode 100644
index 0000000..bb319ca
--- /dev/null
+++ b/aux/checks/manpages/footer.pt.0.in
@@ -0,0 +1,13 @@
+.SH AUTHORS
+
+.MT eu@euandre.org EuAndreh .ME and contributors.
+
+
+.SH BUGS
+
+.IP \(bu Report bugs to the .MT ~euandreh/@MAILING_LIST@@lists.sr.ht mailing
+list .ME . Use the subject "\f(CR[@NAME@] BUG or TASK: <description>\fR".
+.IP \(bu Browse bugs .UR https://@TLD@/@NAME@/TODOs.html online .UE . .IP
+\(bu .UR https://@TLD@/@NAME@/en/ Homepage .UE . .IP \(bu .UR
+https://lists.sr.ht/~euandreh/@MAILING_LIST@?search=%5B@NAME@%5D Comments
+and discussions .UE .
diff --git a/aux/checks/readme.sh b/aux/checks/readme.sh
new file mode 100755
index 0000000..0447b08
--- /dev/null
+++ b/aux/checks/readme.sh
@@ -0,0 +1,82 @@
+#!/bin/sh
+set -eu
+
+while getopts 'h' flag; do
+ case "$flag" in
+ h)
+ usage
+ help
+ exit
+ ;;
+ *)
+ usage >&2
+ exit 2
+ ;;
+ esac
+done
+shift $((OPTIND - 1))
+
+. aux/lib.sh
+
+
+EXPECTED="$(mkstemp)"
+cat <<-EOF >> "$EXPECTED"
+
+ Send contributions to the [mailing list] via
+ [\`git send-email\`](https://git-send-email.io/).
+
+
+ ## Links
+
+ - [homepage](https://$TLD/s/$NAME/en/)
+ - [source code](https://$TLD/git/$NAME/)
+ - [bug tracking](https://$TLD/s/$NAME/TODOs.html)
+ - [mailing list]
+ - [CI logs](https://$TLD/s/$NAME/ci/)
+ - [CHANGELOG](https://$TLD/s/$NAME/en/CHANGELOG.html)
+
+ [mailing list]: https://lists.sr.ht/~euandreh/$MAILING_LIST?search=%5B$NAME%5D
+EOF
+
+RELEASES_LIST="$(mkstemp)"
+add_release() {
+ DATE="$1"
+ VVERSION="$2"
+ echo "- [$VVERSION](https://$TLD/git/$NAME/commit/?id=$VVERSION) [$NAME-$VVERSION.tar.gz](https://$TLD/git/$NAME/snapshot/$NAME-$VVERSION.tar.gz) ([sig](https://$TLD/git/$NAME/snapshot/$NAME-$VVERSION.tar.gz.asc)) - $DATE" >> "$RELEASES_LIST"
+}
+
+for VVERSION in $(git tag); do
+ DATE="$(git log -1 --format=%ad --date=short "$VVERSION")"
+ add_release "$DATE" "$VVERSION"
+done
+
+# "$@" represents a list of tags to be also included in the verification.
+for VVERSION in "$@"; do
+ if ! git tag | grep -qF "$VVERSION"; then
+ DATE="$(date '+%Y-%m-%d')"
+ add_release "$DATE" "$VVERSION"
+ fi
+done
+
+if [ -s "$RELEASES_LIST" ]; then
+ printf '\n\n## Releases\n\n' >> "$EXPECTED"
+ sort -r "$RELEASES_LIST" >> "$EXPECTED"
+fi
+
+cat <<-EOF >> "$EXPECTED"
+
+
+ ## License
+
+ 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://$TLD/git/$NAME/tree/COPYING
+EOF
+
+if ! tail -n "$(wc -l < "$EXPECTED")" README.md | diff - "$EXPECTED"; then
+ echo 'Wrong metadata at the end of README.md file'
+ echo "See expected content at: $EXPECTED"
+ exit 1
+fi
diff --git a/aux/checks/repo.sh b/aux/checks/repo.sh
new file mode 100755
index 0000000..0c00e92
--- /dev/null
+++ b/aux/checks/repo.sh
@@ -0,0 +1,188 @@
+#!/bin/sh
+set -eu
+
+if true; then
+ exit
+fi
+
+if [ -n "${RECURSIVE_CHECK:-}" ]; then
+ exit
+fi
+export RECURSIVE_CHECK=true
+
+. aux/lib.sh
+
+REPODIR="$PWD"
+
+INSTALLCHECK=false
+while getopts 'x:l:f:' flag; do
+ case "$flag" in
+ x)
+ EXECUTABLES="$OPTARG"
+ INSTALLCHECK=true
+ ;;
+ l)
+ SYMLINKS="$OPTARG"
+ INSTALLCHECK=true
+ ;;
+ f)
+ FILES="$OPTARG"
+ INSTALLCHECK=true
+ ;;
+ *)
+ exit 2
+ ;;
+ esac
+done
+shift $((OPTIND - 1))
+
+assert_no_diffs() {
+ if [ -n "$(git status -s)" ]; then
+ echo 'Repository left dirty.' >&2
+ git status >&2
+ exit 1
+ fi
+}
+
+assert_installed_files() {
+ if [ -n "${EXECUTABLES:-}" ]; then
+ ACTUAL="$(find "$1" -type f -perm -u=x | wc -l)"
+ if [ "$EXECUTABLES" != "$ACTUAL" ]; then
+ printf 'Expected %s executables, found %s:\n' \
+ "$EXECUTABLES" "$ACTUAL" >&2
+ echo "find $1 -type f -perm -u=x:" >&2
+ find "$1" -type f -perm -u=x >&2
+ exit 1
+ fi
+ fi
+
+ if [ -n "${SYMLINKS:-}" ]; then
+ ACTUAL="$(find "$1" -type l | wc -l)"
+ if [ "$SYMLINKS" != "$ACTUAL" ]; then
+ printf 'Expected %s symlinks, found %s:\n' \
+ "$SYMLINKS" "$ACTUAL" >&2
+ echo "find $1 -type l:" >&2
+ find "$1" -type l >&2
+ exit 1
+ fi
+ fi
+
+ if [ -n "${FILES:-}" ]; then
+ ACTUAL="$(find "$1" -type f | wc -l)"
+ if [ "$FILES" != "$ACTUAL" ]; then
+ printf 'Expected %s files, found %s:\n' \
+ "$FILES" "$ACTUAL" >&2
+ echo "find $1 -type f:" >&2
+ find "$1" -type f >&2
+ exit 1
+ fi
+ fi
+}
+
+assert_uninstalled_files() {
+ if [ "$(find "$1" \( -type f -o -type l \) | wc -l)" != 0 ]; then
+ echo 'Left-over files after uninstall' >&2
+ echo "find $1 \( -type f -o -type l \):"
+ find "$1" \( -type f -o -type l \)
+ exit 1
+ fi
+}
+
+assert_install() {
+ if [ "$INSTALLCHECK" != 'true' ]; then
+ return
+ fi
+
+ make clean
+
+ echo 'Asserting "canonical" install path' >&2
+ INSTALL1="$(mkdtemp)"
+ make PREFIX="$INSTALL1"
+ make check PREFIX="$INSTALL1"
+ make install PREFIX="$INSTALL1"
+ assert_installed_files "$INSTALL1"
+ make uninstall PREFIX="$INSTALL1"
+ assert_uninstalled_files "$INSTALL1"
+
+ make clean
+
+ echo 'Asserting "straigh-forward" install path' >&2
+ INSTALL2="$(mkdtemp)"
+ make install PREFIX="$INSTALL2"
+ assert_installed_files "$INSTALL2"
+ make uninstall PREFIX="$INSTALL2"
+ assert_uninstalled_files "$INSTALL2"
+
+ make clean
+
+ echo 'Asserting "idempotent" install path' >&2
+ INSTALL3="$(mkdtemp)"
+ make install PREFIX="$INSTALL3"
+ make install PREFIX="$INSTALL3"
+ assert_installed_files "$INSTALL3"
+ make uninstall PREFIX="$INSTALL3"
+ make uninstall PREFIX="$INSTALL3"
+ assert_uninstalled_files "$INSTALL3"
+
+ make clean
+
+ echo 'Asserting "destdir" install path' >&2
+ DESTDIR="$(mkdtemp)"
+ INSTALL4="$(mkdtemp)"
+ make install DESTDIR="$DESTDIR" PREFIX="$INSTALL4"
+ assert_installed_files "$DESTDIR/$INSTALL4"
+ make uninstall DESTDIR="$DESTDIR" PREFIX="$INSTALL4"
+ assert_uninstalled_files "$DESTDIR/$INSTALL4"
+}
+
+assert_clean_clone() {
+ CLONEDIR="$(mkdtemp)"
+ cd "$CLONEDIR"
+
+ git clone "$REPODIR" .
+
+ make clean public dev-check
+ assert_no_diffs
+ make clean
+ assert_no_diffs
+
+ if [ -n "$(git clean -ffdx --dry-run)" ]; then
+ echo '"make clean" left files:' >&2
+ git clean -ffdx --dry-run >&2
+ echo "Clone directory: $CLONEDIR" >&2
+ exit 1
+ fi
+
+ rm -rf aux/
+ make clean check || {
+ echo 'Cannot run "make check" without "aux/".' >&2
+ echo "Clone directory: $CLONEDIR" >&2
+ exit 1
+ }
+
+ assert_install
+
+ cd - > /dev/null
+}
+
+assert_clean_checkout() {
+ CHECKOUTDIR="$(mkdtemp)"
+ git --work-tree="$CHECKOUTDIR" checkout HEAD -- .
+ cd "$CHECKOUTDIR"
+
+ FILECOUNT="$(find . -type f | wc -l)"
+ make clean public dev-check
+ make clean
+ if [ "$FILECOUNT" != "$(find . -type f | wc -l)" ]; then
+ echo 'File count mismatch after "make clean".' >&2
+ echo "Checkout directory: $CHECKOUTDIR" >&2
+ exit 1
+ fi
+
+ assert_install
+
+ cd - > /dev/null
+}
+
+assert_clean_clone
+assert_clean_checkout
diff --git a/aux/checks/shellcheck.sh b/aux/checks/shellcheck.sh
new file mode 100755
index 0000000..40fd364
--- /dev/null
+++ b/aux/checks/shellcheck.sh
@@ -0,0 +1,6 @@
+#!/bin/sh
+set -eu
+
+find . -name '*.sh' -print0 |
+ xargs -0 awk 'FNR==1 && /^#!\/bin\/sh$/ { print FILENAME }' |
+ xargs shellcheck
diff --git a/aux/checks/spelling.sh b/aux/checks/spelling.sh
new file mode 100755
index 0000000..4368820
--- /dev/null
+++ b/aux/checks/spelling.sh
@@ -0,0 +1,5 @@
+#!/bin/sh
+set -eu
+
+echo FIXME
+exit
diff --git a/aux/checks/todos.sh b/aux/checks/todos.sh
new file mode 100755
index 0000000..2b9a570
--- /dev/null
+++ b/aux/checks/todos.sh
@@ -0,0 +1,62 @@
+#!/bin/sh
+set -eu
+
+if true; then
+ exit
+fi
+
+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."
+ 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