-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
224 lines (180 loc) · 7.04 KB
/
Makefile
File metadata and controls
224 lines (180 loc) · 7.04 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
# Makefile for cloudmon-metrics
# Rust project build, test, and quality automation
.PHONY: all build build-release build-convertor build-reporter \
test test-verbose coverage coverage-html \
fmt fmt-check lint lint-fix clean check \
doc doc-serve doc-open doc-api help install-tools
# Binary names
CONVERTOR_BIN = cloudmon-metrics-convertor
REPORTER_BIN = cloudmon-metrics-reporter
# Tool versions
TARPAULIN_VERSION = 0.35.1
# Default target
all: fmt-check lint test build
# ============================================================================
# Build targets
# ============================================================================
## Build all debug binaries
build:
cargo build
## Build all release binaries (optimized)
build-release:
cargo build --release
## Build only the convertor binary (debug)
build-convertor:
cargo build --bin $(CONVERTOR_BIN)
## Build only the reporter binary (debug)
build-reporter:
cargo build --bin $(REPORTER_BIN)
## Build only the convertor binary (release)
build-convertor-release:
cargo build --release --bin $(CONVERTOR_BIN)
## Build only the reporter binary (release)
build-reporter-release:
cargo build --release --bin $(REPORTER_BIN)
## Check code compiles without producing binaries (faster)
check:
cargo check
# ============================================================================
# Test targets
# ============================================================================
## Run all tests (including binary targets)
test:
cargo test --all-targets
## Run tests with verbose output
test-verbose:
cargo test -- --nocapture
## Run tests with specific filter (usage: make test-filter FILTER=test_name)
test-filter:
cargo test $(FILTER)
# ============================================================================
# Code coverage
# ============================================================================
## Run tests with coverage (requires cargo-tarpaulin)
coverage:
cargo tarpaulin --lib --tests --exclude-files 'src/bin/*' --out Stdout --skip-clean
## Generate HTML coverage report
coverage-html:
cargo tarpaulin --lib --tests --exclude-files 'src/bin/*' --out Html --output-dir target/coverage --skip-clean
@echo "Coverage report generated at target/coverage/tarpaulin-report.html"
## Run coverage with 95% threshold enforcement (library code only)
coverage-check:
cargo tarpaulin --lib --tests --exclude-files 'src/bin/*' --fail-under 95 --skip-clean
# ============================================================================
# Code formatting
# ============================================================================
## Format code using rustfmt
fmt:
cargo fmt
## Check formatting without making changes
fmt-check:
cargo fmt -- --check
# ============================================================================
# Linting
# ============================================================================
## Run clippy linter with warnings as errors
lint:
cargo clippy -- -D warnings
## Run clippy and automatically fix warnings where possible
lint-fix:
cargo clippy --fix --allow-dirty --allow-staged
# ============================================================================
# Documentation
# ============================================================================
## Build mdbook documentation
doc: doc-schema
mdbook build doc/
## Serve documentation locally with live reload
doc-serve:
mdbook serve doc/
## Open documentation in browser
doc-open:
mdbook build doc/ --open
## Generate Rust API documentation
doc-api:
cargo doc --no-deps
## Generate and open Rust API documentation in browser
doc-api-open:
cargo doc --no-deps --open
## Generate JSON schema for configuration
doc-schema:
cargo test --lib -- generate_config_schema --ignored --nocapture
## Clean generated documentation
doc-clean:
rm -rf docs/*
# ============================================================================
# Cleanup
# ============================================================================
## Clean build artifacts
clean:
cargo clean
## Clean and remove Cargo.lock (full clean)
clean-all: clean
rm -f Cargo.lock
# ============================================================================
# Development helpers
# ============================================================================
## Install required development tools
install-tools:
rustup component add rustfmt clippy
cargo install cargo-tarpaulin --version $(TARPAULIN_VERSION)
cargo install mdbook mdbook-mermaid mdbook-linkcheck
## Run all quality checks (CI simulation)
ci: fmt-check lint test coverage-check
## Watch for changes and run tests (requires cargo-watch)
watch:
cargo watch -x test
## Update dependencies
update:
cargo update
# ============================================================================
# Help
# ============================================================================
## Show this help message
help:
@echo "Available targets:"
@echo ""
@echo " Build:"
@echo " build - Build all debug binaries"
@echo " build-release - Build all release binaries (optimized)"
@echo " build-convertor - Build convertor binary (debug)"
@echo " build-reporter - Build reporter binary (debug)"
@echo " build-convertor-release - Build convertor binary (release)"
@echo " build-reporter-release - Build reporter binary (release)"
@echo " check - Check code compiles without producing binaries"
@echo ""
@echo " Test:"
@echo " test - Run all tests"
@echo " test-verbose - Run tests with verbose output"
@echo " test-filter - Run tests matching FILTER (usage: make test-filter FILTER=name)"
@echo ""
@echo " Coverage:"
@echo " coverage - Run tests with coverage report"
@echo " coverage-html - Generate HTML coverage report"
@echo " coverage-check - Run coverage with 95% threshold"
@echo ""
@echo " Code Quality:"
@echo " fmt - Format code"
@echo " fmt-check - Check code formatting"
@echo " lint - Run clippy linter"
@echo " lint-fix - Fix linter warnings automatically"
@echo ""
@echo " Documentation:"
@echo " doc - Build mdbook documentation"
@echo " doc-serve - Serve documentation locally with live reload"
@echo " doc-open - Build and open documentation in browser"
@echo " doc-api - Generate Rust API documentation"
@echo " doc-api-open - Generate and open Rust API docs in browser"
@echo " doc-schema - Generate JSON schema for configuration"
@echo " doc-clean - Clean generated documentation"
@echo ""
@echo " Utilities:"
@echo " clean - Clean build artifacts"
@echo " clean-all - Clean everything including Cargo.lock"
@echo " install-tools - Install required development tools"
@echo " ci - Run all CI checks (fmt, lint, test, coverage)"
@echo " watch - Watch for changes and run tests"
@echo " update - Update dependencies"
@echo ""
@echo " Default (all):"
@echo " fmt-check lint test build"