-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathMakefile
More file actions
117 lines (100 loc) · 3.03 KB
/
Makefile
File metadata and controls
117 lines (100 loc) · 3.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
.PHONY: help build run test clean fmt lint check run-guidelines watch install lint-test-naming
# Default target
help:
@echo "Available targets:"
@echo " build - Build the project"
@echo " run - Run the project"
@echo " test - Run tests"
@echo " clean - Clean build artifacts"
@echo " fmt - Format code with rustfmt"
@echo " lint - Run clippy linter"
@echo " lint-test-naming - Check test file naming convention"
@echo " check - Run fmt + lint + test"
@echo " run-guidelines - Run complete validation (fmt + lint + build + test)"
@echo " watch - Watch and rebuild on changes"
@echo " install - Install the binary"
# Build the project
build:
cargo build
# Build in release mode
release:
cargo build --release
# Run the project
run:
cargo run
# Run tests
test:
cargo test
# Run tests with output
test-verbose:
cargo test -- --nocapture
# Clean build artifacts
clean:
cargo clean
# Format code
fmt:
cargo fmt
# Check formatting without applying
fmt-check:
cargo fmt -- --check
# Run clippy linter
lint:
cargo clippy --all-targets --all-features -- -D warnings
# Run all checks (format, lint, test)
check: fmt-check lint test
# Run complete validation pipeline (format, lint, build, test)
run-guidelines: lint-test-naming
@echo "=== Running Complete Validation Pipeline ==="
@echo ""
@echo "Step 1/3: Formatting code..."
@cargo fmt
@echo "✓ Code formatted"
@echo ""
@echo "Step 2/3: Running linter (includes build)..."
@cargo clippy --all-targets -- -D warnings
@echo "✓ Linting passed"
@echo ""
@echo "Step 3/3: Running tests..."
@cargo test --lib -- --test-threads=4
@cargo test --test '*' -- --test-threads=4
@cargo test --doc
@echo ""
@echo "=== ✓ All guidelines passed! ==="
# Fast check - just clippy + lib tests (skip integration/doc tests)
run-guidelines-fast:
@echo "=== Fast Validation ==="
@cargo fmt
@cargo clippy --all-targets -- -D warnings
@cargo test --lib -- --test-threads=4
@echo "=== ✓ Fast check passed! ==="
# Super fast - clippy + unit tests only
run-guidelines-quick:
@echo "=== Quick Validation ==="
@cargo fmt
@cargo clippy --all-targets -- -D warnings
@cargo test --lib -- --test-threads=4
@echo "=== ✓ Quick check passed! ==="
# Watch for changes and rebuild
watch:
cargo watch -x build
# Install the binary
install:
cargo install --path crates/mother-cli
# Lint test file naming convention
# - Test files must be in tests/ directories
# - Test files must have tests_ prefix
lint-test-naming:
@echo "Checking test file naming conventions..."
@errors=0; \
bad_pattern=$$(find crates -name "*_test.rs" -o -name "test_*.rs" 2>/dev/null | grep -v target); \
if [ -n "$$bad_pattern" ]; then \
echo "❌ Found test files with old naming pattern (*_test.rs or test_*.rs):"; \
echo "$$bad_pattern" | sed 's/^/ - /'; \
errors=1; \
fi; \
if [ $$errors -eq 1 ]; then \
echo ""; \
echo "Test files should follow the pattern: tests_<name>.rs"; \
exit 1; \
fi; \
echo "✓ Test naming conventions OK"