ci.yml 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538
  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. # Core library - all features EXCEPT swagger (which breaks MSRV)
  362. '-p cdk --features "mint,wallet,auth,nostr,bip353,tor,prometheus"',
  363. # Mintd with all backends, databases, and features (no swagger)
  364. # This also validates cdk-axum, all LN backends, all databases as dependencies
  365. '-p cdk-mintd --no-default-features --features "cln,lnd,lnbits,fakewallet,ldk-node,grpc-processor,sqlite,postgres,auth,prometheus,redis,management-rpc"',
  366. # CLI - default features (excludes redb which breaks MSRV)
  367. -p cdk-cli,
  368. # Minimal builds to ensure no-default-features works
  369. -p cdk --no-default-features --features wallet,
  370. ]
  371. steps:
  372. - name: checkout
  373. uses: actions/checkout@v4
  374. - name: Get flake hash
  375. id: flake-hash
  376. run: echo "hash=$(sha256sum flake.lock | cut -d' ' -f1 | cut -c1-8)" >> $GITHUB_OUTPUT
  377. - name: Install Nix
  378. uses: DeterminateSystems/nix-installer-action@v17
  379. - name: Nix Cache
  380. uses: DeterminateSystems/magic-nix-cache-action@main
  381. with:
  382. diagnostic-endpoint: ""
  383. use-flakehub: false
  384. - name: Rust Cache
  385. uses: Swatinem/rust-cache@v2
  386. with:
  387. shared-key: "msrv-${{ steps.flake-hash.outputs.hash }}"
  388. - name: Build
  389. run: nix develop -i -L .#msrv --command cargo build ${{ matrix.build-args }}
  390. check-wasm-msrv:
  391. name: Check WASM
  392. runs-on: ubuntu-latest
  393. timeout-minutes: 30
  394. needs: pre-commit-checks
  395. strategy:
  396. fail-fast: true
  397. matrix:
  398. rust:
  399. - msrv
  400. target:
  401. - wasm32-unknown-unknown
  402. build-args:
  403. [
  404. -p cdk,
  405. -p cdk --no-default-features,
  406. -p cdk --no-default-features --features wallet,
  407. ]
  408. steps:
  409. - name: checkout
  410. uses: actions/checkout@v4
  411. - name: Get flake hash
  412. id: flake-hash
  413. run: echo "hash=$(sha256sum flake.lock | cut -d' ' -f1 | cut -c1-8)" >> $GITHUB_OUTPUT
  414. - name: Install Nix
  415. uses: DeterminateSystems/nix-installer-action@v17
  416. - name: Nix Cache
  417. uses: DeterminateSystems/magic-nix-cache-action@main
  418. with:
  419. diagnostic-endpoint: ""
  420. use-flakehub: false
  421. - name: Rust Cache
  422. uses: Swatinem/rust-cache@v2
  423. with:
  424. shared-key: "msrv-${{ steps.flake-hash.outputs.hash }}"
  425. - name: Build cdk wasm
  426. run: nix develop -i -L ".#${{ matrix.rust }}" --command cargo build ${{ matrix.build-args }} --target ${{ matrix.target }}
  427. fake-mint-auth-itest:
  428. name: "Integration fake mint auth tests"
  429. runs-on: ubuntu-latest
  430. timeout-minutes: 30
  431. needs: pre-commit-checks
  432. strategy:
  433. fail-fast: true
  434. matrix:
  435. database:
  436. [
  437. SQLITE,
  438. ]
  439. steps:
  440. - name: checkout
  441. uses: actions/checkout@v4
  442. - name: Get flake hash
  443. id: flake-hash
  444. run: echo "hash=$(sha256sum flake.lock | cut -d' ' -f1 | cut -c1-8)" >> $GITHUB_OUTPUT
  445. - name: Free Disk Space (Ubuntu)
  446. uses: jlumbroso/free-disk-space@main
  447. with:
  448. tool-cache: false
  449. android: true
  450. dotnet: true
  451. haskell: true
  452. large-packages: true
  453. docker-images: true
  454. swap-storage: true
  455. - name: Install Nix
  456. uses: DeterminateSystems/nix-installer-action@v17
  457. - name: Nix Cache
  458. uses: DeterminateSystems/magic-nix-cache-action@main
  459. with:
  460. diagnostic-endpoint: ""
  461. use-flakehub: false
  462. - name: Rust Cache
  463. uses: Swatinem/rust-cache@v2
  464. with:
  465. shared-key: "stable-${{ steps.flake-hash.outputs.hash }}"
  466. - name: Start Keycloak with Backup
  467. run: |
  468. docker compose -f misc/keycloak/docker-compose-recover.yml up -d
  469. 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
  470. - name: Verify Keycloak Import
  471. run: |
  472. docker logs $(docker ps -q --filter "ancestor=quay.io/keycloak/keycloak:25.0.6") | grep "Imported"
  473. - name: Test fake auth mint
  474. 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
  475. - name: Stop and clean up Docker Compose
  476. run: |
  477. docker compose -f misc/keycloak/docker-compose-recover.yml down
  478. docs:
  479. name: "Documentation tests and checks"
  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: Free Disk Space (Ubuntu)
  490. uses: jlumbroso/free-disk-space@main
  491. with:
  492. tool-cache: false
  493. android: true
  494. dotnet: true
  495. haskell: true
  496. large-packages: true
  497. docker-images: true
  498. swap-storage: true
  499. - name: Install Nix
  500. uses: DeterminateSystems/nix-installer-action@v17
  501. - name: Nix Cache
  502. uses: DeterminateSystems/magic-nix-cache-action@main
  503. with:
  504. diagnostic-endpoint: ""
  505. use-flakehub: false
  506. - name: Rust Cache
  507. uses: Swatinem/rust-cache@v2
  508. with:
  509. shared-key: "stable-${{ steps.flake-hash.outputs.hash }}"
  510. - name: Run doc tests
  511. run: nix develop -i -L .#stable --command cargo test --doc
  512. - name: Check docs with strict warnings
  513. run: nix develop -i -L .#stable --command just docs-strict