justfile 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251
  1. alias b := build
  2. alias c := check
  3. alias t := test
  4. default:
  5. @just --list
  6. final-check: typos format clippy test
  7. # run `cargo build` on everything
  8. build *ARGS="--workspace --all-targets":
  9. #!/usr/bin/env bash
  10. set -euo pipefail
  11. if [ ! -f Cargo.toml ]; then
  12. cd {{invocation_directory()}}
  13. fi
  14. cargo build {{ARGS}}
  15. # run `cargo check` on everything
  16. check *ARGS="--workspace --all-targets":
  17. #!/usr/bin/env bash
  18. set -euo pipefail
  19. if [ ! -f Cargo.toml ]; then
  20. cd {{invocation_directory()}}
  21. fi
  22. cargo check {{ARGS}}
  23. # run code formatters
  24. format:
  25. #!/usr/bin/env bash
  26. set -euo pipefail
  27. if [ ! -f Cargo.toml ]; then
  28. cd {{invocation_directory()}}
  29. fi
  30. cargo fmt --all
  31. nixpkgs-fmt $(echo **.nix)
  32. # run doc tests
  33. test: build
  34. #!/usr/bin/env bash
  35. set -euo pipefail
  36. if [ ! -f Cargo.toml ]; then
  37. cd {{invocation_directory()}}
  38. fi
  39. cargo test --lib
  40. # Run pure integration tests
  41. cargo test -p cdk-integration-tests --test mint
  42. # run doc tests
  43. test-pure db="memory": build
  44. #!/usr/bin/env bash
  45. set -euo pipefail
  46. if [ ! -f Cargo.toml ]; then
  47. cd {{invocation_directory()}}
  48. fi
  49. # Run pure integration tests
  50. CDK_TEST_DB_TYPE={{db}} cargo test -p cdk-integration-tests --test integration_tests_pure -- --test-threads 1
  51. test-all db="memory":
  52. #!/usr/bin/env bash
  53. just test {{db}}
  54. ./misc/itests.sh "{{db}}"
  55. ./misc/fake_itests.sh "{{db}}" external_signatory
  56. ./misc/fake_itests.sh "{{db}}"
  57. test-nutshell:
  58. #!/usr/bin/env bash
  59. docker run -d -p 3338:3338 --name nutshell -e MINT_LIGHTNING_BACKEND=FakeWallet -e MINT_LISTEN_HOST=0.0.0.0 -e MINT_LISTEN_PORT=3338 -e MINT_PRIVATE_KEY=TEST_PRIVATE_KEY -e MINT_INPUT_FEE_PPK=100 cashubtc/nutshell:latest poetry run mint
  60. # Wait for the Nutshell service to be ready
  61. echo "Waiting for Nutshell to start..."
  62. max_attempts=30
  63. attempt=0
  64. while ! curl -s http://127.0.0.1:3338/v1/info > /dev/null; do
  65. attempt=$((attempt+1))
  66. if [ $attempt -ge $max_attempts ]; then
  67. echo "Nutshell failed to start after $max_attempts attempts"
  68. docker stop nutshell
  69. docker rm nutshell
  70. exit 1
  71. fi
  72. echo "Waiting for Nutshell to start (attempt $attempt/$max_attempts)..."
  73. sleep 1
  74. done
  75. echo "Nutshell is ready!"
  76. export CDK_TEST_MINT_URL=http://127.0.0.1:3338
  77. export LN_BACKEND=FAKEWALLET
  78. cargo test -p cdk-integration-tests --test happy_path_mint_wallet
  79. cargo test -p cdk-integration-tests --test test_fees
  80. unset CDK_TEST_MINT_URL
  81. unset LN_BACKEND
  82. docker stop nutshell
  83. docker rm nutshell
  84. # run `cargo clippy` on everything
  85. clippy *ARGS="--locked --offline --workspace --all-targets":
  86. cargo clippy {{ARGS}}
  87. # run `cargo clippy --fix` on everything
  88. clippy-fix *ARGS="--locked --offline --workspace --all-targets":
  89. cargo clippy {{ARGS}} --fix
  90. typos:
  91. typos
  92. # fix all typos
  93. [no-exit-message]
  94. typos-fix:
  95. just typos -w
  96. itest db:
  97. #!/usr/bin/env bash
  98. ./misc/itests.sh "{{db}}"
  99. fake-mint-itest db:
  100. #!/usr/bin/env bash
  101. ./misc/fake_itests.sh "{{db}}" external_signatory
  102. ./misc/fake_itests.sh "{{db}}"
  103. itest-payment-processor ln:
  104. #!/usr/bin/env bash
  105. ./misc/mintd_payment_processor.sh "{{ln}}"
  106. fake-auth-mint-itest db openid_discovery:
  107. #!/usr/bin/env bash
  108. ./misc/fake_auth_itests.sh "{{db}}" "{{openid_discovery}}"
  109. nutshell-wallet-itest:
  110. #!/usr/bin/env bash
  111. ./misc/nutshell_wallet_itest.sh
  112. run-examples:
  113. cargo r --example p2pk
  114. cargo r --example mint-token
  115. cargo r --example melt-token
  116. cargo r --example proof_selection
  117. cargo r --example wallet
  118. check-wasm *ARGS="--target wasm32-unknown-unknown":
  119. #!/usr/bin/env bash
  120. set -euo pipefail
  121. if [ ! -f Cargo.toml ]; then
  122. cd {{invocation_directory()}}
  123. fi
  124. buildargs=(
  125. "-p cdk"
  126. "-p cdk --no-default-features"
  127. "-p cdk --no-default-features --features wallet"
  128. "-p cdk --no-default-features --features mint"
  129. )
  130. for arg in "${buildargs[@]}"; do
  131. echo "Checking '$arg'"
  132. cargo check $arg {{ARGS}}
  133. echo
  134. done
  135. release m="":
  136. #!/usr/bin/env bash
  137. set -euo pipefail
  138. args=(
  139. "-p cashu"
  140. "-p cdk-common"
  141. "-p cdk-sqlite"
  142. "-p cdk-redb"
  143. "-p cdk"
  144. "-p cdk-rexie"
  145. "-p cdk-axum"
  146. "-p cdk-mint-rpc"
  147. "-p cdk-cln"
  148. "-p cdk-lnd"
  149. "-p cdk-lnbits"
  150. "-p cdk-fake-wallet"
  151. "-p cdk-payment-processor"
  152. "-p cdk-signatory"
  153. "-p cdk-cli"
  154. "-p cdk-mintd"
  155. )
  156. for arg in "${args[@]}";
  157. do
  158. echo "Publishing '$arg'"
  159. cargo publish $arg {{m}}
  160. echo
  161. done
  162. check-docs:
  163. #!/usr/bin/env bash
  164. set -euo pipefail
  165. args=(
  166. "-p cashu"
  167. "-p cdk-common"
  168. "-p cdk"
  169. "-p cdk-redb"
  170. "-p cdk-sqlite"
  171. "-p cdk-axum"
  172. "-p cdk-rexie"
  173. "-p cdk-cln"
  174. "-p cdk-lnd"
  175. "-p cdk-lnbits"
  176. "-p cdk-fake-wallet"
  177. "-p cdk-mint-rpc"
  178. "-p cdk-signatory"
  179. "-p cdk-cli"
  180. "-p cdk-mintd"
  181. )
  182. for arg in "${args[@]}"; do
  183. echo "Checking '$arg' docs"
  184. cargo doc $arg --all-features
  185. echo
  186. done
  187. # Build docs for all crates and error on warnings
  188. docs-strict:
  189. #!/usr/bin/env bash
  190. set -euo pipefail
  191. args=(
  192. "-p cashu"
  193. "-p cdk-common"
  194. "-p cdk"
  195. "-p cdk-redb"
  196. "-p cdk-sqlite"
  197. "-p cdk-axum"
  198. "-p cdk-rexie"
  199. "-p cdk-cln"
  200. "-p cdk-lnd"
  201. "-p cdk-lnbits"
  202. "-p cdk-fake-wallet"
  203. "-p cdk-mint-rpc"
  204. "-p cdk-payment-processor"
  205. "-p cdk-cli"
  206. "-p cdk-mintd"
  207. )
  208. for arg in "${args[@]}"; do
  209. echo "Building docs for $arg with strict warnings"
  210. RUSTDOCFLAGS="-D warnings" cargo doc $arg --all-features --no-deps
  211. echo
  212. done