ci.yml 16 KB

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