-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathlint.sh
More file actions
executable file
·61 lines (53 loc) · 1.5 KB
/
Copy pathlint.sh
File metadata and controls
executable file
·61 lines (53 loc) · 1.5 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
#!/bin/bash
set -e
cd "$(dirname "$0")"
FIX=0
if [ "$1" = "--fix" ]; then
FIX=1
fi
FAILED=0
echo "=== Python (ruff) ==="
if [ "$FIX" = "1" ]; then
uv run ruff check --fix . && uv run ruff format . || FAILED=1
else
uv run ruff check . && uv run ruff format --check . || FAILED=1
fi
echo ""
echo "=== C++ (clang-format) ==="
CPP_FILES=$(find bench -name '*.cpp' -o -name '*.h' | sort)
if [ "$FIX" = "1" ]; then
echo "$CPP_FILES" | xargs clang-format -i && echo "Formatted." || FAILED=1
else
echo "$CPP_FILES" | xargs clang-format --dry-run --Werror 2>&1 && echo "OK" || FAILED=1
fi
echo ""
echo "=== Bazel (buildifier) ==="
BZL_FILES=$(find bench -name 'BUILD.bazel' -o -name '*.bzl' | sort)
if [ "$FIX" = "1" ]; then
echo "$BZL_FILES" | xargs buildifier && echo "Formatted." || FAILED=1
else
echo "$BZL_FILES" | xargs buildifier --mode=check 2>&1 && echo "OK" || FAILED=1
fi
echo ""
echo "=== Zig (zig fmt) ==="
ZIG_BIN=$(find ~/.cache/bazel -name "zig" -type f -executable -path "*zig_0.14*" 2>/dev/null | head -1)
if [ -z "$ZIG_BIN" ]; then
ZIG_BIN="zig"
fi
ZIG_FILES=$(find bench -name '*.zig' | sort)
if [ -n "$ZIG_FILES" ]; then
if [ "$FIX" = "1" ]; then
echo "$ZIG_FILES" | xargs "$ZIG_BIN" fmt && echo "Formatted." || FAILED=1
else
echo "$ZIG_FILES" | xargs "$ZIG_BIN" fmt --check 2>&1 && echo "OK" || FAILED=1
fi
else
echo "No Zig files found."
fi
echo ""
if [ "$FAILED" = "1" ]; then
echo "LINT FAILED. Run './lint.sh --fix' to auto-fix."
exit 1
else
echo "All checks passed."
fi