-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
225 lines (192 loc) · 7.6 KB
/
Makefile
File metadata and controls
225 lines (192 loc) · 7.6 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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
# Odometer Development Makefile
#
# Key targets:
# make install-tools - Install development dependencies
# make ci-local - Local CI with all checks
# make release-validation - Complete release validation
# make fixtures - Generate all test fixtures
# make test - Run unit tests (no fixtures)
# make test-integration - Run integration tests with fixtures
# make test-all - Run all tests
# =============================================================================
# Development Setup
# =============================================================================
.PHONY: install-tools
install-tools:
@echo "Installing development tools..."
@which cargo >/dev/null || (echo "❌ cargo not found. Install Rust: https://rustup.rs/" && exit 1)
@echo "✅ cargo found"
@cargo --version
@which npm >/dev/null || (echo "❌ npm not found. Install Node.js: https://nodejs.org/" && exit 1)
@echo "✅ npm found"
@npm --version
@cargo install cargo-workspaces --force
@echo "✅ Development tools ready"
# =============================================================================
# CI Targets
# =============================================================================
.PHONY: ci
ci:
@echo "🚀 Running comprehensive CI validation..."
$(MAKE) fmt-check
$(MAKE) check
$(MAKE) test-all
@echo "All binaries clippy:"
cargo clippy --all-targets --all-features -- -D warnings
@echo "Publish dry run:"
cargo publish --dry-run --allow-dirty
@echo "✅ CI passed"
.PHONY: ci-local
ci-local: ci
@echo "✅ Local CI passed"
# Release validation - comprehensive checks before publishing
.PHONY: release-validation
release-validation:
@echo "🚀 Running release validation..."
@echo "Verifying tag matches Cargo.toml version..."
@if [ -n "$$TAG_VERSION" ] && [ -n "$$(grep '^version = ' Cargo.toml | sed 's/version = \"\(.*\)\"/\1/')" ]; then \
CARGO_VERSION=$$(grep '^version = ' Cargo.toml | sed 's/version = \"\(.*\)\"/\1/'); \
if [ "$$TAG_VERSION" != "$$CARGO_VERSION" ]; then \
echo "❌ Tag version $$TAG_VERSION doesn't match Cargo.toml version $$CARGO_VERSION"; \
exit 1; \
fi; \
echo "✅ Tag version matches Cargo.toml version: $$TAG_VERSION"; \
fi
$(MAKE) ci
@echo "✅ Release validation passed"
# Publish to crates.io (requires CARGO_REGISTRY_TOKEN)
.PHONY: publish
publish:
@echo "📦 Publishing to crates.io..."
cargo publish --token $$CARGO_REGISTRY_TOKEN
@echo "✅ Published to crates.io"
# Dogfooding - Use our own tool for releases! 🎯
.PHONY: release-patch release-minor release-major
release-patch:
@./scripts/release.sh patch
release-minor:
@./scripts/release.sh minor
release-major:
@./scripts/release.sh major
# Install odo locally for dogfooding
.PHONY: install-local
install-local:
@echo "📦 Installing odo locally..."
cargo install --path . --force
@echo "✅ odo installed! Try: odo show"
# =============================================================================
# Test Fixtures (Git-ignored, generated on demand)
# =============================================================================
FIXTURES_DIR = tests/fixtures
.PHONY: fixtures.clean
fixtures.clean:
@rm -rf $(FIXTURES_DIR)
.PHONY: fixtures.dir
fixtures.dir:
@mkdir -p $(FIXTURES_DIR)
.PHONY: fixtures
fixtures: fixtures.node fixtures.rust
.PHONY: fixtures.node
fixtures.node:
$(MAKE) fixtures.node.basic-node-workspace
.PHONY: fixtures.rust
fixtures.rust:
$(MAKE) fixtures.rust.basic-rust-workspace
.PHONY: fixtures.rust.basic-rust-workspace
fixtures.rust.basic-rust-workspace: fixtures.dir
@rm -fr $(FIXTURES_DIR)/basic-rust-workspace && mkdir -p $(FIXTURES_DIR)/basic-rust-workspace
@cargo new --vcs none --frozen --bin $(FIXTURES_DIR)/basic-rust-workspace/bin1
@cargo new --vcs none --frozen --bin $(FIXTURES_DIR)/basic-rust-workspace/bin2
@cargo new --vcs none --frozen --lib $(FIXTURES_DIR)/basic-rust-workspace/lib1
@cargo new --vcs none --frozen --lib $(FIXTURES_DIR)/basic-rust-workspace/lib2
@cargo workspaces init $(FIXTURES_DIR)/basic-rust-workspace
.PHONY: fixtures.node.basic-node-workspace
.PHONY: fixtures.node.basic-node-workspace
fixtures.node.basic-node-workspace: fixtures.dir
@rm -fr $(FIXTURES_DIR)/basic-node-workspace && mkdir -p $(FIXTURES_DIR)/basic-node-workspace
@cd $(FIXTURES_DIR)/basic-node-workspace && npm init -y
@mkdir -p $(FIXTURES_DIR)/basic-node-workspace/bin1 $(FIXTURES_DIR)/basic-node-workspace/bin2 $(FIXTURES_DIR)/basic-node-workspace/lib1 $(FIXTURES_DIR)/basic-node-workspace/lib2
@cd $(FIXTURES_DIR)/basic-node-workspace/bin1 && npm init -y
@cd $(FIXTURES_DIR)/basic-node-workspace/bin2 && npm init -y
@cd $(FIXTURES_DIR)/basic-node-workspace/lib1 && npm init -y
@cd $(FIXTURES_DIR)/basic-node-workspace/lib2 && npm init -y
@cd $(FIXTURES_DIR)/basic-node-workspace && jq '.workspaces = ["bin1", "bin2", "lib1", "lib2"]' package.json > package.json.tmp && mv package.json.tmp package.json
# =============================================================================
# Testing
# =============================================================================
.PHONY: test
test: build
@echo "Running unit tests (no fixtures)..."
cargo test --lib
.PHONY: test-integration
test-integration: build fixtures.clean fixtures.dir
@echo "Running integration tests with fresh fixtures..."
cargo test --features fixture-tests
.PHONY: test-all
test-all: build test test-integration
# =============================================================================
# Code Quality
# =============================================================================
.PHONY: fmt
fmt:
@echo "🎨 Formatting code..."
cargo fmt --all
@echo "✅ Code formatted"
.PHONY: fmt-check
fmt-check:
@echo "🎨 Checking code formatting..."
cargo fmt --all -- --check
@echo "✅ Code formatting OK"
# =============================================================================
# Development
# =============================================================================
.PHONY: check
check:
@echo "🔍 Checking workspace..."
cargo check --workspace
@echo "✅ Workspace check passed"
.PHONY: build
build:
@echo "Building odo binary..."
cargo build --bin odo
.PHONY: clean
clean: fixtures.clean
cargo clean
# Default target
.PHONY: help
help:
@echo "Odometer Development Commands:"
@echo ""
@echo "Setup:"
@echo " make install-tools Install development dependencies"
@echo ""
@echo "Testing:"
@echo " make test Run unit tests (fast)"
@echo " make test-integration Run integration walkthrough with fixtures"
@echo " make test-all Run all tests"
@echo ""
@echo "CI & Quality:"
@echo " make ci Comprehensive CI validation (recommended)"
@echo " make ci-local Local CI (same as 'ci')"
@echo " make fmt Format code"
@echo " make fmt-check Check code formatting"
@echo ""
@echo "Release:"
@echo " make release-validation Complete release validation"
@echo " make publish Publish to crates.io"
@echo ""
@echo "Dogfooding (using our own odo tool!):"
@echo " make install-local Install odo locally"
@echo " make release-patch Release patch version (bug fixes)"
@echo " make release-minor Release minor version (new features)"
@echo " make release-major Release major version (breaking changes)"
@echo ""
@echo "Fixtures:"
@echo " make fixtures Generate all test fixtures"
@echo " make fixtures.clean Remove all fixtures"
@echo ""
@echo "Development:"
@echo " make check Check code without building"
@echo " make build Build project"
@echo " make clean Clean build artifacts and fixtures"
.DEFAULT_GOAL := help