forked from ApexChainx/ApexChainx-Contracts
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjustfile
More file actions
109 lines (86 loc) · 3.9 KB
/
Copy pathjustfile
File metadata and controls
109 lines (86 loc) · 3.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
# =============================================================================
# ApexChainx Contracts — common developer commands (issue #113)
# =============================================================================
#
# One-liners for the sequences that CI runs, so a contributor can reproduce a
# CI failure locally without reading the workflow YAML. Every cargo recipe
# mirrors the matching step in .github/workflows/ci.yml (noted per recipe) and
# runs in the contract crate, which is CI's `working-directory`.
#
# Install just: brew install just | cargo install just | https://just.systems
# Usage: just <recipe> | `just` on its own lists every recipe.
# =============================================================================
# Contract crate — matches `working-directory: apexchainx_calculator` in CI.
crate := "apexchainx_calculator"
wasm_target := "wasm32-unknown-unknown"
# List available recipes.
default:
@just --list
# ----------------------------------------------------------- bootstrap ------
# Bootstrap the dev environment — install toolchain, targets, and tools.
bootstrap:
@echo "🔧 Bootstrapping ApexChainx development environment..."
rustup target add wasm32-unknown-unknown
@echo "✅ Bootstrap complete. Run 'just ci' to verify."
# ---------------------------------------------------------------- test ------
# Run the library test suite. [CI: E2E Tests]
test:
cd {{crate}} && cargo test --lib
# Run the property-based fuzz tests. [CI: Fuzz Tests (proptest)]
fuzz:
cd {{crate}} && cargo test --lib fuzz_tests::
# ---------------------------------------------------------------- lint ------
# Format the crate in place.
fmt:
cd {{crate}} && cargo fmt
# Verify formatting without writing. [CI: Format check]
fmt-check:
cd {{crate}} && cargo fmt --check
# Clippy with warnings denied. [CI: Clippy]
lint:
cd {{crate}} && cargo clippy --all-targets -- -D warnings
# Type-check the crate. [CI: Cargo check]
check:
cd {{crate}} && cargo check
# --------------------------------------------------------------- build ------
# Build natively. [CI: Build native]
build:
cd {{crate}} && cargo build
# Build the WASM contract. [CI: Build WASM]
wasm:
cd {{crate}} && cargo build --target {{wasm_target}}
# Build the release WASM. [CI: Provenance & Hashes]
wasm-release:
cd {{crate}} && cargo build --target {{wasm_target}} --release
# Assert no_std compliance for wasm32. [CI: WASM no-std compliance check]
no-std:
cd {{crate}} && cargo check --target {{wasm_target}} --lib
# sha256 of the release WASM. [CI: Generate hash]
hash: wasm-release
#!/usr/bin/env bash
set -euo pipefail
# Workspace build — artifacts land in the ROOT target/, not {{crate}}/target/.
wasm="target/{{wasm_target}}/release/{{crate}}.wasm"
if [ ! -f "$wasm" ]; then
echo "WASM file not found at $wasm" >&2
exit 1
fi
# sha256sum on Linux/CI, shasum on macOS.
if command -v sha256sum >/dev/null 2>&1; then
sha256sum "$wasm" | awk '{print $1 " {{crate}}.wasm"}'
else
shasum -a 256 "$wasm" | awk '{print $1 " {{crate}}.wasm"}'
fi
# --------------------------------------------------------------- tooling -----
# Generate a ship-review note from CHANGELOG.md.
# Pass a version tag to summarise a released block: just release-summary 0.3.0
# Defaults to the [Unreleased] block when no argument is given.
release-summary version="Unreleased":
npx --yes tsx tooling/releaseSummary.ts --version {{version}}
# ----------------------------------------------------------------- all ------
# Remove build artifacts.
clean:
cd {{crate}} && cargo clean
# Everything CI gates on, in CI's order. Run before opening a PR.
ci: fmt-check lint check no-std test fuzz wasm
@echo "✓ local CI equivalent passed"