Skip to content

Commit 047ab0d

Browse files
authored
ci: add proto freshness check to pre-push hook (koala73#1594)
Mirror the CI proto-check workflow locally so stale generated code is caught before push, not after. Only triggers when proto-related files changed. Gracefully skips if buf/plugins are not installed.
1 parent 259cbd1 commit 047ab0d

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

.husky/pre-push

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,5 +34,36 @@ npm run lint:md || exit 1
3434
echo "Running MDX lint (Mintlify compatibility)..."
3535
node --test tests/mdx-lint.test.mjs || exit 1
3636

37+
echo "Running proto freshness check..."
38+
if git diff --name-only origin/main -- proto/ src/generated/ docs/api/ Makefile | grep -q .; then
39+
if command -v buf &>/dev/null && command -v protoc-gen-ts-client &>/dev/null; then
40+
make generate
41+
if ! git diff --exit-code src/generated/ docs/api/; then
42+
echo ""
43+
echo "============================================================"
44+
echo "ERROR: Proto-generated code is out of date."
45+
echo "Run 'make generate' locally and commit the updated files."
46+
echo "============================================================"
47+
exit 1
48+
fi
49+
UNTRACKED=$(git ls-files --others --exclude-standard src/generated/ docs/api/)
50+
if [ -n "$UNTRACKED" ]; then
51+
echo ""
52+
echo "============================================================"
53+
echo "ERROR: Untracked generated files found:"
54+
echo "$UNTRACKED"
55+
echo "Run 'make generate' locally and commit the new files."
56+
echo "============================================================"
57+
exit 1
58+
fi
59+
echo "Proto-generated code is up to date."
60+
else
61+
echo "WARNING: buf or protoc plugins not installed, skipping proto freshness check."
62+
echo " Install with: make install-buf install-plugins"
63+
fi
64+
else
65+
echo "No proto-related changes, skipping."
66+
fi
67+
3768
echo "Running version sync check..."
3869
npm run version:check || exit 1

0 commit comments

Comments
 (0)