forked from Hahfyeex/Stellar-PolyMarket
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJustfile
More file actions
135 lines (115 loc) Β· 4.9 KB
/
Justfile
File metadata and controls
135 lines (115 loc) Β· 4.9 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
# Justfile for Stellar PolyMarket
# Install just: https://github.com/casey/just
# Default recipe to display help
default:
@just --list
# Format all Rust code
fmt:
@echo "π¨ Formatting Rust code..."
cd contracts/prediction_market && cargo fmt --all
@echo "β
Formatting complete"
# Check formatting without making changes
fmt-check:
@echo "π Checking Rust formatting..."
cd contracts/prediction_market && cargo fmt --all -- --check
@echo "β
Formatting check complete"
# Run Clippy lints
clippy:
@echo "π Running Clippy lints..."
cd contracts/prediction_market && cargo clippy --all-targets --all-features -- -D warnings
@echo "β
Clippy check complete"
# Run all lints (format + clippy)
lint: fmt-check clippy
@echo "β
All lints passed"
# Build WASM in debug mode
build:
@echo "π¨ Building WASM (debug)..."
cd contracts/prediction_market && cargo build --target wasm32-unknown-unknown
@echo "β
Debug build complete"
# Build WASM in release mode
build-release:
@echo "π¨ Building WASM (release)..."
cd contracts/prediction_market && cargo build --target wasm32-unknown-unknown --release
@echo "β
Release build complete"
# Check WASM size
check-size: build-release
@echo "π Checking WASM size..."
@SIZE_BYTES=$$(stat -c%s contracts/prediction_market/target/wasm32-unknown-unknown/release/prediction_market.wasm 2>/dev/null || stat -f%z contracts/prediction_market/target/wasm32-unknown-unknown/release/prediction_market.wasm); \
SIZE_KB=$$((SIZE_BYTES / 1024)); \
echo "π¦ WASM size: $${SIZE_KB} KB ($${SIZE_BYTES} bytes)"; \
if [ $$SIZE_KB -gt 64 ]; then \
echo "β WASM exceeds 64KB limit!"; \
exit 1; \
else \
PERCENTAGE=$$((SIZE_KB * 100 / 64)); \
echo "β
Within 64KB limit ($${PERCENTAGE}% used)"; \
fi
# Run unit tests
test:
@echo "π§ͺ Running unit tests..."
cd contracts/prediction_market && cargo test --lib -- --nocapture
@echo "β
Tests complete"
# Run tests with coverage
test-coverage:
@echo "π§ͺ Running tests with coverage..."
cd contracts/prediction_market && cargo tarpaulin --out Html --output-dir coverage
@echo "β
Coverage report generated in contracts/prediction_market/coverage/"
# Run security audit
audit:
@echo "π Running security audit..."
cd contracts/prediction_market && cargo audit
@echo "β
Security audit complete"
# Clean build artifacts
clean:
@echo "π§Ή Cleaning build artifacts..."
cd contracts/prediction_market && cargo clean
@echo "β
Clean complete"
# Run all CI checks locally
ci: lint test build-release check-size
@echo "β
All CI checks passed locally"
# Fix all auto-fixable issues
fix:
@echo "π§ Fixing auto-fixable issues..."
cd contracts/prediction_market && cargo fmt --all
cd contracts/prediction_market && cargo clippy --all-targets --all-features --fix --allow-dirty --allow-staged
@echo "β
Auto-fix complete"
# Install development dependencies
install-deps:
@echo "π¦ Installing development dependencies..."
cargo install cargo-audit
cargo install cargo-tarpaulin
cargo install just
@echo "β
Dependencies installed"
# Optimize WASM build
optimize: build-release
@echo "β‘ Optimizing WASM..."
@if command -v wasm-opt >/dev/null 2>&1; then \
wasm-opt -Oz contracts/prediction_market/target/wasm32-unknown-unknown/release/prediction_market.wasm \
-o contracts/prediction_market/target/wasm32-unknown-unknown/release/prediction_market_optimized.wasm; \
echo "β
Optimization complete"; \
SIZE_BEFORE=$$(stat -c%s contracts/prediction_market/target/wasm32-unknown-unknown/release/prediction_market.wasm 2>/dev/null || stat -f%z contracts/prediction_market/target/wasm32-unknown-unknown/release/prediction_market.wasm); \
SIZE_AFTER=$$(stat -c%s contracts/prediction_market/target/wasm32-unknown-unknown/release/prediction_market_optimized.wasm 2>/dev/null || stat -f%z contracts/prediction_market/target/wasm32-unknown-unknown/release/prediction_market_optimized.wasm); \
SAVED=$$((SIZE_BEFORE - SIZE_AFTER)); \
echo "π Saved $${SAVED} bytes"; \
else \
echo "β οΈ wasm-opt not found. Install binaryen for optimization."; \
fi
# Watch for changes and run tests
watch:
@echo "π Watching for changes..."
cd contracts/prediction_market && cargo watch -x test
# Generate documentation
docs:
@echo "π Generating documentation..."
cd contracts/prediction_market && cargo doc --no-deps --open
@echo "β
Documentation generated"
# Check for outdated dependencies
outdated:
@echo "π Checking for outdated dependencies..."
cd contracts/prediction_market && cargo outdated
@echo "β
Check complete"
# Update dependencies
update:
@echo "β¬οΈ Updating dependencies..."
cd contracts/prediction_market && cargo update
@echo "β
Dependencies updated"