| 1 | name: CI |
| 2 | |
| 3 | on: |
| 4 | workflow_dispatch: |
| 5 | inputs: |
| 6 | expected_sha: |
| 7 | description: Exact 40-character commit selected by --ref (manual runs force all CI gates) |
| 8 | required: true |
| 9 | type: string |
| 10 | workspace_test_mode: |
| 11 | description: Workspace runner (shared-process qualification uses Ubuntu only; other gates still run) |
| 12 | type: choice |
| 13 | default: nextest |
| 14 | options: |
| 15 | - nextest |
| 16 | - shared-process-twice |
| 17 | crate: |
| 18 | description: Scoped run, in a few minutes. One workspace package (for example codewhale-tui); with crate or filter set only the scoped test runs, not the full suite |
| 19 | required: false |
| 20 | default: '' |
| 21 | type: string |
| 22 | filter: |
| 23 | description: Scoped run, in a few minutes. A nextest filterset (for example 'test(auto_review)'), alone or with crate; with crate or filter set only the scoped test runs |
| 24 | required: false |
| 25 | default: '' |
| 26 | type: string |
| 27 | os: |
| 28 | description: Operating systems for a scoped run, comma separated (ubuntu-latest, macos-latest, windows-latest, or all); ignored by a full run |
| 29 | required: false |
| 30 | default: ubuntu-latest |
| 31 | type: string |
| 32 | macos_runner: |
| 33 | description: macOS suite runner for a full run (default follows the CW_SELF_HOSTED_MAC repository variable; self-hosted is the codewhale-mac runner) |
| 34 | type: choice |
| 35 | default: default |
| 36 | options: |
| 37 | - default |
| 38 | - self-hosted |
| 39 | - hosted |
| 40 | |
| 41 | permissions: |
| 42 | contents: read |
| 43 | |
| 44 | # A new dispatch on the same non-main branch (an agent's ci/<task> branch) |
| 45 | # cancels the older run still in progress. |
| 46 | # Runs on main are keyed by SHA and never cancel each other, and a scoped |
| 47 | # dispatch gets its own group so it cannot cancel a full run on the same branch. |
| 48 | concurrency: |
| 49 | group: ${{ ((inputs.crate != '' || inputs.filter != '') && format('ci-scoped-{0}', github.run_id)) || (github.ref != 'refs/heads/main' && format('ci-ref-{0}', github.ref)) || format('ci-{0}-{1}', github.workflow, github.sha) }} |
| 50 | cancel-in-progress: ${{ github.ref != 'refs/heads/main' && !(inputs.crate != '' || inputs.filter != '') }} |
| 51 | |
| 52 | env: |
| 53 | CARGO_TERM_COLOR: always |
| 54 | CARGO_INCREMENTAL: 0 |
| 55 | RUSTFLAGS: -Dwarnings |
| 56 | # Test threads share a process and tokio/async frames run deep; the default |
| 57 | # 2 MiB stack overflowed sporadically in runtime_api::tests::start_turn_* |
| 58 | # under load and aborted the whole lib suite (signal 6). 8 MiB is the |
| 59 | # measured-safe floor; nextest's per-process runs are unaffected either way. |
| 60 | RUST_MIN_STACK: 8388608 |
| 61 | |
| 62 | jobs: |
| 63 | changes: |
| 64 | name: Change detection |
| 65 | timeout-minutes: 10 |
| 66 | runs-on: ubuntu-24.04 |
| 67 | outputs: |
| 68 | scoped: ${{ steps.scope.outputs.scoped }} |
| 69 | scoped_os: ${{ steps.scope.outputs.scoped_os }} |
| 70 | macos_self_hosted: ${{ steps.macos.outputs.self_hosted }} |
| 71 | steps: |
| 72 | - name: Choose the macOS suite runner |
| 73 | id: macos |
| 74 | shell: bash |
| 75 | env: |
| 76 | EVENT_NAME: ${{ github.event_name }} |
| 77 | THIS_REPO: ${{ github.repository }} |
| 78 | REQUESTED: ${{ inputs.macos_runner }} |
| 79 | SWITCH: ${{ vars.CW_SELF_HOSTED_MAC }} |
| 80 | run: | |
| 81 | set -euo pipefail |
| 82 | # Only a dispatch in this repository (write access required) may use the self-hosted Mac. |
| 83 | self_hosted=false |
| 84 | if [ "${EVENT_NAME}" = workflow_dispatch ] && [ "${THIS_REPO}" = codewhale-hq/Codewhale ]; then |
| 85 | case "${REQUESTED:-default}" in |
| 86 | self-hosted) self_hosted=true ;; |
| 87 | hosted) ;; |
| 88 | *) if [ "${SWITCH}" = true ]; then self_hosted=true; fi ;; |
| 89 | esac |
| 90 | fi |
| 91 | echo "self_hosted=${self_hosted}" >> "${GITHUB_OUTPUT}" |
| 92 | - name: Classify scoped dispatch |
| 93 | id: scope |
| 94 | shell: bash |
| 95 | env: |
| 96 | SCOPE_CRATE: ${{ inputs.crate }} |
| 97 | SCOPE_FILTER: ${{ inputs.filter }} |
| 98 | SCOPE_OS: ${{ inputs.os }} |
| 99 | run: | |
| 100 | set -euo pipefail |
| 101 | # A dispatch with a crate or a filter runs only the scoped test job. |
| 102 | # Inputs reach the shell only through env, and the crate and OS |
| 103 | # names are validated before anything uses them. |
| 104 | scoped=false |
| 105 | scoped_os='["ubuntu-latest"]' |
| 106 | if [[ -n "${SCOPE_CRATE}" || -n "${SCOPE_FILTER}" ]]; then |
| 107 | scoped=true |
| 108 | if [[ -n "${SCOPE_CRATE}" && ! "${SCOPE_CRATE}" =~ ^[A-Za-z0-9_-]+$ ]]; then |
| 109 | echo "::error::crate must be a package name (letters, digits, - and _)." >&2 |
| 110 | exit 1 |
| 111 | fi |
| 112 | oses=() |
| 113 | IFS=',' read -r -a requested <<< "${SCOPE_OS:-ubuntu-latest}" |
| 114 | for name in "${requested[@]}"; do |
| 115 | name="${name//[[:space:]]/}" |
| 116 | case "${name}" in |
| 117 | ubuntu|ubuntu-latest|linux) oses+=("ubuntu-latest") ;; |
| 118 | macos|macos-latest) oses+=("macos-latest") ;; |
| 119 | windows|windows-latest) oses+=("windows-latest") ;; |
| 120 | all) oses+=("ubuntu-latest" "macos-latest" "windows-latest") ;; |
| 121 | "") ;; |
| 122 | *) |
| 123 | echo "::error::os entries must be ubuntu-latest, macos-latest, windows-latest or all." >&2 |
| 124 | exit 1 |
| 125 | ;; |
| 126 | esac |
| 127 | done |
| 128 | if [[ "${#oses[@]}" -eq 0 ]]; then oses=("ubuntu-latest"); fi |
| 129 | scoped_os="$(printf '%s\n' "${oses[@]}" | sort -u | jq -R . | jq -sc .)" |
| 130 | fi |
| 131 | echo "scoped=${scoped}" >> "${GITHUB_OUTPUT}" |
| 132 | echo "scoped_os=${scoped_os}" >> "${GITHUB_OUTPUT}" |
| 133 | - uses: actions/checkout@v7 |
| 134 | with: |
| 135 | fetch-depth: 0 |
| 136 | - name: Check the dispatched commit |
| 137 | shell: bash |
| 138 | env: |
| 139 | EXPECTED_SHA: ${{ inputs.expected_sha }} |
| 140 | run: | |
| 141 | set -euo pipefail |
| 142 | if [[ "${#EXPECTED_SHA}" -ne 40 || "${EXPECTED_SHA}" =~ [^0-9a-fA-F] ]]; then |
| 143 | echo "::error::expected_sha must be a full 40-character commit SHA." >&2 |
| 144 | exit 1 |
| 145 | fi |
| 146 | actual="$(git rev-parse HEAD)" |
| 147 | expected_normalized="$(printf '%s' "${EXPECTED_SHA}" | tr '[:upper:]' '[:lower:]')" |
| 148 | if [[ "${actual}" != "${expected_normalized}" ]]; then |
| 149 | echo "::error::Dispatch resolved to ${actual}, not requested ${EXPECTED_SHA}." >&2 |
| 150 | exit 1 |
| 151 | fi |
| 152 | |
| 153 | versions: |
| 154 | name: Version drift |
| 155 | needs: changes |
| 156 | if: needs.changes.outputs.scoped != 'true' |
| 157 | timeout-minutes: 15 |
| 158 | runs-on: ubuntu-24.04 |
| 159 | steps: |
| 160 | - uses: actions/checkout@v7 |
| 161 | with: |
| 162 | fetch-depth: 0 |
| 163 | - uses: dtolnay/rust-toolchain@1.100.0 |
| 164 | - uses: actions/setup-node@v7.1.0 |
| 165 | with: |
| 166 | node-version: 22 |
| 167 | - name: Check version drift |
| 168 | # Checks 7 and 12 audit the previous-tag..HEAD commit range, not this |
| 169 | # tree, so a receipt another landing forgot reddens every run. They |
| 170 | # report here and block on every release path (release-candidate.yml, |
| 171 | # auto-tag.yml, release.yml, prepare-release.sh), which is where a |
| 172 | # missing receipt actually matters. |
| 173 | run: ./scripts/release/check-versions.sh --range-audit-advisory |
| 174 | - name: Check contributor credit |
| 175 | # The three credit surfaces were only ever cross-checked against |
| 176 | # `requiredCandidateCredits`, a hand-maintained list -- so they proved |
| 177 | # each other consistent while a contributor nobody remembered stayed |
| 178 | # invisible. Nine were missing from 0.10.0. This derives the expected |
| 179 | # set from the commit range instead (authors, co-author trailers, and |
| 180 | # `Integrated from #N by @handle` or `Harvested from PR #N by |
| 181 | # @handle` lines), so forgetting someone is red. |
| 182 | run: python3 scripts/check-contributor-credit.py |
| 183 | - name: Check bundled plugin claims |
| 184 | # The 0.10.0 section claimed Computer Use 0.4.0 at revision ca6be22 |
| 185 | # while the tree shipped 0.11.2 at d8640b17f275 -- three upstream |
| 186 | # releases apart, with nothing comparing the prose to the assets. |
| 187 | run: python3 scripts/check-bundled-plugin-claims.py |
| 188 | - name: Check docs version drift |
| 189 | run: python3 scripts/check-docs-drift.py --version-drift-only |
| 190 | - name: Check OHOS dependency graph |
| 191 | run: ./scripts/release/check-ohos-deps.sh |
| 192 | - name: Check release helper contracts |
| 193 | run: | |
| 194 | bash .github/scripts/agent-task-metadata.test.sh |
| 195 | bash scripts/check-behaviour-line.test.sh |
| 196 | python3 scripts/check-docs-drift.test.py |
| 197 | python3 scripts/check-swallowed-errors-budget.test.py |
| 198 | bash scripts/release/app-server-smoke.test.sh |
| 199 | bash scripts/release/check-feature-release-notes.test.sh |
| 200 | bash scripts/release/check-npm-binary-version.test.sh |
| 201 | bash scripts/release/check-ohos-deps.test.sh |
| 202 | bash scripts/release/check-versions.test.sh |
| 203 | node --test scripts/release/compiled-host-delivery.test.js |
| 204 | bash scripts/release/ensure-release-on-main.test.sh |
| 205 | bash scripts/release/generate-release-body.test.sh |
| 206 | bash scripts/release/install-dogfood.test.sh |
| 207 | node --test scripts/release/install-safety.test.js |
| 208 | node --test scripts/release/npm-wrapper-smoke.test.js |
| 209 | bash scripts/release/prepare-release.test.sh |
| 210 | bash scripts/release/prune-actions-caches.test.sh |
| 211 | bash scripts/release/require-rc-receipt.test.sh |
| 212 | bash scripts/release/require-full-ci-receipt.test.sh |
| 213 | bash scripts/release/require-release-tag-checkout.test.sh |
| 214 | bash scripts/release/validate-crate-publish-order.test.sh |
| 215 | python3 scripts/release/contributor-wall.test.py |
| 216 | python3 scripts/release/publish-crates.test.py |
| 217 | bash scripts/release/verify-remote-tag.test.sh |
| 218 | bash packaging/aur/render.test.sh |
| 219 | sh scripts/dev-cache.test.sh |
| 220 | sh scripts/with-hermetic-test-home.test.sh |
| 221 | bash .github/scripts/update-homebrew-tap.test.sh |
| 222 | node .github/scripts/release-workflows.test.js |
| 223 | node --test .github/scripts/d8-executable.test.js |
| 224 | node --test scripts/release/assemble-release-assets.test.js |
| 225 | node --test scripts/release/ensure-release-assets-absent.test.js |
| 226 | python3 -B scripts/test_ci_migration_wiring.py |
| 227 | python3 -B -m unittest scripts/test_check_command_session_proof.py |
| 228 | node --test scripts/ci/compiled-host-native-receipt.test.js |
| 229 | node --test scripts/release/verify-release-inventory.test.js |
| 230 | - name: Run runtime web client tests |
| 231 | # crates/app-server/tests/runtime_web_client.test.mjs exercises the embedded |
| 232 | # web client's event/snapshot state machine; it ran nowhere before. |
| 233 | run: node --test crates/app-server/tests/runtime_web_client.test.mjs |
| 234 | |
| 235 | plugin-conversion: |
| 236 | name: Plugin conversion |
| 237 | needs: changes |
| 238 | if: needs.changes.outputs.scoped != 'true' |
| 239 | timeout-minutes: 5 |
| 240 | runs-on: ubuntu-24.04 |
| 241 | steps: |
| 242 | - uses: actions/checkout@v7 |
| 243 | - uses: actions/setup-python@v7 |
| 244 | with: |
| 245 | python-version: '3.12' |
| 246 | - uses: actions/setup-node@v7.1.0 |
| 247 | with: |
| 248 | node-version: 22 |
| 249 | - name: Install data parser |
| 250 | run: python3 -m pip install --disable-pip-version-check PyYAML==6.0.2 |
| 251 | - name: Check offline plugin conversion |
| 252 | # Pinned upstream YAML is data only; only our synthetic Node fixtures run. |
| 253 | # Always on: scripts and fixture changes must not depend on Rust CI filters. |
| 254 | run: python3 -B scripts/dsh-plugin-acceptance/test_convert_plugin.py -v |
| 255 | |
| 256 | integrations: |
| 257 | name: Integrations |
| 258 | needs: changes |
| 259 | if: needs.changes.outputs.scoped != 'true' |
| 260 | timeout-minutes: 15 |
| 261 | runs-on: ubuntu-24.04 |
| 262 | steps: |
| 263 | - uses: actions/checkout@v7 |
| 264 | - name: Check Lighthouse SSH policy |
| 265 | run: python3 scripts/tencent-lighthouse/test_bootstrap_ssh.py |
| 266 | - uses: actions/setup-node@v7.1.0 |
| 267 | with: |
| 268 | node-version: 22 |
| 269 | - name: Test reusable GitHub review action |
| 270 | run: node --test scripts/github-action/*.test.mjs |
| 271 | - name: Run Runtime SDK runtime and type tests |
| 272 | run: | |
| 273 | npm ci --ignore-scripts --workspace @codewhale/runtime-sdk |
| 274 | npm test --workspace @codewhale/runtime-sdk |
| 275 | - name: Run chat-bridge suites |
| 276 | # These node --test suites run without npm ci. |
| 277 | run: | |
| 278 | set -euo pipefail |
| 279 | for bridge in bridge-core dingtalk-bridge feishu-bridge telegram-bridge wecom-bridge weixin-bridge; do |
| 280 | echo "== ${bridge}" |
| 281 | (cd "integrations/${bridge}" && npm test) |
| 282 | done |
| 283 | |
| 284 | - name: Run extension host suites and check the committed bundle |
| 285 | # The TypeScript extension host (experimental, [features] |
| 286 | # extension_host). Tests exercise both the committed bundle and |
| 287 | # source services backed by locked Cordis dependencies. Install before |
| 288 | # testing; then reject any bundle drift. Node 22 matches the host floor. |
| 289 | run: | |
| 290 | set -euo pipefail |
| 291 | cd crates/engine/extension-host |
| 292 | npm ci --ignore-scripts |
| 293 | npm test |
| 294 | npm run typecheck |
| 295 | npm run build |
| 296 | git diff --exit-code -- dist |
| 297 | - uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # v2.2.0 |
| 298 | with: |
| 299 | # The validated floor (`BUN_MIN_VERSION_FOR_EXTENSION_HOST`). |
| 300 | bun-version: 1.4.0 |
| 301 | - name: Run extension host suites on Bun |
| 302 | # Bun is an opt-in host runtime (`runtime = "bun"` or `"auto"`); |
| 303 | # Node stays the default. The same suites spawn the committed bundle |
| 304 | # under `bun test`, with Bun's launch flags. This leg runs the JS |
| 305 | # suites only; the Rust host tests run on Node. |
| 306 | run: | |
| 307 | set -euo pipefail |
| 308 | cd crates/engine/extension-host |
| 309 | npm run test:bun |
| 310 | |
| 311 | extension-host-runtimes: |
| 312 | name: Extension host runtimes (${{ matrix.os }}) |
| 313 | needs: changes |
| 314 | if: needs.changes.outputs.scoped != 'true' |
| 315 | timeout-minutes: 15 |
| 316 | strategy: |
| 317 | fail-fast: false |
| 318 | matrix: |
| 319 | os: [ubuntu-latest, macos-latest, windows-latest] |
| 320 | runs-on: ${{ matrix.os == 'ubuntu-latest' && 'ubuntu-24.04' || matrix.os }} |
| 321 | defaults: |
| 322 | run: |
| 323 | working-directory: crates/engine/extension-host |
| 324 | shell: bash |
| 325 | steps: |
| 326 | - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7 |
| 327 | - uses: actions/setup-node@v7.1.0 |
| 328 | with: |
| 329 | node-version: 22 |
| 330 | - uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # v2.2 |
| 331 | with: |
| 332 | bun-version: 1.4.0 |
| 333 | - run: npm ci |
| 334 | - run: npm run typecheck && npm run build |
| 335 | - name: Required Node and Bun source-host receipts |
| 336 | run: npm test && npm run test:bun |
| 337 | - name: Compile the same entry with the installed runtime and test it |
| 338 | run: | |
| 339 | bun_binary="$(bun -p 'process.execPath')" |
| 340 | host_binary="$(node -p "require('path').join(process.env.RUNNER_TEMP, 'codewhale-extension-host' + (process.platform === 'win32' ? '.exe' : ''))")" |
| 341 | node compile-host.mjs --bun "$bun_binary" --output "$host_binary" |
| 342 | CODEWHALE_COMPILED_HOST_TEST_BINARY="$host_binary" CODEWHALE_BUN_TEST_BINARY="$bun_binary" node --test test/compiled-host.test.mjs |
| 343 | - name: Keep runtime receipts on failure |
| 344 | if: failure() |
| 345 | uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7 |
| 346 | with: |
| 347 | name: extension-host-runtime-${{ matrix.os }} |
| 348 | path: crates/engine/extension-host/dist/builtin-modules.json |
| 349 | if-no-files-found: error |
| 350 | |
| 351 | vscode-extension: |
| 352 | name: VS Code extension |
| 353 | needs: changes |
| 354 | if: needs.changes.outputs.scoped != 'true' |
| 355 | timeout-minutes: 15 |
| 356 | runs-on: ubuntu-24.04 |
| 357 | defaults: |
| 358 | run: |
| 359 | working-directory: extensions/vscode |
| 360 | steps: |
| 361 | - uses: actions/checkout@v7 |
| 362 | - uses: actions/setup-node@v7.1.0 |
| 363 | with: |
| 364 | # The extension targets VS Code >=1.90, whose extension host is |
| 365 | # Node 20, and its @types/node pin is ^20. Build and test on the |
| 366 | # runtime the extension actually ships against. |
| 367 | node-version: 20 |
| 368 | - name: Install extension dependencies |
| 369 | run: npm ci |
| 370 | - name: Run VS Code extension suites |
| 371 | # extensions/vscode ships node --test suites (api, markdown, sse) that |
| 372 | # NO workflow ran: release.yml only reads package.json for a version |
| 373 | # string, so the whole client compiled and shipped without its tests or |
| 374 | # `tsc` ever running in CI. `npm test` compiles first (tsc -p ./), so |
| 375 | # this is the type-check gate for the extension too. |
| 376 | run: npm test |
| 377 | # @vscode/vsce 4 is a build-only packager that requires Node >=22. The |
| 378 | # extension itself still compiles and tests on Node 20 above. |
| 379 | - uses: actions/setup-node@v7.1.0 |
| 380 | with: |
| 381 | node-version: 22 |
| 382 | - name: Package VS Code extension |
| 383 | run: npm run package |
| 384 | |
| 385 | safety-gate: |
| 386 | name: Safety gate |
| 387 | needs: changes |
| 388 | if: needs.changes.outputs.scoped != 'true' |
| 389 | timeout-minutes: 30 |
| 390 | runs-on: ubuntu-24.04 |
| 391 | steps: |
| 392 | - uses: actions/checkout@v7 |
| 393 | - uses: dtolnay/rust-toolchain@master |
| 394 | with: |
| 395 | toolchain: 1.100.0 |
| 396 | - uses: mozilla-actions/sccache-action@v0.0.11 |
| 397 | with: |
| 398 | version: "v0.19.0" |
| 399 | id: sccache |
| 400 | # Every run reads the cache main wrote; only main writes it |
| 401 | # (SCCACHE_GHA_RW_MODE in Enable sccache), mirroring rust-cache's |
| 402 | # save-if. Pull request runs once wrote thousands of refs/pull/N entries that |
| 403 | # pushed the repo past its 10 GiB cache cap. |
| 404 | continue-on-error: true |
| 405 | - name: Enable sccache |
| 406 | if: steps.sccache.outcome == 'success' |
| 407 | shell: bash |
| 408 | run: | |
| 409 | echo "SCCACHE_GHA_ENABLED=true" >> "${GITHUB_ENV}" |
| 410 | if [ "${GITHUB_REF}" = refs/heads/main ]; then rw=READ_WRITE; else rw=READ_ONLY; fi |
| 411 | echo "SCCACHE_GHA_RW_MODE=${rw}" >> "${GITHUB_ENV}" |
| 412 | echo "RUSTC_WRAPPER=sccache" >> "${GITHUB_ENV}" |
| 413 | echo "SCCACHE_IGNORE_SERVER_IO_ERROR=1" >> "${GITHUB_ENV}" |
| 414 | echo "SCCACHE_IDLE_TIMEOUT=0" >> "${GITHUB_ENV}" |
| 415 | - name: Install Linux system dependencies |
| 416 | run: | |
| 417 | bash scripts/ci/ci-apt-install.sh libdbus-1-dev pkg-config bubblewrap apparmor-profiles |
| 418 | sh scripts/ci/prepare-linux-test-sandbox.sh |
| 419 | - name: Ubuntu build headroom |
| 420 | shell: bash |
| 421 | run: bash scripts/ci/prepare-ubuntu-build-headroom.sh |
| 422 | - uses: Swatinem/rust-cache@v2 |
| 423 | with: |
| 424 | cache-bin: false |
| 425 | cache-on-failure: true |
| 426 | save-if: ${{ github.ref == 'refs/heads/main' }} |
| 427 | - uses: taiki-e/install-action@b6620ca104fb7b50dafa1109be9622abc1fdd381 |
| 428 | with: |
| 429 | tool: cargo-nextest@0.9.151 |
| 430 | - uses: actions/setup-node@v7.1.0 |
| 431 | with: |
| 432 | node-version: 24 |
| 433 | - name: Hermetic safety and authorization tests |
| 434 | env: |
| 435 | RUST_MIN_STACK: "8388608" |
| 436 | CODEWHALE_EXT_HOST_TESTS: '1' |
| 437 | # nextest fails when the filter selects no test (`--no-tests=fail`), |
| 438 | # so moving these modules to another crate cannot turn this step into |
| 439 | # a silent 0-test pass. It does not catch a step that merely shrinks, |
| 440 | # so name every package that owns safety tests explicitly: |
| 441 | # codewhale-runtime owns `safe_label` (its hostile-authority test) |
| 442 | # since RS-2; add the next package when another safety module moves. |
| 443 | run: | |
| 444 | sh scripts/with-hermetic-test-home.sh cargo nextest run -p codewhale-engine -p codewhale-tui -p codewhale-runtime --lib --locked --no-tests=fail -E 'test(auto_review) | test(authority) | test(sandbox)' |
| 445 | sh scripts/with-hermetic-test-home.sh cargo test -p codewhale-execpolicy --locked |
| 446 | |
| 447 | lint: |
| 448 | name: Lint |
| 449 | needs: changes |
| 450 | if: needs.changes.outputs.scoped != 'true' |
| 451 | # Measured on 89ee629e with runner headroom: clippy 10 min, runtime-contract |
| 452 | # budget 16 min, and persistence-backlog still running at the old 45-minute |
| 453 | # cancellation. Commands, filters and budgets are unchanged. |
| 454 | timeout-minutes: 75 |
| 455 | runs-on: ubuntu-24.04 |
| 456 | steps: |
| 457 | - uses: actions/checkout@v7 |
| 458 | with: |
| 459 | fetch-depth: 0 |
| 460 | - uses: dtolnay/rust-toolchain@master |
| 461 | with: |
| 462 | toolchain: 1.100.0 |
| 463 | components: rustfmt, clippy |
| 464 | - uses: mozilla-actions/sccache-action@v0.0.11 |
| 465 | with: |
| 466 | version: "v0.19.0" |
| 467 | id: sccache |
| 468 | # Cache bootstrap failures (e.g. GitHub 504s fetching the sccache |
| 469 | # binary) degrade to an uncached build instead of failing product CI. |
| 470 | continue-on-error: true |
| 471 | # Every run reads the GitHub Actions cache main wrote; only main writes (see Enable sccache). |
| 472 | - name: Enable sccache |
| 473 | if: steps.sccache.outcome == 'success' |
| 474 | shell: bash |
| 475 | run: | |
| 476 | echo "SCCACHE_GHA_ENABLED=true" >> "${GITHUB_ENV}" |
| 477 | if [ "${GITHUB_REF}" = refs/heads/main ]; then rw=READ_WRITE; else rw=READ_ONLY; fi |
| 478 | echo "SCCACHE_GHA_RW_MODE=${rw}" >> "${GITHUB_ENV}" |
| 479 | echo "RUSTC_WRAPPER=sccache" >> "${GITHUB_ENV}" |
| 480 | echo "SCCACHE_IGNORE_SERVER_IO_ERROR=1" >> "${GITHUB_ENV}" |
| 481 | echo "SCCACHE_IDLE_TIMEOUT=0" >> "${GITHUB_ENV}" |
| 482 | - name: Install Linux system dependencies |
| 483 | run: | |
| 484 | bash scripts/ci/ci-apt-install.sh libdbus-1-dev pkg-config |
| 485 | - name: Ubuntu build headroom |
| 486 | shell: bash |
| 487 | run: bash scripts/ci/prepare-ubuntu-build-headroom.sh |
| 488 | - uses: Swatinem/rust-cache@v2 |
| 489 | with: |
| 490 | cache-bin: false |
| 491 | cache-on-failure: true |
| 492 | # Other refs restore the cache seeded by main but skip the expensive |
| 493 | # post-job save; sccache covers their compilation deltas. |
| 494 | save-if: ${{ github.ref == 'refs/heads/main' }} |
| 495 | - name: Check formatting |
| 496 | run: cargo fmt --all -- --check |
| 497 | - name: Run clippy |
| 498 | # --all-targets, because without it CI never lints test code at all. |
| 499 | # That gap is not theoretical: the v0.9.10 release gate opened with |
| 500 | # four clippy failures sitting on a green main, and every one of them |
| 501 | # was in a test target. crates/tui/AGENTS.md already documents the |
| 502 | # all-targets command as the release gate; this makes CI run the gate |
| 503 | # it points contributors at instead of a weaker subset. |
| 504 | # |
| 505 | # collapsible_if and assertions_on_constants are no longer allowed for |
| 506 | # the same reason — they were three of those four, so the allowances |
| 507 | # were hiding exactly the class of problem that reached the gate. The |
| 508 | # three that remain are deliberate project style, not oversights. |
| 509 | run: | |
| 510 | cargo clippy --workspace --all-targets --all-features --locked -- \ |
| 511 | -D warnings \ |
| 512 | -A clippy::uninlined_format_args \ |
| 513 | -A clippy::too_many_arguments \ |
| 514 | -A clippy::unnecessary_map_or |
| 515 | - name: sccache stats |
| 516 | if: steps.sccache.outcome == 'success' |
| 517 | continue-on-error: true |
| 518 | shell: bash |
| 519 | run: sccache --show-stats |
| 520 | - name: Check core navigation source and normal dependency boundary |
| 521 | shell: bash |
| 522 | run: | |
| 523 | python3 -B scripts/test_check_command_core_navigation_proof.py |
| 524 | graph=$(mktemp) |
| 525 | trap 'rm -f "$graph"' EXIT |
| 526 | cargo tree --locked -p codewhale-portable-core-navigation --edges normal --all-features --target all --prefix none > "$graph" |
| 527 | python3 -B scripts/check-command-core-navigation-proof.py --graph "$graph" |
| 528 | - name: Check provider registry drift |
| 529 | run: | |
| 530 | python3 scripts/check-provider-registry.py |
| 531 | python3 scripts/check-config-example.py |
| 532 | - name: Check the offline model seed is generated |
| 533 | # crates/config/assets/models_dev.bundled.json is rendered from |
| 534 | # scripts/catalog/models_dev_seed.toml and its lock (#6396). A hand edit |
| 535 | # fails here; docs/CATALOG_REFRESH.md has the regenerate steps. The age |
| 536 | # check fails a pin that has silently rotted: render --check only proves |
| 537 | # the asset matches the lock, never that the lock is recent. |
| 538 | run: | |
| 539 | python3 scripts/catalog/catalog_models_dev.py seed render --check |
| 540 | python3 scripts/catalog/catalog_models_dev.py seed age --max-days 30 |
| 541 | python3 -m unittest scripts/catalog/catalog_models_dev_test.py |
| 542 | - name: Check command-contract prototype boundary |
| 543 | run: | |
| 544 | python3 scripts/test_check_command_crate_boundaries.py |
| 545 | python3 scripts/check-command-crate-boundaries.py |
| 546 | - name: Check command migration manifest |
| 547 | run: | |
| 548 | python3 scripts/test_check_command_migration_manifest.py |
| 549 | python3 scripts/check-command-migration-manifest.py |
| 550 | - name: Check reqwest client constructors |
| 551 | run: | |
| 552 | python3 scripts/test_check_reqwest_builders.py |
| 553 | python3 scripts/check-reqwest-builders.py |
| 554 | - name: Check git spawns |
| 555 | run: | |
| 556 | python3 scripts/test_check_bare_git.py |
| 557 | python3 scripts/check-bare-git.py |
| 558 | # Clippy above runs with `--all-targets` (see the clippy step), so the |
| 559 | # gap this ratchet covers is not "tests keep it alive" but suppression |
| 560 | # itself: it refuses to let dead-code suppression rise (#4785), counting |
| 561 | # both `#[allow(dead_code)]` and `#[expect(dead_code)]`, because counting |
| 562 | # one spelling let a sweep rewrite allows as expects and book it as |
| 563 | # progress (#6241). |
| 564 | - name: Test dead-code and blocking-calls budget scripts |
| 565 | run: | |
| 566 | python3 scripts/test_check_dead_code_budget.py |
| 567 | python3 scripts/test_check_blocking_calls_budget.py |
| 568 | # The four budget ratchets below (dead-code, blocking-calls, |
| 569 | # runtime-contract, persistence-backlog) assert whole-repo properties. |
| 570 | # scripts/ci/ratchet-gate.sh blocks on a failure and prints the `--update` |
| 571 | # receipt command that lands the fix. |
| 572 | - name: Check dead-code budget |
| 573 | run: >- |
| 574 | bash scripts/ci/ratchet-gate.sh --name dead-code |
| 575 | --update "python3 scripts/check-dead-code-budget.py --update" |
| 576 | -- python3 scripts/check-dead-code-budget.py |
| 577 | # Ratchet for blocking calls that could park Tokio workers: any new |
| 578 | # thread::sleep/std::fs site outside spawn_blocking, dedicated-thread, |
| 579 | # or test scopes must be isolated or budgeted (#6149). |
| 580 | - name: Check blocking-calls budget |
| 581 | run: >- |
| 582 | bash scripts/ci/ratchet-gate.sh --name blocking-calls |
| 583 | --update "python3 scripts/check-blocking-calls-budget.py --update" |
| 584 | -- python3 scripts/check-blocking-calls-budget.py |
| 585 | - name: Check swallowed-errors budget |
| 586 | run: >- |
| 587 | bash scripts/ci/ratchet-gate.sh --name swallowed-errors |
| 588 | --update "python3 scripts/check-swallowed-errors-budget.py --update" |
| 589 | -- python3 scripts/check-swallowed-errors-budget.py |
| 590 | - name: Test runtime-contract measurement harness |
| 591 | run: | |
| 592 | python3 scripts/test_measure_runtime_contract.py |
| 593 | python3 scripts/test_check_runtime_contract_budget.py |
| 594 | # The offline runtime-contract measurement needs the full locked graph, |
| 595 | # dev-dependencies included (e.g. wiremock -> assert-json-diff), but |
| 596 | # clippy above builds no test targets and the rust-cache registry key |
| 597 | # derives from Cargo.lock, so any lock-changing branch (every dependabot |
| 598 | # bump) restores an empty cache and the hermetic `cargo test --offline` |
| 599 | # dies with "failed to download ... --offline was specified" before a |
| 600 | # single budget is measured. Fetch the locked graph once here so the |
| 601 | # measurement below is deterministic on every branch. |
| 602 | - name: Fetch locked dependency graph for offline measurement |
| 603 | run: cargo fetch --locked |
| 604 | # Provider-free local measurement. The checker forces Cargo offline and |
| 605 | # the measurement script runs only locked, ignored Rust metric tests. |
| 606 | - name: Check runtime-contract budget |
| 607 | run: >- |
| 608 | bash scripts/ci/ratchet-gate.sh --name runtime-contract |
| 609 | --update "python3 scripts/check-runtime-contract-budget.py --update --allow-increase" |
| 610 | -- python3 scripts/check-runtime-contract-budget.py |
| 611 | # Provider-free paused-consumer measurement of the production |
| 612 | # persistence request channel. RSS is sampled only on macOS; every host |
| 613 | # enforces the accepted/retained request and payload contract. |
| 614 | - name: Test persistence-backlog measurement and checker harnesses |
| 615 | run: | |
| 616 | python3 scripts/test_measure_persistence_backlog.py |
| 617 | python3 scripts/test_check_persistence_backlog_budget.py |
| 618 | - name: Check persistence-backlog budget |
| 619 | run: >- |
| 620 | bash scripts/ci/ratchet-gate.sh --name persistence-backlog |
| 621 | --update "python3 scripts/check-persistence-backlog-budget.py --update" |
| 622 | -- python3 scripts/check-persistence-backlog-budget.py |
| 623 | - name: Check README translations stay in sync |
| 624 | run: python3 scripts/check-readme-translations.py |
| 625 | - name: Check README locale link symmetry |
| 626 | run: bash scripts/check-readme-locales.sh |
| 627 | - name: Check TUI locale pack parity |
| 628 | run: python3 scripts/check-tui-locale-parity.py |
| 629 | - name: Check TUI product vocabulary |
| 630 | run: sh scripts/check-tui-product-vocabulary.sh |
| 631 | - name: Report docs findings (warn-only) |
| 632 | continue-on-error: true |
| 633 | run: sh scripts/docs/run-checks.sh |
| 634 | - name: Check website locale dictionary parity |
| 635 | run: node web/scripts/check-locales.mjs |
| 636 | |
| 637 | msrv: |
| 638 | # The workspace must build on its minimum supported toolchain. A lint |
| 639 | # expectation that newer rustc fulfils can be unfulfilled on 1.89 and |
| 640 | # fail the build there while stable stays green (#6543). |
| 641 | name: MSRV check (1.89) |
| 642 | needs: changes |
| 643 | if: needs.changes.outputs.scoped != 'true' |
| 644 | timeout-minutes: 45 |
| 645 | runs-on: ubuntu-24.04 |
| 646 | env: |
| 647 | RUSTUP_TOOLCHAIN: "1.89" |
| 648 | steps: |
| 649 | - uses: actions/checkout@v7 |
| 650 | - uses: dtolnay/rust-toolchain@master |
| 651 | with: |
| 652 | toolchain: "1.89" |
| 653 | - name: Install Linux system dependencies |
| 654 | run: | |
| 655 | bash scripts/ci/ci-apt-install.sh libdbus-1-dev pkg-config |
| 656 | - uses: Swatinem/rust-cache@v2 |
| 657 | with: |
| 658 | cache-bin: false |
| 659 | save-if: ${{ github.ref == 'refs/heads/main' }} |
| 660 | - name: cargo +1.89 check |
| 661 | run: cargo +1.89 check --workspace --locked |
| 662 | |
| 663 | workflow-rlm-cache: |
| 664 | name: Workflow RLM cache |
| 665 | needs: changes |
| 666 | if: needs.changes.outputs.scoped != 'true' |
| 667 | timeout-minutes: 30 |
| 668 | runs-on: ubuntu-24.04 |
| 669 | steps: |
| 670 | - uses: actions/checkout@v7 |
| 671 | - uses: dtolnay/rust-toolchain@1.100.0 |
| 672 | - uses: mozilla-actions/sccache-action@v0.0.11 |
| 673 | with: |
| 674 | version: "v0.19.0" |
| 675 | id: sccache |
| 676 | # Every run reads the GitHub Actions cache main wrote; only main writes (see Enable sccache). |
| 677 | continue-on-error: true |
| 678 | - name: Enable sccache |
| 679 | if: steps.sccache.outcome == 'success' |
| 680 | shell: bash |
| 681 | run: | |
| 682 | echo "SCCACHE_GHA_ENABLED=true" >> "${GITHUB_ENV}" |
| 683 | if [ "${GITHUB_REF}" = refs/heads/main ]; then rw=READ_WRITE; else rw=READ_ONLY; fi |
| 684 | echo "SCCACHE_GHA_RW_MODE=${rw}" >> "${GITHUB_ENV}" |
| 685 | echo "RUSTC_WRAPPER=sccache" >> "${GITHUB_ENV}" |
| 686 | echo "SCCACHE_IGNORE_SERVER_IO_ERROR=1" >> "${GITHUB_ENV}" |
| 687 | echo "SCCACHE_IDLE_TIMEOUT=0" >> "${GITHUB_ENV}" |
| 688 | - uses: Swatinem/rust-cache@v2 |
| 689 | with: |
| 690 | cache-bin: false |
| 691 | save-if: ${{ github.ref == 'refs/heads/main' }} |
| 692 | - name: Run workflow crate tests |
| 693 | run: sh scripts/with-hermetic-test-home.sh cargo test -p codewhale-workflow --locked |
| 694 | |
| 695 | test: |
| 696 | # Manual shared-process qualification only (workspace_test_mode = |
| 697 | # shared-process-twice): the GH6698 evidence of two libtest passes at one |
| 698 | # exact revision on one hosted Ubuntu runner. Every other run executes the |
| 699 | # suite through test-build, test-shard and test-suite below. |
| 700 | name: Shared-process tests |
| 701 | needs: changes |
| 702 | if: inputs.workspace_test_mode == 'shared-process-twice' && needs.changes.outputs.scoped != 'true' |
| 703 | # A cold GitHub-hosted runner spent 111 minutes compiling with no cache on |
| 704 | # 2026-10-04. The limit stays a literal (release-workflows.test.js, #5496); |
| 705 | # 210 bounds cold compilation and both complete passes. |
| 706 | timeout-minutes: 210 |
| 707 | runs-on: ubuntu-24.04 |
| 708 | steps: |
| 709 | - uses: actions/checkout@v7 |
| 710 | - uses: dtolnay/rust-toolchain@1.100.0 |
| 711 | - uses: mozilla-actions/sccache-action@v0.0.11 |
| 712 | with: |
| 713 | version: "v0.19.0" |
| 714 | id: sccache |
| 715 | continue-on-error: true |
| 716 | # Every run reads the GitHub Actions cache main wrote; only main writes (see Enable sccache). |
| 717 | - name: Enable sccache |
| 718 | if: steps.sccache.outcome == 'success' |
| 719 | shell: bash |
| 720 | run: | |
| 721 | echo "SCCACHE_GHA_ENABLED=true" >> "${GITHUB_ENV}" |
| 722 | if [ "${GITHUB_REF}" = refs/heads/main ]; then rw=READ_WRITE; else rw=READ_ONLY; fi |
| 723 | echo "SCCACHE_GHA_RW_MODE=${rw}" >> "${GITHUB_ENV}" |
| 724 | echo "RUSTC_WRAPPER=sccache" >> "${GITHUB_ENV}" |
| 725 | echo "SCCACHE_IGNORE_SERVER_IO_ERROR=1" >> "${GITHUB_ENV}" |
| 726 | echo "SCCACHE_IDLE_TIMEOUT=0" >> "${GITHUB_ENV}" |
| 727 | - name: Install Linux system dependencies |
| 728 | run: | |
| 729 | bash scripts/ci/ci-apt-install.sh libdbus-1-dev pkg-config bubblewrap apparmor-profiles |
| 730 | sh scripts/ci/prepare-linux-test-sandbox.sh |
| 731 | - name: Ubuntu build headroom |
| 732 | # Reuse the same fixed hosted-runner provisioning as Safety and Lint. |
| 733 | # Exit 143 is a shutdown observation, not proof of OOM or timeout. |
| 734 | shell: bash |
| 735 | run: bash scripts/ci/prepare-ubuntu-build-headroom.sh |
| 736 | - uses: Swatinem/rust-cache@v2 |
| 737 | with: |
| 738 | cache-bin: false |
| 739 | cache-on-failure: true |
| 740 | save-if: ${{ github.ref == 'refs/heads/main' }} |
| 741 | - uses: actions/setup-node@v7.1.0 |
| 742 | # The extension-host integration tests spawn the real bundle under |
| 743 | # Node >= 22.19; CODEWHALE_EXT_HOST_TESTS below makes a missing Node a |
| 744 | # failure instead of a silent skip. |
| 745 | with: |
| 746 | node-version: 22 |
| 747 | - uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # v2.2 |
| 748 | with: |
| 749 | bun-version: 1.4.0 |
| 750 | - name: Build matching compiled-host input for required Native containment receipts |
| 751 | shell: bash |
| 752 | run: bash scripts/ci/compiled-host-test-input.sh |
| 753 | - name: Build canonical executable for acceptance tests |
| 754 | shell: bash |
| 755 | run: cargo build -p codewhale-cli --bin codewhale --all-features --locked |
| 756 | - name: Shared-process workspace qualification |
| 757 | if: inputs.workspace_test_mode == 'shared-process-twice' |
| 758 | shell: bash |
| 759 | env: |
| 760 | CARGO_BUILD_JOBS: '1' |
| 761 | EXPECTED_SHA: ${{ inputs.expected_sha }} |
| 762 | CODEWHALE_EXT_HOST_TESTS: '1' |
| 763 | CODEWHALE_EXT_HOST_BUN_TESTS: '1' |
| 764 | RUST_MIN_STACK: '16777216' |
| 765 | RUSTFLAGS: '' |
| 766 | CARGO_ENCODED_RUSTFLAGS: '' |
| 767 | RUSTC_WRAPPER: '' |
| 768 | CARGO_TERM_COLOR: never |
| 769 | run: | |
| 770 | set -euo pipefail |
| 771 | umask 077 |
| 772 | evidence="$RUNNER_TEMP/shared-process-workspace" |
| 773 | mkdir -p "$evidence" |
| 774 | unset RUST_TEST_THREADS |
| 775 | if [[ ! "$EXPECTED_SHA" =~ ^[0-9a-fA-F]{40}$ ]]; then |
| 776 | echo "::error::expected_sha must be a full 40-character commit SHA." | tee "$evidence/preflight-error.txt" |
| 777 | exit 1 |
| 778 | fi |
| 779 | expected="$(printf '%s' "$EXPECTED_SHA" | tr '[:upper:]' '[:lower:]')" |
| 780 | if [[ "$(git rev-parse HEAD)" != "$expected" || "$GITHUB_SHA" != "$expected" ]]; then |
| 781 | echo "::error::Qualification checkout does not match the exact dispatch SHA." | tee "$evidence/preflight-error.txt" |
| 782 | exit 1 |
| 783 | fi |
| 784 | { |
| 785 | printf 'commit=%s\ntree=%s\n' "$expected" "$(git rev-parse 'HEAD^{tree}')" |
| 786 | rustc -Vv |
| 787 | cargo -V |
| 788 | uname -a |
| 789 | printf 'available_cpus=%s\n' "$(getconf _NPROCESSORS_ONLN)" |
| 790 | printf 'runner_os=%s\nrunner_arch=%s\n' "$RUNNER_OS" "$RUNNER_ARCH" |
| 791 | printf 'image_os=%s\nimage_version=%s\n' "${ImageOS:-unknown}" "${ImageVersion:-unknown}" |
| 792 | printf 'RUST_MIN_STACK=%s\nCARGO_INCREMENTAL=%s\nCARGO_BUILD_JOBS=%s\n' \ |
| 793 | "$RUST_MIN_STACK" "${CARGO_INCREMENTAL:-default}" "${CARGO_BUILD_JOBS:-default}" |
| 794 | printf '%s\n' 'RUST_TEST_THREADS=unset (default libtest concurrency)' \ |
| 795 | 'RUSTFLAGS=empty; CARGO_ENCODED_RUSTFLAGS=empty; RUSTC_WRAPPER=empty' \ |
| 796 | 'command=sh scripts/with-hermetic-test-home.sh cargo test --workspace --all-features --locked -- --format=pretty' |
| 797 | } > "$evidence/environment.txt" |
| 798 | cat > "$evidence/required-tests.txt" <<'EOF' |
| 799 | remote_control::tests::classic_recovery_uses_persisted_seq_floor_and_ignores_older_terminal |
| 800 | remote_control::tests::actual_start_reclaims_runtime_chat_writer_before_worker_spawn |
| 801 | remote_control::tests::separate_predispatch_crashes_on_one_run_get_distinct_recovery_turn_ids |
| 802 | runtime_api::tests::events_endpoint_respects_since_seq_cursor |
| 803 | runtime_threads::tests::approval_required_awaits_external_decision_allow |
| 804 | runtime_threads::tests::approval_remember_grants_tool_class_without_changing_posture |
| 805 | tools::subagent::budget_handback_tests::budget_handback_inflight_wall_timeout_persists_unreported_usage |
| 806 | tools::subagent::tests::child_permission_gate::wall_deadline_ends_pending_wait_with_receipt |
| 807 | tools::subagent::tests::resume_keeps_recorded_reasoning_in_manifest_and_request_after_parent_changes |
| 808 | EOF |
| 809 | failed=0 |
| 810 | # Two fixed attempts, not retry-until-green. Preserve both native |
| 811 | # outcomes even when the first run fails; missing identities fail too. |
| 812 | for run in 1 2; do |
| 813 | if [[ "$(git rev-parse HEAD)" != "$expected" ]] || \ |
| 814 | ! git diff --quiet || ! git diff --cached --quiet; then |
| 815 | printf 'run=%s not_run=source_changed\n' "$run" >> "$evidence/results.txt" |
| 816 | failed=1 |
| 817 | continue |
| 818 | fi |
| 819 | qualification_tmp=$(mktemp -d /tmp/cw69.XXXXXX) |
| 820 | printf 'run=%s start=%s tmpdir=%s\n' "$run" "$(date -u +%FT%TZ)" "$qualification_tmp" >> "$evidence/results.txt" |
| 821 | set +e |
| 822 | TMPDIR="$qualification_tmp" sh scripts/with-hermetic-test-home.sh cargo test --workspace --all-features --locked -- --format=pretty \ |
| 823 | 2>&1 | tee "$evidence/run-$run.log" |
| 824 | pipeline_status=("${PIPESTATUS[@]}") |
| 825 | set -e |
| 826 | printf 'run=%s cargo_exit=%s log_exit=%s end=%s\n' \ |
| 827 | "$run" "${pipeline_status[0]}" "${pipeline_status[1]}" "$(date -u +%FT%TZ)" >> "$evidence/results.txt" |
| 828 | if [[ "${pipeline_status[0]}" != 0 || "${pipeline_status[1]}" != 0 ]]; then |
| 829 | failed=1 |
| 830 | fi |
| 831 | while IFS= read -r identity; do |
| 832 | if grep -Fxq "test $identity ... ok" "$evidence/run-$run.log"; then |
| 833 | printf 'run=%s test=%s result=ok\n' "$run" "$identity" >> "$evidence/results.txt" |
| 834 | else |
| 835 | printf 'run=%s test=%s result=missing_pass\n' "$run" "$identity" >> "$evidence/results.txt" |
| 836 | failed=1 |
| 837 | fi |
| 838 | done < "$evidence/required-tests.txt" |
| 839 | if [[ "$(git rev-parse HEAD)" != "$expected" ]] || \ |
| 840 | ! git diff --quiet || ! git diff --cached --quiet; then |
| 841 | printf 'run=%s source_changed=true\n' "$run" >> "$evidence/results.txt" |
| 842 | failed=1 |
| 843 | fi |
| 844 | # Plugin fixtures can leave read-only directories outside HOME. |
| 845 | # Change only owned directories; never follow links or chmod files. |
| 846 | permission_exit=0 |
| 847 | find -P "$qualification_tmp" -type d -exec chmod u+w {} + || permission_exit=$? |
| 848 | cleanup_exit=0 |
| 849 | rm -rf -- "$qualification_tmp" || cleanup_exit=$? |
| 850 | printf 'run=%s permission_exit=%s cleanup_exit=%s\n' \ |
| 851 | "$run" "$permission_exit" "$cleanup_exit" >> "$evidence/results.txt" |
| 852 | if [[ "$permission_exit" != 0 || "$cleanup_exit" != 0 ]]; then |
| 853 | failed=1 |
| 854 | fi |
| 855 | done |
| 856 | cat "$evidence/results.txt" |
| 857 | exit "$failed" |
| 858 | - name: Retain shared-process qualification evidence |
| 859 | if: always() && inputs.workspace_test_mode == 'shared-process-twice' |
| 860 | uses: actions/upload-artifact@v7 |
| 861 | with: |
| 862 | name: shared-process-workspace-${{ github.sha }}-${{ github.run_attempt }} |
| 863 | path: ${{ runner.temp }}/shared-process-workspace/ |
| 864 | if-no-files-found: error |
| 865 | retention-days: 30 |
| 866 | |
| 867 | # One sharded pipeline per OS (ci-test-suite.yml). Shard counts follow the |
| 868 | # measured serial test time of each OS (2026-11-12, run 43216596942: Linux 19 |
| 869 | # min, macOS 24 min, Windows 25 min of test execution, on top of 30 to 65 |
| 870 | # minutes of single-job compilation), so a shard is five to eight minutes of |
| 871 | # tests plus setup. Hosted macOS is the scarce pool, so it gets three shards. |
| 872 | test-ubuntu: |
| 873 | name: Sharded tests (ubuntu-latest) |
| 874 | needs: changes |
| 875 | if: >- |
| 876 | needs.changes.outputs.scoped != 'true' && |
| 877 | inputs.workspace_test_mode != 'shared-process-twice' |
| 878 | uses: ./.github/workflows/ci-test-suite.yml |
| 879 | with: |
| 880 | os: ubuntu-latest |
| 881 | shards: 4 |
| 882 | shard_list: '[1,2,3,4]' |
| 883 | build_jobs: '2' |
| 884 | debug: line-tables-only |
| 885 | |
| 886 | test-macos: |
| 887 | name: Sharded tests (macos-latest) |
| 888 | needs: changes |
| 889 | if: >- |
| 890 | needs.changes.outputs.scoped != 'true' && |
| 891 | inputs.workspace_test_mode != 'shared-process-twice' |
| 892 | uses: ./.github/workflows/ci-test-suite.yml |
| 893 | with: |
| 894 | os: macos-latest |
| 895 | self_hosted: ${{ needs.changes.outputs.macos_self_hosted == 'true' }} |
| 896 | shards: ${{ needs.changes.outputs.macos_self_hosted == 'true' && 1 || 3 }} |
| 897 | shard_list: ${{ needs.changes.outputs.macos_self_hosted == 'true' && '[1]' || '[1,2,3]' }} |
| 898 | build_jobs: ${{ needs.changes.outputs.macos_self_hosted == 'true' && '6' || '1' }} |
| 899 | debug: '0' |
| 900 | |
| 901 | test-windows: |
| 902 | name: Sharded tests (windows-latest) |
| 903 | needs: changes |
| 904 | if: >- |
| 905 | needs.changes.outputs.scoped != 'true' && |
| 906 | inputs.workspace_test_mode != 'shared-process-twice' |
| 907 | uses: ./.github/workflows/ci-test-suite.yml |
| 908 | with: |
| 909 | os: windows-latest |
| 910 | shards: 4 |
| 911 | shard_list: '[1,2,3,4]' |
| 912 | build_jobs: '4' |
| 913 | debug: '0' |
| 914 | |
| 915 | portable-boundaries: |
| 916 | name: Portable boundaries |
| 917 | needs: changes |
| 918 | if: >- |
| 919 | needs.changes.outputs.scoped != 'true' |
| 920 | timeout-minutes: 45 |
| 921 | runs-on: ubuntu-24.04 |
| 922 | steps: |
| 923 | - uses: actions/checkout@v7 |
| 924 | - uses: dtolnay/rust-toolchain@1.100.0 |
| 925 | - uses: mozilla-actions/sccache-action@v0.0.11 |
| 926 | with: |
| 927 | version: "v0.19.0" |
| 928 | id: sccache |
| 929 | continue-on-error: true |
| 930 | # Every run reads the GitHub Actions cache main wrote; only main writes (see Enable sccache). |
| 931 | - name: Enable sccache |
| 932 | if: steps.sccache.outcome == 'success' |
| 933 | shell: bash |
| 934 | run: | |
| 935 | if [ "${GITHUB_REF}" = refs/heads/main ]; then rw=READ_WRITE; else rw=READ_ONLY; fi |
| 936 | { |
| 937 | echo "SCCACHE_GHA_ENABLED=true" |
| 938 | echo "SCCACHE_GHA_RW_MODE=${rw}" |
| 939 | echo "RUSTC_WRAPPER=sccache" |
| 940 | echo "SCCACHE_IGNORE_SERVER_IO_ERROR=1" |
| 941 | echo "SCCACHE_IDLE_TIMEOUT=0" |
| 942 | } >> "${GITHUB_ENV}" |
| 943 | - name: Install Linux system dependencies |
| 944 | run: | |
| 945 | bash scripts/ci/ci-apt-install.sh libdbus-1-dev pkg-config bubblewrap apparmor-profiles |
| 946 | sh scripts/ci/prepare-linux-test-sandbox.sh |
| 947 | - uses: Swatinem/rust-cache@v2 |
| 948 | with: |
| 949 | cache-bin: false |
| 950 | save-if: ${{ github.ref == 'refs/heads/main' }} |
| 951 | - uses: taiki-e/install-action@b6620ca104fb7b50dafa1109be9622abc1fdd381 |
| 952 | with: |
| 953 | tool: cargo-nextest@0.9.151 |
| 954 | - uses: actions/setup-node@v7.1.0 |
| 955 | with: |
| 956 | node-version: 22 |
| 957 | - uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # v2.2 |
| 958 | with: |
| 959 | bun-version: 1.4.0 |
| 960 | - name: Check portable config policy boundary |
| 961 | shell: bash |
| 962 | run: | |
| 963 | python3 -B scripts/test_check_command_config_proof.py |
| 964 | sh scripts/check-portable-config.sh |
| 965 | - name: Check portable core navigation boundary |
| 966 | shell: bash |
| 967 | run: | |
| 968 | python3 -B scripts/test_check_command_core_navigation_proof.py |
| 969 | sh scripts/check-portable-core-navigation.sh |
| 970 | |
| 971 | scoped-test: |
| 972 | # workflow_dispatch with `crate` and/or `filter`: one package or one nextest |
| 973 | # filterset on the chosen OSes (default ubuntu-latest) instead of the full |
| 974 | # suite. `changes` skips every other job for such a run. The build uses the |
| 975 | # same flags as the full build; only `-p` and `-E` narrow what runs. |
| 976 | name: Scoped test (${{ matrix.os }}) |
| 977 | needs: changes |
| 978 | if: needs.changes.outputs.scoped == 'true' |
| 979 | timeout-minutes: 90 |
| 980 | runs-on: ${{ matrix.os == 'ubuntu-latest' && 'ubuntu-24.04' || matrix.os }} |
| 981 | strategy: |
| 982 | fail-fast: false |
| 983 | matrix: |
| 984 | os: ${{ fromJSON(needs.changes.outputs.scoped_os) }} |
| 985 | env: |
| 986 | CARGO_BUILD_JOBS: ${{ matrix.os == 'macos-latest' && '1' || '2' }} |
| 987 | CARGO_PROFILE_DEV_DEBUG: ${{ matrix.os == 'ubuntu-latest' && 'line-tables-only' || '0' }} |
| 988 | CARGO_PROFILE_TEST_DEBUG: ${{ matrix.os == 'ubuntu-latest' && 'line-tables-only' || '0' }} |
| 989 | CODEWHALE_EXT_HOST_TESTS: '1' |
| 990 | CODEWHALE_EXT_HOST_BUN_TESTS: '1' |
| 991 | RUST_MIN_STACK: '16777216' |
| 992 | SCOPE_CRATE: ${{ inputs.crate }} |
| 993 | SCOPE_FILTER: ${{ inputs.filter }} |
| 994 | steps: |
| 995 | - uses: actions/checkout@v7 |
| 996 | - name: Point terminal failure diagnostics at the runner temp directory |
| 997 | shell: bash |
| 998 | run: echo "QA_PTY_DIAGNOSTICS_DIR=${RUNNER_TEMP}/pty-failures" >> "${GITHUB_ENV}" |
| 999 | - uses: dtolnay/rust-toolchain@1.100.0 |
| 1000 | - name: Install Linux system dependencies |
| 1001 | if: matrix.os == 'ubuntu-latest' |
| 1002 | run: | |
| 1003 | bash scripts/ci/ci-apt-install.sh libdbus-1-dev pkg-config bubblewrap apparmor-profiles |
| 1004 | sh scripts/ci/prepare-linux-test-sandbox.sh |
| 1005 | - uses: Swatinem/rust-cache@v2 |
| 1006 | with: |
| 1007 | cache-bin: false |
| 1008 | save-if: false |
| 1009 | - uses: taiki-e/install-action@b6620ca104fb7b50dafa1109be9622abc1fdd381 |
| 1010 | with: |
| 1011 | tool: cargo-nextest@0.9.151 |
| 1012 | - uses: actions/setup-node@v7.1.0 |
| 1013 | with: |
| 1014 | node-version: 22 |
| 1015 | - uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # v2.2 |
| 1016 | with: |
| 1017 | bun-version: 1.4.0 |
| 1018 | - name: Build matching compiled-host input for required Native containment receipts |
| 1019 | shell: bash |
| 1020 | run: bash scripts/ci/compiled-host-test-input.sh |
| 1021 | - name: Build canonical executable for acceptance tests |
| 1022 | # Acceptance tests in the TUI, engine and CLI crates, and any run that |
| 1023 | # names no crate, look for the codewhale binary next to the test |
| 1024 | # binaries; a narrow run on another crate does not need it. |
| 1025 | if: env.SCOPE_CRATE == '' || env.SCOPE_CRATE == 'codewhale-tui' || env.SCOPE_CRATE == 'codewhale-engine' || env.SCOPE_CRATE == 'codewhale-cli' |
| 1026 | shell: bash |
| 1027 | run: cargo build -p codewhale-cli --bin codewhale --all-features --locked |
| 1028 | - name: Run the scoped tests |
| 1029 | shell: bash |
| 1030 | run: | |
| 1031 | set -euo pipefail |
| 1032 | args=(--all-features --locked --profile ci --no-tests=fail) |
| 1033 | if [ -n "${SCOPE_CRATE}" ]; then args+=(-p "${SCOPE_CRATE}"); else args+=(--workspace); fi |
| 1034 | if [ -n "${SCOPE_FILTER}" ]; then args+=(-E "${SCOPE_FILTER}"); fi |
| 1035 | sh scripts/with-hermetic-test-home.sh cargo nextest run "${args[@]}" |
| 1036 | - name: Retain sealed terminal failure diagnostics |
| 1037 | if: failure() |
| 1038 | uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7 |
| 1039 | with: |
| 1040 | name: terminal-failures-scoped-${{ runner.os }}-${{ github.sha }}-${{ github.run_attempt }} |
| 1041 | path: ${{ runner.temp }}/pty-failures/ |
| 1042 | include-hidden-files: true |
| 1043 | if-no-files-found: ignore |
| 1044 | retention-days: 7 |
| 1045 | |
| 1046 | macos-budget: |
| 1047 | # The RSS budget and the offline eval each rebuild codewhale-tui on a cold |
| 1048 | # hosted Mac, so they run here under their own timeout instead of inside |
| 1049 | # the sharded macOS suite. Every full dispatch (main-landing issues one |
| 1050 | # per push to main) runs it. |
| 1051 | name: macOS budget and eval |
| 1052 | needs: changes |
| 1053 | if: needs.changes.outputs.scoped != 'true' |
| 1054 | # Cold hosted builds consumed 73 minutes before eval could start (F run |
| 1055 | # 37497498829). Match Test's compile allowance; RSS/eval limits stay intact. |
| 1056 | timeout-minutes: 210 |
| 1057 | runs-on: macos-latest |
| 1058 | steps: |
| 1059 | - uses: actions/checkout@v7 |
| 1060 | - uses: dtolnay/rust-toolchain@1.100.0 |
| 1061 | - uses: Swatinem/rust-cache@v2 |
| 1062 | with: |
| 1063 | cache-bin: false |
| 1064 | save-if: false |
| 1065 | - name: Fetch dependencies before offline measurement |
| 1066 | run: cargo fetch --locked |
| 1067 | - name: Check persistence-backlog RSS budget |
| 1068 | run: python3 scripts/check-persistence-backlog-budget.py |
| 1069 | - name: Run Offline Eval Harness |
| 1070 | run: cargo run -p codewhale-cli --bin codewhale --all-features -- eval |
| 1071 | |
| 1072 | npm-wrapper-smoke: |
| 1073 | name: npm wrapper smoke |
| 1074 | needs: changes |
| 1075 | if: needs.changes.outputs.scoped != 'true' |
| 1076 | # A cold Windows compile can take 42 minutes; leave room for cache save |
| 1077 | # after the separately bounded five-minute install/entrypoint smoke test. |
| 1078 | timeout-minutes: 60 |
| 1079 | runs-on: ${{ matrix.os == 'ubuntu-latest' && 'ubuntu-24.04' || matrix.os }} |
| 1080 | strategy: |
| 1081 | matrix: |
| 1082 | os: [ubuntu-latest, windows-latest] |
| 1083 | steps: |
| 1084 | - uses: actions/checkout@v7 |
| 1085 | - uses: dtolnay/rust-toolchain@1.100.0 |
| 1086 | - uses: mozilla-actions/sccache-action@v0.0.11 |
| 1087 | with: |
| 1088 | version: "v0.19.0" |
| 1089 | id: sccache |
| 1090 | continue-on-error: true |
| 1091 | # Every run reads the GitHub Actions cache main wrote; only main writes (see Enable sccache). |
| 1092 | - name: Enable sccache |
| 1093 | if: steps.sccache.outcome == 'success' && matrix.os != 'windows-latest' |
| 1094 | shell: bash |
| 1095 | run: | |
| 1096 | echo "SCCACHE_GHA_ENABLED=true" >> "${GITHUB_ENV}" |
| 1097 | if [ "${GITHUB_REF}" = refs/heads/main ]; then rw=READ_WRITE; else rw=READ_ONLY; fi |
| 1098 | echo "SCCACHE_GHA_RW_MODE=${rw}" >> "${GITHUB_ENV}" |
| 1099 | echo "RUSTC_WRAPPER=sccache" >> "${GITHUB_ENV}" |
| 1100 | echo "SCCACHE_IGNORE_SERVER_IO_ERROR=1" >> "${GITHUB_ENV}" |
| 1101 | echo "SCCACHE_IDLE_TIMEOUT=0" >> "${GITHUB_ENV}" |
| 1102 | - uses: actions/setup-node@v7.1.0 |
| 1103 | with: |
| 1104 | node-version: 22 |
| 1105 | - name: Install Linux system dependencies |
| 1106 | if: matrix.os == 'ubuntu-latest' |
| 1107 | run: | |
| 1108 | bash scripts/ci/ci-apt-install.sh libdbus-1-dev pkg-config |
| 1109 | - uses: Swatinem/rust-cache@v2 |
| 1110 | with: |
| 1111 | cache-bin: false |
| 1112 | save-if: ${{ github.ref == 'refs/heads/main' }} |
| 1113 | - name: Build wrapper binaries |
| 1114 | # The smoke validates wrapper install/delegation plumbing, not |
| 1115 | # codegen quality, so skip fat LTO + codegen-units=1 for a much |
| 1116 | # cheaper release build. Shipped binaries keep the real profile via |
| 1117 | # the Release workflow. |
| 1118 | env: |
| 1119 | CARGO_PROFILE_RELEASE_LTO: 'off' |
| 1120 | CARGO_PROFILE_RELEASE_CODEGEN_UNITS: '16' |
| 1121 | run: cargo build --release --locked -p codewhale-cli --bin codewhale |
| 1122 | - name: Smoke wrapper install and delegated entrypoints |
| 1123 | timeout-minutes: 5 |
| 1124 | run: node scripts/release/npm-wrapper-smoke.js |
| 1125 | - name: sccache stats |
| 1126 | if: steps.sccache.outcome == 'success' |
| 1127 | continue-on-error: true |
| 1128 | shell: bash |
| 1129 | run: sccache --show-stats |
| 1130 | |
| 1131 | mobile-smoke: |
| 1132 | name: Mobile runtime smoke |
| 1133 | needs: changes |
| 1134 | if: needs.changes.outputs.scoped != 'true' |
| 1135 | timeout-minutes: 30 |
| 1136 | runs-on: ubuntu-24.04 |
| 1137 | steps: |
| 1138 | - uses: actions/checkout@v7 |
| 1139 | - uses: dtolnay/rust-toolchain@1.100.0 |
| 1140 | - uses: mozilla-actions/sccache-action@v0.0.11 |
| 1141 | with: |
| 1142 | version: "v0.19.0" |
| 1143 | id: sccache |
| 1144 | # Every run reads the GitHub Actions cache main wrote; only main writes (see Enable sccache). |
| 1145 | continue-on-error: true |
| 1146 | - name: Enable sccache |
| 1147 | if: steps.sccache.outcome == 'success' |
| 1148 | shell: bash |
| 1149 | run: | |
| 1150 | echo "SCCACHE_GHA_ENABLED=true" >> "${GITHUB_ENV}" |
| 1151 | if [ "${GITHUB_REF}" = refs/heads/main ]; then rw=READ_WRITE; else rw=READ_ONLY; fi |
| 1152 | echo "SCCACHE_GHA_RW_MODE=${rw}" >> "${GITHUB_ENV}" |
| 1153 | echo "RUSTC_WRAPPER=sccache" >> "${GITHUB_ENV}" |
| 1154 | echo "SCCACHE_IGNORE_SERVER_IO_ERROR=1" >> "${GITHUB_ENV}" |
| 1155 | echo "SCCACHE_IDLE_TIMEOUT=0" >> "${GITHUB_ENV}" |
| 1156 | - name: Install Linux system dependencies |
| 1157 | run: | |
| 1158 | bash scripts/ci/ci-apt-install.sh libdbus-1-dev pkg-config |
| 1159 | - uses: Swatinem/rust-cache@v2 |
| 1160 | with: |
| 1161 | cache-bin: false |
| 1162 | save-if: ${{ github.ref == 'refs/heads/main' }} |
| 1163 | - name: Run mobile smoke tests |
| 1164 | # The smoke exercises HTTP/SSE runtime behaviour, not codegen |
| 1165 | # quality; skipping fat LTO + codegen-units=1 cuts the in-script |
| 1166 | # release build from ~12min to a fraction of that. |
| 1167 | env: |
| 1168 | CARGO_PROFILE_RELEASE_LTO: 'off' |
| 1169 | CARGO_PROFILE_RELEASE_CODEGEN_UNITS: '16' |
| 1170 | run: ./scripts/e2e/mobile-smoke.sh |
| 1171 | - name: sccache stats |
| 1172 | if: steps.sccache.outcome == 'success' |
| 1173 | continue-on-error: true |
| 1174 | shell: bash |
| 1175 | run: sccache --show-stats |
| 1176 | |
| 1177 | actionlint: |
| 1178 | name: Workflow lint |
| 1179 | needs: changes |
| 1180 | if: needs.changes.outputs.scoped != 'true' |
| 1181 | timeout-minutes: 15 |
| 1182 | runs-on: ubuntu-24.04 |
| 1183 | steps: |
| 1184 | - uses: actions/checkout@v7 |
| 1185 | - name: Run actionlint |
| 1186 | uses: docker://rhysd/actionlint:1.7.12 |
| 1187 | with: |
| 1188 | # SC2129 (grouped redirects) is style-only and endemic to the |
| 1189 | # existing GITHUB_ENV/GITHUB_OUTPUT append pattern. |
| 1190 | args: -color -ignore SC2129 |
| 1191 | |
| 1192 | # Check documentation builds without warnings |
| 1193 | docs: |
| 1194 | name: Documentation |
| 1195 | needs: changes |
| 1196 | if: needs.changes.outputs.scoped != 'true' |
| 1197 | timeout-minutes: 60 |
| 1198 | runs-on: ubuntu-24.04 |
| 1199 | steps: |
| 1200 | - uses: actions/checkout@v7 |
| 1201 | - uses: dtolnay/rust-toolchain@1.100.0 |
| 1202 | - name: Install Linux system dependencies |
| 1203 | if: runner.os == 'Linux' |
| 1204 | run: | |
| 1205 | bash scripts/ci/ci-apt-install.sh libdbus-1-dev pkg-config |
| 1206 | - uses: Swatinem/rust-cache@v2 |
| 1207 | with: |
| 1208 | cache-bin: false |
| 1209 | - name: Build docs |
| 1210 | run: cargo doc --workspace --no-deps |
| 1211 | env: |
| 1212 | RUSTDOCFLAGS: -Dwarnings |
| 1213 | |
| 1214 | cargo-deny: |
| 1215 | name: cargo-deny |
| 1216 | needs: changes |
| 1217 | if: needs.changes.outputs.scoped != 'true' |
| 1218 | uses: ./.github/workflows/cargo-deny.yml |
| 1219 | |
| 1220 | security-audit: |
| 1221 | name: Security audit |
| 1222 | needs: changes |
| 1223 | if: needs.changes.outputs.scoped != 'true' |
| 1224 | uses: ./.github/workflows/security-audit.yml |
| 1225 | |
| 1226 | ohos: |
| 1227 | name: OpenHarmony |
| 1228 | needs: changes |
| 1229 | if: needs.changes.outputs.scoped != 'true' |
| 1230 | uses: ./.github/workflows/ohos.yml |
| 1231 |