chore(ci): add ruff to pre-push hook and Makefile
Add Python/ruff block to .config/hooks/pre-push (runs on tooling/ changes). Add lint-python and setup-venv Makefile targets, wire both into make lint and make setup respectively. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -14,10 +14,12 @@ REMOTE_REF="origin/$BRANCH"
|
||||
if git rev-parse --verify "$REMOTE_REF" >/dev/null 2>&1; then
|
||||
CLIENT_CHANGED=$(git diff --name-only "$REMOTE_REF"..HEAD -- client/ 2>/dev/null | wc -l)
|
||||
SERVER_CHANGED=$(git diff --name-only "$REMOTE_REF"..HEAD -- server/ 2>/dev/null | wc -l)
|
||||
TOOLING_CHANGED=$(git diff --name-only "$REMOTE_REF"..HEAD -- tooling/ pyproject.toml 2>/dev/null | wc -l)
|
||||
else
|
||||
# New branch or no remote ref — fall through to directory checks
|
||||
CLIENT_CHANGED=1
|
||||
SERVER_CHANGED=1
|
||||
TOOLING_CHANGED=1
|
||||
fi
|
||||
|
||||
# --- GDScript parse check (headless Godot) ---
|
||||
@@ -97,6 +99,20 @@ else
|
||||
echo "pre-push: WARNING — cargo not found or server/ missing, skipping Rust lint"
|
||||
fi
|
||||
|
||||
# --- Python lint (ruff) ---
|
||||
if [ "$TOOLING_CHANGED" -eq 0 ]; then
|
||||
echo "pre-push: no tooling/ changes — skipping Python lint"
|
||||
elif command -v ruff >/dev/null 2>&1 && [ -d "$REPO_ROOT/tooling" ]; then
|
||||
echo "pre-push: checking Python (ruff)..."
|
||||
if ! (cd "$REPO_ROOT" && ruff check tooling/ 2>&1); then
|
||||
ERRORS=$((ERRORS + 1))
|
||||
else
|
||||
echo "pre-push: ruff — OK"
|
||||
fi
|
||||
else
|
||||
echo "pre-push: skipping Python lint (ruff not found — install with: pip install 'ruff>=0.9')"
|
||||
fi
|
||||
|
||||
if [ "$ERRORS" -gt 0 ]; then
|
||||
echo ""
|
||||
echo "pre-push: $ERRORS check(s) failed. Push aborted."
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
GODOT := $(shell command -v godot4 2>/dev/null || command -v godot 2>/dev/null)
|
||||
|
||||
.PHONY: help setup build check-protocol client server game stop test lint ci ci-client ci-server clean \
|
||||
.PHONY: help setup build check-protocol client server game stop test lint lint-python setup-venv ci ci-client ci-server clean \
|
||||
decisions-sync decisions-coverage decisions-active decisions-orphan \
|
||||
db-backup db-install validate-content check-fact-ids setup-hooks \
|
||||
audit atlas-verify \
|
||||
@@ -22,7 +22,8 @@ GODOT_VERSION ?= 4.6
|
||||
help:
|
||||
@echo "The Settled Reach — Development Commands"
|
||||
@echo ""
|
||||
@echo " make setup Install dev dependencies (Rust, Godot, tooling)"
|
||||
@echo " make setup Install dev dependencies (Rust, Godot, tooling, venv)"
|
||||
@echo " make setup-venv Create .venv and install Python tooling deps"
|
||||
@echo " make build Build client and server"
|
||||
@echo " make game Build and run the full game (server + client)"
|
||||
@echo " make stop Stop any running server instance"
|
||||
@@ -33,7 +34,8 @@ help:
|
||||
@echo " make test-ipc-protocol Layer 2: mock IPC protocol tests"
|
||||
@echo " make test-ipc-integration Layer 3: real subprocess round-trip"
|
||||
@echo " make test-ipc-benchmark IPC latency benchmark (blocked: #555/#556)"
|
||||
@echo " make lint Run all linters"
|
||||
@echo " make lint Run all linters (server, client, python)"
|
||||
@echo " make lint-python Run ruff on tooling/"
|
||||
@echo " make ci Run full CI pipeline locally"
|
||||
@echo " make ci-client Run client CI checks"
|
||||
@echo " make ci-server Run server CI checks"
|
||||
@@ -82,7 +84,7 @@ help:
|
||||
|
||||
# --- Setup ---
|
||||
|
||||
setup: setup-rust setup-godot setup-tooling setup-hooks decisions-sync
|
||||
setup: setup-rust setup-godot setup-tooling setup-venv setup-hooks decisions-sync
|
||||
@echo "Dev environment ready."
|
||||
|
||||
setup-rust:
|
||||
@@ -103,6 +105,11 @@ setup-hooks:
|
||||
@git config core.hooksPath .config/hooks
|
||||
@echo "Git hooks path set to .config/hooks"
|
||||
|
||||
setup-venv:
|
||||
@python3 -m venv .venv
|
||||
@.venv/bin/pip install -e ".[dev]" --quiet
|
||||
@echo "Venv ready at .venv — activate with: source .venv/bin/activate"
|
||||
|
||||
# --- Build ---
|
||||
|
||||
check-protocol:
|
||||
@@ -222,7 +229,10 @@ clean-imports:
|
||||
|
||||
# --- Lint ---
|
||||
|
||||
lint: lint-server lint-client
|
||||
lint: lint-server lint-client lint-python
|
||||
|
||||
lint-python:
|
||||
ruff check tooling/
|
||||
|
||||
lint-server:
|
||||
cd server && cargo clippy -- -D warnings
|
||||
|
||||
Reference in New Issue
Block a user