Skip to content

Commit 1e70e56

Browse files
author
Test User
committed
feat(hooks): add pre-push --all-features cargo check hook Refs #1304
Add scripts/pre-push-check.sh that runs cargo check --workspace --all-features before every push, catching feature-gated compilation breaks on the developer machine before a full CI round-trip. Wire the script into install_native_hooks() in install-hooks.sh so ./scripts/install-hooks.sh installs it as .git/hooks/pre-push. Escape hatch: SKIP_ALL_FEATURES_CHECK=1 git push bypasses the check for WIP pushes to non-main branches. Document the hook in CONTRIBUTING.md and the hook overview summary.
1 parent 3f1ff8a commit 1e70e56

3 files changed

Lines changed: 52 additions & 0 deletions

File tree

CONTRIBUTING.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,8 @@ This installs pre-commit hooks that will:
8282
- Check for secrets and large files
8383
- Ensure consistent code style
8484

85+
It also installs a **pre-push hook** that runs `cargo check --workspace --all-features` before every push, catching feature-gated compilation breaks locally before they reach CI. This saves an 8-15 minute CI round-trip for a compile error. To bypass on a WIP push: `SKIP_ALL_FEATURES_CHECK=1 git push`.
86+
8587
**No Python required!** The script supports multiple hook managers (prek, lefthook, or native Git hooks).
8688

8789
### Commit Standards

scripts/install-hooks.sh

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,14 @@ install_native_hooks() {
7373
else
7474
print_status "WARN" "Native commit-msg hook not found at scripts/hooks/commit-msg"
7575
fi
76+
77+
if [ -f "scripts/pre-push-check.sh" ]; then
78+
cp scripts/pre-push-check.sh .git/hooks/pre-push
79+
chmod +x .git/hooks/pre-push
80+
print_status "SUCCESS" "Installed pre-push --all-features check hook"
81+
else
82+
print_status "WARN" "Pre-push check script not found at scripts/pre-push-check.sh"
83+
fi
7684
}
7785

7886
# Function to setup Biome
@@ -355,6 +363,7 @@ echo " - JavaScript/TypeScript: Biome check"
355363
echo " - Security: Secret detection, large file blocking"
356364
echo " - Syntax: YAML, TOML validation"
357365
echo " - Ultimate Bug Scanner (UBS): AST-based bug detection (if installed)"
366+
echo " - Pre-push: cargo check --workspace --all-features (SKIP_ALL_FEATURES_CHECK=1 to bypass)"
358367
echo ""
359368
print_status "INFO" "Pre-commit/Prek/Lefthook enhancements (if installed):"
360369
echo " ✓ Automatic whitespace fixing (trailing spaces, EOF)"

scripts/pre-push-check.sh

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
#!/bin/bash
2+
#
3+
# Pre-push hook: cargo check --workspace --all-features
4+
#
5+
# Catches --all-features compilation breaks on the developer machine before
6+
# a full CI round-trip is needed. Runs in under 90 seconds on a warm cache.
7+
#
8+
# Escape hatch (for WIP pushes to non-main branches):
9+
# SKIP_ALL_FEATURES_CHECK=1 git push
10+
#
11+
# This hook is installed by scripts/install-hooks.sh as .git/hooks/pre-push
12+
# and works alongside the CI gate added by issue #1295.
13+
#
14+
set -euo pipefail
15+
16+
RED='\033[0;31m'
17+
GREEN='\033[0;32m'
18+
YELLOW='\033[1;33m'
19+
NC='\033[0m'
20+
21+
if [ "${SKIP_ALL_FEATURES_CHECK:-0}" = "1" ]; then
22+
echo -e "${YELLOW}[pre-push] SKIP_ALL_FEATURES_CHECK=1: skipping --all-features check${NC}"
23+
exit 0
24+
fi
25+
26+
echo -e "${GREEN}[pre-push] Running cargo check --workspace --all-features ...${NC}"
27+
echo " (Set SKIP_ALL_FEATURES_CHECK=1 to bypass on WIP branches)"
28+
29+
if cargo check --workspace --all-features 2>&1; then
30+
echo -e "${GREEN}[pre-push] All features check passed.${NC}"
31+
exit 0
32+
else
33+
echo ""
34+
echo -e "${RED}[pre-push] ERROR: cargo check --workspace --all-features failed.${NC}"
35+
echo -e "${RED} Fix the compilation errors above before pushing.${NC}"
36+
echo ""
37+
echo " To bypass (WIP branches only):"
38+
echo " SKIP_ALL_FEATURES_CHECK=1 git push"
39+
echo ""
40+
exit 1
41+
fi

0 commit comments

Comments
 (0)