ci.yml 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  1. # Main quality gate (task 42).
  2. #
  3. # Per-PR legs (all must be green):
  4. # fmt, clippy, audit, deny, sqlx-prepare-check, nextest, doc-tests,
  5. # fuzz-build (nightly leg inside `fuzz/`, so the pinned stable
  6. # `rust-toolchain.toml` at the root is never violated).
  7. # Scheduled legs (not per-PR):
  8. # mutants (weekly budgeted mutation run over the pure security modules).
  9. #
  10. # Must NOT gate on miri for tokio/sqlx/redis; no lint suppressions anywhere.
  11. name: ci
  12. on:
  13. push:
  14. branches: ["main"]
  15. pull_request: {}
  16. schedule:
  17. # Weekly budgeted mutation run (Sunday 03:00 UTC).
  18. - cron: "0 3 * * 0"
  19. workflow_dispatch: {}
  20. permissions:
  21. contents: read
  22. env:
  23. CARGO_TERM_COLOR: always
  24. SQLX_OFFLINE: "true"
  25. jobs:
  26. fmt:
  27. name: fmt
  28. runs-on: ubuntu-latest
  29. steps:
  30. - uses: actions/checkout@v4
  31. - uses: dtolnay/rust-toolchain@stable
  32. with:
  33. components: rustfmt
  34. - name: Check formatting
  35. run: cargo fmt --check
  36. clippy:
  37. name: clippy
  38. runs-on: ubuntu-latest
  39. steps:
  40. - uses: actions/checkout@v4
  41. - uses: dtolnay/rust-toolchain@stable
  42. with:
  43. components: clippy
  44. - name: Clippy (all targets, warnings denied)
  45. run: cargo clippy --all-targets -- -D warnings
  46. audit:
  47. name: audit
  48. runs-on: ubuntu-latest
  49. steps:
  50. - uses: actions/checkout@v4
  51. - uses: dtolnay/rust-toolchain@stable
  52. - name: Install cargo-audit
  53. run: cargo install cargo-audit --locked
  54. - name: Audit advisories
  55. run: cargo audit
  56. deny:
  57. name: deny
  58. runs-on: ubuntu-latest
  59. steps:
  60. - uses: actions/checkout@v4
  61. - uses: dtolnay/rust-toolchain@stable
  62. - name: Install cargo-deny
  63. run: cargo install cargo-deny --locked
  64. - name: Check supply chain (ring-only TLS enforced in deny.toml)
  65. run: cargo deny check
  66. sqlx-prepare-check:
  67. name: sqlx-prepare-check
  68. runs-on: ubuntu-latest
  69. services:
  70. postgres:
  71. image: postgres:16
  72. env:
  73. POSTGRES_USER: postgres
  74. POSTGRES_PASSWORD: sqlxcheck
  75. POSTGRES_DB: postgres
  76. ports:
  77. - 5432:5432
  78. options: >-
  79. --health-cmd "pg_isready -U postgres"
  80. --health-interval 5s
  81. --health-timeout 5s
  82. --health-retries 10
  83. steps:
  84. - uses: actions/checkout@v4
  85. - uses: dtolnay/rust-toolchain@stable
  86. - name: Install sqlx-cli
  87. run: cargo install sqlx-cli --locked --version 0.9.0 --no-default-features --features postgres,rustls
  88. - name: Apply migrations to the check database
  89. env:
  90. DATABASE_URL: postgres://postgres:sqlxcheck@127.0.0.1:5432/postgres
  91. run: cargo sqlx migrate run
  92. - name: Fail if the committed .sqlx cache is stale
  93. env:
  94. DATABASE_URL: postgres://postgres:sqlxcheck@127.0.0.1:5432/postgres
  95. run: cargo sqlx prepare --check --workspace
  96. doc-links:
  97. name: doc-links
  98. runs-on: ubuntu-latest
  99. steps:
  100. - uses: actions/checkout@v4
  101. - uses: actions/setup-python@v5
  102. with:
  103. python-version: "3.x"
  104. - name: Check documentation links (markdown-link-check equivalent)
  105. run: python3 scripts/check_doc_links.py
  106. nextest:
  107. name: nextest
  108. runs-on: ubuntu-latest
  109. steps:
  110. - uses: actions/checkout@v4
  111. - uses: dtolnay/rust-toolchain@stable
  112. - name: Install cargo-nextest
  113. uses: taiki-e/install-action@v2
  114. with:
  115. tool: nextest
  116. - name: Install redis-server (in-process Sentinel/Cluster fixtures)
  117. run: sudo apt-get update && sudo apt-get install -y redis-server
  118. - name: Full test suite (testcontainers provide Postgres/Redis)
  119. run: cargo nextest run --all-targets
  120. doc-tests:
  121. name: doc-tests
  122. runs-on: ubuntu-latest
  123. steps:
  124. - uses: actions/checkout@v4
  125. - uses: dtolnay/rust-toolchain@stable
  126. - name: Documentation tests
  127. run: cargo test --doc
  128. fuzz-build:
  129. name: fuzz-build
  130. runs-on: ubuntu-latest
  131. defaults:
  132. run:
  133. working-directory: fuzz
  134. steps:
  135. - uses: actions/checkout@v4
  136. # The `fuzz/rust-toolchain.toml` in the working directory selects
  137. # nightly via rustup override; the root stable pin is untouched.
  138. - name: Install cargo-fuzz (nightly, per fuzz/rust-toolchain.toml)
  139. run: cargo install cargo-fuzz --locked
  140. - name: Build all fuzz targets
  141. run: cargo fuzz build
  142. mutants:
  143. name: mutants
  144. # Scheduled budgeted job only: never blocks a PR.
  145. if: github.event_name == 'schedule' || github.event_name == 'workflow_dispatch'
  146. runs-on: ubuntu-latest
  147. timeout-minutes: 60
  148. steps:
  149. - uses: actions/checkout@v4
  150. - uses: dtolnay/rust-toolchain@stable
  151. - name: Install cargo-mutants
  152. run: cargo install cargo-mutants --locked
  153. - name: Budgeted mutation run (see .cargo/mutants.toml)
  154. run: cargo mutants --timeout 1800 --test-tool nextest