Skip to content

Commit 54a37af

Browse files
committed
test hooks
1 parent 1a44dd1 commit 54a37af

6 files changed

Lines changed: 52 additions & 40 deletions

File tree

.githooks/pre-push

Lines changed: 29 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4,36 +4,49 @@
44
REPO_ROOT="$(git rev-parse --show-toplevel)"
55
GITHOOKS_DIR="$REPO_ROOT/.githooks"
66

7-
# Check for changes in Python files
8-
python_changed_files=($(git diff --name-only --diff-filter=ACM | grep '^python/' || true))
9-
10-
echo "Changed Python files:"
11-
echo " ${python_changed_files[*]}"
7+
echo "========================================"
8+
echo " Pre-Push Checks"
9+
echo "========================================"
1210
echo
1311

12+
# Check for changes in Python files
13+
# Compare against the remote branch being pushed to
14+
python_changed_files=($(git diff --name-only --diff-filter=ACM @{upstream}... | grep '^python/' || true))
15+
16+
echo "→ Python files changed:"
1417
if [[ -n "$python_changed_files" ]]; then
15-
echo "Python files changed, running Python formatting and linting..."
18+
echo " ${python_changed_files[*]}"
19+
echo
20+
echo " [1/3] Formatting and linting..."
1621
bash "$GITHOOKS_DIR/pre-push-python/fmt-lint.sh"
1722

18-
echo "Running Python stub checks..."
23+
echo " [2/3] Stub generation..."
1924
bash "$GITHOOKS_DIR/pre-push-python/stubs.sh"
2025

21-
echo "Running Python extras checks..."
26+
echo " [3/3] Extras validation..."
2227
bash "$GITHOOKS_DIR/pre-push-python/extras.sh"
28+
echo
29+
else
30+
echo " (none)"
31+
echo
2332
fi
2433

2534
# Check for changes in Rust bindings files
26-
bindings_changed_files=($(git diff --name-only --diff-filter=ACM | grep '^rust/crates/sift_stream_bindings/src/' || true))
27-
28-
echo
29-
echo "Changed SiftStream Python bindings files:"
30-
echo " ${bindings_changed_files[*]}"
31-
echo
35+
bindings_changed_files=($(git diff --name-only --diff-filter=ACM @{upstream}... | grep '^rust/crates/sift_stream_bindings/src/' || true))
3236

37+
echo "→ Rust binding files changed:"
3338
if [[ -n "$bindings_changed_files" ]]; then
34-
echo "Rust bindings files changed, running Rust stub checks..."
39+
echo " ${bindings_changed_files[*]}"
40+
echo
41+
echo " [1/1] Stub generation..."
3542
bash "$GITHOOKS_DIR/pre-push-rust/stubs.sh"
43+
echo
44+
else
45+
echo " (none)"
46+
echo
3647
fi
3748

38-
echo "Pre-push checks completed successfully."
49+
echo "========================================"
50+
echo " ✓ All checks passed"
51+
echo "========================================"
3952

.githooks/pre-push-python/extras.sh

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,19 +11,20 @@ check_extras_changes() {
1111
local changed_files=$(git status --porcelain "$target_path" || true)
1212

1313
if [ -n "$changed_files" ]; then
14-
echo "❌ ERROR: Generated pyproject.toml extras are not up-to-date. Please commit the changed files:"
15-
echo "$changed_files"
14+
echo " ✗ ERROR: Generated extras are not up-to-date:"
15+
echo "$changed_files" | sed 's/^/ /'
16+
echo " Please commit these changes before pushing."
1617
exit 1
1718
fi
1819
}
1920

