ci.yml 16 KB

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