# AutoBot CI/CD Pipeline # # THE pull-request workflow (#18208, delivering #15360's "8 -> 1"). Change detection runs # ONCE here, in the `changes` job; every gate below reads its answer. Before #18208 about # twenty workflows each booted a runner to run the same dorny/paths-filter against the # same diff (13 rows on a docs-only pull request, 17 on a train), and a required context # was published by a real job plus a "shim" job of the same name in a second workflow. # # SHAPE # changes one job, one dorny step per filter file in .github/filters/. Its outputs are # `run_` booleans, each defined once. The workflow files themselves count # as an input: `self` (gate-paths.yml) forces every gate. # work the bodies. python-suite's shards live in this file; every other body is a # reusable `_gate-.yml` called from a `run-` job. Work jobs may be # skipped; their names never equal a required context. # gates one top-level `if: always()` job per required context, named exactly as # branch protection names it. A gate is never `skipped`: it passes "not # affected", passes on a verified run, and fails on a draft, a failed or # cancelled run, or a failed detection (.github/actions/gate-verdict). # # WHY GATES ARE TOP-LEVEL. A required status context is matched by check-run NAME. A job # in a called workflow reports as ` / `, so a required context must never # be published from inside a `_gate-*.yml`. repo_tests/required_context_complements_test.py # enforces that, and that each gate is `if: always()`. # # NOT HERE, ON PURPOSE. `No commit trailers` and `No open blocks-merge issues reference # this PR` stay their own workflows: the second listens to `edited`, and folding it in would # rerun full CI on every pull-request body edit. Scheduled and manual runs of the bodies # are the thin `scheduled-*.yml` callers. name: AutoBot CI/CD Pipeline on: push: branches: [ release, main ] merge_group: # #14054: every required context reports inside a merge queue. Inert until the # `merge_queue` ruleset rule is enabled -- this event does not exist before then. pull_request: # ready_for_review is REQUIRED here: marking a PR ready fires ONLY this event, and the # gates fail ("draft: mark ready for review") on a draft until it does. types: [opened, synchronize, reopened, ready_for_review] # NO `branches:` FILTER (#14747): a STACKED pull request -- base is another feature # branch -- must start the run, or no required context ever reports on it. # # NO `paths:` FILTER, DELIBERATE (#13388, #14353): a path-filtered workflow that # publishes a required context deadlocks every pull request that misses the filter. # Which gates have work is decided by `changes` below, never by the event filter. concurrency: # #19283 review: a push keys on its own commit, so no later merge can cancel it. With one # group per ref, GitHub's `queue: single` cancelled a PENDING push run when the next merge # queued -- and the ratchets' base for a push is the commit before it, so a raise in the # cancelled merge was accepted for good by the next one (`queue: max` cannot be combined # with cancel-in-progress, which PRs need). PRs and merge groups keep the per-ref group. group: ${{ github.workflow }}-${{ github.event_name == 'push' && github.sha || github.ref }} # #13432: cancel superseded PR runs, but let a push to a base branch finish. # # On a pull request a new push makes the previous run obsolete, so cancelling is right. # On a push to main it meant each merge cancelled the previous merge's verification, and # merges arrive faster than the suite completes: of the last 39 completed base runs, 26 # were cancelled and NONE succeeded. # # Base pushes no longer serialise in one group (#19283 review, above): each runs in its # own, so every merge gets a verdict. That is bounded by the merge rate -- trains land a # few times an hour -- not by PR traffic, which keeps the per-ref, cancel-superseded group. # # #18558: this is the ONE concurrency block. Seven workflows used to carry a copy of it. cancel-in-progress: ${{ github.event_name == 'pull_request' }} permissions: contents: read packages: read # pull the ghcr CI image mirror (#18160) jobs: changes: # DELIBERATELY UNGATED (#17957). Path detection costs seconds and every gate reads # `needs.changes.result`. Gating it makes those read `skipped` and fail, so a REQUIRED # context would report FAILED on every draft -- worse than no gate. name: Detect changed paths runs-on: ubuntu-latest timeout-minutes: 10 outputs: # ready: the run is not a draft pull request. Work behind a required gate is held back # until then; the gate itself fails with the reason (D4, #18208). ready: ${{ github.event_name != 'pull_request' || (github.event.pull_request.draft == false && steps.hold.outputs.held != 'true') }} # held (#21490, #21519): a dependabot pull request that is neither a `train-*` head nor labelled `ci:full`, # or the release promotion pull request without `ci:full`. # It starts no expensive work; every gate reports it as held (fails, never passes) in its summary. held: ${{ steps.hold.outputs.held }} # D8: python-suite on merge_group is parity -- it runs only when Python changed. run_python_suite: ${{ steps.gp.outputs.self == 'true' || steps.suite.outputs.python == 'true' }} run_frontend_tests: ${{ steps.gp.outputs.self == 'true' || steps.fe.outputs.frontend == 'true' }} run_code_quality: ${{ github.event_name == 'merge_group' || steps.gp.outputs.self == 'true' || steps.cq.outputs.backend == 'true' }} run_startup_smoke: ${{ github.event_name == 'merge_group' || steps.gp.outputs.self == 'true' || steps.bp.outputs.startup_smoke == 'true' }} run_unit_tests: ${{ github.event_name == 'merge_group' || steps.gp.outputs.self == 'true' || steps.fe.outputs.frontend == 'true' }} # A push to main builds the images unconditionally (as docker-smoke-test.yml did); a # pull request builds them only when an image input changed. run_docker_smoke: >- ${{ github.event_name == 'merge_group' || (github.event_name == 'push' && github.ref_name == 'main') || steps.gp.outputs.self == 'true' || steps.dk.outputs.docker == 'true' }} run_api_wiring: ${{ github.event_name == 'merge_group' || steps.gp.outputs.self == 'true' || steps.bp.outputs.wiring == 'true' }} # `!= 'false'`, not `== 'true'`: an empty output still RUNS the check (#13862). run_migrations: ${{ steps.gp.outputs.self == 'true' || steps.gp.outputs.migrations != 'false' }} run_types: ${{ steps.gp.outputs.self == 'true' || steps.gp.outputs.types != 'false' }} run_slm_types: ${{ steps.gp.outputs.self == 'true' || steps.gp.outputs.slm_types != 'false' }} # verify-precommit-config is never filtered; only its repo-wide sweep is scoped. run_precommit_sweep: ${{ steps.docs.outputs.precommit_sweep == 'true' }} run_security: >- ${{ (github.event_name == 'push' && contains(fromJSON('["release","main"]'), github.ref_name)) || (github.event_name == 'pull_request' && (steps.gp.outputs.self == 'true' || steps.gp.outputs.security_scope == 'true')) }} run_deps_scan: ${{ steps.gp.outputs.self == 'true' || steps.bp.outputs.deps == 'true' }} run_static_analysis: ${{ steps.gp.outputs.self == 'true' || steps.bp.outputs.static_analysis == 'true' }} codeql_languages: ${{ steps.langs.outputs.languages }} run_ai_review: ${{ github.event_name == 'pull_request' && (steps.gp.outputs.self == 'true' || steps.bp.outputs.reviewable == 'true') }} run_npm: >- ${{ steps.gp.outputs.self == 'true' || steps.gp.outputs.npm_browser_worker == 'true' || steps.gp.outputs.npm_mcp == 'true' || steps.gp.outputs.npm_sdk_ts == 'true' || steps.gp.outputs.npm_structured_thinking == 'true' }} npm_browser_worker: ${{ steps.gp.outputs.self == 'true' || steps.gp.outputs.npm_browser_worker == 'true' }} npm_mcp: ${{ steps.gp.outputs.self == 'true' || steps.gp.outputs.npm_mcp == 'true' }} npm_sdk_ts: ${{ steps.gp.outputs.self == 'true' || steps.gp.outputs.npm_sdk_ts == 'true' }} npm_structured_thinking: ${{ steps.gp.outputs.self == 'true' || steps.gp.outputs.npm_structured_thinking == 'true' }} run_slm_frontend: ${{ steps.gp.outputs.self == 'true' || steps.gp.outputs.slm_frontend == 'true' }} steps: # #21490 / #21519: decide first, from facts of the PULL REQUEST (its author, its head and base) # -- `github.actor` becomes the human who re-runs it. Labels are read from the event payload, so # `ci:full` takes effect on the next run the event starts (push, reopen, ready for review), not # when the label is applied. Two kinds are held: a dependabot pull request, and the release # promotion pull request (head = the default branch of THIS repository, base = release). - name: Hold dependabot and release promotion pull requests id: hold env: EVENT: ${{ github.event_name }} AUTHOR: ${{ github.event.pull_request.user.login }} HEAD_REF: ${{ github.event.pull_request.head.ref }} HEAD_REPO: ${{ github.event.pull_request.head.repo.full_name }} BASE_REF: ${{ github.event.pull_request.base.ref }} DEFAULT_BRANCH: ${{ github.event.repository.default_branch }} REPO: ${{ github.repository }} LABELS: ${{ toJSON(github.event.pull_request.labels.*.name) }} # FAILS OPEN. A broken hold step must degrade to "run everything", never "block everything": # a failure here fails `changes` and with it every gate of every pull request. So no `set -e`, # and an unreadable label list (jq missing, malformed payload) means NOT held, plus a warning. # Watch item: this step needs `jq` (present on the hosted runner image). run: | set -uo pipefail held=false kind="" if [ "${EVENT}" = "pull_request" ]; then if [ "${AUTHOR}" = "dependabot[bot]" ] && [[ "${HEAD_REF}" != train-* ]]; then kind="dependabot pull request" # Same-repository head only: a fork branch that happens to be called main is not a promotion. elif [ -n "${DEFAULT_BRANCH}" ] && [ "${HEAD_REF}" = "${DEFAULT_BRANCH}" ] \ && [ "${HEAD_REPO}" = "${REPO}" ] && [ "${BASE_REF}" = "release" ]; then kind="release promotion pull request" fi fi if [ -n "${kind}" ]; then if full=$(jq -r 'if index("ci:full") then "yes" else "no" end' <<<"${LABELS}" 2>/dev/null) \ && [ -n "${full}" ]; then [ "${full}" = "no" ] && held=true else echo "::warning title=hold::cannot read the pull request labels; not holding this ${kind} (#21490)" fi fi echo "held=${held}" >> "$GITHUB_OUTPUT" if [ "${held}" = "true" ]; then { echo "### Held: ${kind} (#21490, #21519)" echo "The expensive work was NOT run and every required gate reports it as held, not passed." echo "It runs once the \`ci:full\` label is on the PR and a new run starts (a dependabot PR also on a \`train-*\` branch)." } >> "$GITHUB_STEP_SUMMARY" fi - uses: actions/checkout@v7 # One dorny step per filter file, each with a distinct id. `base` is the merge group's # base on EVERY step: dorny/paths-filter errors on a merge_group event unless it is # given, and a failed `changes` job fails every gate closed (#14054). It is empty on # push/PR, so their behaviour is unchanged. This subsumes #18191 (the old ci.yml # steps never set it). - uses: dorny/paths-filter@ceb8a2b8f2d89434be7ff52d3de7ec3738c5cc9d # v4.0.3 id: gp with: base: ${{ github.event.merge_group.base_sha || '' }} filters: .github/filters/gate-paths.yml - uses: dorny/paths-filter@ceb8a2b8f2d89434be7ff52d3de7ec3738c5cc9d # v4.0.3 id: suite with: base: ${{ github.event.merge_group.base_sha || '' }} filters: .github/filters/python-paths.yml - uses: dorny/paths-filter@ceb8a2b8f2d89434be7ff52d3de7ec3738c5cc9d # v4.0.3 id: cq with: base: ${{ github.event.merge_group.base_sha || '' }} filters: .github/filters/code-quality-paths.yml # #12986: the canonical backend-Python set and every filter composed from it. - uses: dorny/paths-filter@ceb8a2b8f2d89434be7ff52d3de7ec3738c5cc9d # v4.0.3 id: bp with: base: ${{ github.event.merge_group.base_sha || '' }} filters: .github/filters/backend-python-paths.yml - uses: dorny/paths-filter@ceb8a2b8f2d89434be7ff52d3de7ec3738c5cc9d # v4.0.3 id: fe with: base: ${{ github.event.merge_group.base_sha || '' }} filters: .github/filters/frontend-paths.yml - uses: dorny/paths-filter@ceb8a2b8f2d89434be7ff52d3de7ec3738c5cc9d # v4.0.3 id: dk with: base: ${{ github.event.merge_group.base_sha || '' }} filters: .github/filters/docker-paths.yml - uses: dorny/paths-filter@ceb8a2b8f2d89434be7ff52d3de7ec3738c5cc9d # v4.0.3 id: docs with: base: ${{ github.event.merge_group.base_sha || '' }} filters: .github/filters/docs-only-paths.yml # The languages CodeQL analyses. A pull request analyses the languages whose filter # matched (all three when ci.yml itself changed); a push to release/main analyses all # three, unfiltered, because a pull request's results are compared with the analysis of # its base branch and a base scan must never be skipped by a path filter. Any other # event analyses nothing. A step that yields no answer falls through to ALL three on a # pull request, never to none. - name: Select the CodeQL languages id: langs env: EVENT: ${{ github.event_name }} REF_NAME: ${{ github.ref_name }} SELF: ${{ steps.gp.outputs.self }} PY: ${{ steps.gp.outputs.codeql_python }} JS: ${{ steps.gp.outputs.codeql_javascript_typescript }} ACTIONS: ${{ steps.gp.outputs.codeql_actions }} run: | set -euo pipefail all='["python","javascript-typescript","actions"]' case "${EVENT}" in push) if [ "${REF_NAME}" = "release" ] || [ "${REF_NAME}" = "main" ]; then langs="${all}"; else langs='[]'; fi ;; pull_request) if [ "${SELF}" = "true" ]; then langs="${all}" else picked=() [ "${PY}" = "true" ] && picked+=('"python"') [ "${JS}" = "true" ] && picked+=('"javascript-typescript"') [ "${ACTIONS}" = "true" ] && picked+=('"actions"') langs="[$(IFS=,; echo "${picked[*]:-}")]" fi ;; *) langs='[]' ;; esac echo "languages=${langs}" >> "$GITHUB_OUTPUT" echo "CodeQL languages: ${langs}" # Short check (#20552): the fast guards, seconds to minutes, before anything expensive starts. # Every expensive job needs it, so a red here stops them, and each gate then fails on its own # verdict (a skipped upstream is no evidence, verdict.sh step 5): a required context reports a # failure, never a skip. A cancel still clears the way: the gates pass this result to # cancel-run-on-cancelled-upstream. The three reach_* guards import the whole backend, so they # stay with the suite. Drafts run it too, because run-security and friends run on drafts. short-check: name: short-check needs: changes runs-on: ubuntu-latest timeout-minutes: 15 steps: - uses: actions/checkout@v7 with: fetch-depth: 2 - uses: actions/setup-python@v7 with: python-version-file: '.python-version' - uses: ./.github/actions/release-promotion-base id: release-base - name: Ratchet base (#19283) env: EVENT_BASE: ${{ steps.release-base.outputs.base-sha || github.event.merge_group.base_sha || (github.event_name == 'push' && github.event.before) || '' }} run: | if [ -n "${EVENT_BASE//0/}" ]; then git fetch --no-tags --depth=1 origin "$EVENT_BASE" echo "AUTOBOT_RATCHET_BASE_SHA=${EVENT_BASE}" >> "$GITHUB_ENV" fi - name: Install what the guards import run: | grep -E '^pytest(-asyncio|-xdist)?(==|$)' requirements-ci-test.txt > "$RUNNER_TEMP/short-check.txt" pip install -c constraints/shared.txt -r "$RUNNER_TEMP/short-check.txt" pyyaml jinja2 - name: Fast guards run: | sed -e 's/#.*//' -e 's/[[:space:]]*$//' -e '/^$/d' tools/git-hooks/fast_guard_tests.txt \ | grep -vE '^repo_tests/reach_(declarations|roots_record|scope_claim)' \ | xargs python -m pytest -q -p no:cacheprovider -m "not reach_floor" --tb=short -n auto # #13316: the suite is split eight ways here (twelve until #19527); `python-suite` below reports the # combined verdict. Measured per-step baseline of the single job this replaces: # dependency install 162s, TEST EXECUTION 3055s, everything else ~14s — so # 95% of the job was the pytest run and nothing but parallelising the tests # themselves could matter. # # Sharding was chosen over running only the tests affected by a diff: every # test still runs, so no regression can be silently missed. Impact analysis # under-selects badly against this repo's conftest, which installs module # stubs whose PEP 562 `__getattr__` returns a MagicMock for ANY attribute. # # This runs on ubuntu-latest, NOT the singleton [self-hosted, Linux, X64] # pool (only no-commit-trailers, code-quality, frontend-test, # verify-generated-types, auto-fix-generated-types and auto-update use that). # Six concurrent shards therefore cost the self-hosted queue nothing — which # is what makes a matrix safe here and was the original #10691 objection. # #18102: fetch the CI system packages ONCE per run, not once per shard. # # The twelve shards each ran the same ~100MB apt fetch, so one run made the same # download up to twelve times and a different shard drew the slow mirror every time -- # four reds on 2026-10-08 (shards 4, 1, 2, 6), each burning ~16 minutes and reporting # red having run no tests. Exposure is now one fetch per run instead of twelve, and a # provisioning failure is a single named job rather than a random 1-of-12 shard red. # # This job runs the setup action UNCHANGED rather than carrying its own copy of the apt # retry logic -- a second copy of that is the kind of fork the repo is trying to retire. # Running the whole action also warms the venv cache the shards read, so the redundant # work is not wasted. provision-packages: name: provision-packages needs: [changes, short-check] if: ${{ needs.changes.outputs.run_python_suite == 'true' && needs.changes.outputs.ready == 'true' }} runs-on: ubuntu-latest timeout-minutes: 30 steps: - uses: actions/checkout@v7 # #18102: the runner's apt mirror can be too slow to fetch the ~63 MB ffmpeg/tesseract set # inside the per-attempt bound, and a failed provision skips every shard. The archive cache, # including the partial downloads apt resumes from, is carried between runs: a hit installs # offline, and a slow run still saves what it fetched (if: always()), so the next run resumes # instead of starting from zero. Keys are per run (caches are immutable); restore takes the # newest for this image, then any image -- debs a newer image no longer wants are ignored. # #19308: `env.ImageVersion` was always empty -- ImageOS/ImageVersion are runner # environment variables, not entries of the `env` context -- so every key read # `ci-apt-archives-Linux--` and debs from any runner image were restored alike. - name: "Runner image for the apt cache key (#19308)" id: image shell: bash run: echo "image=${ImageOS}-${ImageVersion}" >> "$GITHUB_OUTPUT" - name: "Restore the apt archive cache (#18102)" uses: actions/cache/restore@v6 with: path: ${{ runner.temp }}/apt-archive-cache key: ci-apt-archives-${{ runner.os }}-${{ steps.image.outputs.image }}-${{ github.run_id }}-${{ github.run_attempt }} restore-keys: | ci-apt-archives-${{ runner.os }}-${{ steps.image.outputs.image }}- ci-apt-archives-${{ runner.os }}- - name: "Seed apt's archive directory from the cache (#18102)" shell: bash run: | set -euo pipefail src="${RUNNER_TEMP}/apt-archive-cache" if [ -d "$src" ] && [ -n "$(ls -A "$src" 2>/dev/null)" ]; then sudo mkdir -p /var/cache/apt/archives/partial sudo cp -a "$src"/. /var/cache/apt/archives/ echo "seeded $(find "$src" -maxdepth 1 -name '*.deb' | wc -l) .deb(s) and $(find "$src/partial" -type f 2>/dev/null | wc -l) partial file(s)" else echo "no apt archive cache for this image yet; downloading from the mirror" fi - uses: ./.github/actions/setup-python-suite - name: "Stage the apt archive for the cache, complete or partial (#18102)" if: always() shell: bash run: | set -euo pipefail dst="${RUNNER_TEMP}/apt-archive-cache" rm -rf "$dst" && mkdir -p "$dst/partial" sudo cp /var/cache/apt/archives/*.deb "$dst"/ 2>/dev/null || true sudo cp /var/cache/apt/archives/partial/* "$dst/partial"/ 2>/dev/null || true sudo chown -R "$(id -u):$(id -g)" "$dst" echo "staged $(find "$dst" -maxdepth 1 -name '*.deb' | wc -l) .deb(s), $(du -sb "$dst" | cut -f1) bytes" - name: "Save the apt archive cache (#18102)" if: always() uses: actions/cache/save@v6 with: path: ${{ runner.temp }}/apt-archive-cache key: ci-apt-archives-${{ runner.os }}-${{ steps.image.outputs.image }}-${{ github.run_id }}-${{ github.run_attempt }} - name: "Collect the downloaded .debs for the shards (#18102)" shell: bash run: | set -euo pipefail dest="${RUNNER_TEMP}/apt-debs" mkdir -p "$dest" # An empty archive cache means the runner image already carried the binaries, so # the shards will find them too and their own early-out applies. Not a failure. if ! sudo cp /var/cache/apt/archives/*.deb "$dest"/ 2>/dev/null; then echo "::notice title=no .debs to share::the image already provides ffmpeg/tesseract (#18102)" fi sudo chown -R "$(id -u):$(id -g)" "$dest" echo "collected $(find "$dest" -maxdepth 1 -name '*.deb' | wc -l) .deb(s)" - uses: actions/upload-artifact@v7.0.2 with: name: ci-apt-debs path: ${{ runner.temp }}/apt-debs retention-days: 1 if-no-files-found: ignore python-shard: name: python-suite shard ${{ matrix.shard }}/${{ strategy.job-total }} needs: [changes, provision-packages] if: ${{ needs.changes.outputs.run_python_suite == 'true' && needs.changes.outputs.ready == 'true' }} runs-on: ubuntu-latest # #16320: first in, first out across PRs. # # Every push used to start all of its shards at once, and GitHub interleaved # them with every other PR's jobs, so no suite finished early. Over five PRs # on 2026-09-11 the median push-to-green was 132.6 min, and 44-98 min of it # passed before the first shard even started. # # A job-level group per shard with `queue: max` holds up to 100 pending shard # jobs and starts them in turn, so a PR that pushed earlier gets its shards # through ahead of one that pushed later. # # - The shard number is in the key. One shared key would make a PR's own # shards wait on each other. # - Pushes and merge groups key on the ref as well, so a post-merge # verification never queues behind PR work. # - `queue: max` can't be combined with cancel-in-progress, and doesn't need # to be. A superseded push is still cancelled by the workflow-level group # above, and its pending shards go with it. # - A shard waiting here is `pending`, not `queued`: it holds a place in # line and isn't waiting for a runner. Watchdogs must not read it as an # outage (#16309). concurrency: group: ${{ github.event_name == 'pull_request' && format('python-suite-shard-{0}', matrix.shard) || format('python-suite-shard-{0}-{1}', matrix.shard, github.ref) }} queue: max cancel-in-progress: false # An eighth of a ~51-minute run, with generous headroom: observed runner # variance on this suite is roughly 2x for identical work (12m18s and # 1h24m have both been recorded), and a shard whose durations have drifted # can run long without being broken. timeout-minutes: 60 # #16516: a hung test used this job's whole hour and printed nothing: `-q` # prints bare dots, so the log could not say which test was stuck. Both # pytest invocations below pass `-o faulthandler_timeout` from this ONE # setting. A test still running after this many seconds gets every thread's # traceback dumped into the log, naming the test and the frame it blocks in. # The dump neither fails nor stops the test (faulthandler_exit_on_timeout # stays off), so a spurious one costs a few log lines, never a red shard. # # 600s against the slowest recorded tests: 180.6s in .test_durations_slm and # 10.8s in .test_durations. That clears the ~2x runner variance noted above, # and a hang still dumps within ten minutes of starting, well inside the hour. # # Under xdist the dump still reaches this log. execnet starts each worker # with stdin and stdout piped and stderr inherited from this step, and # pytest's faulthandler plugin writes to a dup of the worker's stderr taken # while capture is suspended, so per-test output capture does not swallow it. # # timeout-minutes is NOT derived from this setting: a job-level # timeout-minutes cannot read the `env` context, and expressions have no # arithmetic to turn seconds into minutes. # repo_tests/ci_faulthandler_timeout_16516_test.py pins the wiring. env: PYTEST_FAULTHANDLER_TIMEOUT_S: 600 strategy: # Never cancel sibling shards. Cancelling them would hide every failure # outside the first shard to go red — and this suite currently has # standing failures, so fail-fast would make the other five shards # useless on essentially every run. fail-fast: false matrix: # #19527: eight, not twelve. Every shard pays a fixed ~4.8 min (setup # plus collecting the whole tree), so with twelve shards ~58 of a run's # ~86 runner-minutes were that fixed cost, and the twelve-wide fan-out # alone filled most of the ~20-job hosted-runner ceiling. With durations # that match the tree, eight shards finish about as fast as the # unbalanced twelve did. THIS LIST IS THE SHARD COUNT: the job name and # both --shard-splits read it through `strategy.job-total`, and # repo_tests/ci_shard_count_message_test.py holds the aggregate's # message to it. shard: [1, 2, 3, 4, 5, 6, 7, 8] # #10691: the suite has always run with no Redis, so every test needing # real atomic ops (rather than a `fakeredis` stub) was a standing failure # that could never go green — `services/redis_listeners_e2e_test.py` # imports the real `redis` client with no marker or skip guard, and # `autobot-backend/knowledge/connectors/scheduler_test.py::TestConnectorSchedulerRedis` # needs real INCR/EXPIRE semantics. Same service definition as # marker-tests.yml (#13304); the config fixture written by the composite # action already points at localhost:6379, so no extra env wiring is needed. services: redis: # Mirror of the upstream image (ci-image-mirror.yml, #18160): anonymous # pulls hit the per-IP quota. The ghcr packages must be public or grant # this repo read access so fork PRs can pull them. image: ghcr.io/mrveiss/ci-redis:7-alpine credentials: username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} ports: - 6379:6379 options: >- --health-cmd "redis-cli ping" --health-interval 5s --health-timeout 5s --health-retries 10 steps: - uses: actions/checkout@v7 # #19283: depth 2, so HEAD^1 -- the merge ref's base parent -- is readable. Down-only # ratchets compare each entry with the base commit's table (repo_tests/_ratchet_base.py) # instead of a hand-summed total, and refuse when the base cannot be read. with: fetch-depth: 2 # #19283 review: the base a ratchet compares with. A merge group names its own base; a push # to main compares with the commit main pointed at before, always an ancestor, so a raise a # cancelled PR run missed turns main red on the push that lands it. A pull_request's # `before` is the previous PR head (orphaned by a rebase), so it is not passed; HEAD^1 of # the merge ref is the base there. The named commit is fetched here. # # #19466: a PR into `release` is judged only on commits not already on main (owner ruling # 2026-10-24), so its base is the merge base with main, not the release tip. HEAD^1 there is # the weeks-old release tip, and every ceiling main raised on its own gated PRs read as a raise. # The action yields nothing for any other event or base; the step below fetches the base. - uses: ./.github/actions/release-promotion-base id: release-base - name: Ratchet base (#19283) env: EVENT_BASE: ${{ steps.release-base.outputs.base-sha || github.event.merge_group.base_sha || (github.event_name == 'push' && github.event.before) || '' }} run: | if [ -n "${EVENT_BASE//0/}" ]; then git fetch --no-tags --depth=1 origin "$EVENT_BASE" echo "AUTOBOT_RATCHET_BASE_SHA=${EVENT_BASE}" >> "$GITHUB_ENV" fi # #18102: the .debs provision-packages already fetched. The setup action installs from # this directory with --no-download when it exists, so a shard does no network fetch. # `continue-on-error` keeps the suite alive if the artifact is missing: the action # falls back to fetching, which is exactly its behaviour for coverage.yml. - uses: actions/download-artifact@v8 continue-on-error: true with: name: ci-apt-debs path: ${{ runner.temp }}/apt-debs - uses: ./.github/actions/setup-python-suite # #16394: named so the SLM venv's own path (the `slm-venv` output) is # reachable from later steps in this job -- the composite action # deliberately does not activate it onto $GITHUB_PATH, unlike the # backend venv, so it must be reached explicitly by this output. id: setup-python-suite # #16264: requirements-ci.txt drifted below two declared floors # (websockets, langchain-community) with nothing here noticing -- # pipeline-scripts/check_dependency_floors.py has carried a --strict mode # since #15091, but no workflow ever called it. Gated to shard 1 only: # every shard restores the identical cached venv keyed off the same # requirements-ci.txt (see setup-python-suite's cache key), so checking # every shard would report the same drift once per shard for one PR-blocking # signal. # # #16394: scoped with --roots to the files THIS (backend) venv actually # installs -- requirements-ci.txt, requirements-ci-test.txt and # autobot-backend/requirements.txt, same pattern # scripts/setup-ci-parity-env.sh already uses for the same reason. Before # the SLM venv split below, the default (unscoped) sweep also read # autobot-slm-backend/requirements.txt and reported ITS websockets>=17.1 # floor against this interpreter's <16 install -- a real shortfall for # this interpreter, but not this venv's drift to fix, since this venv # never installs SLM's requirements at all. That reported shortfall is # exactly what pipeline-scripts/check_dependency_floors.py's # KNOWN_CROSS_VENV_EXEMPTIONS used to paper over; scoping the sweep to # what this venv actually installs makes the exemption unnecessary rather # than silencing it. The SLM venv gets its own scoped check below, judged # against its own install. - name: Fail on a declared dependency floor the CI install does not meet (#16264) if: matrix.shard == 1 run: >- python pipeline-scripts/check_dependency_floors.py --strict --roots requirements-ci.txt requirements-ci-test.txt autobot-backend/requirements.txt # #16394: the SLM venv's own strict floor check, run under ITS OWN # interpreter and scoped to exactly what it installs -- so SLM's declared # websockets>=17.1 floor is judged against the SLM venv's actual install # (17.1.x+, satisfying it), not the backend venv's <16 build. This is the # other half of the pair above; together they are what makes the # KNOWN_CROSS_VENV_EXEMPTIONS entry removed in this same change # unnecessary rather than just quieter. - name: Fail on a declared dependency floor the SLM CI install does not meet (#16394) if: matrix.shard == 1 run: >- ${{ steps.setup-python-suite.outputs.slm-venv }}/bin/python pipeline-scripts/check_dependency_floors.py --strict --roots requirements-ci-test.txt autobot-slm-backend/requirements.txt # #13927: repo_tests/promtool_rules_test.py runs `promtool check rules` over # every deployed rule file and `promtool test rules` over every behavioural # suite — and on a GitHub-hosted runner it did NONE of that, because nothing # installed the binary. Four of its ten collected checks skipped, so rule behaviour # was verified by nothing in CI. # # That is not hypothetical: #13909 shipped a recording rule whose `and` # operands were reversed, so ServiceMemoryHeadroomLow compared a byte count # against 0.15 and could never fire. Every Python test passed, because they # asserted substrings of the expr strings. The promtool suite catches it. # # Version: read from the monitoring role's prometheus_version, the one # declaration of the Prometheus version (#18556), so CI and hosts cannot drift. # Cached: the tarball is ~95.7 MB and this job runs 8 shards, so an # uncached download is ~1.15 GB per run of which ~1.05 GB is waste — the # promtool tests collect into exactly one shard. Not gated on the shard # number: which shard they land in is a function of .test_durations and # moves silently. - name: Resolve the Prometheus version from the monitoring role (#18556) id: promver run: | set -euo pipefail V=$(sed -nE 's/^prometheus_version:[[:space:]]*"?([0-9][0-9.]*)"?.*/\1/p' autobot-slm-backend/ansible/roles/monitoring/defaults/main.yml) test -n "$V" echo "version=$V" >> "$GITHUB_OUTPUT" - name: Cache promtool id: promtool-cache uses: actions/cache@v6 with: path: /usr/local/bin/promtool key: promtool-${{ runner.os }}-${{ steps.promver.outputs.version }} - name: Install promtool (Prometheus rule validation, #13927) if: steps.promtool-cache.outputs.cache-hit != 'true' run: | set -euo pipefail PROM_VERSION="${{ steps.promver.outputs.version }}" TARBALL="prometheus-${PROM_VERSION}.linux-amd64" # --retry: this step sits in front of the entire Python suite. One # transient CDN 5xx would redden python-shard -> python-suite -> # deployment-check with a message about Prometheus, once per shard. A PR # about indicators whose red carries no information must not add that. curl -fsSL --retry 5 --retry-all-errors --retry-delay 2 --connect-timeout 10 \ -o "/tmp/${TARBALL}.tar.gz" \ "https://github.com/prometheus/prometheus/releases/download/v${PROM_VERSION}/${TARBALL}.tar.gz" # noqa: pinned upstream release URL (#14053); the version is PROM_VERSION above tar xzf "/tmp/${TARBALL}.tar.gz" -C /tmp sudo install -m 0755 "/tmp/${TARBALL}/promtool" /usr/local/bin/promtool - name: Require promtool in the rule tests (#13927) # Explicit, rather than keying on the generic CI var: repo_tests also runs # in coverage.yml and test-durations.yml, which are equally "CI" and never # promised the binary. Keying on CI made those emit a fixture error # asserting "a regression in the install step" — a false diagnosis, and # swallowed anyway because both steps end in `|| echo ::warning::`. run: | echo "AUTOBOT_REQUIRE_PROMTOOL=1" >> "$GITHUB_ENV" promtool --version - name: Enforce reach-floor staleness on merge trains (#19282) # A floor the tree outgrew is stale, not lost. It fails where it is fixed -- the merge train, # which re-pins with scripts/repin_reach_floors.py -- and only warns on other PRs, whose # authors did not grow the tree. A real reach loss fails everywhere (repo_tests/_reach.py). if: startsWith(github.head_ref, 'train-') run: echo "AUTOBOT_REACH_AUDIT=1" >> "$GITHUB_ENV" # Static checks (black / isort / flake8 / bandit) deliberately live in # code-quality.yml, NOT here (#13162). They were duplicated across both # workflows over the same three trees; code-quality.yml's bandit has no # severity floor where this one filtered to medium+, so it is the stricter # of the two and nothing is lost by removing this copy. Keeping them here # also meant four checks that finish in minutes were gated behind a # ~105-minute pytest run in the same job. # #13300: these two invocations used to live in ONE `run:` block. GitHub's # default shell is `bash -e`, so the first invocation's non-zero exit on the # standing failures aborted the step and the second NEVER executed. Two # separate steps with `!cancelled()` on the second decouple them: each # reports its own conclusion in the job UI, both contribute to the job # result, and neither can silently swallow the other. # # #10691: BOTH invocations are sharded, rather than giving each invocation # a whole job. The two are wildly unequal — the backend invocation is the # measured ~51 minutes, while slm-backend had never executed in CI at all # before #13300 — so splitting per-invocation would have produced one # enormous job and one short one, capping the speed-up at roughly 1x. Shards # that each run an equal share of BOTH keeps every shard the same shape and # keeps the #13084 interpreter separation intact inside each shard. - name: Run unit tests — backend, shared, tts-worker, repo_tests run: | echo "Running unit tests for autobot-backend / autobot_shared / autobot-tts-worker / repo_tests..." # Run all unit tests excluding slow/integration/distributed/performance # markers. Those markers are NOT a way to retire a test: marker-tests.yml # runs exactly the excluded set on a schedule (#13286). # # -n auto --dist loadscope is UNCHANGED from the pre-sharding job and # must stay that way. --dist worksteal was measured on the same machine: # faster (12m36s vs 14m53s) but 352 failures against 246, because # loadscope is what keeps same-module tests on one worker so # shared-fixture and ordering behaviour matches a serial run. Sharding # composes with it rather than replacing it: pytest-split deselects # everything outside this shard's group at collection time, and xdist # then distributes what remains by scope exactly as before. # # #14111: assignment is `repo_tests/stable_shard.py`, not pytest-split. # # The rule the old note protected still holds and is now enforced by a # test rather than a comment: whole modules stay inside one shard, so # --dist loadscope keeps behaving as it did. `least_duration`, which # scatters individual tests and splits modules, remains the thing not # to do — it is the same fixture-sharing hazard that made worksteal # worse. # # What changed is *stability*, not that rule. pytest-split cut the # COLLECTED LIST into contiguous chunks, so a shard's membership was a # function of that list's order and membership: adding one test file # shifted every downstream boundary and re-dealt every later shard, # reddening PRs on failures nowhere near their diff. It also meant a # checkout missing optional dependencies collected a different set and # so named different tests for the same --group, which is why a shard # failure could not be reproduced locally. # # The replacement hashes each module into one of 512 buckets and maps # buckets to shards from the DURATIONS FILE — an input a PR adding # tests does not touch. Measured on the real file: 1.18x spread by test # count, and zero modules move when one is added, grown or removed. # Regenerating durations is the one operation that legitimately # re-deals, and a test names it so. # # #13084: two SEPARATE pytest invocations, not one combined session. # autobot-backend/ and autobot-slm-backend/ each define top-level # packages with identical names (api, services, user_management, # middleware, migrations). Collecting both in one interpreter session # makes whichever backend's file collects first bind that dotted name # in sys.modules for the rest of the session, breaking the other # backend's own tests. # #13653: `scripts` was absent from this list, so the seven test files # guarding the pre-commit checkers (nosec format, exec bits, token # contrast, websockets cap, api wiring) ran in no workflow at all. # They pass — measured at 118 passed — so this is a wiring fix, not a # quarantine. scripts/lib/*_test.sh are bash and are covered separately # by repo_tests/shell_lib_test.py. # #14986: `.claude/skills/claims-audit` -- 42 tests of the claims-audit skill # that no workflow collected, because pytest.ini's testpaths is an allowlist # and `.claude` was not on it. Six were red against real defects in the # verifiers; all six are fixed and all 42 pass, so this is a wiring fix, not a # quarantine. Named in all four carriers because they are required to agree # (#14917). Narrow on purpose: `.claude/` as a whole is harness territory. # #15051: `autobot-infrastructure/shared/tests` and `libs` were named by no # pytest invocation in any workflow and by no `pytest.ini` `testpaths` entry # -- 17 of their test functions ran nowhere at all, ever (the other 11 of the # 28 originally measured gained a marker since, #14979/#15166, and run in # marker-tests.yml's third invocation instead). Named in all four # `repo_tests`-carrying invocations together so `hook_suites_run_in_ci_test.py`'s # root-set agreement (#14917) stays true; the marker selection below # deselects the marker-carrying tests already covered elsewhere, so nothing # here runs twice within the PR gate. # #21359: `-rs` prints one `SKIPPED [n] file:line: reason` line per distinct skip in the shard's # final summary. The pre-board guard lane accepts a skip only when it is on its reviewed allowlist, # and no log of this step named a reason before, so that list could not be reviewed against the suite. python -m pytest \ autobot-backend autobot_shared autobot-tts-worker repo_tests tools scripts pipeline-scripts autobot-infrastructure/shared/scripts/hooks autobot-infrastructure/shared/scripts/monitoring .claude/skills/claims-audit autobot-infrastructure/shared/tests libs plugins/core-plugins \ -n auto --dist loadscope \ -p repo_tests.stable_shard \ --shard-splits ${{ strategy.job-total }} --shard-group ${{ matrix.shard }} \ --shard-durations .test_durations \ -m "not integration and not slow and not distributed and not performance" \ --tb=short \ -o faulthandler_timeout="$PYTEST_FAULTHANDLER_TIMEOUT_S" \ --durations=25 \ --durations-min=10.0 \ -q -rs - name: Run unit tests — slm-backend # Runs even when the invocation above failed: it is a separate interpreter # testing a separate tree (#13300). if: ${{ !cancelled() }} env: # #16394: SLM's tests now run under the SLM venv's OWN interpreter # (built from autobot-slm-backend/requirements.txt, not the shared # requirements-ci.txt the backend venv above installs), instead of the # ambient `python` "Activate virtualenv for subsequent steps" put on # $GITHUB_PATH -- that one is still the BACKEND venv. Only the # interpreter changes here; every pytest-split/duration/exit-5-tolerance # /shard argument below is unchanged. SLM_PYTHON: ${{ steps.setup-python-suite.outputs.slm-venv }}/bin/python run: | echo "Running unit tests for autobot-slm-backend (shard ${{ matrix.shard }}/${{ strategy.job-total }})..." # A SECOND durations file, not the backend one: pytest-split's # --clean-durations regeneration writes only the tests that ran, so a # shared path would have each invocation truncate the other's timings. # # No --cov here: coverage moved to coverage.yml (#10691). Measured on # this very suite, instrumentation was the dominant cost — the same # trees run in 336s without it and 35m11s with it, while pytest's own # --durations reported every one of the 25 slowest tests under 10s. It # is the wrong thing to pay for on every PR. # #13637: pytest exits 5 for "no tests collected", which under the old # contiguous packing was a scheduling artefact rather than a result — # .test_durations_slm describes 1501 tests against 1644 collected, so # group 1 took 497 while groups 8-12 took none, and `bash -e` failed the # step on runs with zero test failures. # # #14111 is the repair that note asked for. Measured against the real # .test_durations_slm under the new assignment: 106 modules across all # twelve shards, none empty, 1.22x spread by test count. # # The tolerance is kept anyway, deliberately. It costs nothing, and the # condition it guards is a property of the *module set*, not of the # algorithm: a target that genuinely has fewer modules than shards still # empties one, and that must stay announced rather than red. The empty # shard is printed, and 5 remains the only tolerated code. set +e "$SLM_PYTHON" -m pytest \ autobot-slm-backend \ -n auto --dist loadscope \ -p repo_tests.stable_shard \ --shard-splits ${{ strategy.job-total }} --shard-group ${{ matrix.shard }} \ --shard-durations .test_durations_slm \ -m "not integration and not slow and not distributed and not performance" \ --tb=short \ -o faulthandler_timeout="$PYTEST_FAULTHANDLER_TIMEOUT_S" \ --durations=25 \ --durations-min=10.0 \ -q status=$? set -e if [ "$status" -eq 5 ]; then echo "::notice::autobot-slm-backend shard ${{ matrix.shard }}/${{ strategy.job-total }} collected no tests (pytest exit 5) — empty split group, see #13637" exit 0 fi exit "$status" # #19647: autobot-backend/conftest.py leaves a hollow chromadb stub in sys.modules, so in a shared # session a test of the real library skips itself and reads as green. Its own session, and a skip fails. - name: Run the real-ChromaDB tests in their own session if: matrix.shard == 1 run: | out=$(python -m pytest repo_tests/backup_embeddings_on_real_chroma_19647_test.py \ repo_tests/chromadb_missing_key_serving_where_18820_test.py -q -rs) || { echo "$out"; exit 1; } echo "$out" if grep -q SKIPPED <<< "$out"; then echo "::error::a real-ChromaDB test was skipped" exit 1 fi # RETIRED (#15051). This step named `infrastructure/shared/tests/integration`, # a path #734 moved to `autobot-infrastructure/shared/tests/integration` # without updating this reference — so the `if [ -d "$TEST_DIR" ]` guard # never once ran the pytest inside it, and every shard-1 run since #734 # passed on nothing but its own `::warning::`. Quietly, not loudly: the # step exited 0 either way, so a real regression here would have shipped # green forever. # # NOT repointed at the path that exists, because doing so would not # restore a check — it would duplicate one and widen the PR gate by # accident. `autobot-infrastructure/shared/tests` is now a root of the # "Run unit tests" step above (#15051), which already reaches # `.../tests/integration` on this same shard with the correct # `-m "not integration and not slow and not distributed and not # performance"` filter. This step's `python -m pytest "$TEST_DIR" -v # --tb=short --maxfail=5` carried no `-m` at all, so repointing it would # collect that directory a second time AND select the `integration`-marked # tests inside it (`test_architecture_compliance.py`, # `test_distributed_system_integration.py`) into the required, blocking PR # gate — the "separate decision with its own blast radius" #13286's # marker-tests.yml explicitly declines to make inline, and #15051 does not # make it either. Those stay where #13286 puts every marked test: # marker-tests.yml, selected deliberately, not swept in by a directory # check regaining its footing. # Gate: publishes the REQUIRED `python-suite` context (#10691). Its job id is kept so `deployment-check` # and `notify`, which gate on `needs.python-suite.result`, need no change. # # `if: always()`, never `!cancelled()` and never a filter condition: a gate that can be SKIPPED re-publishes # `skipped` on the context, which is the defect #18208 retires (and #18106: a re-run of a draft-era run # replayed `draft: true` and settled the context as skipped with zero shards run). A draft or a failed shard # is a red here, a missing shard run is a red here, and only "Python did not change" is a green without shards. # The number in 'All 12' must equal the python-shard matrix length (repo_tests/ci_shard_count_message_test.py). python-suite: name: python-suite needs: [changes, short-check, provision-packages, python-shard] if: always() # actions: write lets the cancel step force-cancel this run when an upstream was cancelled (#17764). permissions: contents: read actions: write runs-on: ubuntu-latest timeout-minutes: 5 steps: - uses: actions/checkout@v7 with: sparse-checkout: .github/actions persist-credentials: false # A parked or superseded run has no verdict: end the gate cancelled, never failed or skipped (#17764). - uses: ./.github/actions/cancel-run-on-cancelled-upstream with: results: ${{ needs.changes.result }} ${{ needs.short-check.result }} ${{ needs.provision-packages.result }} ${{ needs.python-shard.result }} - uses: ./.github/actions/gate-verdict with: context: python-suite changes-result: ${{ needs.changes.result }} applies: ${{ needs.changes.outputs.run_python_suite }} work-ok: ${{ needs.python-shard.result == 'success' }} work-detail: short-check=${{ needs.short-check.result }} ${{ needs.python-shard.result == 'success' && 'All 8 python-suite shards passed.' || format('python-shard={0}', needs.python-shard.result) }} event: ${{ github.event_name }} draft: ${{ github.event.pull_request.draft == true }} held: ${{ needs.changes.outputs.held }} frontend-tests: needs: [changes, short-check] if: ${{ needs.changes.outputs.held != 'true' && needs.changes.outputs.run_frontend_tests == 'true' }} runs-on: ubuntu-latest steps: - uses: actions/checkout@v7 - name: Setup Node.js uses: actions/setup-node@v7 with: node-version-file: .nvmrc cache: 'npm' cache-dependency-path: autobot-frontend/package-lock.json - name: Install frontend dependencies # #13410: no CI job runs Cypress (only `test:e2e` needs the binary), so # skip the ~100MB CDN download — a Cypress CDN 504 must never red out a # required check. Local dev `npm ci` is unaffected and still gets it. env: CYPRESS_INSTALL_BINARY: '0' run: | cd autobot-frontend npm ci - name: Run frontend linting run: | cd autobot-frontend npm run lint - name: Check i18n keys run: | cd autobot-frontend npm run check:i18n - name: Run frontend type checking env: # Baseline from #7227: known type-debt. Same gate as frontend-typecheck-regression.yml. BASELINE: 240 run: | cd autobot-frontend set +e ERRORS=$(npx vue-tsc --noEmit -p tsconfig.app.json 2>&1 | grep -cE "error TS") echo "Type error baseline: $BASELINE current: $ERRORS" if [ "$ERRORS" -gt "$BASELINE" ]; then echo "Regression: $ERRORS > $BASELINE type errors" exit 1 fi echo "Type check passed ($ERRORS errors within baseline of $BASELINE)" - name: Build frontend run: | cd autobot-frontend npm run build - name: Run frontend unit tests with coverage gate run: | cd autobot-frontend # test:coverage enforces the floors in autobot-frontend/vitest.config.ts # (source of truth, #17324); 70% is the long-term target, not the enforced value. npm run test:coverage - name: Cleanup if: always() run: | rm -rf autobot-frontend/node_modules autobot-frontend/dist || true # Work behind the `code-quality` gate. Only the body's one secret is passed, by name (never `secrets: inherit`). run-code-quality: needs: [changes, short-check] if: ${{ needs.changes.outputs.ready == 'true' && needs.changes.outputs.run_code_quality == 'true' }} uses: ./.github/workflows/_gate-code-quality.yml secrets: CONVENTIONS_DENYLIST: ${{ secrets.CONVENTIONS_DENYLIST }} permissions: contents: read security-events: read # Gate: publishes the REQUIRED `code-quality` context. code-quality: name: code-quality needs: [changes, short-check, run-code-quality] if: always() # actions: write lets the cancel step force-cancel this run when an upstream was cancelled (#17764). permissions: contents: read actions: write runs-on: ubuntu-latest timeout-minutes: 5 steps: - uses: actions/checkout@v7 with: sparse-checkout: .github/actions persist-credentials: false # A parked or superseded run has no verdict: end the gate cancelled, never failed or skipped (#17764). - uses: ./.github/actions/cancel-run-on-cancelled-upstream with: results: ${{ needs.changes.result }} ${{ needs.short-check.result }} ${{ needs.run-code-quality.result }} - uses: ./.github/actions/gate-verdict with: context: code-quality changes-result: ${{ needs.changes.result }} applies: ${{ needs.changes.outputs.run_code_quality }} work-ok: ${{ needs.run-code-quality.outputs.ok == 'true' }} work-detail: short-check=${{ needs.short-check.result }} run-code-quality=${{ needs.run-code-quality.result }} event: ${{ github.event_name }} draft: ${{ github.event.pull_request.draft == true }} held: ${{ needs.changes.outputs.held }} run-startup-import-smoke: needs: [changes, short-check] if: ${{ needs.changes.outputs.ready == 'true' && needs.changes.outputs.run_startup_smoke == 'true' }} uses: ./.github/workflows/_gate-startup-import-smoke.yml permissions: contents: read # Gate: publishes the REQUIRED `startup-import-smoke` context. startup-import-smoke: name: startup-import-smoke needs: [changes, short-check, run-startup-import-smoke] if: always() # actions: write lets the cancel step force-cancel this run when an upstream was cancelled (#17764). permissions: contents: read actions: write runs-on: ubuntu-latest timeout-minutes: 5 steps: - uses: actions/checkout@v7 with: sparse-checkout: .github/actions persist-credentials: false # A parked or superseded run has no verdict: end the gate cancelled, never failed or skipped (#17764). - uses: ./.github/actions/cancel-run-on-cancelled-upstream with: results: ${{ needs.changes.result }} ${{ needs.short-check.result }} ${{ needs.run-startup-import-smoke.result }} - uses: ./.github/actions/gate-verdict with: context: startup-import-smoke changes-result: ${{ needs.changes.result }} applies: ${{ needs.changes.outputs.run_startup_smoke }} work-ok: ${{ needs.run-startup-import-smoke.outputs.ok == 'true' }} work-detail: short-check=${{ needs.short-check.result }} run-startup-import-smoke=${{ needs.run-startup-import-smoke.result }} event: ${{ github.event_name }} draft: ${{ github.event.pull_request.draft == true }} held: ${{ needs.changes.outputs.held }} run-frontend-test: needs: [changes, short-check] if: ${{ needs.changes.outputs.ready == 'true' && needs.changes.outputs.run_unit_tests == 'true' }} uses: ./.github/workflows/_gate-frontend-test.yml permissions: contents: read # Gate: publishes the REQUIRED `Unit & Integration Tests` context. Only the unit suite decides it; # the Security Scan and Build Test jobs in the same body report for themselves, as they always did. unit-tests: name: Unit & Integration Tests needs: [changes, short-check, run-frontend-test] if: always() # actions: write lets the cancel step force-cancel this run when an upstream was cancelled (#17764). permissions: contents: read actions: write runs-on: ubuntu-latest timeout-minutes: 5 steps: - uses: actions/checkout@v7 with: sparse-checkout: .github/actions persist-credentials: false # A parked or superseded run has no verdict: end the gate cancelled, never failed or skipped (#17764). - uses: ./.github/actions/cancel-run-on-cancelled-upstream with: results: ${{ needs.changes.result }} ${{ needs.short-check.result }} ${{ needs.run-frontend-test.result }} - uses: ./.github/actions/gate-verdict with: context: Unit & Integration Tests changes-result: ${{ needs.changes.result }} applies: ${{ needs.changes.outputs.run_unit_tests }} work-ok: ${{ needs.run-frontend-test.outputs.ok == 'true' }} work-detail: short-check=${{ needs.short-check.result }} run-frontend-test=${{ needs.run-frontend-test.result }} event: ${{ github.event_name }} draft: ${{ github.event.pull_request.draft == true }} held: ${{ needs.changes.outputs.held }} run-docker-smoke: needs: [changes, short-check] if: ${{ needs.changes.outputs.ready == 'true' && needs.changes.outputs.run_docker_smoke == 'true' }} uses: ./.github/workflows/_gate-docker-smoke.yml permissions: contents: read # Gate: publishes the REQUIRED `smoke-test` context. Fail-closed when detection fails (#17126): # "cannot tell" is a red here, no longer a build that races a second publisher (#17391). smoke-test: name: smoke-test needs: [changes, short-check, run-docker-smoke] if: always() # actions: write lets the cancel step force-cancel this run when an upstream was cancelled (#17764). permissions: contents: read actions: write runs-on: ubuntu-latest timeout-minutes: 5 steps: - uses: actions/checkout@v7 with: sparse-checkout: .github/actions persist-credentials: false # A parked or superseded run has no verdict: end the gate cancelled, never failed or skipped (#17764). - uses: ./.github/actions/cancel-run-on-cancelled-upstream with: results: ${{ needs.changes.result }} ${{ needs.short-check.result }} ${{ needs.run-docker-smoke.result }} - uses: ./.github/actions/gate-verdict with: context: smoke-test changes-result: ${{ needs.changes.result }} applies: ${{ needs.changes.outputs.run_docker_smoke }} work-ok: ${{ needs.run-docker-smoke.outputs.ok == 'true' }} work-detail: short-check=${{ needs.short-check.result }} run-docker-smoke=${{ needs.run-docker-smoke.result }} event: ${{ github.event_name }} draft: ${{ github.event.pull_request.draft == true }} held: ${{ needs.changes.outputs.held }} run-api-wiring: needs: [changes, short-check] if: ${{ needs.changes.outputs.ready == 'true' && needs.changes.outputs.run_api_wiring == 'true' }} uses: ./.github/workflows/_gate-api-wiring.yml permissions: contents: read # Gate: publishes the REQUIRED `api-wiring` context. api-wiring: name: api-wiring needs: [changes, short-check, run-api-wiring] if: always() # actions: write lets the cancel step force-cancel this run when an upstream was cancelled (#17764). permissions: contents: read actions: write runs-on: ubuntu-latest timeout-minutes: 5 steps: - uses: actions/checkout@v7 with: sparse-checkout: .github/actions persist-credentials: false # A parked or superseded run has no verdict: end the gate cancelled, never failed or skipped (#17764). - uses: ./.github/actions/cancel-run-on-cancelled-upstream with: results: ${{ needs.changes.result }} ${{ needs.short-check.result }} ${{ needs.run-api-wiring.result }} - uses: ./.github/actions/gate-verdict with: context: api-wiring changes-result: ${{ needs.changes.result }} applies: ${{ needs.changes.outputs.run_api_wiring }} work-ok: ${{ needs.run-api-wiring.outputs.ok == 'true' }} work-detail: short-check=${{ needs.short-check.result }} run-api-wiring=${{ needs.run-api-wiring.result }} event: ${{ github.event_name }} draft: ${{ github.event.pull_request.draft == true }} held: ${{ needs.changes.outputs.held }} run-migration-gate: needs: [changes, short-check] if: ${{ needs.changes.outputs.ready == 'true' && needs.changes.outputs.run_migrations == 'true' }} uses: ./.github/workflows/_gate-migration.yml permissions: contents: read packages: read # Gate: publishes the REQUIRED `migration-matrix` context. migration-matrix: name: migration-matrix needs: [changes, short-check, run-migration-gate] if: always() # actions: write lets the cancel step force-cancel this run when an upstream was cancelled (#17764). permissions: contents: read actions: write runs-on: ubuntu-latest timeout-minutes: 5 steps: - uses: actions/checkout@v7 with: sparse-checkout: .github/actions persist-credentials: false # A parked or superseded run has no verdict: end the gate cancelled, never failed or skipped (#17764). - uses: ./.github/actions/cancel-run-on-cancelled-upstream with: results: ${{ needs.changes.result }} ${{ needs.short-check.result }} ${{ needs.run-migration-gate.result }} - uses: ./.github/actions/gate-verdict with: context: migration-matrix changes-result: ${{ needs.changes.result }} applies: ${{ needs.changes.outputs.run_migrations }} work-ok: ${{ needs.run-migration-gate.outputs.ok == 'true' }} work-detail: short-check=${{ needs.short-check.result }} run-migration-gate=${{ needs.run-migration-gate.result }} event: ${{ github.event_name }} draft: ${{ github.event.pull_request.draft == true }} held: ${{ needs.changes.outputs.held }} run-generated-types: needs: [changes, short-check] if: ${{ needs.changes.outputs.ready == 'true' && (needs.changes.outputs.run_types == 'true' || needs.changes.outputs.run_slm_types == 'true') }} uses: ./.github/workflows/_gate-generated-types.yml permissions: contents: read with: run_types: ${{ needs.changes.outputs.run_types }} run_slm_types: ${{ needs.changes.outputs.run_slm_types }} # #20552: regenerate only after verify failed; a green or skipped verify has nothing to fix. run-auto-fix-types: needs: [changes, run-generated-types] if: ${{ !cancelled() && github.event_name == 'pull_request' && needs.run-generated-types.result == 'failure' }} uses: ./.github/workflows/auto-fix-generated-types.yml secrets: AUTOBOT_PUSH_TOKEN: ${{ secrets.AUTOBOT_PUSH_TOKEN }} permissions: contents: read actions: write statuses: write pull-requests: read # Gate: publishes the REQUIRED `verify-generated-types` context. It applies when either the main or the # SLM freshness job applies, and fails if either one that applies did not pass (the SLM job used to run # with no gating effect). verify-generated-types: name: verify-generated-types needs: [changes, short-check, run-generated-types] if: always() # actions: write lets the cancel step force-cancel this run when an upstream was cancelled (#17764). permissions: contents: read actions: write runs-on: ubuntu-latest timeout-minutes: 5 steps: - uses: actions/checkout@v7 with: sparse-checkout: .github/actions persist-credentials: false # A parked or superseded run has no verdict: end the gate cancelled, never failed or skipped (#17764). - uses: ./.github/actions/cancel-run-on-cancelled-upstream with: results: ${{ needs.changes.result }} ${{ needs.short-check.result }} ${{ needs.run-generated-types.result }} - uses: ./.github/actions/gate-verdict with: context: verify-generated-types changes-result: ${{ needs.changes.result }} applies: ${{ needs.changes.outputs.run_types == 'true' || needs.changes.outputs.run_slm_types == 'true' }} work-ok: ${{ (needs.changes.outputs.run_types != 'true' || needs.run-generated-types.outputs.ok == 'true') && (needs.changes.outputs.run_slm_types != 'true' || needs.run-generated-types.outputs.slm_ok == 'true') }} work-detail: short-check=${{ needs.short-check.result }} run-generated-types=${{ needs.run-generated-types.result }} event: ${{ github.event_name }} draft: ${{ github.event.pull_request.draft == true }} held: ${{ needs.changes.outputs.held }} # Never filtered and never draft-gated: it carries the SPDX and symlink checks, which must cover EVERY pull # request including docs-only drafts (#17957). Only the repo-wide sweep inside is scoped, by `sweep`. run-precommit: needs: changes uses: ./.github/workflows/_gate-precommit.yml permissions: contents: read with: sweep: ${{ needs.changes.outputs.run_precommit_sweep }} # Gate: publishes the REQUIRED `verify-precommit-config` context. It always applies: nothing about a diff # makes the config check not affected, so `applies` is the literal 'true' and drafts run it too. verify-precommit-config: name: verify-precommit-config needs: [changes, run-precommit] if: always() # actions: write lets the cancel step force-cancel this run when an upstream was cancelled (#17764). permissions: contents: read actions: write runs-on: ubuntu-latest timeout-minutes: 5 steps: - uses: actions/checkout@v7 with: sparse-checkout: .github/actions persist-credentials: false # A parked or superseded run has no verdict: end the gate cancelled, never failed or skipped (#17764). - uses: ./.github/actions/cancel-run-on-cancelled-upstream with: results: ${{ needs.changes.result }} ${{ needs.run-precommit.result }} - uses: ./.github/actions/gate-verdict with: context: verify-precommit-config changes-result: ${{ needs.changes.result }} applies: 'true' work-ok: ${{ needs.run-precommit.outputs.ok == 'true' }} work-detail: run-precommit=${{ needs.run-precommit.result }} event: ${{ github.event_name }} draft: ${{ github.event.pull_request.draft == true }} draft-gated: 'false' # ---- checks that are not required contexts: same bodies, same conditions as before ---- run-security: needs: [changes, short-check] if: ${{ needs.changes.outputs.held != 'true' && needs.changes.outputs.run_security == 'true' }} uses: ./.github/workflows/_gate-security.yml permissions: contents: read security-events: write with: deps: ${{ needs.changes.outputs.run_deps_scan }} static_analysis: ${{ needs.changes.outputs.run_static_analysis }} run-codeql: needs: [changes, short-check] if: ${{ needs.changes.outputs.held != 'true' && needs.changes.outputs.codeql_languages != '[]' }} uses: ./.github/workflows/_gate-codeql.yml permissions: contents: read security-events: write with: languages: ${{ needs.changes.outputs.codeql_languages }} run-ai-security-review: needs: [changes, short-check] if: ${{ needs.changes.outputs.held != 'true' && needs.changes.outputs.run_ai_review == 'true' }} uses: ./.github/workflows/_gate-ai-security-review.yml secrets: CLAUDE_CODE_OAUTH_TOKEN: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }} permissions: contents: read pull-requests: write run-npm-package-tests: needs: [changes, short-check] if: ${{ needs.changes.outputs.held != 'true' && needs.changes.outputs.run_npm == 'true' }} uses: ./.github/workflows/_gate-npm-package-tests.yml permissions: contents: read with: browser_worker: ${{ needs.changes.outputs.npm_browser_worker }} mcp: ${{ needs.changes.outputs.npm_mcp }} sdk_ts: ${{ needs.changes.outputs.npm_sdk_ts }} structured_thinking: ${{ needs.changes.outputs.npm_structured_thinking }} run-slm-frontend: needs: [changes, short-check] if: ${{ needs.changes.outputs.held != 'true' && needs.changes.outputs.run_slm_frontend == 'true' }} uses: ./.github/workflows/_gate-slm-frontend.yml permissions: contents: read with: slm_frontend: ${{ needs.changes.outputs.run_slm_frontend }} deployment-check: runs-on: ubuntu-latest needs: [changes, short-check, python-suite, frontend-tests] if: | (github.ref == 'refs/heads/release' || github.ref == 'refs/heads/main') && (needs.python-suite.result == 'success' || needs.python-suite.result == 'skipped') && (needs.frontend-tests.result == 'success' || needs.frontend-tests.result == 'skipped') steps: - uses: actions/checkout@v7 # #13162: the step was named "Set up Python 3.12" while pinning 3.14. The # name carries no version at all rather than a second copy to drift. # #13842: `python-version-file` reads the SSOT instead of restating it. - name: Set up Python uses: actions/setup-python@v7 with: python-version-file: '.python-version' cache: 'pip' cache-dependency-path: | requirements*.txt autobot-backend/requirements*.txt - name: Install CI requirements uses: ./.github/actions/install-ci-requirements - name: Create necessary directories and config files run: | mkdir -p data logs static config touch data/.gitkeep logs/.gitkeep static/.gitkeep # Create minimal config.yaml for CI testing cp .github/actions/setup-python-suite/ci-config.yaml config/config.yaml - name: Test production configuration run: | echo "🚀 Testing production readiness..." # Check that all required files exist echo "Checking required files..." test -f main.py || (echo "❌ main.py missing" && exit 1) test -f requirements.txt || (echo "❌ requirements.txt missing" && exit 1) echo "✅ All required files present" # Test configuration loading (PYTHONPATH includes backend for imports) PYTHONPATH="autobot-backend:autobot_shared:$PYTHONPATH" \ python3 -c 'from config import config; print("Configuration system working")' # Test core imports. # #14252: this named `security.secure_command_executor`, which has never # existed -- the module is at autobot-backend/secure_command_executor.py, # top level, not inside the `security` package. The step therefore raised # ModuleNotFoundError on every run since #798, so this job was red # continuously and could not report a real import break. It is not a # required context, which is why nothing blocked on it. PYTHONPATH="autobot-backend:autobot_shared:$PYTHONPATH" \ python3 -c 'from security_layer import SecurityLayer; from secure_command_executor import SecureCommandExecutor; from app_factory import create_app; print("Core imports working")' - name: Generate deployment artifact run: | echo "📦 Generating deployment summary..." { echo "# AutoBot Deployment Summary" echo "Generated at: $(date -u '+%Y-%m-%d %H:%M:%S UTC')" echo "Commit: $GITHUB_SHA" echo "Branch: $GITHUB_REF_NAME" echo "" echo "## Test Results" echo "- ✅ Security tests passed" echo "- ✅ Integration tests passed" echo "- ✅ Frontend build successful" echo "" echo "## Security Features" echo "- Command execution sandboxing ✅" echo "- Risk assessment system ✅" echo "- Audit logging ✅" echo "- Role-based access control ✅" echo "- API security endpoints ✅" } > DEPLOYMENT_SUMMARY.md cat DEPLOYMENT_SUMMARY.md - name: Upload deployment artifact uses: actions/upload-artifact@v7.0.2 with: name: deployment-summary path: DEPLOYMENT_SUMMARY.md - name: Cleanup if: always() run: | rm -rf .venv || true notify: runs-on: ubuntu-latest needs: [changes, python-suite, frontend-tests, deployment-check] if: always() steps: - name: Notify results run: | echo "🎯 CI/CD Pipeline Results:" echo "==========================" if [ "${{ needs.python-suite.result }}" == "success" ]; then echo "✅ Security tests: PASSED" else echo "❌ Security tests: FAILED" fi if [ "${{ needs.frontend-tests.result }}" == "success" ]; then echo "✅ Frontend tests: PASSED" else echo "❌ Frontend tests: FAILED" fi if [ "${{ needs.deployment-check.result }}" == "success" ]; then echo "✅ Deployment check: PASSED" else echo "❌ Deployment check: FAILED" fi echo "" if [ "${{ needs.python-suite.result }}" == "success" ] && [ "${{ needs.frontend-tests.result }}" == "success" ] && [ "${{ needs.deployment-check.result }}" == "success" ]; then echo "🎉 All checks passed! AutoBot is ready for deployment." else echo "⚠️ Some checks failed. Review the logs above." fi