2021
# Function to generate Python extras
2122
generate_python_extras() {
22-
echo "Generating Python extras..."
23+
echo " → Generating extras..."
2324
cd "$PYTHON_DIR"
2425

2526
if [[ ! -d "$PYTHON_DIR/venv" ]]; then
26-
echo "Running bootstrap script..."
27+
echo "Running bootstrap script..."
2728
bash ./scripts/dev bootstrap
2829
fi
2930

@@ -33,4 +34,4 @@ generate_python_extras() {
3334

3435
generate_python_extras
3536

36-
echo "All extras are up-to-date."
37+
echo " ✓ Extras are up-to-date"

.githooks/pre-push-python/fmt-lint.sh

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,15 @@ set -e
66
REPO_ROOT="$(git rev-parse --show-toplevel)"
77
PYTHON_DIR="$REPO_ROOT/python"
88

9-
echo "Running Python formatting and linting with --fix..."
10-
119
# Change to Python directory
1210
cd "$PYTHON_DIR"
1311

1412
# Run ruff format (formatter)
15-
echo "Running ruff format..."
13+
echo "Running ruff format..."
1614
bash ./scripts/dev fmt
1715

1816
# Run ruff check with --fix (linter)
19-
echo "Running ruff check --fix..."
17+
echo "Running ruff check --fix..."
2018
bash ./scripts/dev lint-fix
2119

2220
# Check if any files were modified by formatting/linting
@@ -25,11 +23,11 @@ changed_files=$(git status --porcelain python/lib/sift_client/ | grep -E '\.py$'
2523

2624
if [ -n "$changed_files" ]; then
2725
echo ""
28-
echo "ERROR: Formatting/linting made changes to the following files:"
29-
echo "$changed_files"
26+
echo "ERROR: Formatting/linting made changes:"
27+
echo "$changed_files" | sed 's/^/ /'
3028
echo ""
31-
echo "Please commit these changes before pushing."
29+
echo " Please commit these changes before pushing."
3230
exit 1
3331
fi
3432

35-
echo "Python formatting and linting completed successfully."
33+
echo " ✓ Formatting and linting passed"

.githooks/pre-push-python/stubs.sh

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,19 +11,20 @@ check_stub_changes() {
1111
local changed_files=$(git status --porcelain "$target_path" | grep -E '\.pyi$' || true)
1212

1313
if [ -n "$changed_files" ]; then
14-
echo "❌ ERROR: Generated python stubs are not up-to-date. Please commit the changed files:"
15-
echo "$changed_files"
14+
echo " ✗ ERROR: Generated stubs are not up-to-date:"
15+
echo "$changed_files" | sed 's/^/ /'
16+
echo " Please commit these changes before pushing."
1617
exit 1
1718
fi
1819
}
1920

2021
# Function to generate Python stubs
2122
generate_python_stubs() {
22-
echo "Generating Python stubs..."
23+
echo " → Generating stubs..."
2324
cd "$PYTHON_DIR"
2425

2526
if [[ ! -d "$PYTHON_DIR/venv" ]]; then
26-
echo "Running bootstrap script..."
27+
echo "Running bootstrap script..."
2728
bash ./scripts/dev bootstrap
2829
fi
2930

@@ -33,4 +34,4 @@ generate_python_stubs() {
3334

3435
generate_python_stubs
3536

36-
echo "All stubs are up-to-date."
37+
echo " ✓ Stubs are up-to-date"

.githooks/pre-push-rust/stubs.sh

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,16 @@ check_stub_changes() {
1010
local changed_files=$(git status --porcelain "$target_path" | grep -E '\.pyi$' || true)
1111

1212
if [ -n "$changed_files" ]; then
13-
echo "ERROR: Generated python stubs are not up-to-date. Please commit the changed files:"
14-
echo "$changed_files"
13+
echo " ✗ ERROR: Generated stubs are not up-to-date:"
14+
echo "$changed_files" | sed 's/^/ /'
15+
echo " Please commit these changes before pushing."
1516
exit 1
1617
fi
1718
}
1819

1920
# Function to generate bindings stubs
2021
generate_bindings_stubs() {
21-
echo "Generating bindings stubs..."
22+
echo " → Generating stubs..."
2223
cd "$BINDINGS_DIR"
2324
cargo run --bin stub_gen
2425

@@ -29,4 +30,4 @@ generate_bindings_stubs() {
2930

3031
generate_bindings_stubs
3132

32-
echo "All stubs are up-to-date."
33+
echo " ✓ Stubs are up-to-date"

python/pyproject.toml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,8 +119,6 @@ development = [
119119
'tomlkit~=0.13.3',
120120
]
121121

122-
123-
124122
docs = [
125123
'griffe-pydantic',
126124
'mike',

0 commit comments

Comments
 (0)