ci.yml 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513
  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. -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 sqlcipher,
  121. --bin cdk-mintd --no-default-features --features lnd --features sqlite,
  122. --bin cdk-mintd --no-default-features --features cln --features postgres,
  123. --bin cdk-mintd --no-default-features --features lnbits --features sqlite,
  124. --bin cdk-mintd --no-default-features --features fakewallet --features sqlite,
  125. --bin cdk-mintd --no-default-features --features grpc-processor --features sqlite,
  126. --bin cdk-mintd --no-default-features --features "management-rpc lnd sqlite",
  127. --bin cdk-mintd --no-default-features --features cln --features sqlite,
  128. --bin cdk-mintd --no-default-features --features lnd --features postgres,
  129. --bin cdk-mintd --no-default-features --features lnbits --features postgres,
  130. --bin cdk-mintd --no-default-features --features fakewallet --features postgres,
  131. --bin cdk-mintd --no-default-features --features grpc-processor --features postgres,
  132. --bin cdk-mintd --no-default-features --features "management-rpc cln postgres",
  133. --bin cdk-mintd --no-default-features --features "auth sqlite fakewallet",
  134. --bin cdk-mintd --no-default-features --features "auth postgres lnd",
  135. --bin cdk-mint-cli,
  136. ]
  137. steps:
  138. - name: checkout
  139. uses: actions/checkout@v4
  140. - name: Install Nix
  141. uses: DeterminateSystems/nix-installer-action@v17
  142. - name: Nix Cache
  143. uses: DeterminateSystems/magic-nix-cache-action@main
  144. - name: Rust Cache
  145. uses: Swatinem/rust-cache@v2
  146. with:
  147. shared-key: "stable"
  148. - name: Clippy
  149. run: nix develop -i -L .#stable --command cargo clippy ${{ matrix.build-args }} -- -D warnings
  150. - name: Test
  151. run: nix develop -i -L .#stable --command cargo test ${{ matrix.build-args }}
  152. regtest-itest:
  153. name: "Integration regtest tests"
  154. runs-on: ubuntu-latest
  155. timeout-minutes: 30
  156. needs: [pre-commit-checks, clippy, pure-itest, fake-mint-itest]
  157. strategy:
  158. matrix:
  159. build-args:
  160. [
  161. -p cdk-integration-tests,
  162. ]
  163. database:
  164. [
  165. SQLITE,
  166. POSTGRES
  167. ]
  168. steps:
  169. - name: checkout
  170. uses: actions/checkout@v4
  171. - name: Free Disk Space (Ubuntu)
  172. uses: jlumbroso/free-disk-space@main
  173. with:
  174. tool-cache: false
  175. android: true
  176. dotnet: true
  177. haskell: true
  178. large-packages: true
  179. docker-images: true
  180. swap-storage: true
  181. - name: Install Nix
  182. uses: DeterminateSystems/nix-installer-action@v17
  183. - name: Nix Cache
  184. uses: DeterminateSystems/magic-nix-cache-action@main
  185. - name: Rust Cache
  186. uses: Swatinem/rust-cache@v2
  187. with:
  188. shared-key: "stable"
  189. - name: Test
  190. run: nix develop -i -L .#stable --command just itest ${{ matrix.database }}
  191. fake-mint-itest:
  192. name: "Integration fake mint tests"
  193. runs-on: ubuntu-latest
  194. timeout-minutes: 30
  195. needs: [pre-commit-checks, clippy]
  196. strategy:
  197. matrix:
  198. build-args:
  199. [
  200. -p cdk-integration-tests,
  201. ]
  202. database:
  203. [
  204. SQLITE,
  205. ]
  206. steps:
  207. - name: checkout
  208. uses: actions/checkout@v4
  209. - name: Free Disk Space (Ubuntu)
  210. uses: jlumbroso/free-disk-space@main
  211. with:
  212. tool-cache: true
  213. android: true
  214. dotnet: true
  215. haskell: true
  216. large-packages: true
  217. docker-images: true
  218. swap-storage: true
  219. - name: Install Nix
  220. uses: DeterminateSystems/nix-installer-action@v17
  221. - name: Nix Cache
  222. uses: DeterminateSystems/magic-nix-cache-action@main
  223. - name: Rust Cache
  224. uses: Swatinem/rust-cache@v2
  225. with:
  226. shared-key: "stable"
  227. - name: Clippy
  228. run: nix develop -i -L .#stable --command cargo clippy -- -D warnings
  229. - name: Test fake auth mint
  230. run: nix develop -i -L .#stable --command just fake-mint-itest ${{ matrix.database }}
  231. pure-itest:
  232. name: "Integration fake wallet tests"
  233. runs-on: ubuntu-latest
  234. timeout-minutes: 30
  235. needs: [pre-commit-checks, clippy]
  236. strategy:
  237. matrix:
  238. database:
  239. [
  240. memory,
  241. sqlite,
  242. redb
  243. ]
  244. steps:
  245. - name: checkout
  246. uses: actions/checkout@v4
  247. - name: Free Disk Space (Ubuntu)
  248. uses: jlumbroso/free-disk-space@main
  249. with:
  250. tool-cache: true
  251. android: true
  252. dotnet: true
  253. haskell: true
  254. large-packages: true
  255. docker-images: true
  256. swap-storage: true
  257. - name: Install Nix
  258. uses: DeterminateSystems/nix-installer-action@v17
  259. - name: Nix Cache
  260. uses: DeterminateSystems/magic-nix-cache-action@main
  261. - name: Rust Cache
  262. uses: Swatinem/rust-cache@v2
  263. with:
  264. shared-key: "stable"
  265. - name: Test fake mint
  266. run: nix develop -i -L .#stable --command just test-pure ${{ matrix.database }}
  267. - name: Install Postgres
  268. run: bash -x crates/cdk-postgres/start_db_for_test.sh
  269. - name: Test mint
  270. run: nix develop -i -L .#stable --command just test
  271. payment-processor-itests:
  272. name: "Payment processor tests"
  273. runs-on: ubuntu-latest
  274. timeout-minutes: 30
  275. needs: [pre-commit-checks, clippy, pure-itest, fake-mint-itest, regtest-itest]
  276. strategy:
  277. matrix:
  278. ln:
  279. [
  280. FAKEWALLET,
  281. CLN,
  282. LND
  283. ]
  284. steps:
  285. - name: checkout
  286. uses: actions/checkout@v4
  287. - name: Free Disk Space (Ubuntu)
  288. uses: jlumbroso/free-disk-space@main
  289. with:
  290. tool-cache: true
  291. android: true
  292. dotnet: true
  293. haskell: true
  294. large-packages: true
  295. docker-images: true
  296. swap-storage: true
  297. - name: Install Nix
  298. uses: DeterminateSystems/nix-installer-action@v17
  299. - name: Nix Cache
  300. uses: DeterminateSystems/magic-nix-cache-action@main
  301. - name: Rust Cache
  302. uses: Swatinem/rust-cache@v2
  303. with:
  304. shared-key: "stable"
  305. - name: Test
  306. run: nix develop -i -L .#stable --command just itest-payment-processor ${{matrix.ln}}
  307. msrv-build:
  308. name: "MSRV build"
  309. runs-on: ubuntu-latest
  310. timeout-minutes: 30
  311. needs: [pre-commit-checks, clippy]
  312. strategy:
  313. matrix:
  314. build-args:
  315. [
  316. -p cashu --no-default-features --features "wallet mint",
  317. -p cdk-common --no-default-features --features "wallet mint",
  318. -p cdk-sql-common,
  319. -p cdk,
  320. -p cdk --no-default-features --features "mint auth",
  321. -p cdk --no-default-features --features "wallet auth",
  322. -p cdk --no-default-features --features "http_subscription",
  323. -p cdk-axum,
  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