ci.yml 18 KB

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