aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile44
-rwxr-xr-xbin/check47
-rwxr-xr-xopt/tests/assert-gpg-expiration.sh22
3 files changed, 76 insertions, 37 deletions
diff --git a/Makefile b/Makefile
index 5d8e2c4..c1723b3 100644
--- a/Makefile
+++ b/Makefile
@@ -31,5 +31,49 @@ $(XDG_DATA_HOME)/euandreh/e.list.txt: ~/Documents/txt/ opt/aux/gen-e-list.sh
+check-shellcheck:
+ git ls-files | \
+ xargs awk '/^#!\/bin\/sh$$/ { print FILENAME } { nextfile }' | \
+ xargs shellcheck -x
+
+check-perlcritic:
+ git ls-files | \
+ xargs awk '/^#!\/usr\/bin\/env perl$$/ { print FILENAME } { nextfile }' | \
+ xargs perlcritic
+
+check-fixme:
+ if git grep FIXME -- ':(exclude)Makefile'; then \
+ printf 'Leftover FIXME markers.\n' >&2; \
+ exit 1; \
+ fi
+
+check-dirty-public:
+ if ! git diff --quiet || ! git diff --quiet --staged; then \
+ printf 'Dirty tilde repository.\n' >&2; \
+ exit 1; \
+ fi
+
+check-dirty-private:
+ if ! git -C $(PRIV_CONFIG) diff --quiet || \
+ ! git -C $(PRIV_CONFIG) diff --quiet --staged; then \
+ printf 'Dirty private tilde repository.\n' >&2; \
+ exit 1; \
+ fi
+
+check-opt:
+ find opt/tests/ -name '*.sh' -exec {} +
+
+check-pod:
+ podchecker bin/z
+
+check-sync:
+ if git status --short --branch --porcelain | head -n1 | grep -E '(ahead|behind)'; then \
+ printf 'Out of sync with origin.\n' >&2; \
+ exit 1; \
+ fi
+
+check: check-shellcheck check-perlcritic check-fixme check-dirty-public \
+ check-dirty-private check-opt check-pod check-sync
+
clean:
rm -f $(derived-assets)
diff --git a/bin/check b/bin/check
index 4dd96f1..5919482 100755
--- a/bin/check
+++ b/bin/check
@@ -1,19 +1,25 @@
#!/bin/sh
set -eu
+
usage() {
cat <<-'EOF'
Usage:
- check.sh
- check.sh -h
+ check
+ check -h
EOF
}
help() {
cat <<-'EOF'
+
Options:
-h, --help show this message
+
+
+ Run Makefile tests. This binary is available to simplify the
+ cronjob.
EOF
}
@@ -47,39 +53,6 @@ while getopts 'h' flag; do
done
shift $((OPTIND - 1))
-cd -- "$(dirname -- "$0")"
-cd -- "$(git rev-parse --show-toplevel)"
-
-
-git ls-files |
- xargs awk 'FNR==1 && /^#!\/bin\/sh$/ { print FILENAME }' |
- xargs shellcheck -x
-
-git ls-files |
- xargs awk 'FNR==1 && /^#!\/usr\/bin\/env perl$/ { print FILENAME }' |
- xargs perlcritic
-
-if git grep FIXME -- ":(exclude)$0"; then
- printf 'Leftover FIXME markers\n' >&2
- exit 1
-fi
-
-if ! git diff --quiet || ! git diff --quiet --staged; then
- printf 'Dirty tilde repository.\n' >&2
- exit 1
-fi
-
-PRIV="$XDG_CONFIG_HOME/../var/lib/private/tilde"
-if ! git -C "$PRIV" diff --quiet || ! git -C "$PRIV" diff --quiet --staged; then
- printf 'Dirty private tilde repository.\n' >&2
- exit 1
-fi
-
-for f in opt/tests/*; do
- sh "$f"
-done
-# FIXME:
-# verify that the expiry date on the GPG key is greater than 1 year
-# assert git pushed
-# podchecker
+cd ~/.usr/
+make check
diff --git a/opt/tests/assert-gpg-expiration.sh b/opt/tests/assert-gpg-expiration.sh
new file mode 100755
index 0000000..d17486e
--- /dev/null
+++ b/opt/tests/assert-gpg-expiration.sh
@@ -0,0 +1,22 @@
+#!/bin/sh
+set -eu
+
+
+SECRET_KEY='81F90EC3CD356060'
+NEXT_6_MONTHS="$(echo "$(date '+%s') + (60 * 60 * 24 * 30 * 6)" | bc)"
+
+gpg --with-colons --fixed-list-mode --list-keys "$SECRET_KEY" |
+ grep -e ^pub -e ^sub |
+ while read -r subkey; do
+ EXPIRY="$(echo "$subkey" | cut -d: -f7)"
+ if [ -z "$EXPIRY" ]; then
+ continue
+ fi
+
+ if [ "$EXPIRY" -gt "$(date '+%s')" ] &&
+ [ "$EXPIRY" -lt "$NEXT_6_MONTHS" ]; then
+ printf 'Key %s to expire soon!.\n' \
+ "$(echo "$subkey" | cut -d: -f5)" >&2
+ exit 1
+ fi
+ done