ci.yml 20 KB

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