ci.yml 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502
  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. matrix:
  43. build-args:
  44. [
  45. mint-token,
  46. melt-token,
  47. p2pk,
  48. proof-selection,
  49. wallet
  50. ]
  51. steps:
  52. - name: checkout
  53. uses: actions/checkout@v4
  54. - name: Install Nix
  55. uses: DeterminateSystems/nix-installer-action@v17
  56. - name: Nix Cache
  57. uses: DeterminateSystems/magic-nix-cache-action@main
  58. - name: Rust Cache
  59. uses: Swatinem/rust-cache@v2
  60. with:
  61. shared-key: "stable"
  62. - name: Run example
  63. run: nix develop -i -L .#stable --command cargo r --example ${{ matrix.build-args }}
  64. clippy:
  65. name: "Stable build, clippy and test"
  66. runs-on: ubuntu-latest
  67. timeout-minutes: 30
  68. needs: pre-commit-checks
  69. strategy:
  70. matrix:
  71. build-args:
  72. [
  73. # Core crate testing
  74. -p cashu,
  75. -p cashu --no-default-features,
  76. -p cashu --no-default-features --features wallet,
  77. -p cashu --no-default-features --features mint,
  78. -p cashu --no-default-features --features auth,
  79. -p cdk-common,
  80. -p cdk-common --no-default-features,
  81. -p cdk-common --no-default-features --features wallet,
  82. -p cdk-common --no-default-features --features mint,
  83. -p cdk-common --no-default-features --features auth,
  84. -p cdk,
  85. -p cdk --no-default-features,
  86. -p cdk --no-default-features --features wallet,
  87. -p cdk --no-default-features --features mint,
  88. -p cdk --no-default-features --features auth,
  89. -p cdk-sql-common,
  90. -p cdk-sql-common --no-default-features --features wallet,
  91. -p cdk-sql-common --no-default-features --features mint,
  92. # Database and infrastructure crates
  93. -p cdk-redb,
  94. -p cdk-sqlite,
  95. -p cdk-sqlite --features sqlcipher,
  96. # HTTP/API layer - consolidated
  97. -p cdk-axum,
  98. -p cdk-axum --no-default-features,
  99. -p cdk-axum --no-default-features --features redis,
  100. -p cdk-axum --no-default-features --features "redis swagger",
  101. # Lightning backends
  102. -p cdk-cln,
  103. -p cdk-lnd,
  104. -p cdk-lnbits,
  105. -p cdk-fake-wallet,
  106. -p cdk-payment-processor,
  107. -p cdk-ldk-node,
  108. -p cdk-signatory,
  109. -p cdk-mint-rpc,
  110. # FFI bindings
  111. -p cdk-ffi,
  112. -p cdk-ffi --no-default-features,
  113. -p cdk-ffi --no-default-features --features auth,
  114. -p cdk-ffi --no-default-features --features bip353,
  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, clippy, pure-itest, fake-mint-itest]
  158. strategy:
  159. matrix:
  160. build-args:
  161. [
  162. -p cdk-integration-tests,
  163. ]
  164. database:
  165. [
  166. SQLITE,
  167. POSTGRES
  168. ]
  169. steps:
  170. - name: checkout
  171. uses: actions/checkout@v4
  172. - name: Free Disk Space (Ubuntu)
  173. uses: jlumbroso/free-disk-space@main
  174. with:
  175. tool-cache: false
  176. android: true
  177. dotnet: true
  178. haskell: true
  179. large-packages: true
  180. docker-images: true
  181. swap-storage: true
  182. - name: Install Nix
  183. uses: DeterminateSystems/nix-installer-action@v17
  184. - name: Nix Cache
  185. uses: DeterminateSystems/magic-nix-cache-action@main
  186. - name: Rust Cache
  187. uses: Swatinem/rust-cache@v2
  188. with:
  189. shared-key: "stable"
  190. - name: Test
  191. run: nix develop -i -L .#stable --command just itest ${{ matrix.database }}
  192. fake-mint-itest:
  193. name: "Integration fake mint tests"
  194. runs-on: ubuntu-latest
  195. timeout-minutes: 30
  196. needs: [pre-commit-checks, clippy]
  197. strategy:
  198. matrix:
  199. build-args:
  200. [
  201. -p cdk-integration-tests,
  202. ]
  203. database:
  204. [
  205. SQLITE,
  206. ]
  207. steps:
  208. - name: checkout
  209. uses: actions/checkout@v4
  210. - name: Free Disk Space (Ubuntu)
  211. uses: jlumbroso/free-disk-space@main
  212. with:
  213. tool-cache: true
  214. android: true
  215. dotnet: true
  216. haskell: true
  217. large-packages: true
  218. docker-images: true
  219. swap-storage: true
  220. - name: Install Nix
  221. uses: DeterminateSystems/nix-installer-action@v17
  222. - name: Nix Cache
  223. uses: DeterminateSystems/magic-nix-cache-action@main
  224. - name: Rust Cache
  225. uses: Swatinem/rust-cache@v2
  226. with:
  227. shared-key: "stable"
  228. - name: Clippy
  229. run: nix develop -i -L .#stable --command cargo clippy -- -D warnings
  230. - name: Test fake auth mint
  231. run: nix develop -i -L .#stable --command just fake-mint-itest ${{ matrix.database }}
  232. pure-itest:
  233. name: "Integration fake wallet tests"
  234. runs-on: ubuntu-latest
  235. timeout-minutes: 30
  236. needs: [pre-commit-checks, clippy]
  237. strategy:
  238. matrix:
  239. database:
  240. [
  241. memory,
  242. sqlite,
  243. redb
  244. ]
  245. steps:
  246. - name: checkout
  247. uses: actions/checkout@v4
  248. - name: Free Disk Space (Ubuntu)
  249. uses: jlumbroso/free-disk-space@main
  250. with:
  251. tool-cache: true
  252. android: true
  253. dotnet: true
  254. haskell: true
  255. large-packages: true
  256. docker-images: true
  257. swap-storage: true
  258. - name: Install Nix
  259. uses: DeterminateSystems/nix-installer-action@v17
  260. - name: Nix Cache
  261. uses: DeterminateSystems/magic-nix-cache-action@main
  262. - name: Rust Cache
  263. uses: Swatinem/rust-cache@v2
  264. with:
  265. shared-key: "stable"
  266. - name: Test fake mint
  267. run: nix develop -i -L .#stable --command just test-pure ${{ matrix.database }}
  268. - name: Install Postgres
  269. run: bash -x crates/cdk-postgres/start_db_for_test.sh
  270. - name: Test mint
  271. run: nix develop -i -L .#stable --command just test
  272. payment-processor-itests:
  273. name: "Payment processor tests"
  274. runs-on: ubuntu-latest
  275. timeout-minutes: 30
  276. needs: [pre-commit-checks, clippy, pure-itest, fake-mint-itest, regtest-itest]
  277. strategy:
  278. matrix:
  279. ln:
  280. [
  281. FAKEWALLET,
  282. CLN,
  283. LND
  284. ]
  285. steps:
  286. - name: checkout
  287. uses: actions/checkout@v4
  288. - name: Free Disk Space (Ubuntu)
  289. uses: jlumbroso/free-disk-space@main
  290. with:
  291. tool-cache: true
  292. android: true
  293. dotnet: true
  294. haskell: true
  295. large-packages: true
  296. docker-images: true
  297. swap-storage: true
  298. - name: Install Nix
  299. uses: DeterminateSystems/nix-installer-action@v17
  300. - name: Nix Cache
  301. uses: DeterminateSystems/magic-nix-cache-action@main
  302. - name: Rust Cache
  303. uses: Swatinem/rust-cache@v2
  304. with:
  305. shared-key: "stable"
  306. - name: Test
  307. run: nix develop -i -L .#stable --command just itest-payment-processor ${{matrix.ln}}
  308. msrv-build:
  309. name: "MSRV build"
  310. runs-on: ubuntu-latest
  311. timeout-minutes: 30
  312. needs: [pre-commit-checks, clippy]
  313. strategy:
  314. matrix:
  315. build-args:
  316. [
  317. -p cashu --no-default-features --features "wallet mint",
  318. -p cdk-common --no-default-features --features "wallet mint",
  319. -p cdk-sql-common,
  320. -p cdk,
  321. -p cdk --no-default-features --features "mint auth",
  322. -p cdk --no-default-features --features "wallet auth",
  323. -p cdk --no-default-features --features "http_subscription",
  324. -p cdk-axum,
  325. -p cdk-axum --no-default-features --features redis,
  326. -p cdk-lnbits,
  327. -p cdk-fake-wallet,
  328. -p cdk-cln,
  329. -p cdk-lnd,
  330. -p cdk-mint-rpc,
  331. -p cdk-sqlite,
  332. -p cdk-mintd,
  333. -p cdk-payment-processor --no-default-features,
  334. ]
  335. steps:
  336. - name: checkout
  337. uses: actions/checkout@v4
  338. - name: Install Nix
  339. uses: DeterminateSystems/nix-installer-action@v17
  340. - name: Nix Cache
  341. uses: DeterminateSystems/magic-nix-cache-action@main
  342. - name: Rust Cache
  343. uses: Swatinem/rust-cache@v2
  344. with:
  345. shared-key: "msrv"
  346. - name: Build
  347. run: nix develop -i -L .#msrv --command cargo build ${{ matrix.build-args }}
  348. check-wasm:
  349. name: Check WASM
  350. runs-on: ubuntu-latest
  351. timeout-minutes: 30
  352. needs: [pre-commit-checks, clippy]
  353. strategy:
  354. matrix:
  355. rust:
  356. - stable
  357. target:
  358. - wasm32-unknown-unknown
  359. build-args:
  360. [
  361. -p cdk,
  362. -p cdk --no-default-features,
  363. -p cdk --no-default-features --features wallet,
  364. ]
  365. steps:
  366. - name: checkout
  367. uses: actions/checkout@v4
  368. - name: Install Nix
  369. uses: DeterminateSystems/nix-installer-action@v17
  370. - name: Nix Cache
  371. uses: DeterminateSystems/magic-nix-cache-action@main
  372. - name: Rust Cache
  373. uses: Swatinem/rust-cache@v2
  374. with:
  375. shared-key: "stable"
  376. - name: Build cdk and binding
  377. run: nix develop -i -L ".#${{ matrix.rust }}" --command cargo build ${{ matrix.build-args }} --target ${{ matrix.target }}
  378. check-wasm-msrv:
  379. name: Check WASM
  380. runs-on: ubuntu-latest
  381. timeout-minutes: 30
  382. needs: [pre-commit-checks, clippy, msrv-build]
  383. strategy:
  384. matrix:
  385. rust:
  386. - msrv
  387. target:
  388. - wasm32-unknown-unknown
  389. build-args:
  390. [
  391. -p cdk,
  392. -p cdk --no-default-features,
  393. -p cdk --no-default-features --features wallet,
  394. ]
  395. steps:
  396. - name: checkout
  397. uses: actions/checkout@v4
  398. - name: Install Nix
  399. uses: DeterminateSystems/nix-installer-action@v17
  400. - name: Nix Cache
  401. uses: DeterminateSystems/magic-nix-cache-action@main
  402. - name: Rust Cache
  403. uses: Swatinem/rust-cache@v2
  404. with:
  405. shared-key: "msrv"
  406. - name: Build cdk wasm
  407. run: nix develop -i -L ".#${{ matrix.rust }}" --command cargo build ${{ matrix.build-args }} --target ${{ matrix.target }}
  408. fake-mint-auth-itest:
  409. name: "Integration fake mint auth tests"
  410. runs-on: ubuntu-latest
  411. timeout-minutes: 30
  412. needs: [pre-commit-checks, clippy, pure-itest, fake-mint-itest]
  413. strategy:
  414. matrix:
  415. database:
  416. [
  417. SQLITE,
  418. ]
  419. steps:
  420. - name: checkout
  421. uses: actions/checkout@v4
  422. - name: Install Nix
  423. uses: DeterminateSystems/nix-installer-action@v17
  424. - name: Nix Cache
  425. uses: DeterminateSystems/magic-nix-cache-action@main
  426. - name: Rust Cache
  427. uses: Swatinem/rust-cache@v2
  428. with:
  429. shared-key: "stable"
  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. doc-tests:
  443. name: "Documentation Tests"
  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: Install Nix
  451. uses: DeterminateSystems/nix-installer-action@v17
  452. - name: Nix Cache
  453. uses: DeterminateSystems/magic-nix-cache-action@main
  454. - name: Rust Cache
  455. uses: Swatinem/rust-cache@v2
  456. with:
  457. shared-key: "stable"
  458. - name: Run doc tests
  459. run: nix develop -i -L .#stable --command cargo test --doc
  460. strict-docs:
  461. name: "Strict Documentation Check"
  462. runs-on: ubuntu-latest
  463. timeout-minutes: 30
  464. needs: doc-tests
  465. steps:
  466. - name: checkout
  467. uses: actions/checkout@v4
  468. - name: Install Nix
  469. uses: DeterminateSystems/nix-installer-action@v17
  470. - name: Nix Cache
  471. uses: DeterminateSystems/magic-nix-cache-action@main
  472. - name: Rust Cache
  473. uses: Swatinem/rust-cache@v2
  474. with:
  475. shared-key: "stable"
  476. - name: Check docs with strict warnings
  477. run: nix develop -i -L .#stable --command just docs-strict