ci.yml 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526
  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, POSTGRES]
  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: Test mint with PostgreSQL
  280. run: nix develop -i -L .#stable --command bash -c "start-postgres && just test"
  281. payment-processor-itests:
  282. name: "Payment processor tests"
  283. runs-on: ubuntu-latest
  284. timeout-minutes: 30
  285. needs: pre-commit-checks
  286. strategy:
  287. fail-fast: true
  288. matrix:
  289. ln: [FAKEWALLET, CLN, LND]
  290. steps:
  291. - name: checkout
  292. uses: actions/checkout@v4
  293. - name: Get flake hash
  294. id: flake-hash
  295. run: echo "hash=$(sha256sum flake.lock | cut -d' ' -f1 | cut -c1-8)" >> $GITHUB_OUTPUT
  296. - name: Free Disk Space (Ubuntu)
  297. uses: jlumbroso/free-disk-space@main
  298. with:
  299. tool-cache: true
  300. android: true
  301. dotnet: true
  302. haskell: true
  303. large-packages: true
  304. docker-images: true
  305. swap-storage: true
  306. - name: Install Nix
  307. uses: DeterminateSystems/nix-installer-action@v17
  308. - name: Nix Cache
  309. uses: DeterminateSystems/magic-nix-cache-action@main
  310. with:
  311. diagnostic-endpoint: ""
  312. use-flakehub: false
  313. - name: Rust Cache
  314. uses: Swatinem/rust-cache@v2
  315. with:
  316. shared-key: "stable-${{ steps.flake-hash.outputs.hash }}"
  317. - name: Test
  318. run: nix develop -i -L .#stable --command just itest-payment-processor ${{matrix.ln}}
  319. msrv-build:
  320. name: "MSRV build"
  321. runs-on: ubuntu-latest
  322. timeout-minutes: 30
  323. needs: pre-commit-checks
  324. strategy:
  325. fail-fast: true
  326. matrix:
  327. build-args: [
  328. # Core library - all features EXCEPT swagger (which breaks MSRV)
  329. '-p cdk --features "mint,wallet,auth,nostr,bip353,tor,prometheus"',
  330. # Mintd with all backends, databases, and features (no swagger)
  331. # This also validates cdk-axum, all LN backends, all databases as dependencies
  332. '-p cdk-mintd --no-default-features --features "cln,lnd,lnbits,fakewallet,ldk-node,grpc-processor,sqlite,postgres,auth,prometheus,redis,management-rpc"',
  333. # CLI - default features (excludes redb which breaks MSRV)
  334. -p cdk-cli,
  335. # Minimal builds to ensure no-default-features works
  336. -p cdk --no-default-features --features wallet,
  337. ]
  338. steps:
  339. - name: checkout
  340. uses: actions/checkout@v4
  341. - name: Get flake hash
  342. id: flake-hash
  343. run: echo "hash=$(sha256sum flake.lock | cut -d' ' -f1 | cut -c1-8)" >> $GITHUB_OUTPUT
  344. - name: Install Nix
  345. uses: DeterminateSystems/nix-installer-action@v17
  346. - name: Nix Cache
  347. uses: DeterminateSystems/magic-nix-cache-action@main
  348. with:
  349. diagnostic-endpoint: ""
  350. use-flakehub: false
  351. - name: Rust Cache
  352. uses: Swatinem/rust-cache@v2
  353. with:
  354. shared-key: "msrv-${{ steps.flake-hash.outputs.hash }}"
  355. - name: Build
  356. run: nix develop -i -L .#msrv --command cargo build ${{ matrix.build-args }}
  357. check-wasm-msrv:
  358. name: Check WASM
  359. runs-on: ubuntu-latest
  360. timeout-minutes: 30
  361. needs: pre-commit-checks
  362. strategy:
  363. fail-fast: true
  364. matrix:
  365. rust:
  366. - msrv
  367. target:
  368. - wasm32-unknown-unknown
  369. build-args:
  370. [
  371. -p cdk,
  372. -p cdk --no-default-features,
  373. -p cdk --no-default-features --features wallet,
  374. ]
  375. steps:
  376. - name: checkout
  377. uses: actions/checkout@v4
  378. - name: Get flake hash
  379. id: flake-hash
  380. run: echo "hash=$(sha256sum flake.lock | cut -d' ' -f1 | cut -c1-8)" >> $GITHUB_OUTPUT
  381. - name: Install Nix
  382. uses: DeterminateSystems/nix-installer-action@v17
  383. - name: Nix Cache
  384. uses: DeterminateSystems/magic-nix-cache-action@main
  385. with:
  386. diagnostic-endpoint: ""
  387. use-flakehub: false
  388. - name: Rust Cache
  389. uses: Swatinem/rust-cache@v2
  390. with:
  391. shared-key: "msrv-${{ steps.flake-hash.outputs.hash }}"
  392. - name: Build cdk wasm
  393. run: nix develop -i -L ".#${{ matrix.rust }}" --command cargo build ${{ matrix.build-args }} --target ${{ matrix.target }}
  394. fake-mint-auth-itest:
  395. name: "Integration fake mint auth tests"
  396. runs-on: ubuntu-latest
  397. timeout-minutes: 30
  398. needs: pre-commit-checks
  399. strategy:
  400. fail-fast: true
  401. matrix:
  402. database: [SQLITE]
  403. steps:
  404. - name: checkout
  405. uses: actions/checkout@v4
  406. - name: Get flake hash
  407. id: flake-hash
  408. run: echo "hash=$(sha256sum flake.lock | cut -d' ' -f1 | cut -c1-8)" >> $GITHUB_OUTPUT
  409. - name: Free Disk Space (Ubuntu)
  410. uses: jlumbroso/free-disk-space@main
  411. with:
  412. tool-cache: false
  413. android: true
  414. dotnet: true
  415. haskell: true
  416. large-packages: true
  417. docker-images: true
  418. swap-storage: true
  419. - name: Install Nix
  420. uses: DeterminateSystems/nix-installer-action@v17
  421. - name: Nix Cache
  422. uses: DeterminateSystems/magic-nix-cache-action@main
  423. with:
  424. diagnostic-endpoint: ""
  425. use-flakehub: false
  426. - name: Rust Cache
  427. uses: Swatinem/rust-cache@v2
  428. with:
  429. shared-key: "stable-${{ steps.flake-hash.outputs.hash }}"
  430. - name: Start Keycloak with Backup
  431. run: |
  432. docker compose -f misc/keycloak/docker-compose-recover.yml up -d
  433. 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
  434. - name: Verify Keycloak Import
  435. run: |
  436. docker logs $(docker ps -q --filter "ancestor=quay.io/keycloak/keycloak:25.0.6") | grep "Imported"
  437. - name: Test fake auth mint
  438. 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
  439. - name: Stop and clean up Docker Compose
  440. run: |
  441. docker compose -f misc/keycloak/docker-compose-recover.yml down
  442. docs:
  443. name: "Documentation tests and checks"
  444. runs-on: ubuntu-latest
  445. timeout-minutes: 30
  446. needs: pre-commit-checks
  447. steps:
  448. - name: checkout
  449. uses: actions/checkout@v4
  450. - name: Get flake hash
  451. id: flake-hash
  452. run: echo "hash=$(sha256sum flake.lock | cut -d' ' -f1 | cut -c1-8)" >> $GITHUB_OUTPUT
  453. - name: Free Disk Space (Ubuntu)
  454. uses: jlumbroso/free-disk-space@main
  455. with:
  456. tool-cache: false
  457. android: true
  458. dotnet: true
  459. haskell: true
  460. large-packages: true
  461. docker-images: true
  462. swap-storage: true
  463. - name: Install Nix
  464. uses: DeterminateSystems/nix-installer-action@v17
  465. - name: Nix Cache
  466. uses: DeterminateSystems/magic-nix-cache-action@main
  467. with:
  468. diagnostic-endpoint: ""
  469. use-flakehub: false
  470. - name: Rust Cache
  471. uses: Swatinem/rust-cache@v2
  472. with:
  473. shared-key: "stable-${{ steps.flake-hash.outputs.hash }}"
  474. - name: Run doc tests
  475. run: nix develop -i -L .#stable --command cargo test --doc
  476. - name: Check docs with strict warnings
  477. run: nix develop -i -L .#stable --command just docs-strict
  478. ffi-tests:
  479. name: "FFI Python tests"
  480. runs-on: ubuntu-latest
  481. timeout-minutes: 30
  482. needs: pre-commit-checks
  483. steps:
  484. - name: checkout
  485. uses: actions/checkout@v4
  486. - name: Get flake hash
  487. id: flake-hash
  488. run: echo "hash=$(sha256sum flake.lock | cut -d' ' -f1 | cut -c1-8)" >> $GITHUB_OUTPUT
  489. - name: Install Nix
  490. uses: DeterminateSystems/nix-installer-action@v17
  491. - name: Nix Cache
  492. uses: DeterminateSystems/magic-nix-cache-action@main
  493. with:
  494. diagnostic-endpoint: ""
  495. use-flakehub: false
  496. - name: Rust Cache
  497. uses: Swatinem/rust-cache@v2
  498. with:
  499. shared-key: "stable-${{ steps.flake-hash.outputs.hash }}"
  500. - name: Run FFI tests
  501. run: nix develop -i -L .#integration --command just ffi-test