ci.yml 16 KB

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