-
Notifications
You must be signed in to change notification settings - Fork 126
Expand file tree
/
Copy pathMakefile
More file actions
237 lines (190 loc) · 8.7 KB
/
Copy pathMakefile
File metadata and controls
237 lines (190 loc) · 8.7 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
226
227
228
229
230
231
232
233
234
235
236
237
# =============================================================================
# ILN Smart Contract — Developer Makefile
# =============================================================================
# Usage:
# make build Build optimised WASM for all contracts
# make test Run the full test suite (native target)
# make fmt Format all Rust source code
# make lint Run Clippy linter across the workspace
# make deploy-testnet Deploy all contracts to Stellar testnet
# make coverage Run tarpaulin code-coverage report
# make clean Remove build artefacts
# make help Print this help message
# =============================================================================
.PHONY: build test fmt lint deploy-testnet coverage clean help
# Default target
.DEFAULT_GOAL := help
# ---------------------------------------------------------------------------
# Build
# ---------------------------------------------------------------------------
## build: Compile all contracts to optimised WASM (wasm32v1-none, release profile)
build:
cargo build-wasm
@echo "--- Built WASM artefacts ---"
@ls -lh target/wasm32v1-none/release/*.wasm
# ---------------------------------------------------------------------------
# Test
# ---------------------------------------------------------------------------
## test: Run the full test suite on the native target (includes unit + integration tests)
test:
cargo test-native
# ---------------------------------------------------------------------------
# Format
# ---------------------------------------------------------------------------
## fmt: Format all Rust source files using rustfmt
fmt:
cargo fmt --all
# ---------------------------------------------------------------------------
# Lint
# ---------------------------------------------------------------------------
## lint: Run Clippy with workspace-wide checks and deny warnings
lint:
cargo clippy --all-targets --all-features -- -D warnings
# ---------------------------------------------------------------------------
# Deploy
# ---------------------------------------------------------------------------
## deploy-testnet: Deploy all contracts to the Stellar testnet
## Requires the Stellar CLI to be installed and STELLAR_ACCOUNT to be set.
## Example: STELLAR_ACCOUNT=my-account make deploy-testnet
deploy-testnet: build
@if [ -z "$$STELLAR_ACCOUNT" ]; then \
echo "Error: STELLAR_ACCOUNT is not set. Export your Stellar account alias before deploying."; \
exit 1; \
fi
@echo "--- Deploying invoice_liquidity ---"
stellar contract deploy \
--wasm target/wasm32v1-none/release/invoice_liquidity.wasm \
--source "$$STELLAR_ACCOUNT" \
--network testnet
@echo "--- Deploying iln_governance ---"
stellar contract deploy \
--wasm target/wasm32v1-none/release/iln_governance.wasm \
--source "$$STELLAR_ACCOUNT" \
--network testnet
@echo "--- Deploying iln_distribution ---"
stellar contract deploy \
--wasm target/wasm32v1-none/release/iln_distribution.wasm \
--source "$$STELLAR_ACCOUNT" \
--network testnet
@echo "--- Deploying reputation_bonus ---"
stellar contract deploy \
--wasm target/wasm32v1-none/release/reputation_bonus.wasm \
--source "$$STELLAR_ACCOUNT" \
--network testnet
# ---------------------------------------------------------------------------
# Coverage
# ---------------------------------------------------------------------------
## coverage: Run cargo-tarpaulin and produce an HTML coverage report
## Requires cargo-tarpaulin: cargo install cargo-tarpaulin
coverage:
cargo tarpaulin \
--target x86_64-unknown-linux-gnu \
--workspace \
--exclude iln_fuzz \
--out Html \
--output-dir coverage/
@echo "--- Coverage report written to coverage/tarpaulin-report.html ---"
# ---------------------------------------------------------------------------
# Clean
# ---------------------------------------------------------------------------
## clean: Remove all build artefacts
clean:
cargo clean
# ---------------------------------------------------------------------------
# Help
# ---------------------------------------------------------------------------
## help: Print all documented Makefile targets
help:
@echo ""
@echo "ILN Smart Contract — available targets:"
@echo ""
@grep -E '^## ' Makefile | sed 's/^## / /'
@echo ""
.PHONY: help install build build-rust build-sdk test test-rust test-e2e fuzz test-fuzz lint \
fmt fmt-check clippy deploy-testnet seed reset reset-testnet docs spec \
changelog soroban-optimize health test-insurance test-invoice test-governance test-distribution
# Package manager for the TypeScript workspaces (sdk, indexer, notifications,
# tests/e2e). Prefer pnpm when available, otherwise fall back to npm.
PKG := $(shell command -v pnpm >/dev/null 2>&1 && echo pnpm || echo npm)
NODE_PKGS := sdk indexer notifications tests/e2e
# Default target: list everything.
.DEFAULT_GOAL := help
help: ## Show this help message
@echo "ILN Smart Contract — developer workflows"
@echo ""
@echo "Usage: make <target>"
@echo ""
@grep -E '^[a-zA-Z0-9_-]+:.*?## .*$$' $(MAKEFILE_LIST) \
| sort \
| awk 'BEGIN {FS = ":.*?## "}; {printf " \033[36m%-16s\033[0m %s\n", $$1, $$2}'
install: ## Install Node dependencies across all TypeScript packages
@for pkg in $(NODE_PKGS); do \
echo "📦 installing $$pkg ($(PKG))"; \
(cd $$pkg && $(PKG) install) || exit 1; \
done
build: build-rust build-sdk ## Build everything (contracts + SDK)
build-rust: ## Build optimized contract WASM (wasm32v1-none release)
cargo build --target wasm32v1-none --release
build-sdk: ## Build the @iln/sdk TypeScript package
cd sdk && $(PKG) run build
build-insurance: ## Build the insurance pool contract to optimised WASM
cargo build --target wasm32v1-none --release -p insurance_pool
@echo "--- Built insurance_pool WASM artefact ---"
@ls -lh target/wasm32v1-none/release/insurance_pool.wasm
soroban-optimize: ## Build WASM via the wasm32-unknown-unknown target
cargo build --release --target wasm32-unknown-unknown
test: test-rust ## Run the Rust unit/integration test suite
test-rust: ## Run cargo test for the whole workspace
cargo test
test-invoice: ## Run tests for the invoice liquidity contract
cargo test -p invoice_liquidity
test-governance: ## Run tests for the governance contract
cargo test -p iln_governance
test-distribution: ## Run tests for the distribution contract
cargo test -p iln_distribution
test-insurance: ## Run tests for the insurance pool contract
cargo test -p insurance_pool
test-e2e: ## Run the end-to-end test suite (tests/e2e)
cd tests/e2e && $(PKG) run test:e2e
fuzz: ## Run the property/fuzz test suite
cargo test -p iln_fuzz
test-fuzz: ## Run fuzz tests for the iln_fuzz crate
cargo test -p iln_fuzz
lint: fmt-check clippy ## Lint everything (rustfmt check + clippy)
fmt: ## Format all Rust code in place
cargo fmt --all
fmt-check: ## Verify Rust formatting without modifying files
cargo fmt --all -- --check
clippy: ## Run clippy with warnings denied
cargo clippy --all-targets -- -D warnings
deploy-testnet: ## Deploy all contracts to Stellar testnet
bash scripts/deploy-testnet.sh
seed: ## Seed the testnet deployment with sample data
npx tsx scripts/seed.ts
reset: reset-testnet ## Alias for reset-testnet
reset-testnet: ## Reset local/testnet state
bash scripts/reset-testnet.sh
health: ## Run the deployment health check (JSON metrics)
npx tsx scripts/check-contract-health.ts --pretty
docs: ## Generate SDK API documentation (typedoc)
cd sdk && $(PKG) run docs
# Generate the contract ABI/spec JSON (Issue #111).
# Every `pub fn` in the `#[contractimpl]` block is exported into the Soroban
# spec automatically. When the `stellar` CLI and a built WASM are available we
# emit the canonical embedded spec; otherwise we fall back to a toolchain-free
# source generator that produces an equivalent JSON. Output: docs/contract-spec.json
spec: ## Generate the contract ABI/spec JSON (docs/contract-spec.json)
@if command -v stellar >/dev/null 2>&1 && [ -f target/wasm32v1-none/release/invoice_liquidity.wasm ]; then \
stellar contract inspect --wasm target/wasm32v1-none/release/invoice_liquidity.wasm --output json > docs/contract-spec.json && \
echo "✅ spec from 'stellar contract inspect' -> docs/contract-spec.json"; \
else \
echo "ℹ️ stellar CLI/WASM not found; generating spec from source"; \
npx --yes tsx scripts/gen-spec.ts; \
fi
# Generate CHANGELOG.md from conventional commits using git-cliff.
# Install: cargo install git-cliff
# Usage:
# make changelog # update for unreleased commits
# make changelog TAG=v1.0.0 # generate up to a specific tag
changelog: ## Generate CHANGELOG.md from conventional commits (git-cliff)
git cliff $(if $(TAG),--tag $(TAG)) --output CHANGELOG.md