ci.yml 16 KB

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