-
Notifications
You must be signed in to change notification settings - Fork 119
40 lines (36 loc) · 1.8 KB
/
Copy pathno-eval-in-source.yml
File metadata and controls
40 lines (36 loc) · 1.8 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
name: "No #eval in source files"
on: [pull_request, merge_group]
jobs:
check-no-eval:
name: "Check no #eval in source files"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
- name: Check for #eval in source files
run: |
# Find #eval statements in module source files (excluding tests and test-projects)
# Non-module files are allowed to have #eval since their private/scoped definitions
# cannot be tested externally, and there's no phase issue with builds.
OFFENDING_FILES=()
while IFS= read -r -d '' file; do
# Check if file contains #eval
if grep -qE '^[[:space:]]*#eval([[:space:]]|$)' "$file"; then
# Check if file is a module file (has 'module' on its own line)
if grep -q '^module$' "$file"; then
OFFENDING_FILES+=("$file")
fi
fi
done < <(find ./src -path ./src/tests -prune -o \
-path ./src/test-projects -prune -o \
-path ./src/errata-tests -prune -o \
-name "*.lean" -type f -print0)
if [ ${#OFFENDING_FILES[@]} -gt 0 ]; then
echo "Found #eval statements in module source files (should be in src/tests/ or src/errata-tests/):"
printf '%s\n' "${OFFENDING_FILES[@]}"
echo ""
echo "Offending lines:"
grep -nE '^[[:space:]]*#eval([[:space:]]|$)' "${OFFENDING_FILES[@]}" || true
exit 1
else
echo "No #eval statements found in module source files."
fi