diff --git a/Makefile b/Makefile index 843ed8efb..6658e2e5f 100644 --- a/Makefile +++ b/Makefile @@ -2,7 +2,9 @@ GODOT := $(shell command -v godot4 2>/dev/null || command -v godot 2>/dev/null) .PHONY: help setup build client server game stop test lint ci ci-client ci-server clean \ decisions-sync decisions-coverage decisions-active decisions-orphan \ - db-backup db-install validate-content content-ron check-fact-ids setup-hooks + db-backup db-install validate-content content-ron check-fact-ids setup-hooks \ + pre-pr pre-pr-lint pre-pr-build pre-pr-test pre-pr-validate pre-pr-fixtures \ + pre-pr-server pre-pr-client pre-pr-content # --- Configuration --- @@ -36,6 +38,11 @@ help: @echo " make check-fact-ids Check fact_id references against knowledge catalogs" @echo " make content-ron Convert content YAML to RON (build-time)" @echo "" + @echo " make pre-pr Run all pre-PR checks (lint, build, test, validate, fixtures)" + @echo " make pre-pr-server Server-scoped pre-PR (lint, build, test, fixtures)" + @echo " make pre-pr-client Client-scoped pre-PR (lint, build, test)" + @echo " make pre-pr-content Content-scoped pre-PR (schema + cross-ref validation)" + @echo "" @echo " make setup-hooks Install pre-commit hooks (included in setup)" @echo "" @echo " GODOT_VERSION=4.6 make setup Override Godot version" @@ -121,6 +128,54 @@ lint-client: @echo "Checking GDScript for errors..." @$(GODOT) --headless --path client --quit 2>&1 | grep -i "SCRIPT ERROR" && { echo "GDScript errors found"; exit 1; } || echo "No script errors found" +# --- Pre-PR verification --- + +pre-pr: pre-pr-lint pre-pr-build pre-pr-test pre-pr-validate pre-pr-fixtures + @echo "" + @echo "=== PRE-PR: ALL CHECKS PASSED ===" + @echo "Safe to create PR." + +pre-pr-lint: lint-server lint-client + @echo "--- Lint: PASS ---" + +pre-pr-build: build-server build-client + @echo "--- Build: PASS ---" + +pre-pr-test: test-server test-client + @echo "--- Tests: PASS ---" + +pre-pr-validate: validate-content check-fact-ids + @echo "--- Content validation: PASS ---" + +pre-pr-fixtures: + @echo "Checking fixture staleness..." + @cd server && cargo test --test gen_fixtures -- --ignored 2>/dev/null + @if git diff --quiet client/tests/fixtures/; then \ + echo "--- Fixtures: UP TO DATE ---"; \ + else \ + echo ""; \ + echo "--- FIXTURES STALE ---"; \ + echo " Protocol changed but fixtures not regenerated."; \ + echo " Stale fixtures make all client tests FALSE POSITIVES."; \ + echo ""; \ + echo " Changed files:"; \ + git diff --stat client/tests/fixtures/; \ + echo ""; \ + echo " Fix: commit the updated fixtures with your protocol change."; \ + exit 1; \ + fi + +# Branch-specific variants (faster, scope-appropriate) + +pre-pr-server: lint-server build-server test-server pre-pr-fixtures + @echo "=== Server pre-PR: PASSED ===" + +pre-pr-client: lint-client build-client test-client + @echo "=== Client pre-PR: PASSED ===" + +pre-pr-content: validate-content check-fact-ids + @echo "=== Content pre-PR: PASSED ===" + # --- CI (run locally) --- ci: ci-server ci-client diff --git a/docs/DEVOPS.md b/docs/DEVOPS.md index 8d6c3a0ae..550fc97c9 100644 --- a/docs/DEVOPS.md +++ b/docs/DEVOPS.md @@ -89,6 +89,34 @@ make ci-client # lint-client → build-client → test-client CI targets chain lint → build → test sequentially. A failure in any stage stops the pipeline. +### Pre-PR Checks + +Before pushing a PR, run: + +```bash +make pre-pr +``` + +This runs all checks in order: lint → build → test → content validation → fixture staleness. Total runtime ~2.5 minutes (incremental build), under 3 minutes clean. + +For branch-specific checks: + +```bash +make pre-pr-server # Server changes: lint, build, test, fixture staleness +make pre-pr-client # Client changes: lint, build, test +make pre-pr-content # Content changes: schema + cross-reference validation +``` + +If `pre-pr-fixtures` fails, your protocol changes require fixture regeneration: + +```bash +make fixtures +git add client/tests/fixtures/ +git commit -m "chore(fixtures): regenerate for protocol vN" +``` + +The fixture staleness check is a **blocker** (exit 1) — stale fixtures cause false positive client tests. + ### Clean ```bash