-
Notifications
You must be signed in to change notification settings - Fork 61
Expand file tree
/
Copy pathMakefile.devops
More file actions
211 lines (172 loc) · 5.75 KB
/
Copy pathMakefile.devops
File metadata and controls
211 lines (172 loc) · 5.75 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
# QuDAG DevOps Makefile
# Simplifies common DevOps operations
.PHONY: help build test deploy clean monitor
# Default target
help:
@echo "QuDAG DevOps Commands:"
@echo " make build-all - Build all Docker images"
@echo " make test-ci - Run CI tests locally"
@echo " make deploy-dev - Deploy development environment"
@echo " make deploy-prod - Deploy production environment"
@echo " make deploy-testnet - Deploy testnet (NODE_COUNT=n)"
@echo " make monitor - Monitor running services"
@echo " make load-test - Run load tests on testnet"
@echo " make security-scan - Run security scans"
@echo " make clean-all - Clean up everything"
@echo ""
@echo "Docker Commands:"
@echo " make docker-build - Build production Docker image"
@echo " make docker-push - Push images to registry"
@echo " make docker-clean - Clean Docker resources"
@echo ""
@echo "Release Commands:"
@echo " make release-patch - Release patch version"
@echo " make release-minor - Release minor version"
@echo " make release-major - Release major version"
# Build targets
build-all: docker-build wasm-build
docker-build:
@echo "Building Docker images..."
docker build -t qudag:latest .
docker build -t qudag:alpine -f Dockerfile.alpine .
docker build -t qudag:dev -f Dockerfile.dev .
wasm-build:
@echo "Building WASM packages..."
cd qudag-wasm && wasm-pack build --target web --out-dir pkg
cd qudag-wasm && wasm-pack build --target nodejs --out-dir pkg-nodejs
cd qudag-wasm && wasm-pack build --target bundler --out-dir pkg-bundler
# Test targets
test-ci:
@echo "Running CI tests locally..."
cargo fmt --all -- --check
cargo clippy --all-features --workspace -- -D warnings
cargo test --workspace --all-features
cd qudag-wasm && wasm-pack test --node
test-integration:
@echo "Running integration tests..."
docker-compose -f docker-compose.yml up -d
sleep 30 # Wait for services
cargo test --features integration
docker-compose down
# Deployment targets
deploy-dev:
@echo "Deploying development environment..."
docker-compose -f docker-compose.dev.yml up -d
@echo "Development environment deployed!"
@echo "Services available at:"
@echo " - QuDAG Dev: http://localhost:8080"
@echo " - Grafana: http://localhost:3001 (admin/admin)"
@echo " - Jaeger: http://localhost:16686"
deploy-prod:
@echo "Deploying production environment..."
docker-compose up -d
@echo "Production environment deployed!"
@echo "Services available at:"
@echo " - QuDAG API: http://localhost:80"
@echo " - Grafana: http://localhost:3000 (admin/admin)"
deploy-testnet:
@echo "Deploying testnet with $(NODE_COUNT) nodes..."
NODE_COUNT=$(NODE_COUNT) ./scripts/testnet/deploy-testnet.sh deploy
stop-testnet:
./scripts/testnet/deploy-testnet.sh stop
clean-testnet:
./scripts/testnet/deploy-testnet.sh clean
# Monitoring
monitor:
@echo "Starting monitoring dashboard..."
./scripts/testnet/monitor-testnet.sh
monitor-logs:
docker-compose logs -f --tail=100
# Load testing
load-test:
@echo "Running load tests..."
./scripts/testnet/load-test.sh all
load-test-quick:
TEST_DURATION=60 ./scripts/testnet/load-test.sh transactions
# Security
security-scan:
@echo "Running security scans..."
cargo audit
cargo clippy -- -W clippy::all
docker run --rm -v $$(pwd):/src \
aquasec/trivy fs --severity HIGH,CRITICAL /src
security-fix:
cargo audit fix
# Clean up
clean-all: clean-docker clean-testnet clean-build
clean-docker:
docker-compose down -v
docker-compose -f docker-compose.dev.yml down -v
docker system prune -f
clean-build:
cargo clean
rm -rf target/
rm -rf qudag-wasm/pkg*
rm -rf node_modules/
clean-logs:
find . -name "*.log" -type f -delete
docker-compose logs --no-color > logs/docker-compose-$(date +%Y%m%d-%H%M%S).log
docker-compose logs --flush
# Release management
release-patch:
@echo "Creating patch release..."
cargo release patch --execute
release-minor:
@echo "Creating minor release..."
cargo release minor --execute
release-major:
@echo "Creating major release..."
cargo release major --execute
tag-release:
@VERSION=$$(grep "^version" Cargo.toml | head -1 | cut -d'"' -f2); \
git tag -a "v$$VERSION" -m "Release v$$VERSION"; \
git push origin "v$$VERSION"
# Development helpers
dev-shell:
docker-compose -f docker-compose.dev.yml exec dev bash
dev-watch:
docker-compose -f docker-compose.dev.yml exec dev \
cargo watch -x 'run -- start --dev'
# Performance
bench:
cargo bench --workspace --features bench
bench-compare:
cargo bench --workspace --features bench -- --save-baseline main
git checkout feature-branch
cargo bench --workspace --features bench -- --baseline main
profile:
cargo build --release
perf record --call-graph=dwarf target/release/qudag
perf report
# Documentation
docs:
cargo doc --no-deps --open
cd qudag-wasm && wasm-pack build --target web
docs-serve:
python3 -m http.server 8000 --directory target/doc
# Utilities
check-deps:
@echo "Checking dependencies..."
@command -v docker >/dev/null 2>&1 || { echo "docker is required but not installed."; exit 1; }
@command -v docker-compose >/dev/null 2>&1 || { echo "docker-compose is required but not installed."; exit 1; }
@command -v cargo >/dev/null 2>&1 || { echo "cargo is required but not installed."; exit 1; }
@command -v wasm-pack >/dev/null 2>&1 || { echo "wasm-pack is required but not installed."; exit 1; }
@echo "All dependencies installed!"
install-tools:
cargo install cargo-audit cargo-release cargo-watch
cargo install wasm-pack
npm install -g npm-check-updates
update-deps:
cargo update
cd qudag-wasm && ncu -u && npm install
# GitHub Actions local testing
act-ci:
act -j build
act-release:
act -j create-release --secret-file .env.secrets
# Quick commands
up: deploy-dev
down: clean-docker
restart: down up
logs: monitor-logs
test: test-ci