forked from 0xMiden/rust-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
192 lines (143 loc) · 7.77 KB
/
Copy pathMakefile
File metadata and controls
192 lines (143 loc) · 7.77 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
.DEFAULT_GOAL := help
.PHONY: help
help: ## Show description of all commands
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
# --- Variables -----------------------------------------------------------------------------------
# The build target can be set via BUILD_TARGET to cross-compile.
# Used when targeting a specific environment (used to produce artifact binaries)
# in the CI.
ifneq ($(BUILD_TARGET),)
TARGET_FLAG = --target $(BUILD_TARGET)
endif
FEATURES_CLIENT=--features "std dap"
WARNINGS=RUSTDOCFLAGS="-D warnings"
TEST_MIDEN_NOTE_TRANSPORT_URL?=http://127.0.0.1:57292
# --- Linting -------------------------------------------------------------------------------------
.PHONY: clippy
clippy: ## Run Clippy with configs
cargo clippy --workspace --features "testing std" --all-targets -- -D warnings
.PHONY: fix
fix: ## Run Fix with configs
cargo fix --workspace --features "testing std" --all-targets --allow-staged --allow-dirty
.PHONY: format
format: ## Run format using nightly toolchain
cargo +nightly fmt --all
.PHONY: format-check
format-check: ## Run format using nightly toolchain but only in check mode
cargo +nightly fmt --all --check
.PHONY: shear
shear: ## Run cargo-shear to find unused or misplaced dependencies
cargo shear
.PHONY: lint
lint: fix format toml clippy typos-check shear ## Run all linting tasks at once (clippy, fixing, formatting, typos)
.PHONY: toml
toml: ## Runs Format for all TOML files
taplo fmt
.PHONY: toml-check
toml-check: ## Runs Format for all TOML files but only in check mode
taplo fmt --check --verbose
.PHONY: typos-check
typos-check: ## Run typos to check for spelling mistakes
@typos --config ./.typos.toml
# --- Documentation -------------------------------------------------------------------------------
.PHONY: doc
doc: ## Generate & check rust documentation. Ensure you have the nightly toolchain installed.
@cd crates/rust-client && \
RUSTDOCFLAGS="-D warnings --cfg docsrs" cargo +nightly doc --lib --no-deps --all-features --keep-going --release
doc-open: ## Generate & open rust documentation in browser. Ensure you have the nightly toolchain installed.
@cd crates/rust-client && \
RUSTDOCFLAGS="-D warnings --cfg docsrs" cargo +nightly doc --lib --no-deps --all-features --keep-going --release --open
.PHONY: serve-docs
serve-docs: ## Serves the docs
cd docs/external && npm run start:dev
# --- Testing -------------------------------------------------------------------------------------
.PHONY: test
test: ## Run tests
cargo nextest run --workspace --release --lib $(FEATURES_CLIENT)
.PHONY: test-miden-bench
test-miden-bench: ## Run miden-bench CLI tests
cargo nextest run --package miden-client-bench --release --test=integration
.PHONY: test-docs
test-docs: ## Run documentation tests
cargo test --doc $(FEATURES_CLIENT)
# --- Integration testing -------------------------------------------------------------------------
.PHONY: start-node
start-node: ## Start the testing node in the foreground, streaming logs (Ctrl+C stops it)
./scripts/start-test-node.sh
.PHONY: start-node-agglayer
start-node-agglayer: ## Start the testing node with agglayer genesis accounts
AGGLAYER_GENESIS=1 ./scripts/start-test-node.sh
.PHONY: start-node-background
start-node-background: ## Start the testing node in the background
./scripts/start-test-node.sh --background
.PHONY: stop-node
stop-node: ## Stop the testing node
./scripts/stop-test-node.sh
.PHONY: start-note-transport-background
start-note-transport-background: ## Start the note transport service in background
./scripts/start-note-transport-bg.sh
.PHONY: stop-note-transport
stop-note-transport: ## Stop the note transport service
./scripts/stop-note-transport.sh
.PHONY: start-note-transport
start-note-transport:
./scripts/start-note-transport.sh
.PHONY: integration-test
integration-test: ## Run integration tests
cargo nextest run --workspace --release --test=integration
.PHONY: integration-test-full
integration-test-full: ## Run the integration test binary with ignored tests included (requires note transport service)
TEST_MIDEN_NOTE_TRANSPORT_URL=$(TEST_MIDEN_NOTE_TRANSPORT_URL) cargo nextest run --workspace --release --test=integration
cargo nextest run --workspace --release --test=integration --run-ignored ignored-only -- import_genesis_accounts_can_be_used_for_transactions
.PHONY: integration-test-miden-bench
integration-test-miden-bench: install-bench ## Run miden-bench smoke tests
./scripts/test-miden-bench-smoke.sh
.PHONY: test-dev
test-dev: ## Run tests with debug assertions enabled via test-dev profile
cargo nextest run --workspace --cargo-profile test-dev --lib $(FEATURES_CLIENT)
.PHONY: integration-test-dev
integration-test-dev: ## Run integration tests with debug assertions enabled via test-dev profile
cargo nextest run --workspace --cargo-profile test-dev --test=integration
.PHONY: integration-test-binary
integration-test-binary: ## Run the integration tests using the standalone binary (requires note transport service)
TEST_MIDEN_NOTE_TRANSPORT_URL=$(TEST_MIDEN_NOTE_TRANSPORT_URL) cargo run --package miden-client-integration-tests --release --locked
# --- Installing ----------------------------------------------------------------------------------
install: ## Install the CLI binary
cargo install --path bin/miden-cli --locked
install-bench: ## Install the benchmark binary
cargo install --path bin/miden-bench --locked
install-tests: ## Install the tests binary
cargo install --path bin/integration-tests --locked
# --- Building ------------------------------------------------------------------------------------
build: ## Build the CLI binary, client library and tests binary in release mode
cargo build --workspace $(TARGET_FLAG) --release --locked
.PHONY: build-wasm
build-wasm: ## Build the client library for wasm32 with no_std (no default features)
cargo build --package miden-client --target wasm32-unknown-unknown --no-default-features --locked
# --- Check ---------------------------------------------------------------------------------------
.PHONY: check
check: ## Build the CLI binary and client library in release mode
cargo check --workspace --release
## --- Setup --------------------------------------------------------------------------------------
.PHONY: check-tools
check-tools: ## Checks if development tools are installed
@echo "Checking development tools..."
@command -v mdbook >/dev/null 2>&1 && echo "[OK] mdbook is installed" || echo "[MISSING] mdbook (make install-tools)"
@command -v typos >/dev/null 2>&1 && echo "[OK] typos is installed" || echo "[MISSING] typos (make install-tools)"
@command -v cargo nextest >/dev/null 2>&1 && echo "[OK] cargo-nextest is installed" || echo "[MISSING] cargo-nextest(make install-tools)"
@command -v cargo-shear >/dev/null 2>&1 && echo "[OK] cargo-shear is installed" || echo "[MISSING] cargo-shear (make install-tools)"
@command -v taplo >/dev/null 2>&1 && echo "[OK] taplo is installed" || echo "[MISSING] taplo (make install-tools)"
.PHONY: install-tools
install-tools: ## Installs Rust tools required by the Makefile
@echo "Installing development tools..."
@rustup show active-toolchain >/dev/null 2>&1 || (echo "Rust toolchain not detected. Install rustup + toolchain first." && exit 1)
@RUST_TC=$$(rustup show active-toolchain | awk '{print $$1}'); \
echo "Ensuring required Rust components are installed for $$RUST_TC..."; \
rustup component add --toolchain $$RUST_TC clippy rust-src rustfmt >/dev/null
# Rust-related
cargo install mdbook --locked
cargo install typos-cli@1.42.3 --locked
cargo install cargo-nextest@0.9.128 --locked
cargo install cargo-shear@1.11.2 --locked
cargo install taplo-cli --locked
@echo "Development tools installation complete!"