ci.yml 20 KB

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