blob: 5803784121ac643066267c77dee2a7fdaefe94f6 (
plain) (
blame)
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
|
#!/bin/sh
# usage: ./check.sh
FAIL=0
fail() {
echo "check: $1"
FAIL=1
}
FILES=$(git ls-files --cached)
ODIN=$(echo "$FILES" | grep '\.odin$')
BAD_IMPORTS=$(for f in $ODIN; do
grep -oE '^[[:space:]]*import[[:space:]]+([A-Za-z_][A-Za-z0-9_]*[[:space:]]+)?"[^"]+"' "$f" |
sed -E 's/.*"([^"]+)"/\1/' |
while read -r imp; do
case "$imp" in
(core:* | base:* | vendor:raylib | vendor:raylib/rlgl | vendor:curl | ../*) ;;
(*) echo "$f: $imp" ;;
esac
done
done)
[ -n "$BAD_IMPORTS" ] && fail "imports not allowed:
$BAD_IMPORTS"
for f in source/game/terrain.odin source/game/weather.odin source/game/route.odin \
source/game/ship.odin source/game/nav.odin; do
[ -f "$f" ] && grep -q 'vendor:raylib' "$f" && fail "$f is simulation code and imports raylib"
done
BANNED=$(echo "$ODIN" | grep -E '(^|/)(utils?|helpers?|common|types|misc)\.odin$')
[ -n "$BANNED" ] && fail "banned file names:
$BANNED"
TEST_FILES=$(echo "$ODIN" | grep -E '_test\.odin$')
[ -n "$TEST_FILES" ] && fail "test files belong in test/, not next to the code:
$TEST_FILES"
[ "$(echo "$ODIN" | grep -c '^test/')" -gt 1 ] && fail "test/ has more than one file"
for f in $FILES; do
[ -f "$f" ] || continue
case "$f" in
assets/belgium.bin | assets/geojson/*) continue ;;
esac
SIZE=$(wc -c < "$f")
[ "$SIZE" -gt 1000000 ] && fail "$f is $SIZE bytes, max 1 MB"
done
[ $FAIL -eq 0 ] && echo "check: ok"
exit $FAIL
|