ci.yml 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393
  1. name: CI
  2. on:
  3. push:
  4. branches: [main]
  5. pull_request:
  6. branches:
  7. - main
  8. - "v[0-9]*.[0-9]*.x" # Match version branches like v0.13.x, v1.0.x, etc.
  9. release:
  10. types: [created]
  11. # Cancel previous runs on same PR
  12. concurrency:
  13. group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
  14. cancel-in-progress: true
  15. env:
  16. CARGO_TERM_COLOR: always
  17. jobs:
  18. pre-commit-checks:
  19. name: "Cargo fmt, typos"
  20. runs-on: self-hosted
  21. timeout-minutes: 30
  22. steps:
  23. - name: checkout
  24. uses: actions/checkout@v4
  25. - uses: cachix/cachix-action@v16
  26. with:
  27. name: cashudevkit
  28. authToken: ${{ secrets.CACHIX_AUTH_TOKEN }}
  29. useDaemon: false
  30. installCommand: nix profile install nixpkgs#cachix
  31. continue-on-error: true
  32. - name: Cargo fmt
  33. run: nix develop -i -L .#stable --command cargo fmt --check
  34. - name: typos
  35. run: nix develop -i -L .#stable --command typos
  36. # Discover example checks from flake - single source of truth
  37. discover-examples:
  38. name: "Discover examples"
  39. runs-on: self-hosted
  40. timeout-minutes: 5
  41. outputs:
  42. examples: ${{ steps.examples.outputs.examples }}
  43. steps:
  44. - name: checkout
  45. uses: actions/checkout@v4
  46. - name: Get example check names
  47. id: examples
  48. run: |
  49. # Get all example check names (prefixed with "example-")
  50. examples=$(nix eval .#checks.x86_64-linux --apply 'attrs: builtins.filter (n: builtins.substring 0 8 n == "example-") (builtins.attrNames attrs)' --json)
  51. echo "examples=$examples" >> $GITHUB_OUTPUT
  52. echo "Found examples: $examples"
  53. examples:
  54. name: "Example: ${{ matrix.example }}"
  55. runs-on: self-hosted
  56. timeout-minutes: 30
  57. needs: [pre-commit-checks, discover-examples]
  58. strategy:
  59. fail-fast: true
  60. matrix:
  61. example: ${{ fromJson(needs.discover-examples.outputs.examples) }}
  62. steps:
  63. - name: checkout
  64. uses: actions/checkout@v4
  65. - uses: cachix/cachix-action@v16
  66. with:
  67. name: cashudevkit
  68. authToken: ${{ secrets.CACHIX_AUTH_TOKEN }}
  69. useDaemon: false
  70. continue-on-error: true
  71. - name: Build example
  72. run: nix build -L .#${{ matrix.example }}
  73. - name: Run example
  74. run: |
  75. # Extract binary name by removing "example-" prefix
  76. BINARY_NAME="${{ matrix.example }}"
  77. BINARY_NAME="${BINARY_NAME#example-}"
  78. ./result/bin/$BINARY_NAME
  79. # Discover clippy checks from flake - single source of truth
  80. discover-checks:
  81. name: "Discover clippy checks"
  82. runs-on: self-hosted
  83. timeout-minutes: 5
  84. outputs:
  85. checks: ${{ steps.checks.outputs.checks }}
  86. steps:
  87. - name: checkout
  88. uses: actions/checkout@v4
  89. - name: Get clippy check names
  90. id: checks
  91. run: |
  92. # Get all check names except pre-commit-check, example-*, msrv-*, wasm-*, doc-tests, strict-docs, ffi-tests
  93. # Those have their own dedicated CI jobs
  94. checks=$(nix eval .#checks.x86_64-linux --apply 'attrs: builtins.filter (n: n != "pre-commit-check" && n != "doc-tests" && n != "strict-docs" && n != "ffi-tests" && builtins.substring 0 8 n != "example-" && builtins.substring 0 5 n != "msrv-" && builtins.substring 0 5 n != "wasm-") (builtins.attrNames attrs)' --json)
  95. echo "checks=$checks" >> $GITHUB_OUTPUT
  96. echo "Found checks: $checks"
  97. # Dynamic clippy matrix - uses cached deps from Cachix
  98. clippy:
  99. name: "Clippy: ${{ matrix.check }}"
  100. runs-on: self-hosted
  101. timeout-minutes: 30
  102. needs: [pre-commit-checks, discover-checks]
  103. strategy:
  104. fail-fast: false
  105. matrix:
  106. check: ${{ fromJson(needs.discover-checks.outputs.checks) }}
  107. steps:
  108. - name: checkout
  109. uses: actions/checkout@v4
  110. - uses: cachix/cachix-action@v16
  111. with:
  112. name: cashudevkit
  113. authToken: ${{ secrets.CACHIX_AUTH_TOKEN }}
  114. useDaemon: false
  115. continue-on-error: true
  116. - name: Run clippy check
  117. run: nix build -L .#checks.x86_64-linux.${{ matrix.check }}
  118. # Run tests using nix develop (tests need to execute, not just build)
  119. tests:
  120. name: "Tests"
  121. runs-on: self-hosted
  122. timeout-minutes: 30
  123. needs: pre-commit-checks
  124. steps:
  125. - name: checkout
  126. uses: actions/checkout@v4
  127. - uses: cachix/cachix-action@v16
  128. with:
  129. name: cashudevkit
  130. authToken: ${{ secrets.CACHIX_AUTH_TOKEN }}
  131. useDaemon: false
  132. continue-on-error: true
  133. - name: Run workspace tests
  134. run: nix develop -i -L .#stable --command bash -c "start-postgres && cargo test --workspace --exclude cdk-integration-tests"
  135. regtest-itest:
  136. name: "Integration regtest tests"
  137. runs-on: self-hosted
  138. timeout-minutes: 30
  139. needs: pre-commit-checks
  140. strategy:
  141. fail-fast: true
  142. matrix:
  143. database: [SQLITE, POSTGRES]
  144. steps:
  145. - name: checkout
  146. uses: actions/checkout@v4
  147. - uses: cachix/cachix-action@v16
  148. with:
  149. name: cashudevkit
  150. authToken: ${{ secrets.CACHIX_AUTH_TOKEN }}
  151. useDaemon: false
  152. continue-on-error: true
  153. - name: Test
  154. run: nix develop -i -L .#stable --command just itest ${{ matrix.database }}
  155. fake-mint-itest:
  156. name: "Integration fake mint tests"
  157. runs-on: self-hosted
  158. timeout-minutes: 30
  159. needs: pre-commit-checks
  160. strategy:
  161. fail-fast: true
  162. matrix:
  163. build-args: [-p cdk-integration-tests]
  164. database: [SQLITE, POSTGRES]
  165. steps:
  166. - name: checkout
  167. uses: actions/checkout@v4
  168. - uses: cachix/cachix-action@v16
  169. with:
  170. name: cashudevkit
  171. authToken: ${{ secrets.CACHIX_AUTH_TOKEN }}
  172. useDaemon: false
  173. continue-on-error: true
  174. - name: Test fake mint
  175. run: nix develop -i -L .#stable --command just fake-mint-itest ${{ matrix.database }}
  176. pure-itest:
  177. name: "Integration fake wallet tests"
  178. runs-on: self-hosted
  179. timeout-minutes: 30
  180. needs: pre-commit-checks
  181. strategy:
  182. fail-fast: true
  183. matrix:
  184. database: [memory, sqlite, redb]
  185. steps:
  186. - name: checkout
  187. uses: actions/checkout@v4
  188. - uses: cachix/cachix-action@v16
  189. with:
  190. name: cashudevkit
  191. authToken: ${{ secrets.CACHIX_AUTH_TOKEN }}
  192. useDaemon: false
  193. continue-on-error: true
  194. - name: Test fake mint
  195. run: nix develop -i -L .#stable --command just test-pure ${{ matrix.database }}
  196. - name: Test mint with PostgreSQL
  197. run: nix develop -i -L .#stable --command bash -c "start-postgres && just test"
  198. payment-processor-itests:
  199. name: "Payment processor tests"
  200. runs-on: self-hosted
  201. timeout-minutes: 30
  202. needs: pre-commit-checks
  203. strategy:
  204. fail-fast: true
  205. matrix:
  206. ln: [FAKEWALLET, CLN, LND]
  207. steps:
  208. - name: checkout
  209. uses: actions/checkout@v4
  210. - uses: cachix/cachix-action@v16
  211. with:
  212. name: cashudevkit
  213. authToken: ${{ secrets.CACHIX_AUTH_TOKEN }}
  214. useDaemon: false
  215. continue-on-error: true
  216. - name: Test
  217. run: nix develop -i -L .#stable --command just itest-payment-processor ${{matrix.ln}}
  218. # Discover MSRV checks from flake - single source of truth
  219. discover-msrv-checks:
  220. name: "Discover MSRV checks"
  221. runs-on: self-hosted
  222. timeout-minutes: 5
  223. outputs:
  224. checks: ${{ steps.checks.outputs.checks }}
  225. steps:
  226. - name: checkout
  227. uses: actions/checkout@v4
  228. - name: Get MSRV check names
  229. id: checks
  230. run: |
  231. # Get all MSRV check names (prefixed with "msrv-")
  232. checks=$(nix eval .#checks.x86_64-linux --apply 'attrs: builtins.filter (n: builtins.substring 0 5 n == "msrv-") (builtins.attrNames attrs)' --json)
  233. echo "checks=$checks" >> $GITHUB_OUTPUT
  234. echo "Found MSRV checks: $checks"
  235. msrv-build:
  236. name: "MSRV: ${{ matrix.check }}"
  237. runs-on: self-hosted
  238. timeout-minutes: 30
  239. needs: [pre-commit-checks, discover-msrv-checks]
  240. strategy:
  241. fail-fast: true
  242. matrix:
  243. check: ${{ fromJson(needs.discover-msrv-checks.outputs.checks) }}
  244. steps:
  245. - name: checkout
  246. uses: actions/checkout@v4
  247. - uses: cachix/cachix-action@v16
  248. with:
  249. name: cashudevkit
  250. authToken: ${{ secrets.CACHIX_AUTH_TOKEN }}
  251. useDaemon: false
  252. continue-on-error: true
  253. - name: Build
  254. run: nix build -L .#checks.x86_64-linux.${{ matrix.check }}
  255. # Discover WASM checks from flake - single source of truth
  256. discover-wasm-checks:
  257. name: "Discover WASM checks"
  258. runs-on: self-hosted
  259. timeout-minutes: 5
  260. outputs:
  261. checks: ${{ steps.checks.outputs.checks }}
  262. steps:
  263. - name: checkout
  264. uses: actions/checkout@v4
  265. - name: Get WASM check names
  266. id: checks
  267. run: |
  268. # Get all WASM check names (prefixed with "wasm-")
  269. checks=$(nix eval .#checks.x86_64-linux --apply 'attrs: builtins.filter (n: builtins.substring 0 5 n == "wasm-") (builtins.attrNames attrs)' --json)
  270. echo "checks=$checks" >> $GITHUB_OUTPUT
  271. echo "Found WASM checks: $checks"
  272. check-wasm:
  273. name: "WASM: ${{ matrix.check }}"
  274. runs-on: self-hosted
  275. timeout-minutes: 30
  276. needs: [pre-commit-checks, discover-wasm-checks]
  277. strategy:
  278. fail-fast: true
  279. matrix:
  280. check: ${{ fromJson(needs.discover-wasm-checks.outputs.checks) }}
  281. steps:
  282. - name: checkout
  283. uses: actions/checkout@v4
  284. - uses: cachix/cachix-action@v16
  285. with:
  286. name: cashudevkit
  287. authToken: ${{ secrets.CACHIX_AUTH_TOKEN }}
  288. useDaemon: false
  289. continue-on-error: true
  290. - name: Build WASM
  291. run: nix build -L .#checks.x86_64-linux.${{ matrix.check }}
  292. fake-mint-auth-itest:
  293. name: "Integration fake mint auth tests"
  294. runs-on: self-hosted
  295. timeout-minutes: 30
  296. needs: pre-commit-checks
  297. strategy:
  298. fail-fast: true
  299. matrix:
  300. database: [SQLITE]
  301. steps:
  302. - name: checkout
  303. uses: actions/checkout@v4
  304. - uses: cachix/cachix-action@v16
  305. with:
  306. name: cashudevkit
  307. authToken: ${{ secrets.CACHIX_AUTH_TOKEN }}
  308. useDaemon: false
  309. continue-on-error: true
  310. - name: Start Keycloak with Backup
  311. run: |
  312. docker compose -f misc/keycloak/docker-compose-recover.yml up -d
  313. 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
  314. - name: Verify Keycloak Import
  315. run: |
  316. # Wait a bit more for import to complete
  317. sleep 5
  318. # Check if the realm endpoint is accessible (better verification than log grep)
  319. curl -f -s http://127.0.0.1:8080/realms/cdk-test-realm/.well-known/openid-configuration > /dev/null && echo "Keycloak realm successfully imported" || (docker logs $(docker ps -q --filter "ancestor=quay.io/keycloak/keycloak:25.0.6") && exit 1)
  320. - name: Test fake auth mint
  321. 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
  322. - name: Stop and clean up Docker Compose
  323. run: |
  324. docker compose -f misc/keycloak/docker-compose-recover.yml down
  325. docs:
  326. name: "Documentation tests"
  327. runs-on: self-hosted
  328. timeout-minutes: 30
  329. needs: pre-commit-checks
  330. steps:
  331. - name: checkout
  332. uses: actions/checkout@v4
  333. - uses: cachix/cachix-action@v16
  334. with:
  335. name: cashudevkit
  336. authToken: ${{ secrets.CACHIX_AUTH_TOKEN }}
  337. useDaemon: false
  338. continue-on-error: true
  339. - name: Run doc tests
  340. run: nix build -L .#checks.x86_64-linux.doc-tests
  341. strict-docs:
  342. name: "Strict Documentation Check"
  343. runs-on: self-hosted
  344. timeout-minutes: 30
  345. needs: docs
  346. steps:
  347. - name: checkout
  348. uses: actions/checkout@v4
  349. - uses: cachix/cachix-action@v16
  350. with:
  351. name: cashudevkit
  352. authToken: ${{ secrets.CACHIX_AUTH_TOKEN }}
  353. useDaemon: false
  354. continue-on-error: true
  355. - name: Check docs with strict warnings
  356. run: nix build -L .#checks.x86_64-linux.strict-docs
  357. ffi-tests:
  358. name: "FFI Python tests"
  359. runs-on: self-hosted
  360. timeout-minutes: 30
  361. needs: pre-commit-checks
  362. steps:
  363. - name: checkout
  364. uses: actions/checkout@v4
  365. - uses: cachix/cachix-action@v16
  366. with:
  367. name: cashudevkit
  368. authToken: ${{ secrets.CACHIX_AUTH_TOKEN }}
  369. useDaemon: false
  370. continue-on-error: true
  371. - name: Run FFI tests
  372. run: nix build -L .#checks.x86_64-linux.ffi-tests