ci.yml 16 KB

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