-
Notifications
You must be signed in to change notification settings - Fork 1
154 lines (135 loc) · 4.86 KB
/
Copy pathci.yml
File metadata and controls
154 lines (135 loc) · 4.86 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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
name: CI
on:
push:
branches: [main]
pull_request:
branches: [main]
jobs:
luacheck:
name: Luacheck
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: nebularg/actions-luacheck@v1
with:
files: '.'
args: '--no-color -q'
luaunit:
name: LuaUnit
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install Lua
run: |
sudo apt-get update
sudo apt-get install -y lua5.4
- name: Run tests
run: lua5.4 tests/Run.lua
toc-validation:
name: TOC validation
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Verify TOC file references exist
run: |
EXIT_CODE=0
while IFS= read -r line; do
line="$(echo "$line" | sed 's/\r$//')"
[[ -z "$line" ]] && continue
[[ "$line" =~ ^## ]] && continue
filepath="$(echo "$line" | tr '\\' '/')"
if [[ ! -f "$filepath" ]]; then
echo "FAIL: $filepath listed in .toc but does not exist"
EXIT_CODE=1
fi
done < EasyFind.toc
exit $EXIT_CODE
commit-hygiene:
name: Commit hygiene
runs-on: ubuntu-latest
if: github.event_name == 'pull_request'
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Validate commit messages
run: |
BASE="${{ github.event.pull_request.base.sha }}"
HEAD="${{ github.event.pull_request.head.sha }}"
EXIT_CODE=0
while IFS= read -r sha; do
MSG="$(git log --format='%B' -n 1 "$sha")"
SUBJECT="$(echo "$MSG" | head -n 1)"
if [[ -z "$SUBJECT" ]]; then
echo "FAIL [$sha]: Empty subject line"
EXIT_CODE=1
continue
fi
if [[ ${#SUBJECT} -gt 72 ]]; then
echo "FAIL [$sha]: Subject exceeds 72 chars (${#SUBJECT})"
EXIT_CODE=1
fi
done < <(git rev-list "$BASE".."$HEAD")
exit $EXIT_CODE
file-hygiene:
name: File hygiene
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Check for prohibited files
run: |
EXIT_CODE=0
# Block .env files
ENV_FILES=$(find . -name '.env' -o -name '.env.*' | grep -v '.env.example' | grep -v '.git/' || true)
if [[ -n "$ENV_FILES" ]]; then
echo "FAIL: .env file(s) in repository: $ENV_FILES"
EXIT_CODE=1
fi
# Block credential files
SECRET_FILES=$(find . -not -path './.git/*' -iregex '.*\.\(key\|pem\|p12\|pfx\)$' || true)
if [[ -n "$SECRET_FILES" ]]; then
echo "FAIL: Credential file(s) found: $SECRET_FILES"
EXIT_CODE=1
fi
# Check for hardcoded secrets in Lua files
SECRET_PATTERNS=$(grep -rlE '(api[_-]?key|secret|token|password)\s*[:=]\s*["'"'"'][A-Za-z0-9+/=_-]{20,}' *.lua Locales/*.lua 2>/dev/null || true)
if [[ -n "$SECRET_PATTERNS" ]]; then
echo "FAIL: Possible hardcoded secret in: $SECRET_PATTERNS"
EXIT_CODE=1
fi
exit $EXIT_CODE
localization:
name: Localization
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Verify locale parity and L[] references
run: |
EXIT_CODE=0
ENUS=Locales/enUS.lua
if [[ ! -f "$ENUS" ]]; then echo "FAIL: $ENUS missing"; exit 1; fi
keys() { grep -oP '^L\["\K[^"]+' "$1" | sort -u; }
# 1. Every locale file carries the exact enUS key set (no missing, no stray).
ENUS_KEYS="$(keys "$ENUS")"
for f in Locales/*.lua; do
[[ "$f" == "$ENUS" || "$f" == "Locales/Localization.lua" ]] && continue
DIFF="$(comm -3 <(echo "$ENUS_KEYS") <(keys "$f"))"
if [[ -n "$DIFF" ]]; then
echo "FAIL: $f key set differs from enUS (< missing in $f, > stray in $f):"
echo "$DIFF"
EXIT_CODE=1
fi
done
# 2. Every L["KEY"] referenced in shipped code is defined in enUS.lua.
# Locale files (definitions) are excluded; dynamic L[var] lookups
# don't match L["..."] and are intentionally not checked.
USED="$(grep -rhoP 'L\["\K[^"]+' --include='*.lua' --exclude-dir=Locales --exclude-dir=dev . | sort -u || true)"
while IFS= read -r k; do
[[ -z "$k" ]] && continue
if ! grep -qxF "$k" <(echo "$ENUS_KEYS"); then
echo "FAIL: L[\"$k\"] used in code but not defined in enUS.lua"
EXIT_CODE=1
fi
done <<< "$USED"
if [[ $EXIT_CODE -eq 0 ]]; then echo "Localization OK: all locales match enUS and all L[] keys are defined."; fi
exit $EXIT_CODE