summaryrefslogtreecommitdiff
path: root/check
blob: ceffb0e1c06c4e53d45b2c4de8f995286f1be216 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#!/bin/bash

set -eu

verbose=false
moar=true
while [ "$#" -gt 0 ] && $moar; do
	case "$1" in
	verbose | -v | --verbose)
		verbose=true
		shift 1
		;;
	esac
done

hideok=
if command -v chronic >/dev/null; then
	hideok=chronic
fi
quiet=-q
if $verbose; then
	quiet=
	hideok=
fi

codegen() {
	target="$(cargo metadata --format-version=1 |
		python3 -c 'import sys, json; o = json.load(sys.stdin); print(o["target_directory"])')"
	$hideok subplot codegen "$1" --output "$2"
	rm -f test.log
	$hideok python3 test.py --log test.log --env "CARGO_TARGET_DIR=$target"
}

docgen() {
	subplot docgen "$1" --output "$2"
}

$hideok cargo build --all-targets
if cargo --list | awk '{ print $1 }' | grep 'clippy$' >/dev/null; then
	# shellcheck disable=SC2086
	cargo clippy $quiet
fi

# shellcheck disable=SC2086
$hideok cargo test $quiet

if cargo fmt --help >/dev/null 2>/dev/null; then
	$hideok cargo fmt -- --check
fi

$hideok ./mktestcert test.key test.pem hunter2

for md in [^R]*.md; do
	$hideok echo "$md ====================================="
	codegen "$md" test.py
	docgen "$md" "$(basename "$md" .md).pdf"
	docgen "$md" "$(basename "$md" .md).html"
	$hideok echo
done

echo "Everything seems to be in order."