Skip to content

Commit b0d4777

Browse files
intel352claude
andcommitted
feat: add pre-push hook for example config validation
Validates all example/*.yaml configs with wfctl before each push. Also unignores scripts/pre-push in .gitignore (extensionless scripts). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent d41d097 commit b0d4777

2 files changed

Lines changed: 47 additions & 0 deletions

File tree

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
!*/
2121
!Dockerfile
2222
!Makefile
23+
!scripts/pre-push
2324

2425
# Dependency directories (remove the comment below to include it)
2526
# vendor/

scripts/pre-push

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
#!/usr/bin/env bash
2+
# Pre-push hook: validate all example configs before pushing.
3+
set -euo pipefail
4+
5+
echo "=== Pre-push config validation ==="
6+
7+
REPO_ROOT="$(git rev-parse --show-toplevel)"
8+
WFCTL="$REPO_ROOT/bin/wfctl"
9+
10+
# Build wfctl if not present
11+
if [ ! -f "$WFCTL" ]; then
12+
echo "Building wfctl..."
13+
(cd "$REPO_ROOT" && go build -o bin/wfctl ./cmd/wfctl)
14+
fi
15+
16+
PASSED=0
17+
FAILED=0
18+
TOTAL=0
19+
20+
# Schema validation on all example configs
21+
echo ""
22+
echo "--- Schema validation ---"
23+
for config in $(find "$REPO_ROOT/example" -name "*.yaml" \
24+
-not -path "*/configs/*" -not -path "*/seed/*" -not -path "*/observability/*" \
25+
-not -path "*/spa/*" -not -path "*/components/*" -not -path "*/node_modules/*" \
26+
-not -path "*/e2e/*" -not -path "*/data/*" -not -path "*/.*" \
27+
-not -name "docker-compose.yaml" -not -name "docker-compose.yml" | sort); do
28+
TOTAL=$((TOTAL + 1))
29+
name=$(basename "$(dirname "$config")")/$(basename "$config")
30+
if "$WFCTL" validate -skip-unknown-types "$config" 2>/dev/null; then
31+
PASSED=$((PASSED + 1))
32+
else
33+
echo " FAIL: $name"
34+
FAILED=$((FAILED + 1))
35+
fi
36+
done
37+
38+
echo ""
39+
echo "Validation: $PASSED/$TOTAL passed, $FAILED failed"
40+
41+
if [ "$FAILED" -gt 0 ]; then
42+
echo "ERROR: Config validation failed. Fix the above configs before pushing."
43+
exit 1
44+
fi
45+
46+
echo "All configs valid. Push allowed."

0 commit comments

Comments
 (0)