Skip to content

ci: add bash script to check if llama-impl.h was included erroneously #11617

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions .github/workflows/precompile-checks.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: Precompile Checks

on:
push:
branches:
- master
paths: ['**/*.c', '**/*.cpp']
pull_request:
types: [opened, synchronize, reopened]
paths: ['**/*.c', '**/*.cpp']

jobs:
precompile-check:
runs-on: ubuntu-latest

steps:
- name: Checkout Repository
uses: actions/checkout@v4

- name: Run Forbidden Includes Check
run: bash scripts/precompile-checks.sh
33 changes: 33 additions & 0 deletions scripts/precompile-checks.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#!/bin/bash

# This runs some pre compilation sanity checks that certain project rules and guidelines are kept
# This will not contain any signifiant logic, but mostly just obvious and easily greppable checks

ERROR_FOUND=0


## START OF INCLUDES EXCLUDED FROM EXAMPLES FOLDER ##
SRC_DIR="./examples"
FORBIDDEN_HEADERS=("llama-impl.h")
echo "🔍 Scanning for forbidden includes in $SRC_DIR..."
for HEADER in "${FORBIDDEN_HEADERS[@]}"; do
MATCHES=$(grep -rn --include=\*.{c,cpp} "#include \"$HEADER\"" "$SRC_DIR" 2>/dev/null)

if [[ -n "$MATCHES" ]]; then
echo "❌ Forbidden include detected: $HEADER"
echo "$MATCHES" | while IFS=: read -r FILE LINE _; do
echo "::error file=$FILE,line=$LINE::Forbidden include: $HEADER in $FILE at line $LINE"
done
ERROR_FOUND=1
fi

done
## END OF INCLUDES EXCLUDED FROM EXAMPLES FOLDER ##


if [[ "$ERROR_FOUND" -eq 1 ]]; then
echo "❌ Forbidden includes found. Please remove!"
exit 1
else
echo "✅ No forbidden includes found."
fi