justfile 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678
  1. alias b := build
  2. alias c := check
  3. alias t := test
  4. default:
  5. @just --list
  6. # Create a new SQL migration file
  7. new-migration target name:
  8. #!/usr/bin/env bash
  9. set -euo pipefail
  10. if [ "{{target}}" != "mint" ] && [ "{{target}}" != "wallet" ]; then
  11. echo "Error: target must be either 'mint' or 'wallet'"
  12. exit 1
  13. fi
  14. timestamp=$(date +%Y%m%d%H%M%S)
  15. migration_path="./crates/cdk-sql-common/src/{{target}}/migrations/${timestamp}_{{name}}.sql"
  16. # Create the file
  17. mkdir -p "$(dirname "$migration_path")"
  18. touch "$migration_path"
  19. echo "Created new migration: $migration_path"
  20. final-check: typos format clippy test
  21. # run `cargo build` on everything
  22. build *ARGS="--workspace --all-targets":
  23. #!/usr/bin/env bash
  24. set -euo pipefail
  25. if [ ! -f Cargo.toml ]; then
  26. cd {{invocation_directory()}}
  27. fi
  28. cargo build {{ARGS}}
  29. # run `cargo check` on everything
  30. check *ARGS="--workspace --all-targets":
  31. #!/usr/bin/env bash
  32. set -euo pipefail
  33. if [ ! -f Cargo.toml ]; then
  34. cd {{invocation_directory()}}
  35. fi
  36. cargo check {{ARGS}}
  37. # run code formatters
  38. format:
  39. #!/usr/bin/env bash
  40. set -euo pipefail
  41. if [ ! -f Cargo.toml ]; then
  42. cd {{invocation_directory()}}
  43. fi
  44. cargo fmt --all
  45. nixpkgs-fmt $(echo **.nix)
  46. # run doc tests
  47. test:
  48. #!/usr/bin/env bash
  49. set -euo pipefail
  50. if [ ! -f Cargo.toml ]; then
  51. cd {{invocation_directory()}}
  52. fi
  53. cargo test --lib --workspace --exclude cdk-postgres
  54. # Run pure integration tests
  55. cargo test -p cdk-integration-tests --test mint
  56. # run doc tests
  57. test-pure db="memory":
  58. #!/usr/bin/env bash
  59. set -euo pipefail
  60. if [ ! -f Cargo.toml ]; then
  61. cd {{invocation_directory()}}
  62. fi
  63. # Run pure integration tests (cargo test will only build what's needed for the test)
  64. CDK_TEST_DB_TYPE={{db}} cargo test -p cdk-integration-tests --test integration_tests_pure -- --test-threads 1
  65. # Run swap flow tests (detailed testing of swap operation)
  66. CDK_TEST_DB_TYPE={{db}} cargo test -p cdk-integration-tests --test test_swap_flow -- --test-threads 1
  67. test-all db="memory":
  68. #!/usr/bin/env bash
  69. set -euo pipefail
  70. just test {{db}}
  71. bash ./misc/itests.sh "{{db}}"
  72. bash ./misc/fake_itests.sh "{{db}}" external_signatory
  73. bash ./misc/fake_itests.sh "{{db}}"
  74. # Mutation Testing Commands
  75. # Run mutation tests on a specific crate
  76. # Usage: just mutants <crate-name>
  77. # Example: just mutants cashu
  78. mutants CRATE:
  79. #!/usr/bin/env bash
  80. set -euo pipefail
  81. echo "Running mutation tests on crate: {{CRATE}}"
  82. cargo mutants --package {{CRATE}} -vV
  83. # Run mutation tests on the cashu crate
  84. mutants-cashu:
  85. #!/usr/bin/env bash
  86. set -euo pipefail
  87. echo "Running mutation tests on cashu crate..."
  88. cargo mutants --package cashu -vV
  89. # Run mutation tests on the cdk crate
  90. mutants-cdk:
  91. #!/usr/bin/env bash
  92. set -euo pipefail
  93. echo "Running mutation tests on cdk crate..."
  94. cargo mutants --package cdk -vV
  95. # Run mutation tests on entire workspace (WARNING: very slow)
  96. mutants-all:
  97. #!/usr/bin/env bash
  98. set -euo pipefail
  99. echo "Running mutation tests on entire workspace..."
  100. echo "WARNING: This may take a very long time!"
  101. cargo mutants -vV
  102. # Quick mutation test for current work (alias for mutants-diff)
  103. mutants-quick:
  104. #!/usr/bin/env bash
  105. set -euo pipefail
  106. echo "Running mutations on changed files since HEAD..."
  107. cargo mutants --in-diff HEAD -vV
  108. # Run mutation tests only on changed code since HEAD
  109. mutants-diff:
  110. #!/usr/bin/env bash
  111. set -euo pipefail
  112. echo "Running mutation tests on changed code..."
  113. cargo mutants --in-diff HEAD -vV
  114. # Run mutation tests and save output to log file
  115. # Usage: just mutants-log <crate-name> <log-suffix>
  116. # Example: just mutants-log cashu baseline
  117. mutants-log CRATE SUFFIX:
  118. #!/usr/bin/env bash
  119. set -euo pipefail
  120. if [ ! -f Cargo.toml ]; then
  121. cd {{invocation_directory()}}
  122. fi
  123. LOG_FILE="mutants-{{CRATE}}-{{SUFFIX}}.log"
  124. echo "Running mutation tests on {{CRATE}}, saving to $LOG_FILE..."
  125. cargo mutants --package {{CRATE}} -vV 2>&1 | tee "$LOG_FILE"
  126. echo "Results saved to $LOG_FILE"
  127. # Mutation test with baseline comparison
  128. # Usage: just mutants-check <crate-name>
  129. # Example: just mutants-check cashu
  130. mutants-check CRATE:
  131. #!/usr/bin/env bash
  132. set -euo pipefail
  133. BASELINE="mutants-{{CRATE}}-baseline.log"
  134. if [ ! -f "$BASELINE" ]; then
  135. echo "ERROR: No baseline found at $BASELINE"
  136. echo "Run: just mutants-log {{CRATE}} baseline"
  137. exit 1
  138. fi
  139. cargo mutants --package {{CRATE}} -vV | tee mutants-{{CRATE}}-current.log
  140. # Compare results
  141. echo "=== Baseline vs Current ==="
  142. diff <(grep "^CAUGHT\|^MISSED" "$BASELINE" | wc -l) \
  143. <(grep "^CAUGHT\|^MISSED" mutants-{{CRATE}}-current.log | wc -l) || true
  144. test-nutshell:
  145. #!/usr/bin/env bash
  146. set -euo pipefail
  147. # Function to cleanup docker containers
  148. cleanup() {
  149. echo "Cleaning up docker containers..."
  150. docker stop nutshell 2>/dev/null || true
  151. docker rm nutshell 2>/dev/null || true
  152. unset CDK_ITESTS_DIR
  153. }
  154. # Trap to ensure cleanup happens on exit (success or failure)
  155. trap cleanup EXIT
  156. # Clean up any leftover containers from previous runs
  157. docker stop nutshell 2>/dev/null || true
  158. docker rm nutshell 2>/dev/null || true
  159. docker run -d --network=host --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
  160. export CDK_ITESTS_DIR=$(mktemp -d)
  161. # Wait for the Nutshell service to be ready
  162. echo "Waiting for Nutshell to start..."
  163. max_attempts=30
  164. attempt=0
  165. while ! curl -s http://127.0.0.1:3338/v1/info > /dev/null; do
  166. attempt=$((attempt+1))
  167. if [ $attempt -ge $max_attempts ]; then
  168. echo "Nutshell failed to start after $max_attempts attempts"
  169. echo "=== Docker container status ==="
  170. docker ps -a --filter name=nutshell
  171. echo "=== Docker logs ==="
  172. docker logs nutshell 2>&1 || true
  173. exit 1
  174. fi
  175. echo "Waiting for Nutshell to start (attempt $attempt/$max_attempts)..."
  176. # Show container status every 10 attempts
  177. if [ $((attempt % 10)) -eq 0 ]; then
  178. echo "=== Container status check ==="
  179. docker ps -a --filter name=nutshell
  180. fi
  181. sleep 1
  182. done
  183. echo "Nutshell is ready!"
  184. # Set environment variables and run tests
  185. export CDK_TEST_MINT_URL=http://127.0.0.1:3338
  186. export LN_BACKEND=FAKEWALLET
  187. # Track test results
  188. test_exit_code=0
  189. # Run first test and capture exit code
  190. echo "Running happy_path_mint_wallet test..."
  191. if ! cargo test -p cdk-integration-tests --test happy_path_mint_wallet; then
  192. echo "ERROR: happy_path_mint_wallet test failed"
  193. test_exit_code=1
  194. fi
  195. # Run second test and capture exit code
  196. echo "Running test_fees test..."
  197. if ! cargo test -p cdk-integration-tests --test test_fees; then
  198. echo "ERROR: test_fees test failed"
  199. test_exit_code=1
  200. fi
  201. unset CDK_TEST_MINT_URL
  202. unset LN_BACKEND
  203. # Exit with error code if any test failed
  204. if [ $test_exit_code -ne 0 ]; then
  205. echo "One or more tests failed"
  206. exit $test_exit_code
  207. fi
  208. echo "All tests passed successfully"
  209. # run `cargo clippy` on everything
  210. clippy *ARGS="--workspace --all-targets":
  211. cargo clippy {{ARGS}} -- -D warnings
  212. # run `cargo clippy --fix` on everything
  213. clippy-fix *ARGS="--workspace --all-targets":
  214. cargo clippy {{ARGS}} --fix
  215. typos:
  216. typos
  217. # fix all typos
  218. [no-exit-message]
  219. typos-fix:
  220. just typos -w
  221. # run all linting checks (format check, typos, nix format)
  222. lint:
  223. #!/usr/bin/env bash
  224. set -euo pipefail
  225. if [ ! -f Cargo.toml ]; then
  226. cd {{invocation_directory()}}
  227. fi
  228. echo "Checking Rust formatting..."
  229. cargo fmt --all -- --check
  230. echo "Checking Nix formatting..."
  231. nixpkgs-fmt --check $(echo **.nix)
  232. echo "Checking for typos..."
  233. typos
  234. echo "All checks passed!"
  235. # Goose AI Recipe Commands
  236. # Update changelog from staged changes using Goose AI
  237. goose-git-msg:
  238. #!/usr/bin/env bash
  239. set -euo pipefail
  240. goose run --recipe ./misc/recipes/git-commit-message.yaml --interactive
  241. # Create git message from staged changes using Goose AI
  242. goose-changelog-staged:
  243. #!/usr/bin/env bash
  244. set -euo pipefail
  245. goose run --recipe ./misc/recipes/changelog-update.yaml --interactive
  246. # Update changelog from recent commits using Goose AI
  247. # Usage: just goose-changelog-commits [number_of_commits]
  248. goose-changelog-commits *COMMITS="5":
  249. #!/usr/bin/env bash
  250. set -euo pipefail
  251. COMMITS={{COMMITS}} goose run --recipe ./misc/recipes/changelog-from-commits.yaml --interactive
  252. itest db:
  253. #!/usr/bin/env bash
  254. set -euo pipefail
  255. bash ./misc/itests.sh "{{db}}"
  256. fake-mint-itest db:
  257. #!/usr/bin/env bash
  258. set -euo pipefail
  259. bash ./misc/fake_itests.sh "{{db}}"
  260. bash ./misc/fake_itests.sh "{{db}}" external_signatory
  261. itest-payment-processor ln:
  262. #!/usr/bin/env bash
  263. set -euo pipefail
  264. bash ./misc/mintd_payment_processor.sh "{{ln}}"
  265. fake-auth-mint-itest db openid_discovery:
  266. #!/usr/bin/env bash
  267. set -euo pipefail
  268. bash ./misc/fake_auth_itests.sh "{{db}}" "{{openid_discovery}}"
  269. nutshell-wallet-itest:
  270. #!/usr/bin/env bash
  271. set -euo pipefail
  272. bash ./misc/nutshell_wallet_itest.sh
  273. # Start interactive regtest environment (Bitcoin + 4 LN nodes + 2 CDK mints)
  274. regtest db="sqlite":
  275. #!/usr/bin/env bash
  276. set -euo pipefail
  277. bash ./misc/interactive_regtest_mprocs.sh {{db}}
  278. # Lightning Network Commands (require regtest environment to be running)
  279. # Get CLN node 1 info
  280. ln-cln1 *ARGS:
  281. #!/usr/bin/env bash
  282. set -euo pipefail
  283. bash ./misc/regtest_helper.sh ln-cln1 {{ARGS}}
  284. # Get CLN node 2 info
  285. ln-cln2 *ARGS:
  286. #!/usr/bin/env bash
  287. set -euo pipefail
  288. bash ./misc/regtest_helper.sh ln-cln2 {{ARGS}}
  289. # Get LND node 1 info
  290. ln-lnd1 *ARGS:
  291. #!/usr/bin/env bash
  292. set -euo pipefail
  293. bash ./misc/regtest_helper.sh ln-lnd1 {{ARGS}}
  294. # Get LND node 2 info
  295. ln-lnd2 *ARGS:
  296. #!/usr/bin/env bash
  297. set -euo pipefail
  298. bash ./misc/regtest_helper.sh ln-lnd2 {{ARGS}}
  299. # Bitcoin regtest commands
  300. btc *ARGS:
  301. #!/usr/bin/env bash
  302. set -euo pipefail
  303. bash ./misc/regtest_helper.sh btc {{ARGS}}
  304. # Mine blocks in regtest
  305. btc-mine blocks="10":
  306. #!/usr/bin/env bash
  307. set -euo pipefail
  308. bash ./misc/regtest_helper.sh btc-mine {{blocks}}
  309. # Show mint information
  310. mint-info:
  311. #!/usr/bin/env bash
  312. set -euo pipefail
  313. bash ./misc/regtest_helper.sh mint-info
  314. # Run integration tests against regtest environment
  315. mint-test:
  316. #!/usr/bin/env bash
  317. set -euo pipefail
  318. bash ./misc/regtest_helper.sh mint-test
  319. # Restart mints after recompiling (useful for development)
  320. restart-mints:
  321. #!/usr/bin/env bash
  322. set -euo pipefail
  323. bash ./misc/regtest_helper.sh restart-mints
  324. # Show regtest environment status
  325. regtest-status:
  326. #!/usr/bin/env bash
  327. set -euo pipefail
  328. bash ./misc/regtest_helper.sh show-status
  329. # Show regtest environment logs
  330. regtest-logs:
  331. #!/usr/bin/env bash
  332. set -euo pipefail
  333. bash ./misc/regtest_helper.sh show-logs
  334. run-examples:
  335. cargo r --example p2pk
  336. cargo r --example mint-token
  337. cargo r --example melt-token
  338. cargo r --example proof_selection
  339. cargo r --example wallet
  340. check-wasm *ARGS="--target wasm32-unknown-unknown":
  341. #!/usr/bin/env bash
  342. set -euo pipefail
  343. if [ ! -f Cargo.toml ]; then
  344. cd {{invocation_directory()}}
  345. fi
  346. buildargs=(
  347. "-p cdk"
  348. "-p cdk --no-default-features"
  349. "-p cdk --no-default-features --features wallet"
  350. "-p cdk --no-default-features --features mint"
  351. )
  352. for arg in "${buildargs[@]}"; do
  353. echo "Checking '$arg'"
  354. cargo check $arg {{ARGS}}
  355. echo
  356. done
  357. release m="":
  358. #!/usr/bin/env bash
  359. set -euo pipefail
  360. args=(
  361. "-p cashu"
  362. "-p cdk-prometheus"
  363. "-p cdk-common"
  364. "-p cdk-sql-common"
  365. "-p cdk-sqlite"
  366. "-p cdk-postgres"
  367. "-p cdk-redb"
  368. "-p cdk-signatory"
  369. "-p cdk-fake-wallet"
  370. "-p cdk"
  371. "-p cdk-ffi"
  372. "-p cdk-axum"
  373. "-p cdk-mint-rpc"
  374. "-p cdk-cln"
  375. "-p cdk-lnd"
  376. "-p cdk-lnbits"
  377. "-p cdk-ldk-node"
  378. "-p cdk-payment-processor"
  379. "-p cdk-cli"
  380. "-p cdk-mintd"
  381. )
  382. for arg in "${args[@]}";
  383. do
  384. echo "Publishing '$arg'"
  385. cargo publish $arg {{m}}
  386. echo
  387. done
  388. # Extract version from the cdk-ffi crate
  389. VERSION=$(cargo metadata --format-version 1 --no-deps | jq -r '.packages[] | select(.name == "cdk-ffi") | .version')
  390. # Trigger Swift package release after Rust crates are published
  391. echo "📦 Triggering Swift package release for version $VERSION..."
  392. just ffi-release-swift $VERSION
  393. check-docs:
  394. #!/usr/bin/env bash
  395. set -euo pipefail
  396. args=(
  397. "-p cashu"
  398. "-p cdk-common"
  399. "-p cdk-sql-common"
  400. "-p cdk"
  401. "-p cdk-redb"
  402. "-p cdk-sqlite"
  403. "-p cdk-axum"
  404. "-p cdk-cln"
  405. "-p cdk-lnd"
  406. "-p cdk-lnbits"
  407. "-p cdk-fake-wallet"
  408. "-p cdk-mint-rpc"
  409. "-p cdk-payment-processor"
  410. "-p cdk-signatory"
  411. "-p cdk-cli"
  412. "-p cdk-mintd"
  413. )
  414. for arg in "${args[@]}"; do
  415. echo "Checking '$arg' docs"
  416. cargo doc $arg --all-features
  417. echo
  418. done
  419. # Build docs for all crates and error on warnings
  420. docs-strict:
  421. #!/usr/bin/env bash
  422. set -euo pipefail
  423. args=(
  424. "-p cashu"
  425. "-p cdk-common"
  426. "-p cdk-sql-common"
  427. "-p cdk"
  428. "-p cdk-redb"
  429. "-p cdk-sqlite"
  430. "-p cdk-axum"
  431. "-p cdk-cln"
  432. "-p cdk-lnd"
  433. "-p cdk-lnbits"
  434. "-p cdk-fake-wallet"
  435. "-p cdk-mint-rpc"
  436. "-p cdk-payment-processor"
  437. "-p cdk-signatory"
  438. "-p cdk-cli"
  439. "-p cdk-mintd"
  440. )
  441. for arg in "${args[@]}"; do
  442. echo "Building docs for $arg with strict warnings"
  443. RUSTDOCFLAGS="-D warnings" cargo doc $arg --all-features --no-deps
  444. echo
  445. done
  446. # =============================================================================
  447. # FFI Commands - CDK Foreign Function Interface bindings
  448. # =============================================================================
  449. # Helper function to get library extension based on platform
  450. _ffi-lib-ext:
  451. #!/usr/bin/env bash
  452. if [[ "$OSTYPE" == "darwin"* ]]; then
  453. echo "dylib"
  454. else
  455. echo "so"
  456. fi
  457. # Build the FFI library
  458. ffi-build *ARGS="--release":
  459. cargo build {{ARGS}} --package cdk-ffi --features postgres
  460. # Generate bindings for a specific language
  461. ffi-generate LANGUAGE *ARGS="--release": ffi-build
  462. #!/usr/bin/env bash
  463. set -euo pipefail
  464. LANG="{{LANGUAGE}}"
  465. # Validate language
  466. case "$LANG" in
  467. python|swift|kotlin)
  468. ;;
  469. *)
  470. echo "❌ Unsupported language: $LANG"
  471. echo "Supported languages: python, swift, kotlin"
  472. exit 1
  473. ;;
  474. esac
  475. # Set emoji and build type
  476. case "$LANG" in
  477. python) EMOJI="🐍" ;;
  478. swift) EMOJI="🍎" ;;
  479. kotlin) EMOJI="🎯" ;;
  480. esac
  481. # Determine build type and library path
  482. if [[ "{{ARGS}}" == *"--release"* ]] || [[ "{{ARGS}}" == "" ]]; then
  483. BUILD_TYPE="release"
  484. else
  485. BUILD_TYPE="debug"
  486. cargo build --package cdk-ffi --features postgres
  487. fi
  488. LIB_EXT=$(just _ffi-lib-ext)
  489. echo "$EMOJI Generating $LANG bindings..."
  490. mkdir -p target/bindings/$LANG
  491. cargo run --bin uniffi-bindgen generate \
  492. --library target/$BUILD_TYPE/libcdk_ffi.$LIB_EXT \
  493. --language $LANG \
  494. --out-dir target/bindings/$LANG
  495. echo "✅ $LANG bindings generated in target/bindings/$LANG/"
  496. # Generate Python bindings (shorthand)
  497. ffi-generate-python *ARGS="--release":
  498. just ffi-generate python {{ARGS}}
  499. # Generate Swift bindings (shorthand)
  500. ffi-generate-swift *ARGS="--release":
  501. just ffi-generate swift {{ARGS}}
  502. # Generate Kotlin bindings (shorthand)
  503. ffi-generate-kotlin *ARGS="--release":
  504. just ffi-generate kotlin {{ARGS}}
  505. # Generate bindings for all supported languages
  506. ffi-generate-all *ARGS="--release": ffi-build
  507. @echo "🔧 Generating UniFFI bindings for all languages..."
  508. just ffi-generate python {{ARGS}}
  509. just ffi-generate swift {{ARGS}}
  510. just ffi-generate kotlin {{ARGS}}
  511. @echo "✅ All bindings generated successfully!"
  512. # Run Python FFI tests
  513. ffi-test: ffi-generate-python
  514. #!/usr/bin/env bash
  515. set -euo pipefail
  516. echo "🧪 Running Python FFI tests..."
  517. python3 crates/cdk-ffi/tests/test_transactions.py
  518. python3 crates/cdk-ffi/tests/test_kvstore.py
  519. echo "✅ Tests completed!"
  520. # Build debug version and generate Python bindings quickly (for development)
  521. ffi-dev-python:
  522. #!/usr/bin/env bash
  523. set -euo pipefail
  524. # Generate Python bindings first
  525. just ffi-generate python --debug
  526. # Copy library to Python bindings directory
  527. LIB_EXT=$(just _ffi-lib-ext)
  528. echo "📦 Copying library to Python bindings directory..."
  529. cp target/debug/libcdk_ffi.$LIB_EXT target/bindings/python/
  530. # Launch Python REPL with CDK FFI loaded
  531. cd target/bindings/python
  532. echo "🐍 Launching Python REPL with CDK FFI library loaded..."
  533. echo "💡 The 'cdk_ffi' module is pre-imported and ready to use!"
  534. python3 -i -c "from cdk_ffi import *; print('✅ CDK FFI library loaded successfully!');"
  535. # Test language bindings with a simple import
  536. ffi-test-bindings LANGUAGE: (ffi-generate LANGUAGE "--debug")
  537. #!/usr/bin/env bash
  538. set -euo pipefail
  539. LANG="{{LANGUAGE}}"
  540. LIB_EXT=$(just _ffi-lib-ext)
  541. echo "📦 Copying library to $LANG bindings directory..."
  542. cp target/debug/libcdk_ffi.$LIB_EXT target/bindings/$LANG/
  543. cd target/bindings/$LANG
  544. echo "🧪 Testing $LANG bindings..."
  545. case "$LANG" in
  546. python)
  547. python3 -c "import cdk_ffi; print('✅ Python bindings work!')"
  548. ;;
  549. *)
  550. echo "✅ $LANG bindings generated (manual testing required)"
  551. ;;
  552. esac
  553. # Test Python bindings (shorthand)
  554. ffi-test-python:
  555. just ffi-test-bindings python
  556. # Trigger Swift Package release workflow
  557. ffi-release-swift VERSION:
  558. #!/usr/bin/env bash
  559. set -euo pipefail
  560. echo "🚀 Triggering Publish Swift Package workflow..."
  561. echo " Version: {{VERSION}}"
  562. echo " CDK Ref: v{{VERSION}}"
  563. # Trigger the workflow using GitHub CLI
  564. gh workflow run "Publish Swift Package" \
  565. --repo cashubtc/cdk-swift \
  566. --field version="{{VERSION}}" \
  567. --field cdk_repo="cashubtc/cdk" \
  568. --field cdk_ref="v{{VERSION}}"
  569. echo "✅ Workflow triggered successfully!"