justfile 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247
  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
  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}}"
  56. test-nutshell:
  57. #!/usr/bin/env bash
  58. 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
  59. # Wait for the Nutshell service to be ready
  60. echo "Waiting for Nutshell to start..."
  61. max_attempts=30
  62. attempt=0
  63. while ! curl -s http://127.0.0.1:3338/v1/info > /dev/null; do
  64. attempt=$((attempt+1))
  65. if [ $attempt -ge $max_attempts ]; then
  66. echo "Nutshell failed to start after $max_attempts attempts"
  67. docker stop nutshell
  68. docker rm nutshell
  69. exit 1
  70. fi
  71. echo "Waiting for Nutshell to start (attempt $attempt/$max_attempts)..."
  72. sleep 1
  73. done
  74. echo "Nutshell is ready!"
  75. export CDK_TEST_MINT_URL=http://127.0.0.1:3338
  76. export LN_BACKEND=FAKEWALLET
  77. cargo test -p cdk-integration-tests --test happy_path_mint_wallet
  78. cargo test -p cdk-integration-tests --test test_fees
  79. unset CDK_TEST_MINT_URL
  80. unset LN_BACKEND
  81. docker stop nutshell
  82. docker rm nutshell
  83. # run `cargo clippy` on everything
  84. clippy *ARGS="--locked --offline --workspace --all-targets":
  85. cargo clippy {{ARGS}}
  86. # run `cargo clippy --fix` on everything
  87. clippy-fix *ARGS="--locked --offline --workspace --all-targets":
  88. cargo clippy {{ARGS}} --fix
  89. typos:
  90. typos
  91. # fix all typos
  92. [no-exit-message]
  93. typos-fix:
  94. just typos -w
  95. itest db:
  96. #!/usr/bin/env bash
  97. ./misc/itests.sh "{{db}}"
  98. fake-mint-itest db:
  99. #!/usr/bin/env bash
  100. ./misc/fake_itests.sh "{{db}}"
  101. itest-payment-processor ln:
  102. #!/usr/bin/env bash
  103. ./misc/mintd_payment_processor.sh "{{ln}}"
  104. fake-auth-mint-itest db openid_discovery:
  105. #!/usr/bin/env bash
  106. ./misc/fake_auth_itests.sh "{{db}}" "{{openid_discovery}}"
  107. nutshell-wallet-itest:
  108. #!/usr/bin/env bash
  109. ./misc/nutshell_wallet_itest.sh
  110. run-examples:
  111. cargo r --example p2pk
  112. cargo r --example mint-token
  113. cargo r --example melt-token
  114. cargo r --example proof_selection
  115. cargo r --example wallet
  116. check-wasm *ARGS="--target wasm32-unknown-unknown":
  117. #!/usr/bin/env bash
  118. set -euo pipefail
  119. if [ ! -f Cargo.toml ]; then
  120. cd {{invocation_directory()}}
  121. fi
  122. buildargs=(
  123. "-p cdk"
  124. "-p cdk --no-default-features"
  125. "-p cdk --no-default-features --features wallet"
  126. "-p cdk --no-default-features --features mint"
  127. )
  128. for arg in "${buildargs[@]}"; do
  129. echo "Checking '$arg'"
  130. cargo check $arg {{ARGS}}
  131. echo
  132. done
  133. release m="":
  134. #!/usr/bin/env bash
  135. set -euo pipefail
  136. args=(
  137. "-p cashu"
  138. "-p cdk-common"
  139. "-p cdk-sqlite"
  140. "-p cdk-redb"
  141. "-p cdk"
  142. "-p cdk-rexie"
  143. "-p cdk-axum"
  144. "-p cdk-mint-rpc"
  145. "-p cdk-cln"
  146. "-p cdk-lnd"
  147. "-p cdk-lnbits"
  148. "-p cdk-fake-wallet"
  149. "-p cdk-payment-processor"
  150. "-p cdk-cli"
  151. "-p cdk-mintd"
  152. )
  153. for arg in "${args[@]}";
  154. do
  155. echo "Publishing '$arg'"
  156. cargo publish $arg {{m}}
  157. echo
  158. done
  159. check-docs:
  160. #!/usr/bin/env bash
  161. set -euo pipefail
  162. args=(
  163. "-p cashu"
  164. "-p cdk-common"
  165. "-p cdk"
  166. "-p cdk-redb"
  167. "-p cdk-sqlite"
  168. "-p cdk-axum"
  169. "-p cdk-rexie"
  170. "-p cdk-cln"
  171. "-p cdk-lnd"
  172. "-p cdk-lnbits"
  173. "-p cdk-fake-wallet"
  174. "-p cdk-mint-rpc"
  175. "-p cdk-cli"
  176. "-p cdk-mintd"
  177. )
  178. for arg in "${args[@]}"; do
  179. echo "Checking '$arg' docs"
  180. cargo doc $arg --all-features
  181. echo
  182. done
  183. # Build docs for all crates and error on warnings
  184. docs-strict:
  185. #!/usr/bin/env bash
  186. set -euo pipefail
  187. args=(
  188. "-p cashu"
  189. "-p cdk-common"
  190. "-p cdk"
  191. "-p cdk-redb"
  192. "-p cdk-sqlite"
  193. "-p cdk-axum"
  194. "-p cdk-rexie"
  195. "-p cdk-cln"
  196. "-p cdk-lnd"
  197. "-p cdk-lnbits"
  198. "-p cdk-fake-wallet"
  199. "-p cdk-mint-rpc"
  200. "-p cdk-payment-processor"
  201. "-p cdk-cli"
  202. "-p cdk-mintd"
  203. )
  204. for arg in "${args[@]}"; do
  205. echo "Building docs for $arg with strict warnings"
  206. RUSTDOCFLAGS="-D warnings" cargo doc $arg --all-features --no-deps
  207. echo
  208. done