forked from fedimint/fedimint
-
Notifications
You must be signed in to change notification settings - Fork 0
/
justfile.fedimint.just
252 lines (209 loc) · 8.89 KB
/
justfile.fedimint.just
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
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
# workaround: https://github.com/casey/just/issues/1669
[private]
default-fedi:
just default
# check if ulimit is set correctly
check-ulimit:
#!/usr/bin/env bash
if [ "$(ulimit -Sn)" -lt "1024" ]; then
>&2 echo "⚠️ ulimit too small. Run 'ulimit -Sn 1024' to avoid problems running tests"
fi
# run tests against real services (like bitcoind)
test-real: check-ulimit
./scripts/tests/rust-tests.sh
# run all tests in parallel like CI would
test-ci-all:
./scripts/tests/test-ci-all.sh
# show number of tests per package
test-count:
./scripts/tests/test-cov.sh
test-compatibility *VERSIONS="v0.2.1":
./scripts/tests/test-ci-all-backcompat.sh {{VERSIONS}}
test-full-compatibility *VERSIONS="v0.2.1":
env FM_FULL_VERSION_MATRIX=1 ./scripts/tests/test-ci-all-backcompat.sh {{VERSIONS}}
test-upgrades *VERSIONS="v0.3.3 v0.4.0 current":
./scripts/tests/upgrade-test.sh {{VERSIONS}}
# `cargo udeps` check
udeps:
nix build -L .#nightly.test.workspaceCargoUdeps
bench:
cargo bench
# run all checks recommended before opening a PR
final-check: lint
# can't use nextest due to: https://github.com/nextest-rs/nextest/issues/16
cargo test --doc --workspace
just check-wasm
just test
# run all/most checks a CI would run
final-check-ci: lint
just clippy
just cargo-sort-check
cargo test --doc --workspace
just check-wasm
./scripts/tests/test-ci-all.sh
just test-compatibility
just udeps
check-wasm:
#!/usr/bin/env bash
env CARGO_BUILD_TARGET_DIR=${CARGO_BUILD_TARGET_DIR:-$(pwd)/target}/pkgs/check-wasm \
nix develop .#crossWasm -c \
cargo check --target wasm32-unknown-unknown \
--package fedimint-client \
--package fedimint-wasm-tests
# regenerate server db migration snapshots
# ex: `just snapshot-server-db-migrations fedimint-server`
# ex: `just snapshot-server-db-migrations fedimint-mint-tests`
# ex: `just snapshot-server-db-migrations fedimint-ln-tests`
# ex: `just snapshot-server-db-migrations fedimint-wallet-tests`
# ex: `just snapshot-server-db-migrations fedimint-dummy-tests`
# ex: `just snapshot-server-db-migrations fedimint-ln-gateway`
snapshot-server-db-migrations PACKAGE *EXTRA_ARGS:
env FM_PREPARE_DB_MIGRATION_SNAPSHOTS=force cargo nextest run --workspace --all-targets ${CARGO_PROFILE:+--profile ${CARGO_PROFILE}} -E 'package({{PACKAGE}})' snapshot_server_db_migrations {{EXTRA_ARGS}}
just test-server-db-migrations {{PACKAGE}} {{EXTRA_ARGS}}
test-server-db-migrations PACKAGE *EXTRA_ARGS:
env FM_PREPARE_DB_MIGRATION_SNAPSHOTS=force cargo nextest run --workspace --all-targets ${CARGO_PROFILE:+--profile ${CARGO_PROFILE}} -E 'package({{PACKAGE}})' test_server_db_migrations {{EXTRA_ARGS}}
# regenerate client db migration snapshots
# ex: `just snapshot-client-db-migrations fedimint-dummy-tests`
# ex: `just snapshot-client-db-migrations fedimint-mint-tests`
# ex: `just snapshot-client-db-migrations fedimint-ln-tests`
# ex: `just snapshot-client-db-migrations fedimint-wallet-tests`
snapshot-client-db-migrations PACKAGE *EXTRA_ARGS:
env FM_PREPARE_DB_MIGRATION_SNAPSHOTS=force cargo nextest run --workspace --all-targets ${CARGO_PROFILE:+--profile ${CARGO_PROFILE}} -E 'package({{PACKAGE}})' snapshot_client_db_migrations {{EXTRA_ARGS}}
just test-client-db-migrations {{PACKAGE}} {{EXTRA_ARGS}}
test-client-db-migrations PACKAGE *EXTRA_ARGS:
env FM_PREPARE_DB_MIGRATION_SNAPSHOTS=force cargo nextest run --workspace --all-targets ${CARGO_PROFILE:+--profile ${CARGO_PROFILE}} -E 'package({{PACKAGE}})' test_client_db_migrations {{EXTRA_ARGS}}
test-db-migrations:
just test-client-db-migrations fedimint-dummy-tests
just test-client-db-migrations fedimint-mint-tests
just test-client-db-migrations fedimint-ln-tests
just test-client-db-migrations fedimint-wallet-tests
just test-server-db-migrations fedimint-dummy-tests
just test-server-db-migrations fedimint-mint-tests
just test-server-db-migrations fedimint-ln-tests
just test-server-db-migrations fedimint-wallet-tests
just test-server-db-migrations fedimint-server
just test-server-db-migrations fedimint-ln-gateway
snapshot-db-migrations:
just snapshot-client-db-migrations fedimint-dummy-tests
just snapshot-client-db-migrations fedimint-mint-tests
just snapshot-client-db-migrations fedimint-ln-tests
just snapshot-client-db-migrations fedimint-wallet-tests
just snapshot-server-db-migrations fedimint-dummy-tests
just snapshot-server-db-migrations fedimint-mint-tests
just snapshot-server-db-migrations fedimint-ln-tests
just snapshot-server-db-migrations fedimint-wallet-tests
just snapshot-server-db-migrations fedimint-server
just snapshot-server-db-migrations fedimint-ln-gateway
just test-db-migrations
# start mprocs with a dev federation setup. Default: 4 nodes, add `-n 1` argument to start only 1 node
mprocs *PARAMS:
./scripts/dev/mprocs/run.sh {{PARAMS}}
# exit mprocs session
exit-mprocs:
mprocs --ctl '{c: quit}' --server 127.0.0.1:4050
# start tmuxinator with dev federation setup
tmuxinator:
./scripts/dev/tmuxinator/run.sh
devimint-env *PARAMS:
./scripts/dev/devimint-env.sh {{PARAMS}}
devimint-env-tmux *PARAMS:
./scripts/dev/tmuxinator/run.sh {{PARAMS}}
devimint-env-mprocs *PARAMS:
./scripts/dev/mprocs/run.sh {{PARAMS}}
# exit tmuxinator session
exit-tmuxinator:
tmux kill-session -t fedimint-dev
# backport a PR
backport-pr pr:
nix shell nixpkgs#nodejs -c npx backport --pr-filter {{pr}}
# sign a release (git tag)
sign-release tag:
./scripts/release/sign.sh {{tag}}
# benchmark compilation times
bench-compilation:
./scripts/bench-compilation.sh
fuzz-target TARGET="" *ARGS="--exit_upon_crash":
#!/usr/bin/env bash
set -euo pipefail
if [ -z "{{TARGET}}" ]; then
>&2 echo "Available targets:"
>&2 echo ""
ls fuzz/src/bin/ | sed -e 's/.rs$//g'
exit 1
fi
# reference: https://github.com/google/honggfuzz/blob/master/docs/USAGE.md#usage
export HFUZZ_RUN_ARGS="{{ARGS}}"
# notes:
# * TODO: make flakebox set CC, as hfuzz seems to ignore CC_<target>
# * TODO: make flakebox set RUSTFLAGS, as hfuzz seems to ignore CARGO_BUILD_<target>_RUSTFLAGS
# * can't be run with sccache, so just disable here
env -u RUSTC_WRAPPER CC=clang RUSTFLAGS="--cfg tokio_unstable" cargo hfuzz run {{TARGET}}
# A quick round of fuzzing for every defined target
fuzz-ci-quick *ARGS="--exit_upon_crash --run_time 30 -q -v --threads 2":
#!/usr/bin/env bash
set -euo pipefail
export HFUZZ_RUN_ARGS="{{ARGS}}"
for target in $(ls fuzz/src/bin/ | sed -e 's/.rs$//g') ; do
>&2 echo "Fuzzing ${target}"
env -u RUSTC_WRAPPER CC=clang RUSTFLAGS="--cfg tokio_unstable" \
cargo hfuzz run "${target}"
done
fuzz-target-debug TARGET="" CRASH="" *ARGS="--exit_upon_crash":
#!/usr/bin/env bash
set -euo pipefail
if [ -z "{{TARGET}}" ]; then
>&2 echo "Available targets:"
>&2 echo ""
ls fuzz/src/bin/ | sed -e 's/.rs$//g'
exit 1
fi
# reference: https://github.com/google/honggfuzz/blob/master/docs/USAGE.md#usage
export HFUZZ_RUN_ARGS="{{ARGS}}"
export HFUZZ_DEBUGGER=${HFUZZ_DEBUGGER:-gdb}
crash="CRASH"
if [ -z "${CRASH:-}" ]; then
CRASH="hfuzz_workspace/{{TARGET}}/*.fuzz"
fi
# notes:
# * TODO: make flakebox set CC, as hfuzz seems to ignore CC_<target>
# * TODO: make flakebox set RUSTFLAGS, as hfuzz seems to ignore CARGO_BUILD_<target>_RUSTFLAGS
# * can't be run with sccache, so just disable here
env -u RUSTC_WRAPPER CC=clang RUSTFLAGS="--cfg tokio_unstable" cargo hfuzz run-debug {{TARGET}} ${CRASH}
# Build `cargo doc`-generated documentation
build-docs:
./scripts/dev/build-docs.sh
# Build `cargo doc`-generated documentation just like on https://docs.fedimint.org
build-docs-nix: build-docs
nix build -L .#nightly.ci.workspaceDocExport
# Open `cargo doc`-generated documentation
docs: build-docs
#!/usr/bin/env bash
if command -v xdg-open 1>/dev/null 2>/dev/null ; then
open_cmd="xdg-open"
elif command -v open 1>/dev/null 2>/dev/null ; then
open_cmd="open"
else
>&2 echo "Install xdg-open. Falling back to one from nix"
open_cmd="nix shell nixpkgs#xdg-utils -c xdg-open"
fi
source "scripts/_common.sh"
main_index_path="${CARGO_BUILD_TARGET_DIR}/doc/index.html"
fallback_index_path="${CARGO_BUILD_TARGET_DIR}/doc/fedimint_core/index.html"
if [ -e "$main_index_path" ]; then
echo "file://$fallback_index_path"
$open_cmd "$main_index_path" || true
else
echo "file://$fallback_index_path"
$open_cmd "$fallback_index_path" || true
fi
# Bump all versions
# ex: `just bump-version 0.5.0-alpha 0.5.0-rc.0`
bump-version FROM_VERSION TO_VERSION:
find . -name 'Cargo.toml' -exec sed -i 's/{{FROM_VERSION}}/{{TO_VERSION}}/g' {} +
cargo_sort_defaults := "-w -g --order package,features,bin,lib,test,bench,dependencies,dev-dependencies,build-dependencies"
# Fix sort order in `Cargo.toml` files
cargo-sort-fix *ARGS="":
cargo sort {{cargo_sort_defaults}} {{ARGS}}
# Check sort order in `Cargo.toml` files
cargo-sort-check *ARGS="":
cargo sort {{cargo_sort_defaults}} --check {{ARGS}}