ci.yml 18 KB

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