ci.yml 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611
  1. name: CI
  2. on:
  3. push:
  4. branches: [main]
  5. pull_request:
  6. branches:
  7. - main
  8. - 'v[0-9]*.[0-9]*.x' # Match version branches like v0.13.x, v1.0.x, etc.
  9. release:
  10. types: [created]
  11. env:
  12. CARGO_TERM_COLOR: always
  13. jobs:
  14. pre-commit-checks:
  15. name: "Cargo fmt, typos"
  16. runs-on: ubuntu-latest
  17. timeout-minutes: 30
  18. steps:
  19. - name: checkout
  20. uses: actions/checkout@v4
  21. - name: Get flake hash
  22. id: flake-hash
  23. run: echo "hash=$(sha256sum flake.lock | cut -d' ' -f1 | cut -c1-8)" >> $GITHUB_OUTPUT
  24. - name: Install Nix
  25. uses: DeterminateSystems/nix-installer-action@v17
  26. - name: Nix Cache
  27. uses: DeterminateSystems/magic-nix-cache-action@main
  28. with:
  29. diagnostic-endpoint: ""
  30. use-flakehub: false
  31. - name: Rust Cache
  32. uses: Swatinem/rust-cache@v2
  33. with:
  34. shared-key: "nightly-${{ steps.flake-hash.outputs.hash }}"
  35. - name: Cargo fmt
  36. run: |
  37. nix develop -i -L .#nightly --command bash -c '
  38. # Force use of Nix-provided rustfmt
  39. export RUSTFMT=$(command -v rustfmt)
  40. cargo fmt --check
  41. '
  42. - name: typos
  43. run: nix develop -i -L .#nightly --command typos
  44. examples:
  45. name: "Run examples"
  46. runs-on: ubuntu-latest
  47. timeout-minutes: 30
  48. needs: pre-commit-checks
  49. strategy:
  50. fail-fast: true
  51. matrix:
  52. build-args:
  53. [
  54. mint-token,
  55. melt-token,
  56. p2pk,
  57. proof-selection,
  58. wallet
  59. ]
  60. steps:
  61. - name: checkout
  62. uses: actions/checkout@v4
  63. - name: Get flake hash
  64. id: flake-hash
  65. run: echo "hash=$(sha256sum flake.lock | cut -d' ' -f1 | cut -c1-8)" >> $GITHUB_OUTPUT
  66. - name: Install Nix
  67. uses: DeterminateSystems/nix-installer-action@v17
  68. - name: Nix Cache
  69. uses: DeterminateSystems/magic-nix-cache-action@main
  70. with:
  71. diagnostic-endpoint: ""
  72. use-flakehub: false
  73. - name: Rust Cache
  74. uses: Swatinem/rust-cache@v2
  75. with:
  76. shared-key: "stable-${{ steps.flake-hash.outputs.hash }}"
  77. - name: Run example
  78. run: nix develop -i -L .#stable --command cargo r --example ${{ matrix.build-args }}
  79. clippy:
  80. name: "Stable build, clippy and test"
  81. runs-on: ubuntu-latest
  82. timeout-minutes: 30
  83. needs: pre-commit-checks
  84. strategy:
  85. fail-fast: true
  86. matrix:
  87. build-args:
  88. [
  89. # Core crate testing
  90. -p cashu,
  91. -p cashu --no-default-features,
  92. -p cashu --no-default-features --features wallet,
  93. -p cashu --no-default-features --features mint,
  94. -p cashu --no-default-features --features auth,
  95. -p cdk-common,
  96. -p cdk-common --no-default-features,
  97. -p cdk-common --no-default-features --features wallet,
  98. -p cdk-common --no-default-features --features mint,
  99. -p cdk-common --no-default-features --features auth,
  100. -p cdk,
  101. -p cdk --no-default-features,
  102. -p cdk --no-default-features --features wallet,
  103. -p cdk --no-default-features --features mint,
  104. -p cdk --no-default-features --features auth,
  105. -p cdk-sql-common,
  106. -p cdk-sql-common --no-default-features --features wallet,
  107. -p cdk-sql-common --no-default-features --features mint,
  108. # Database and infrastructure crates
  109. -p cdk-redb,
  110. -p cdk-sqlite,
  111. -p cdk-sqlite --features sqlcipher,
  112. # HTTP/API layer - consolidated
  113. -p cdk-axum,
  114. -p cdk-axum --no-default-features,
  115. -p cdk-axum --no-default-features --features redis,
  116. -p cdk-axum --no-default-features --features "redis swagger",
  117. # Lightning backends
  118. -p cdk-cln,
  119. -p cdk-lnd,
  120. -p cdk-lnbits,
  121. -p cdk-fake-wallet,
  122. -p cdk-payment-processor,
  123. -p cdk-ldk-node,
  124. -p cdk-signatory,
  125. -p cdk-mint-rpc,
  126. -p cdk-prometheus,
  127. # FFI bindings
  128. -p cdk-ffi,
  129. # Binaries
  130. --bin cdk-cli,
  131. --bin cdk-cli --features sqlcipher,
  132. --bin cdk-cli --features redb,
  133. --bin cdk-mintd,
  134. --bin cdk-mintd --features redis,
  135. --bin cdk-mintd --features sqlcipher,
  136. --bin cdk-mintd --no-default-features --features lnd --features sqlite,
  137. --bin cdk-mintd --no-default-features --features cln --features postgres,
  138. --bin cdk-mintd --no-default-features --features lnbits --features sqlite,
  139. --bin cdk-mintd --no-default-features --features fakewallet --features sqlite,
  140. --bin cdk-mintd --no-default-features --features grpc-processor --features sqlite,
  141. --bin cdk-mintd --no-default-features --features "management-rpc lnd sqlite",
  142. --bin cdk-mintd --no-default-features --features cln --features sqlite,
  143. --bin cdk-mintd --no-default-features --features lnd --features postgres,
  144. --bin cdk-mintd --no-default-features --features lnbits --features postgres,
  145. --bin cdk-mintd --no-default-features --features fakewallet --features postgres,
  146. --bin cdk-mintd --no-default-features --features grpc-processor --features postgres,
  147. --bin cdk-mintd --no-default-features --features "management-rpc cln postgres",
  148. --bin cdk-mintd --no-default-features --features "auth sqlite fakewallet",
  149. --bin cdk-mintd --no-default-features --features "auth postgres lnd",
  150. --bin cdk-mint-cli,
  151. ]
  152. steps:
  153. - name: checkout
  154. uses: actions/checkout@v4
  155. - name: Get flake hash
  156. id: flake-hash
  157. run: echo "hash=$(sha256sum flake.lock | cut -d' ' -f1 | cut -c1-8)" >> $GITHUB_OUTPUT
  158. - name: Install Nix
  159. uses: DeterminateSystems/nix-installer-action@v17
  160. - name: Nix Cache
  161. uses: DeterminateSystems/magic-nix-cache-action@main
  162. with:
  163. diagnostic-endpoint: ""
  164. use-flakehub: false
  165. - name: Rust Cache
  166. uses: Swatinem/rust-cache@v2
  167. with:
  168. shared-key: "stable-${{ steps.flake-hash.outputs.hash }}"
  169. - name: Clippy
  170. run: nix develop -i -L .#stable --command cargo clippy ${{ matrix.build-args }} -- -D warnings
  171. - name: Test
  172. run: nix develop -i -L .#stable --command cargo test ${{ matrix.build-args }}
  173. regtest-itest:
  174. name: "Integration regtest tests"
  175. runs-on: ubuntu-latest
  176. timeout-minutes: 30
  177. needs: pre-commit-checks
  178. strategy:
  179. fail-fast: true
  180. matrix:
  181. build-args:
  182. [
  183. -p cdk-integration-tests,
  184. ]
  185. database:
  186. [
  187. SQLITE,
  188. POSTGRES
  189. ]
  190. steps:
  191. - name: checkout
  192. uses: actions/checkout@v4
  193. - name: Get flake hash
  194. id: flake-hash
  195. run: echo "hash=$(sha256sum flake.lock | cut -d' ' -f1 | cut -c1-8)" >> $GITHUB_OUTPUT
  196. - name: Free Disk Space (Ubuntu)
  197. uses: jlumbroso/free-disk-space@main
  198. with:
  199. tool-cache: false
  200. android: true
  201. dotnet: true
  202. haskell: true
  203. large-packages: true
  204. docker-images: true
  205. swap-storage: true
  206. - name: Install Nix
  207. uses: DeterminateSystems/nix-installer-action@v17
  208. - name: Nix Cache
  209. uses: DeterminateSystems/magic-nix-cache-action@main
  210. with:
  211. diagnostic-endpoint: ""
  212. use-flakehub: false
  213. - name: Rust Cache
  214. uses: Swatinem/rust-cache@v2
  215. with:
  216. shared-key: "stable-${{ steps.flake-hash.outputs.hash }}"
  217. - name: Test
  218. run: nix develop -i -L .#stable --command just itest ${{ matrix.database }}
  219. fake-mint-itest:
  220. name: "Integration fake mint tests"
  221. runs-on: ubuntu-latest
  222. timeout-minutes: 30
  223. needs: pre-commit-checks
  224. strategy:
  225. fail-fast: true
  226. matrix:
  227. build-args:
  228. [
  229. -p cdk-integration-tests,
  230. ]
  231. database:
  232. [
  233. SQLITE,
  234. ]
  235. steps:
  236. - name: checkout
  237. uses: actions/checkout@v4
  238. - name: Get flake hash
  239. id: flake-hash
  240. run: echo "hash=$(sha256sum flake.lock | cut -d' ' -f1 | cut -c1-8)" >> $GITHUB_OUTPUT
  241. - name: Free Disk Space (Ubuntu)
  242. uses: jlumbroso/free-disk-space@main
  243. with:
  244. tool-cache: true
  245. android: true
  246. dotnet: true
  247. haskell: true
  248. large-packages: true
  249. docker-images: true
  250. swap-storage: true
  251. - name: Install Nix
  252. uses: DeterminateSystems/nix-installer-action@v17
  253. - name: Nix Cache
  254. uses: DeterminateSystems/magic-nix-cache-action@main
  255. with:
  256. diagnostic-endpoint: ""
  257. use-flakehub: false
  258. - name: Rust Cache
  259. uses: Swatinem/rust-cache@v2
  260. with:
  261. shared-key: "stable-${{ steps.flake-hash.outputs.hash }}"
  262. - name: Clippy
  263. run: nix develop -i -L .#stable --command cargo clippy -- -D warnings
  264. - name: Test fake auth mint
  265. run: nix develop -i -L .#stable --command just fake-mint-itest ${{ matrix.database }}
  266. pure-itest:
  267. name: "Integration fake wallet tests"
  268. runs-on: ubuntu-latest
  269. timeout-minutes: 30
  270. needs: pre-commit-checks
  271. strategy:
  272. fail-fast: true
  273. matrix:
  274. database:
  275. [
  276. memory,
  277. sqlite,
  278. redb
  279. ]
  280. steps:
  281. - name: checkout
  282. uses: actions/checkout@v4
  283. - name: Get flake hash
  284. id: flake-hash
  285. run: echo "hash=$(sha256sum flake.lock | cut -d' ' -f1 | cut -c1-8)" >> $GITHUB_OUTPUT
  286. - name: Free Disk Space (Ubuntu)
  287. uses: jlumbroso/free-disk-space@main
  288. with:
  289. tool-cache: true
  290. android: true
  291. dotnet: true
  292. haskell: true
  293. large-packages: true
  294. docker-images: true
  295. swap-storage: true
  296. - name: Install Nix
  297. uses: DeterminateSystems/nix-installer-action@v17
  298. - name: Nix Cache
  299. uses: DeterminateSystems/magic-nix-cache-action@main
  300. with:
  301. diagnostic-endpoint: ""
  302. use-flakehub: false
  303. - name: Rust Cache
  304. uses: Swatinem/rust-cache@v2
  305. with:
  306. shared-key: "stable-${{ steps.flake-hash.outputs.hash }}"
  307. - name: Test fake mint
  308. run: nix develop -i -L .#stable --command just test-pure ${{ matrix.database }}
  309. - name: Install Postgres
  310. run: bash -x crates/cdk-postgres/start_db_for_test.sh
  311. - name: Test mint
  312. run: nix develop -i -L .#stable --command just test
  313. payment-processor-itests:
  314. name: "Payment processor tests"
  315. runs-on: ubuntu-latest
  316. timeout-minutes: 30
  317. needs: pre-commit-checks
  318. strategy:
  319. fail-fast: true
  320. matrix:
  321. ln:
  322. [
  323. FAKEWALLET,
  324. CLN,
  325. LND
  326. ]
  327. steps:
  328. - name: checkout
  329. uses: actions/checkout@v4
  330. - name: Get flake hash
  331. id: flake-hash
  332. run: echo "hash=$(sha256sum flake.lock | cut -d' ' -f1 | cut -c1-8)" >> $GITHUB_OUTPUT
  333. - name: Free Disk Space (Ubuntu)
  334. uses: jlumbroso/free-disk-space@main
  335. with:
  336. tool-cache: true
  337. android: true
  338. dotnet: true
  339. haskell: true
  340. large-packages: true
  341. docker-images: true
  342. swap-storage: true
  343. - name: Install Nix
  344. uses: DeterminateSystems/nix-installer-action@v17
  345. - name: Nix Cache
  346. uses: DeterminateSystems/magic-nix-cache-action@main
  347. with:
  348. diagnostic-endpoint: ""
  349. use-flakehub: false
  350. - name: Rust Cache
  351. uses: Swatinem/rust-cache@v2
  352. with:
  353. shared-key: "stable-${{ steps.flake-hash.outputs.hash }}"
  354. - name: Test
  355. run: nix develop -i -L .#stable --command just itest-payment-processor ${{matrix.ln}}
  356. msrv-build:
  357. name: "MSRV build"
  358. runs-on: ubuntu-latest
  359. timeout-minutes: 30
  360. needs: pre-commit-checks
  361. strategy:
  362. fail-fast: true
  363. matrix:
  364. build-args:
  365. [
  366. -p cashu --no-default-features --features "wallet mint",
  367. -p cdk-common --no-default-features --features "wallet mint",
  368. -p cdk-sql-common,
  369. -p cdk,
  370. -p cdk --no-default-features --features "mint auth",
  371. -p cdk --no-default-features --features "wallet auth",
  372. -p cdk --no-default-features --features "http_subscription",
  373. -p cdk-axum,
  374. -p cdk-axum --no-default-features --features redis,
  375. -p cdk-lnbits,
  376. -p cdk-fake-wallet,
  377. -p cdk-cln,
  378. -p cdk-lnd,
  379. -p cdk-mint-rpc,
  380. -p cdk-sqlite,
  381. -p cdk-mintd,
  382. -p cdk-payment-processor --no-default-features,
  383. ]
  384. steps:
  385. - name: checkout
  386. uses: actions/checkout@v4
  387. - name: Get flake hash
  388. id: flake-hash
  389. run: echo "hash=$(sha256sum flake.lock | cut -d' ' -f1 | cut -c1-8)" >> $GITHUB_OUTPUT
  390. - name: Install Nix
  391. uses: DeterminateSystems/nix-installer-action@v17
  392. - name: Nix Cache
  393. uses: DeterminateSystems/magic-nix-cache-action@main
  394. with:
  395. diagnostic-endpoint: ""
  396. use-flakehub: false
  397. - name: Rust Cache
  398. uses: Swatinem/rust-cache@v2
  399. with:
  400. shared-key: "msrv-${{ steps.flake-hash.outputs.hash }}"
  401. - name: Build
  402. run: nix develop -i -L .#msrv --command cargo build ${{ matrix.build-args }}
  403. check-wasm:
  404. name: Check WASM
  405. runs-on: ubuntu-latest
  406. timeout-minutes: 30
  407. needs: pre-commit-checks
  408. strategy:
  409. fail-fast: true
  410. matrix:
  411. rust:
  412. - stable
  413. target:
  414. - wasm32-unknown-unknown
  415. build-args:
  416. [
  417. -p cdk,
  418. -p cdk --no-default-features,
  419. -p cdk --no-default-features --features wallet,
  420. ]
  421. steps:
  422. - name: checkout
  423. uses: actions/checkout@v4
  424. - name: Get flake hash
  425. id: flake-hash
  426. run: echo "hash=$(sha256sum flake.lock | cut -d' ' -f1 | cut -c1-8)" >> $GITHUB_OUTPUT
  427. - name: Install Nix
  428. uses: DeterminateSystems/nix-installer-action@v17
  429. - name: Nix Cache
  430. uses: DeterminateSystems/magic-nix-cache-action@main
  431. with:
  432. diagnostic-endpoint: ""
  433. use-flakehub: false
  434. - name: Rust Cache
  435. uses: Swatinem/rust-cache@v2
  436. with:
  437. shared-key: "stable-${{ steps.flake-hash.outputs.hash }}"
  438. - name: Build cdk and binding
  439. run: nix develop -i -L ".#${{ matrix.rust }}" --command cargo build ${{ matrix.build-args }} --target ${{ matrix.target }}
  440. check-wasm-msrv:
  441. name: Check WASM
  442. runs-on: ubuntu-latest
  443. timeout-minutes: 30
  444. needs: pre-commit-checks
  445. strategy:
  446. fail-fast: true
  447. matrix:
  448. rust:
  449. - msrv
  450. target:
  451. - wasm32-unknown-unknown
  452. build-args:
  453. [
  454. -p cdk,
  455. -p cdk --no-default-features,
  456. -p cdk --no-default-features --features wallet,
  457. ]
  458. steps:
  459. - name: checkout
  460. uses: actions/checkout@v4
  461. - name: Get flake hash
  462. id: flake-hash
  463. run: echo "hash=$(sha256sum flake.lock | cut -d' ' -f1 | cut -c1-8)" >> $GITHUB_OUTPUT
  464. - name: Install Nix
  465. uses: DeterminateSystems/nix-installer-action@v17
  466. - name: Nix Cache
  467. uses: DeterminateSystems/magic-nix-cache-action@main
  468. with:
  469. diagnostic-endpoint: ""
  470. use-flakehub: false
  471. - name: Rust Cache
  472. uses: Swatinem/rust-cache@v2
  473. with:
  474. shared-key: "msrv-${{ steps.flake-hash.outputs.hash }}"
  475. - name: Build cdk wasm
  476. run: nix develop -i -L ".#${{ matrix.rust }}" --command cargo build ${{ matrix.build-args }} --target ${{ matrix.target }}
  477. fake-mint-auth-itest:
  478. name: "Integration fake mint auth tests"
  479. runs-on: ubuntu-latest
  480. timeout-minutes: 30
  481. needs: pre-commit-checks
  482. strategy:
  483. fail-fast: true
  484. matrix:
  485. database:
  486. [
  487. SQLITE,
  488. ]
  489. steps:
  490. - name: checkout
  491. uses: actions/checkout@v4
  492. - name: Get flake hash
  493. id: flake-hash
  494. run: echo "hash=$(sha256sum flake.lock | cut -d' ' -f1 | cut -c1-8)" >> $GITHUB_OUTPUT
  495. - name: Free Disk Space (Ubuntu)
  496. uses: jlumbroso/free-disk-space@main
  497. with:
  498. tool-cache: false
  499. android: true
  500. dotnet: true
  501. haskell: true
  502. large-packages: true
  503. docker-images: true
  504. swap-storage: true
  505. - name: Install Nix
  506. uses: DeterminateSystems/nix-installer-action@v17
  507. - name: Nix Cache
  508. uses: DeterminateSystems/magic-nix-cache-action@main
  509. with:
  510. diagnostic-endpoint: ""
  511. use-flakehub: false
  512. - name: Rust Cache
  513. uses: Swatinem/rust-cache@v2
  514. with:
  515. shared-key: "stable-${{ steps.flake-hash.outputs.hash }}"
  516. - name: Start Keycloak with Backup
  517. run: |
  518. docker compose -f misc/keycloak/docker-compose-recover.yml up -d
  519. until docker logs $(docker ps -q --filter "ancestor=quay.io/keycloak/keycloak:25.0.6") | grep "Keycloak 25.0.6 on JVM (powered by Quarkus 3.8.5) started"; do sleep 1; done
  520. - name: Verify Keycloak Import
  521. run: |
  522. docker logs $(docker ps -q --filter "ancestor=quay.io/keycloak/keycloak:25.0.6") | grep "Imported"
  523. - name: Test fake auth mint
  524. run: nix develop -i -L .#stable --command just fake-auth-mint-itest ${{ matrix.database }} http://127.0.0.1:8080/realms/cdk-test-realm/.well-known/openid-configuration
  525. - name: Stop and clean up Docker Compose
  526. run: |
  527. docker compose -f misc/keycloak/docker-compose-recover.yml down
  528. doc-tests:
  529. name: "Documentation Tests"
  530. runs-on: ubuntu-latest
  531. timeout-minutes: 30
  532. needs: pre-commit-checks
  533. steps:
  534. - name: checkout
  535. uses: actions/checkout@v4
  536. - name: Get flake hash
  537. id: flake-hash
  538. run: echo "hash=$(sha256sum flake.lock | cut -d' ' -f1 | cut -c1-8)" >> $GITHUB_OUTPUT
  539. - name: Free Disk Space (Ubuntu)
  540. uses: jlumbroso/free-disk-space@main
  541. with:
  542. tool-cache: false
  543. android: true
  544. dotnet: true
  545. haskell: true
  546. large-packages: true
  547. docker-images: true
  548. swap-storage: true
  549. - name: Install Nix
  550. uses: DeterminateSystems/nix-installer-action@v17
  551. - name: Nix Cache
  552. uses: DeterminateSystems/magic-nix-cache-action@main
  553. with:
  554. diagnostic-endpoint: ""
  555. use-flakehub: false
  556. - name: Rust Cache
  557. uses: Swatinem/rust-cache@v2
  558. with:
  559. shared-key: "stable-${{ steps.flake-hash.outputs.hash }}"
  560. - name: Run doc tests
  561. run: nix develop -i -L .#stable --command cargo test --doc
  562. strict-docs:
  563. name: "Strict Documentation Check"
  564. runs-on: ubuntu-latest
  565. timeout-minutes: 30
  566. needs: doc-tests
  567. steps:
  568. - name: checkout
  569. uses: actions/checkout@v4
  570. - name: Get flake hash
  571. id: flake-hash
  572. run: echo "hash=$(sha256sum flake.lock | cut -d' ' -f1 | cut -c1-8)" >> $GITHUB_OUTPUT
  573. - name: Install Nix
  574. uses: DeterminateSystems/nix-installer-action@v17
  575. - name: Nix Cache
  576. uses: DeterminateSystems/magic-nix-cache-action@main
  577. with:
  578. diagnostic-endpoint: ""
  579. use-flakehub: false
  580. - name: Rust Cache
  581. uses: Swatinem/rust-cache@v2
  582. with:
  583. shared-key: "stable-${{ steps.flake-hash.outputs.hash }}"
  584. - name: Check docs with strict warnings
  585. run: nix develop -i -L .#stable --command just docs-strict