ci.yml 16 KB

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