Skip to content

Commit 4033365

Browse files
committed
ci: add bash script to check if llama-impl.h was included in example folder erronously
1 parent d92cb67 commit 4033365

File tree

3 files changed

+59
-1
lines changed

3 files changed

+59
-1
lines changed
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
name: Precompile Checks
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
paths: ['**/*.c', '**/*.cpp']
8+
pull_request:
9+
types: [opened, synchronize, reopened]
10+
paths: ['**/*.c', '**/*.cpp']
11+
12+
jobs:
13+
precompile-check:
14+
runs-on: ubuntu-latest
15+
16+
steps:
17+
- name: Checkout Repository
18+
uses: actions/checkout@v4
19+
20+
- name: Run Forbidden Includes Check
21+
run: bash scripts/precompile-checks.sh

Makefile

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ ifdef GGML_VULKAN
211211
BUILD_TARGETS += vulkan-shaders-gen
212212
endif
213213

214-
default: $(BUILD_TARGETS) $(LEGACY_TARGETS_BUILD)
214+
default: precompile_checks $(BUILD_TARGETS) $(LEGACY_TARGETS_BUILD)
215215

216216
test: $(TEST_TARGETS)
217217
@failures=0; \
@@ -248,6 +248,10 @@ test: $(TEST_TARGETS)
248248

249249
all: $(BUILD_TARGETS) $(TEST_TARGETS) $(LEGACY_TARGETS_BUILD)
250250

251+
# Run the forbidden includes check before every build
252+
precompile_checks:
253+
@bash ./scripts/precompile-checks.sh
254+
251255
ifdef RISCV_CROSS_COMPILE
252256
CC := riscv64-unknown-linux-gnu-gcc
253257
CXX := riscv64-unknown-linux-gnu-g++

scripts/precompile-checks.sh

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#!/bin/bash
2+
3+
# This runs some pre compilation sanity checks that certain project rules and guidelines are kept
4+
# This will not contain any signifiant logic, but mostly just obvious and easily greppable checks
5+
6+
ERROR_FOUND=0
7+
8+
9+
## START OF INCLUDES EXCLUDED FROM EXAMPLES FOLDER ##
10+
SRC_DIR="./examples"
11+
FORBIDDEN_HEADERS=("llama-impl.h")
12+
echo "🔍 Scanning for forbidden includes in $SRC_DIR..."
13+
for HEADER in "${FORBIDDEN_HEADERS[@]}"; do
14+
MATCHES=$(grep -rn --include=\*.{c,cpp} "#include \"$HEADER\"" "$SRC_DIR" 2>/dev/null)
15+
16+
if [[ -n "$MATCHES" ]]; then
17+
echo "❌ Forbidden include detected: $HEADER"
18+
echo "$MATCHES" | while IFS=: read -r FILE LINE _; do
19+
echo "::error file=$FILE,line=$LINE::Forbidden include: $HEADER in $FILE at line $LINE"
20+
done
21+
ERROR_FOUND=1
22+
fi
23+
24+
done
25+
## END OF INCLUDES EXCLUDED FROM EXAMPLES FOLDER ##
26+
27+
28+
if [[ "$ERROR_FOUND" -eq 1 ]]; then
29+
echo "❌ Forbidden includes found. Please remove!"
30+
exit 1
31+
else
32+
echo "✅ No forbidden includes found."
33+
fi

0 commit comments

Comments
 (0)