Repository navigation
Expand file tree
/
Copy pathjustfile
More file actions
162 lines (126 loc) · 4.97 KB
/
Copy pathjustfile
File metadata and controls
162 lines (126 loc) · 4.97 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
alias b := build
alias c := check
alias f := fmt
alias t := test
alias p := pre-push
alias d := doc
alias vs := verify-standalone
alias vsa := verify-standalone-all
_default:
@just --list
# Build the project
build:
cargo build
# Check code: formatting, compilation, linting, and commit signature
check:
cargo +nightly fmt --all -- --check
cargo check --workspace --all-features
cargo clippy --all-features --all-targets -- -D warnings
@[ "$(git log --pretty='format:%G?' -1 HEAD)" = "N" ] && \
echo "\n⚠️ Unsigned commit: BDK requires that commits be signed." || \
true
# Format all code
fmt:
cargo +nightly fmt
# Run all tests for all crates with all features enabled
test:
@just _test-bitcoind_rpc
@just _test-chain
@just _test-core
@just _test-electrum
@just _test-esplora
@just _test-file_store
@just _test-testenv
_test-bitcoind_rpc:
cargo test -p bdk_bitcoind_rpc --all-features
_test-chain:
cargo test -p bdk_chain --all-features
_test-core:
cargo test -p bdk_core --all-features
_test-electrum:
cargo test -p bdk_electrum --all-features
_test-esplora:
cargo test -p bdk_esplora --all-features
_test-file_store:
cargo test -p bdk_file_store --all-features
_test-testenv:
cargo test -p bdk_testenv --all-features
# Run pre-push suite: format, check, and test
pre-push: fmt check test
# Check documentation for all workspace packages
doc:
RUSTDOCFLAGS='-D warnings' cargo doc --workspace --no-deps
# A failure usually means the crate uses something from a sibling workspace
# crate that isn't released on crates.io yet
[doc("Verify a crate builds as published, against released workspace crates")]
[positional-arguments]
verify-standalone crate *args:
#!/usr/bin/env bash
set -euo pipefail
command -v jq >/dev/null 2>&1 || { echo "Error: jq is required but not installed" >&2; exit 1; }
# Positional args avoid word-splitting/quoting issues with `{{{{args}}`
CRATE="$1"
shift
echo "Verifying $CRATE can build standalone..."
# Package the crate; extra args are passed to `cargo build` only
cargo package -p "$CRATE" --no-verify --allow-dirty
# Find the packaged tarball (respects CARGO_TARGET_DIR / build.target-dir)
METADATA=$(cargo metadata --format-version 1 --no-deps)
TARGET_DIR=$(jq -r '.target_directory' <<< "$METADATA")
CRATE_VERSION=$(jq -r --arg c "$CRATE" '.packages[] | select(.name == $c) | .version' <<< "$METADATA")
TARBALL="$TARGET_DIR/package/${CRATE}-${CRATE_VERSION}.crate"
if [ ! -f "$TARBALL" ]; then
echo "Error: Could not find packaged tarball at $TARBALL"
exit 1
fi
# Reuse a persistent cache across runs/crates instead of re-downloading
# the registry index and every dependency from scratch each invocation
CACHE_DIR="$TARGET_DIR/verify-standalone-cache"
mkdir -p "$CACHE_DIR/cargo-home" "$CACHE_DIR/target"
# Create a temporary directory for unpacking
TEMP_DIR=$(mktemp -d)
trap "rm -rf $TEMP_DIR" EXIT
# Unpack the tarball
tar -xzf "$TARBALL" -C "$TEMP_DIR"
# Build outside the workspace so sibling crates resolve from crates.io
cd "$TEMP_DIR/${CRATE}-${CRATE_VERSION}"
# Reuse the registry cache and build artifacts across invocations for speed
export CARGO_HOME="$CACHE_DIR/cargo-home"
export CARGO_TARGET_DIR="$CACHE_DIR/target"
echo "Building $CRATE in isolation..."
# --locked: use the packaged Cargo.lock as-is
cargo build --locked "$@"
echo "✅ $CRATE builds successfully in isolation!"
# Verify all publishable crates can be built standalone (with --all-features)
[positional-arguments]
verify-standalone-all *args:
#!/usr/bin/env bash
set -euo pipefail
command -v jq >/dev/null 2>&1 || { echo "Error: jq is required but not installed" >&2; exit 1; }
# Get all publishable workspace crates (examples should set `publish = false`)
CRATES=$(cargo metadata --format-version 1 --no-deps | jq -r '.packages[] | select(.publish != []) | .name' | sort)
if [ -z "$CRATES" ]; then
echo "Error: no publishable crates found via cargo metadata" >&2
exit 1
fi
echo "Verifying all publishable crates can build standalone..."
echo "Crates to verify:"
echo "$CRATES" | sed 's/^/ - /'
echo
for crate in $CRATES; do
echo "========================================="
echo "Verifying $crate..."
echo "========================================="
if ! "{{just_executable()}}" verify-standalone "$crate" --all-features "$@"; then
echo "❌ $crate: FAILED"
echo "========================================="
echo "❌ VERIFICATION FAILED for: $crate"
echo "========================================="
exit 1
fi
echo "✅ $crate: SUCCESS"
echo
done
echo "========================================="
echo "✅ All crates build successfully in isolation!"
echo "========================================="