|
1 | 1 | # Makefile for slack-rs |
2 | 2 |
|
3 | | -.PHONY: build help install release test clean fmt lint check setup pre-commit-hooks bump-patch bump-minor bump-major index publish publish-tag |
| 3 | +.PHONY: build help install release test clean fmt lint check setup pre-commit pre-commit-hooks bump-patch bump-minor bump-major index publish publish-tag |
4 | 4 |
|
5 | 5 | # Default target - build debug version |
6 | 6 | build: |
|
21 | 21 | @echo " make check - Run fmt, lint, and test" |
22 | 22 | @echo " make index - Build Serena symbol index (.serena/cache)" |
23 | 23 | @echo " make setup - Setup development environment" |
| 24 | + @echo " make pre-commit - Run prek on all files" |
24 | 25 | @echo " make pre-commit-hooks - Install git pre-commit hooks" |
25 | 26 | @echo " make bump-patch - Bump patch version (0.1.0 -> 0.1.1) without publish" |
26 | 27 | @echo " make bump-minor - Bump minor version (0.1.0 -> 0.2.0) without publish" |
@@ -79,41 +80,31 @@ setup: pre-commit-hooks |
79 | 80 | @command -v cargo-release >/dev/null 2>&1 || cargo install cargo-release |
80 | 81 | @echo "Development environment setup complete!" |
81 | 82 |
|
| 83 | +# Run prek checks locally (matches CI lint job) |
| 84 | +pre-commit: |
| 85 | + @set -e; \ |
| 86 | + if command -v prek >/dev/null 2>&1; then PREK=prek; \ |
| 87 | + elif [ -x "$$HOME/.local/bin/prek" ]; then PREK="$$HOME/.local/bin/prek"; \ |
| 88 | + else \ |
| 89 | + echo "prek not found. Run 'make pre-commit-hooks' to install it."; \ |
| 90 | + exit 1; \ |
| 91 | + fi; \ |
| 92 | + "$$PREK" run --all-files |
| 93 | + |
82 | 94 | # Install pre-commit hooks |
83 | 95 | pre-commit-hooks: |
84 | | - @echo "Installing pre-commit hooks..." |
85 | | - @mkdir -p .git/hooks |
86 | | - @printf '%s\n' \ |
87 | | - '#!/bin/bash' \ |
88 | | - 'set -e' \ |
89 | | - '' \ |
90 | | - 'echo "Running pre-commit checks..."' \ |
91 | | - '' \ |
92 | | - '# Check formatting' \ |
93 | | - 'echo "Checking code formatting..."' \ |
94 | | - 'if ! cargo fmt -- --check; then' \ |
95 | | - ' echo "❌ Code formatting check failed. Run '\''cargo fmt'\'' to fix."' \ |
96 | | - ' exit 1' \ |
97 | | - 'fi' \ |
98 | | - '' \ |
99 | | - '# Run clippy' \ |
100 | | - 'echo "Running clippy..."' \ |
101 | | - 'if ! cargo clippy -- -D warnings; then' \ |
102 | | - ' echo "❌ Clippy check failed. Fix the warnings above."' \ |
103 | | - ' exit 1' \ |
104 | | - 'fi' \ |
105 | | - '' \ |
106 | | - '# Run tests' \ |
107 | | - 'echo "Running tests..."' \ |
108 | | - 'if ! cargo test --quiet; then' \ |
109 | | - ' echo "❌ Tests failed. Fix the failing tests."' \ |
110 | | - ' exit 1' \ |
111 | | - 'fi' \ |
112 | | - '' \ |
113 | | - 'echo "✅ All pre-commit checks passed!"' \ |
114 | | - > .git/hooks/pre-commit |
115 | | - @chmod +x .git/hooks/pre-commit |
116 | | - @echo "Pre-commit hooks installed successfully!" |
| 96 | + @set -e; \ |
| 97 | + echo "Installing pre-commit hooks (prek)..."; \ |
| 98 | + if command -v prek >/dev/null 2>&1; then PREK=prek; \ |
| 99 | + elif [ -x "$$HOME/.local/bin/prek" ]; then PREK="$$HOME/.local/bin/prek"; \ |
| 100 | + else \ |
| 101 | + echo "prek not found. Installing to $$HOME/.local/bin..."; \ |
| 102 | + mkdir -p "$$HOME/.local/bin"; \ |
| 103 | + curl -LsSf https://github.com/j178/prek/releases/latest/download/prek-installer.sh | sh; \ |
| 104 | + PREK="$$HOME/.local/bin/prek"; \ |
| 105 | + fi; \ |
| 106 | + "$$PREK" install --overwrite --hook-type pre-commit; \ |
| 107 | + echo "Pre-commit hook installed. Run 'make pre-commit' to verify." |
117 | 108 |
|
118 | 109 | # Bump patch version (0.1.0 -> 0.1.1) and create git tag (no publish) |
119 | 110 | bump-patch: |
|
0 commit comments