-
Notifications
You must be signed in to change notification settings - Fork 24
/
justfile
136 lines (101 loc) · 3.51 KB
/
justfile
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
DB_URL := "postgres://postgres:postgres@localhost/moksha-mint"
# list all tasks
default:
@just --list
# install all dependencies
deps:
cargo install sqlx-cli typos-cli grcov wasm-pack wasm-opt just
# clean cargo
clean:
cargo clean
# check code for typos
[no-exit-message]
typos:
#!/usr/bin/env bash
>&2 echo '💡 Valid new words can be added to `typos.toml`'
typos
# fix all typos
[no-exit-message]
typos-fix-all:
#!/usr/bin/env bash
>&2 echo '💡 Valid new words can be added to `typos.toml`'
typos --write-changes
# format code, check typos and run tests
final-check:
cargo fmt --all
just typos
RUST_BACKTRACE=1 cargo test --workspace --exclude integrationtests
just run-itests
just build-wasm
# run coverage and create a report in html and lcov format
run-coverage:
just run-coverage-tests
just run-coverage-report
# runs all tests with coverage instrumentation
run-coverage-tests:
docker compose --profile itest up -d
RUST_BACKTRACE=1 CARGO_INCREMENTAL=0 RUSTFLAGS='-Cinstrument-coverage' LLVM_PROFILE_FILE='cargo-test-%p-%m.profraw' cargo test -- --test-threads=1
docker compose --profile itest down
# creates a coverage report in html and lcov format
run-coverage-report:
#!/usr/bin/env bash
mkdir -p target/coverage
grcov . --binary-path ./target/debug/ -s . -t lcov,html --branch --ignore-not-existing --ignore "*cargo*" --ignore "./data/*" --ignore "*/examples/*" -o target/coverage/
find . -name '*.profraw' -exec rm -r {} \;
>&2 echo '💡 Created the report in html-format target/coverage/html/index.html'
# run the cashu-mint
run-mint *ARGS:
RUST_BACKTRACE=1 MINT_APP_ENV=dev cargo run --bin moksha-mint -- {{ARGS}}
# run cli-wallet with the given args
run-cli *ARGS:
RUST_BACKTRACE=1 cargo run --bin moksha-cli -- --db-dir ./data/wallet {{ARGS}}
# runs all tests
run-tests:
RUST_BACKTRACE=1 cargo test --workspace --exclude integrationtests
# checks if docker and docker compose is installed and running
_check-docker:
#!/usr/bin/env bash
if ! command -v docker &> /dev/null; then
>&2 echo 'Error: Docker is not installed.';
exit 1;
fi
if ! command -v docker compose &> /dev/null; then
>&2 echo 'Error: Docker Compose is not installed.' >&2;
exit 1;
fi
if ! command docker info &> /dev/null; then
>&2 echo 'Error: Docker is not running.';
exit 1;
fi
# starts bitcoind, nutshell, 2 lnd nodes via docker and runs the integration tests
run-itests: _check-docker
cargo build -p moksha-cli
docker compose --profile itest up -d
RUST_BACKTRACE=1 cargo test -p integrationtests -- --test-threads=1
docker compose --profile itest down
# build the mint docker-image
build-docker:
docker build --file Dockerfile.alpine --build-arg COMMITHASH=$(git rev-parse HEAD) --build-arg BUILDTIME=$(date -u '+%F-%T') -t moksha-mint:latest .
# compile all rust crates, that are relevant for the client, to wasm
build-wasm:
cargo +nightly build -p moksha-core -p moksha-wallet \
--target wasm32-unknown-unknown \
-Z build-std=std,panic_abort
# runs sqlx prepare
db-prepare:
cd moksha-mint && \
cargo sqlx prepare --database-url {{ DB_URL }}
# runs sqlx prepare
db-migrate:
cd moksha-mint && \
cargo sqlx migrate run --database-url {{ DB_URL }}
# creates the postgres database
db-create:
cd moksha-mint && \
cargo sqlx database create --database-url {{ DB_URL }}
# publish everything on crates.io
publish:
cargo publish -p moksha-core
cargo publish -p moksha-wallet
cargo publish -p moksha-mint
cargo publish -p moksha-cli