-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
311 lines (259 loc) · 8.41 KB
/
Makefile
File metadata and controls
311 lines (259 loc) · 8.41 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
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
# =============================================================================
# TSN (Trust Stack Network) - Makefile
# Development and deployment automation
# =============================================================================
.PHONY: all build test check fmt clippy audit deny clean help
.PHONY: setup dev-install docker-build docker-run
.PHONY: bench bench-save bench-compare
.PHONY: deploy deploy-staging deploy-production rollback
# Default target
all: check test
# =============================================================================
# Development
# =============================================================================
## Setup development environment
setup:
@echo "Setting up TSN development environment..."
@./scripts/setup-dev.sh
## Install development dependencies
dev-install:
@echo "Installing development tools..."
@rustup component add rustfmt clippy
@cargo install cargo-audit cargo-deny cargo-tarpaulin
@cargo install cargo-criterion
## Build the project
build:
@echo "Building TSN..."
@cargo build --release
## Build with all features
build-all:
@echo "Building TSN with all features..."
@cargo build --release --all-features
# =============================================================================
# Testing
# =============================================================================
## Run all tests
test:
@echo "Running all tests..."
@./scripts/run-tests.sh
## Run quick tests only
test-quick:
@echo "Running quick tests..."
@./scripts/run-tests.sh --quick
## Run unit tests only
test-unit:
@echo "Running unit tests..."
@cargo test --lib
## Run integration tests only
test-integration:
@echo "Running integration tests..."
@cargo test --test '*'
## Run crypto tests only
test-crypto:
@echo "Running crypto tests..."
@cargo test crypto -- --nocapture
## Run consensus tests only
test-consensus:
@echo "Running consensus tests..."
@cargo test consensus -- --nocapture
## Generate test coverage report
coverage:
@echo "Generating test coverage report..."
@cargo tarpaulin --out Html --out Stdout
# =============================================================================
# Code Quality
# =============================================================================
## Run all checks (fmt, clippy, audit, deny)
check: fmt clippy audit deny
## Format code
fmt:
@echo "Formatting code..."
@cargo fmt
## Check formatting
fmt-check:
@echo "Checking code formatting..."
@cargo fmt -- --check
## Run clippy
clippy:
@echo "Running clippy..."
@cargo clippy --all-targets --all-features -- -D warnings
## Run security audit
audit:
@echo "Running security audit..."
@cargo audit
## Check dependencies with cargo-deny
deny:
@echo "Checking dependencies..."
@cargo deny check
# =============================================================================
# Benchmarks
# =============================================================================
## Run all benchmarks
bench:
@echo "Running benchmarks..."
@./scripts/bench.sh
## Save current results as baseline
bench-save:
@echo "Saving benchmark baseline..."
@./scripts/bench.sh --save-baseline main
## Compare against baseline
bench-compare:
@echo "Comparing benchmarks..."
@./scripts/bench.sh --compare main --ci-mode
## Run quick benchmarks
bench-quick:
@echo "Running quick benchmarks..."
@./scripts/bench.sh --quick
## Run crypto benchmarks only
bench-crypto:
@echo "Running crypto benchmarks..."
@./scripts/bench.sh --crypto-only
## Run consensus benchmarks only
bench-consensus:
@echo "Running consensus benchmarks..."
@./scripts/bench.sh --consensus-only
## List available benchmarks
bench-list:
@echo "Available benchmarks:"
@./scripts/bench.sh --list
## Open benchmark report
bench-report:
@echo "Opening benchmark report..."
@./scripts/bench.sh --open
# =============================================================================
# Docker
# =============================================================================
## Build Docker image
docker-build:
@echo "Building Docker image..."
@docker build -t tsn:latest -f Dockerfile --target runtime .
## Build Docker image with cache
docker-build-cache:
@echo "Building Docker image with cache..."
@docker build -t tsn:latest -f Dockerfile --target runtime \
--cache-from type=local,src=/tmp/.buildx-cache \
--cache-to type=local,dest=/tmp/.buildx-cache .
## Run Docker container
docker-run:
@echo "Running TSN in Docker..."
@docker run -it --rm \
-p 8080:8080 \
-p 30303:30303 \
-v tsn-data:/data/tsn \
tsn:latest node --data-dir /data/tsn
## Run Docker container in dev mode
docker-dev:
@echo "Running TSN in Docker (dev mode)..."
@docker run -it --rm \
-p 8080:8080 \
-p 30303:30303 \
-v "$(PWD):/workspace" \
--entrypoint /bin/bash \
tsn:builder
# =============================================================================
# Deployment
# =============================================================================
## Deploy to staging
deploy-staging:
@echo "Deploying to staging..."
@./scripts/deploy.sh --build staging
## Deploy to production
deploy-production:
@echo "Deploying to production..."
@./scripts/deploy.sh --build production
## Rollback staging
rollback-staging:
@echo "Rolling back staging..."
@./scripts/deploy.sh --rollback staging
## Rollback production
rollback-production:
@echo "Rolling back production..."
@./scripts/deploy.sh --rollback production
# Generic deploy target (requires ENV environment variable)
deploy:
ifndef ENV
$(error ENV is not set. Use: make deploy ENV=staging)
endif
@echo "Deploying to $(ENV)..."
@./scripts/deploy.sh --build $(ENV)
# =============================================================================
# CI/CD
# =============================================================================
## Run CI checks locally
ci: fmt-check clippy test audit deny
@echo "All CI checks passed!"
## Run full CI pipeline locally
ci-full: clean setup ci bench-compare
@echo "Full CI pipeline completed!"
# =============================================================================
# Maintenance
# =============================================================================
## Clean build artifacts
clean:
@echo "Cleaning build artifacts..."
@cargo clean
@rm -rf target/
@rm -rf .bench-baseline/
@rm -rf .rollback/
## Update dependencies
update:
@echo "Updating dependencies..."
@cargo update
## Check for outdated dependencies
outdated:
@echo "Checking for outdated dependencies..."
@cargo outdated -R
## Generate documentation
docs:
@echo "Generating documentation..."
@cargo doc --no-deps --open
# =============================================================================
# Help
# =============================================================================
## Show this help message
help:
@echo "TSN (Trust Stack Network) - Available Commands"
@echo ""
@echo "Development:"
@echo " make setup Setup development environment"
@echo " make dev-install Install development tools"
@echo " make build Build the project"
@echo " make build-all Build with all features"
@echo ""
@echo "Testing:"
@echo " make test Run all tests"
@echo " make test-quick Run quick tests only"
@echo " make test-unit Run unit tests only"
@echo " make test-crypto Run crypto tests only"
@echo " make coverage Generate test coverage report"
@echo ""
@echo "Code Quality:"
@echo " make check Run all checks"
@echo " make fmt Format code"
@echo " make clippy Run clippy"
@echo " make audit Run security audit"
@echo " make deny Check dependencies"
@echo ""
@echo "Benchmarks:"
@echo " make bench Run all benchmarks"
@echo " make bench-save Save baseline"
@echo " make bench-compare Compare against baseline"
@echo " make bench-crypto Run crypto benchmarks"
@echo ""
@echo "Docker:"
@echo " make docker-build Build Docker image"
@echo " make docker-run Run Docker container"
@echo ""
@echo "Deployment:"
@echo " make deploy-staging Deploy to staging"
@echo " make deploy-production Deploy to production"
@echo " make rollback-staging Rollback staging"
@echo ""
@echo "CI/CD:"
@echo " make ci Run CI checks locally"
@echo " make ci-full Run full CI pipeline"
@echo ""
@echo "Maintenance:"
@echo " make clean Clean build artifacts"
@echo " make update Update dependencies"
@echo " make docs Generate documentation"