Repository navigation
Expand file tree
/
Copy pathci-pr.sh
More file actions
executable file
·206 lines (184 loc) · 7.21 KB
/
Copy pathci-pr.sh
File metadata and controls
executable file
·206 lines (184 loc) · 7.21 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
#!/usr/bin/env bash
# Gate commands shared by CI, pre-commit, and CONTRIBUTING.md.
# PR lanes fail fast; deep collects every failure. Build/test lanes are
# kernel-free; deny resolves the kernel graph without compiling it.
set -euo pipefail
cd "$(dirname "$0")/.."
usage() {
echo "usage: $0 {fmt|clippy|test-crates|test-binary|test-workspace|test|deny|deep|all}" >&2
exit 2
}
[[ $# -eq 1 ]] || usage
failures=0
collect_failures=false
profile() {
local label="$1"
shift
echo "==> ${label}"
if "$@"; then
echo "==> ok: ${label}"
else
echo "==> FAILED: ${label}" >&2
failures=$((failures + 1))
[[ "$collect_failures" == true ]] || exit 1
fi
}
finish() {
if [[ ${failures} -gt 0 ]]; then
echo "${failures} profile(s) failed" >&2
exit 1
fi
}
# CI test lanes install cargo-nextest (.github/workflows/ci.yml,
# .github/actions/test-deps): its pooled scheduler runs test binaries
# concurrently instead of serially, which removes the long tail of
# process-harness binaries on the 4-vCPU runners. There are no doctests in
# the tree, so the two runners execute the same tests. Environments without
# nextest (local, pre-commit) fall back to `cargo test --no-fail-fast`.
cargo_test() {
if command -v cargo-nextest >/dev/null 2>&1; then
cargo nextest run --locked --no-fail-fast "$@"
else
cargo test --locked --no-fail-fast "$@"
fi
}
clippy_profiles() {
# Four kernel-free all-target profiles. The kernel capability is opt-in and
# never implied by a default, so these lanes exercise the plain builds. The
# explicit `--no-default-features` spellings keep the per-crate rows'
# feature sets pinned even if a default changes again; the workspace row
# builds with default features by design (it is the "plain build works"
# row).
profile "clippy: workspace (kernel-free)" \
cargo clippy --locked --workspace --all-targets \
--features bitcoin-rs/silent-payments \
--exclude bitcoin-rs-consensus --exclude bitcoin-rs-chainstate \
--exclude bitcoin-rs-node \
-- -D warnings
profile "clippy: bitcoin-rs-consensus (native)" \
cargo clippy --locked -p bitcoin-rs-consensus \
--no-default-features --all-targets -- -D warnings
profile "clippy: bitcoin-rs-chainstate (native,fjall)" \
cargo clippy --locked -p bitcoin-rs-chainstate \
--no-default-features --features fjall --all-targets -- -D warnings
profile "clippy: bitcoin-rs-node (fjall,zmq,silent-payments)" \
cargo clippy --locked -p bitcoin-rs-node \
--no-default-features --features fjall,zmq,silent-payments --all-targets -- -D warnings
# All-target builds unify test-seam features through dev-dependencies. Check
# the operator build separately so test-only capabilities cannot hide here.
profile "check: bitcoin-rs (production silent-payments)" \
cargo check --locked -p bitcoin-rs \
--no-default-features --features fjall,silent-payments
}
test_crates_profiles() {
profile "test: bitcoin-rs-rpc (silent-payments adapter)" \
cargo_test -p bitcoin-rs-rpc --features silent-payments --lib handlers::silent_payments
profile "test: bitcoin-rs (silent-payments process)" \
cargo_test -p bitcoin-rs --no-default-features --features fjall,silent-payments --test suite silent_payments::
profile "test: bitcoin-rs (certified inputs process)" \
cargo_test -p bitcoin-rs --no-default-features --features fjall,silent-payments --test suite block_inputs::
profile "test: bitcoin-rs-index (silent-payments codec)" \
cargo_test -p bitcoin-rs-index --features silent-payments --test suite silent_payments::
# Per-crate profiles may use checked-in fixtures but need no pinned Core
# daemon. Tests launching that daemon run in the workspace lane below.
# Smallest first.
# primitives owns the QAC-05 corpus-decoder gate (BITCOIN_RS_FUZZ_CORPUS);
# it must run in the PR lane, not only the merge-only workspace lane.
profile "test: bitcoin-rs-primitives" \
cargo_test -p bitcoin-rs-primitives
# The offline CLI uses the checked-in Core snapshot, not a running daemon.
profile "test: bitcoin-rs-snapshot" \
cargo_test -p bitcoin-rs-snapshot
profile "test: bitcoin-rs-consensus (native)" \
cargo_test -p bitcoin-rs-consensus --no-default-features
profile "test: bitcoin-rs-chainstate (native,fjall)" \
cargo_test -p bitcoin-rs-chainstate \
--no-default-features --features fjall
profile "test: bitcoin-rs-p2p" \
cargo_test -p bitcoin-rs-p2p
profile "test: bitcoin-rs-node (fjall,zmq)" \
cargo_test -p bitcoin-rs-node \
--no-default-features --features fjall,zmq
# Isolated so node's default zmq feature cannot unify this package on.
profile "test: bitcoin-rs-rpc (no default features)" \
cargo_test -p bitcoin-rs-rpc --no-default-features
}
test_binary_profiles() {
# Requires the pinned Core fixture. Formal checks have their own workflow.
profile "test: bitcoin-rs binary (rocksdb,fjall,redb)" \
cargo_test -p bitcoin-rs \
--no-default-features --features "rocksdb,fjall,redb"
}
test_workspace_profiles() {
# Also expects the pinned fixtures: bin/bitcoin-rs is a workspace member,
# so this profile runs its default-feature (fjall,redb,zmq) test binaries,
# including the process-harness suite that launches the pinned bitcoind.
profile "test: workspace (kernel-free)" \
cargo_test --workspace \
--exclude bitcoin-rs-consensus --exclude bitcoin-rs-chainstate \
--exclude bitcoin-rs-p2p \
--exclude bitcoin-rs-node --exclude bitcoin-rs-rpc \
--exclude bitcoin-rs-snapshot
# The RPC package owns libzmq. Its feature-gated process subscriber must
# run explicitly so feature resolution cannot turn it into a zero-test
# binary. Build and identify the daemon with the same default zmq profile.
profile "test: bitcoin-rs-rpc (zmq, process notifications)" test_rpc_reorg_notifications
}
test_rpc_reorg_notifications() {
cargo build --locked -p bitcoin-rs || return $?
local target_dir="${CARGO_TARGET_DIR:-$PWD/target}"
if [[ "$target_dir" != /* ]]; then
target_dir="$PWD/$target_dir"
fi
BITCOIN_RS_NODE="$target_dir/debug/bitcoin-rs" \
cargo_test -p bitcoin-rs-rpc --features zmq
}
case "$1" in
fmt)
cargo fmt --all -- --check
;;
clippy)
clippy_profiles
;;
test-crates)
test_crates_profiles
;;
test-binary)
test_binary_profiles
;;
test-workspace)
test_workspace_profiles
;;
test)
# Local composition of every test lane, smallest first. CI runs the
# lanes as parallel jobs (.github/workflows/ci.yml); this subcommand
# stays the full sequential gate for pre-commit and local use.
"$0" test-crates
"$0" test-binary
"$0" test-workspace
;;
deny)
# Full dependency graph: every storage backend plus the kernel engine.
# cargo-deny 0.20 takes the cargo metadata flags before the subcommand.
cargo deny \
--workspace --no-default-features --features "rocksdb,fjall,redb,kernel" \
check
;;
deep)
collect_failures=true
clippy_profiles
test_crates_profiles
test_binary_profiles
test_workspace_profiles
finish
;;
all)
"$0" fmt || failures=$((failures + 1))
"$0" deep || failures=$((failures + 1))
"$0" deny || failures=$((failures + 1))
finish
;;
*)
usage
;;
esac