-
Notifications
You must be signed in to change notification settings - Fork 0
77 lines (70 loc) · 1.91 KB
/
lint.yml
File metadata and controls
77 lines (70 loc) · 1.91 KB
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
name: lint
on:
push:
branches: [main]
pull_request:
branches: [main]
jobs:
byte-canonical:
name: Byte-canonical invariants
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Check UTF-8 validity
run: |
set -e
fail=0
for f in examples/*.n6; do
if ! iconv -f UTF-8 -t UTF-8 "$f" >/dev/null 2>&1; then
echo "::error file=$f::not valid UTF-8"
fail=1
fi
done
exit $fail
- name: Check no BOM
run: |
set -e
fail=0
for f in examples/*.n6; do
if head -c 3 "$f" | od -An -tx1 | grep -q 'ef bb bf'; then
echo "::error file=$f::BOM present"
fail=1
fi
done
exit $fail
- name: Check LF line endings only
run: |
set -e
fail=0
for f in examples/*.n6; do
if grep -lU $'\r' "$f" >/dev/null 2>&1; then
echo "::error file=$f::CRLF or CR detected"
fail=1
fi
done
exit $fail
- name: Check no trailing whitespace
run: |
set -e
fail=0
for f in examples/*.n6; do
if grep -nE ' +$' "$f"; then
echo "::error file=$f::trailing whitespace"
fail=1
fi
done
exit $fail
- name: Check entry-header well-formed
run: |
set -e
fail=0
for f in examples/*.n6; do
# Every @<type> line must have :: <domain> and [grade]
bad=$(grep -nE '^@[PCLFRSXE?]' "$f" | grep -vE ' :: \S+ \[[0-9]+(\.[0-9]+)?[*!?]*\]\s*$' || true)
if [ -n "$bad" ]; then
echo "::error file=$f::malformed entry-header"
echo "$bad"
fail=1
fi
done
exit $fail