-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathMakefile
More file actions
208 lines (163 loc) · 4.71 KB
/
Makefile
File metadata and controls
208 lines (163 loc) · 4.71 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
# Makefile for common tasks in a Rust project
# Detect current branch
CURRENT_BRANCH := $(shell git rev-parse --abbrev-ref HEAD)
# Default target
.PHONY: all
all: test fmt lint build
# Build the project
.PHONY: build
build:
cargo build
.PHONY: release
release:
cargo build --release
# Run unit tests (main crate only)
.PHONY: test
test:
LOGLEVEL=WARN cargo test --lib
# Run integration tests (requires API running)
.PHONY: test-integration
test-integration:
cargo test -p matchbook-tests
# Run all tests
.PHONY: test-all
test-all: test test-integration
# Run unit tests for all workspace members
.PHONY: test-workspace
test-workspace:
LOGLEVEL=WARN cargo test --workspace --lib
# Format the code
.PHONY: fmt
fmt:
cargo +stable fmt --all
# Check formatting
.PHONY: fmt-check
fmt-check:
cargo +stable fmt --check
# Run Clippy for linting
.PHONY: lint
lint:
cargo clippy --all-targets --all-features --workspace -- -D warnings
.PHONY: lint-fix
lint-fix:
cargo clippy --fix --all-targets --all-features --allow-dirty --allow-staged --workspace -- -D warnings
# Clean the project
.PHONY: clean
clean:
cargo clean
# Pre-push checks
.PHONY: check
check: test fmt-check lint
# Run the project
.PHONY: run
run:
cargo run
# Start API for testing (release mode)
.PHONY: run-test-server
run-test-server:
cargo run --release
.PHONY: fix
fix:
cargo fix --allow-staged --allow-dirty
.PHONY: pre-push
pre-push: fix fmt lint-fix test readme doc
.PHONY: doc
doc:
cargo clippy -- -W missing-docs
.PHONY: doc-open
doc-open:
cargo doc --open
.PHONY: publish
publish: readme
cargo login ${CARGO_REGISTRY_TOKEN}
cargo package
cargo publish
.PHONY: coverage
coverage:
export LOGLEVEL=WARN
cargo install cargo-tarpaulin
mkdir -p coverage
cargo tarpaulin --verbose --all-features --timeout 0 --out Xml --output-dir coverage --packages option-chain-matchbook-backend --packages matchbook-client
.PHONY: coverage-html
coverage-html:
export LOGLEVEL=WARN
cargo install cargo-tarpaulin
mkdir -p coverage
cargo tarpaulin --color Always --tests --all-targets --all-features --timeout 0 --out Html --output-dir coverage --packages option-chain-matchbook-backend --packages matchbook-client
.PHONY: open-coverage
open-coverage:
open coverage/tarpaulin-report.html
# Rule to show git log
git-log:
@if [ "$(CURRENT_BRANCH)" = "HEAD" ]; then \
echo "You are in a detached HEAD state. Please check out a branch."; \
exit 1; \
fi; \
echo "Showing git log for branch $(CURRENT_BRANCH) against main:"; \
git log main..$(CURRENT_BRANCH) --pretty=full
.PHONY: create-doc
create-doc:
cargo doc --no-deps --document-private-items
.PHONY: readme
readme: check-cargo-readme create-doc
cargo readme > README.md
.PHONY: check-cargo-readme
check-cargo-readme:
@command -v cargo-readme > /dev/null || (echo "Installing cargo-readme..."; cargo install cargo-readme)
.PHONY: check-spanish
check-spanish:
@rg -n --pcre2 -e '^\s*(//|///|//!|#|/\*|\*).*?[áéíóúÁÉÍÓÚñÑ¿¡]' \
--glob '!target/*' \
--glob '!**/*.png' \
. || (echo "❌ Spanish comments found"; exit 1)
.PHONY: zip
zip:
@echo "Creating $(ZIP_NAME) without any 'target' directories, 'Cargo.lock', and hidden files..."
@find . -type f \
! -path "*/target/*" \
! -path "./.*" \
! -name "Cargo.lock" \
! -name ".*" \
| zip -@ $(ZIP_NAME)
@echo "$(ZIP_NAME) created successfully."
.PHONY: check-cargo-criterion
check-cargo-criterion:
@command -v cargo-criterion > /dev/null || (echo "Installing cargo-criterion..."; cargo install cargo-criterion)
.PHONY: bench
bench: check-cargo-criterion
cargo criterion --output-format=quiet
.PHONY: bench-show
bench-show:
open target/criterion/report/index.html
.PHONY: bench-save
bench-save: check-cargo-criterion
cargo criterion --output-format quiet --history-id v0.3.2 --history-description "Version 0.3.2 baseline"
.PHONY: bench-compare
bench-compare: check-cargo-criterion
cargo criterion --output-format verbose
.PHONY: bench-json
bench-json: check-cargo-criterion
cargo criterion --message-format json
.PHONY: bench-clean
bench-clean:
rm -rf target/criterion
.PHONY: workflow-coverage
workflow-coverage:
DOCKER_HOST="$${DOCKER_HOST}" act push --job code_coverage_report \
-P ubuntu-latest=catthehacker/ubuntu:latest \
--privileged
.PHONY: workflow-build
workflow-build:
DOCKER_HOST="$${DOCKER_HOST}" act push --job build \
-P ubuntu-latest=catthehacker/ubuntu:latest
.PHONY: workflow-lint
workflow-lint:
DOCKER_HOST="$${DOCKER_HOST}" act push --job lint
.PHONY: workflow-test
workflow-test:
DOCKER_HOST="$${DOCKER_HOST}" act push --job run_tests
.PHONY: workflow
workflow: workflow-build workflow-lint workflow-test workflow-coverage
.PHONY: generate_markdown
generate_markdown:
./doc/generate_md_docs.sh