ci.yml 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394
  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 + test checks from flake - single source of truth
  80. discover-checks:
  81. name: "Discover 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 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 + test matrix - uses cached deps from Cachix
  98. # Each check runs both clippy and unit tests for that crate/feature combination
  99. clippy-and-test:
  100. name: "Check: ${{ matrix.check }}"
  101. runs-on: self-hosted
  102. timeout-minutes: 30
  103. needs: [pre-commit-checks, discover-checks]
  104. strategy:
  105. fail-fast: false
  106. matrix:
  107. check: ${{ fromJson(needs.discover-checks.outputs.checks) }}
  108. steps:
  109. - name: checkout
  110. uses: actions/checkout@v4
  111. - uses: cachix/cachix-action@v16
  112. with:
  113. name: cashudevkit
  114. authToken: ${{ secrets.CACHIX_AUTH_TOKEN }}
  115. useDaemon: false
  116. continue-on-error: true
  117. - name: Run clippy and tests
  118. run: nix build -L .#checks.x86_64-linux.${{ matrix.check }}
  119. # Tests that require a running PostgreSQL instance
  120. postgres-tests:
  121. name: "PostgreSQL Tests"
  122. runs-on: self-hosted
  123. timeout-minutes: 30
  124. needs: pre-commit-checks
  125. steps:
  126. - name: checkout
  127. uses: actions/checkout@v4
  128. - uses: cachix/cachix-action@v16
  129. with:
  130. name: cashudevkit
  131. authToken: ${{ secrets.CACHIX_AUTH_TOKEN }}
  132. useDaemon: false
  133. continue-on-error: true
  134. - name: Run clippy and tests for cdk-postgres
  135. run: nix develop -i -L .#stable --command bash -c "start-postgres && cargo clippy -p cdk-postgres -- -D warnings && cargo test -p cdk-postgres"
  136. regtest-itest:
  137. name: "Integration regtest tests"
  138. runs-on: self-hosted
  139. timeout-minutes: 30
  140. needs: pre-commit-checks
  141. strategy:
  142. fail-fast: true
  143. matrix:
  144. database: [SQLITE, POSTGRES]
  145. steps:
  146. - name: checkout
  147. uses: actions/checkout@v4
  148. - uses: cachix/cachix-action@v16
  149. with:
  150. name: cashudevkit
  151. authToken: ${{ secrets.CACHIX_AUTH_TOKEN }}
  152. useDaemon: false
  153. continue-on-error: true
  154. - name: Test
  155. run: nix develop -i -L .#stable --command just itest ${{ matrix.database }}
  156. fake-mint-itest:
  157. name: "Integration fake mint tests"
  158. runs-on: self-hosted
  159. timeout-minutes: 30
  160. needs: pre-commit-checks
  161. strategy:
  162. fail-fast: true
  163. matrix:
  164. build-args: [-p cdk-integration-tests]
  165. database: [SQLITE, POSTGRES]
  166. steps:
  167. - name: checkout
  168. uses: actions/checkout@v4
  169. - uses: cachix/cachix-action@v16
  170. with:
  171. name: cashudevkit
  172. authToken: ${{ secrets.CACHIX_AUTH_TOKEN }}
  173. useDaemon: false
  174. continue-on-error: true
  175. - name: Test fake mint
  176. run: nix develop -i -L .#stable --command just fake-mint-itest ${{ matrix.database }}
  177. pure-itest:
  178. name: "Integration fake wallet tests"
  179. runs-on: self-hosted
  180. timeout-minutes: 30
  181. needs: pre-commit-checks
  182. strategy:
  183. fail-fast: true
  184. matrix:
  185. database: [memory, sqlite, redb]
  186. steps:
  187. - name: checkout
  188. uses: actions/checkout@v4
  189. - uses: cachix/cachix-action@v16
  190. with:
  191. name: cashudevkit
  192. authToken: ${{ secrets.CACHIX_AUTH_TOKEN }}
  193. useDaemon: false
  194. continue-on-error: true
  195. - name: Test fake mint
  196. run: nix develop -i -L .#stable --command just test-pure ${{ matrix.database }}
  197. - name: Test mint with PostgreSQL
  198. run: nix develop -i -L .#stable --command bash -c "start-postgres && just test"
  199. payment-processor-itests:
  200. name: "Payment processor tests"
  201. runs-on: self-hosted
  202. timeout-minutes: 30
  203. needs: pre-commit-checks
  204. strategy:
  205. fail-fast: true
  206. matrix:
  207. ln: [FAKEWALLET, CLN, LND]
  208. steps:
  209. - name: checkout
  210. uses: actions/checkout@v4
  211. - uses: cachix/cachix-action@v16
  212. with:
  213. name: cashudevkit
  214. authToken: ${{ secrets.CACHIX_AUTH_TOKEN }}
  215. useDaemon: false
  216. continue-on-error: true
  217. - name: Test
  218. run: nix develop -i -L .#stable --command just itest-payment-processor ${{matrix.ln}}
  219. # Discover MSRV checks from flake - single source of truth
  220. discover-msrv-checks:
  221. name: "Discover MSRV checks"
  222. runs-on: self-hosted
  223. timeout-minutes: 5
  224. outputs:
  225. checks: ${{ steps.checks.outputs.checks }}
  226. steps:
  227. - name: checkout
  228. uses: actions/checkout@v4
  229. - name: Get MSRV check names
  230. id: checks
  231. run: |
  232. # Get all MSRV check names (prefixed with "msrv-")
  233. checks=$(nix eval .#checks.x86_64-linux --apply 'attrs: builtins.filter (n: builtins.substring 0 5 n == "msrv-") (builtins.attrNames attrs)' --json)
  234. echo "checks=$checks" >> $GITHUB_OUTPUT
  235. echo "Found MSRV checks: $checks"
  236. msrv-build:
  237. name: "MSRV: ${{ matrix.check }}"
  238. runs-on: self-hosted
  239. timeout-minutes: 30
  240. needs: [pre-commit-checks, discover-msrv-checks]
  241. strategy:
  242. fail-fast: true
  243. matrix:
  244. check: ${{ fromJson(needs.discover-msrv-checks.outputs.checks) }}
  245. steps:
  246. - name: checkout
  247. uses: actions/checkout@v4
  248. - uses: cachix/cachix-action@v16
  249. with:
  250. name: cashudevkit
  251. authToken: ${{ secrets.CACHIX_AUTH_TOKEN }}
  252. useDaemon: false
  253. continue-on-error: true
  254. - name: Build
  255. run: nix build -L .#checks.x86_64-linux.${{ matrix.check }}
  256. # Discover WASM checks from flake - single source of truth
  257. discover-wasm-checks:
  258. name: "Discover WASM checks"
  259. runs-on: self-hosted
  260. timeout-minutes: 5
  261. outputs:
  262. checks: ${{ steps.checks.outputs.checks }}
  263. steps:
  264. - name: checkout
  265. uses: actions/checkout@v4
  266. - name: Get WASM check names
  267. id: checks
  268. run: |
  269. # Get all WASM check names (prefixed with "wasm-")
  270. checks=$(nix eval .#checks.x86_64-linux --apply 'attrs: builtins.filter (n: builtins.substring 0 5 n == "wasm-") (builtins.attrNames attrs)' --json)
  271. echo "checks=$checks" >> $GITHUB_OUTPUT
  272. echo "Found WASM checks: $checks"
  273. check-wasm:
  274. name: "WASM: ${{ matrix.check }}"
  275. runs-on: self-hosted
  276. timeout-minutes: 30
  277. needs: [pre-commit-checks, discover-wasm-checks]
  278. strategy:
  279. fail-fast: true
  280. matrix:
  281. check: ${{ fromJson(needs.discover-wasm-checks.outputs.checks) }}
  282. steps:
  283. - name: checkout
  284. uses: actions/checkout@v4
  285. - uses: cachix/cachix-action@v16
  286. with:
  287. name: cashudevkit
  288. authToken: ${{ secrets.CACHIX_AUTH_TOKEN }}
  289. useDaemon: false
  290. continue-on-error: true
  291. - name: Build WASM
  292. run: nix build -L .#checks.x86_64-linux.${{ matrix.check }}
  293. fake-mint-auth-itest:
  294. name: "Integration fake mint auth tests"
  295. runs-on: self-hosted
  296. timeout-minutes: 30
  297. needs: pre-commit-checks
  298. strategy:
  299. fail-fast: true
  300. matrix:
  301. database: [SQLITE]
  302. steps:
  303. - name: checkout
  304. uses: actions/checkout@v4
  305. - uses: cachix/cachix-action@v16
  306. with:
  307. name: cashudevkit
  308. authToken: ${{ secrets.CACHIX_AUTH_TOKEN }}
  309. useDaemon: false
  310. continue-on-error: true
  311. - name: Start Keycloak with Backup
  312. run: |
  313. docker compose -f misc/keycloak/docker-compose-recover.yml up -d
  314. 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
  315. - name: Verify Keycloak Import
  316. run: |
  317. # Wait a bit more for import to complete
  318. sleep 5
  319. # Check if the realm endpoint is accessible (better verification than log grep)
  320. 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)
  321. - name: Test fake auth mint
  322. 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
  323. - name: Stop and clean up Docker Compose
  324. run: |
  325. docker compose -f misc/keycloak/docker-compose-recover.yml down
  326. docs:
  327. name: "Documentation tests"
  328. runs-on: self-hosted
  329. timeout-minutes: 30
  330. needs: pre-commit-checks
  331. steps:
  332. - name: checkout
  333. uses: actions/checkout@v4
  334. - uses: cachix/cachix-action@v16
  335. with:
  336. name: cashudevkit
  337. authToken: ${{ secrets.CACHIX_AUTH_TOKEN }}
  338. useDaemon: false
  339. continue-on-error: true
  340. - name: Run doc tests
  341. run: nix build -L .#checks.x86_64-linux.doc-tests
  342. strict-docs:
  343. name: "Strict Documentation Check"
  344. runs-on: self-hosted
  345. timeout-minutes: 30
  346. needs: docs
  347. steps:
  348. - name: checkout
  349. uses: actions/checkout@v4
  350. - uses: cachix/cachix-action@v16
  351. with:
  352. name: cashudevkit
  353. authToken: ${{ secrets.CACHIX_AUTH_TOKEN }}
  354. useDaemon: false
  355. continue-on-error: true
  356. - name: Check docs with strict warnings
  357. run: nix build -L .#checks.x86_64-linux.strict-docs
  358. ffi-tests:
  359. name: "FFI Python tests"
  360. runs-on: self-hosted
  361. timeout-minutes: 30
  362. needs: pre-commit-checks
  363. steps:
  364. - name: checkout
  365. uses: actions/checkout@v4
  366. - uses: cachix/cachix-action@v16
  367. with:
  368. name: cashudevkit
  369. authToken: ${{ secrets.CACHIX_AUTH_TOKEN }}
  370. useDaemon: false
  371. continue-on-error: true
  372. - name: Run FFI tests
  373. run: nix build -L .#checks.x86_64-linux.ffi-tests