ci.yml 15 KB

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