ci.yml 15 KB

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