* ci: gate the integration CI long tail by diff scope `integration.yml` starts its long tail on every pull request: the three fuzz families, the chaos legs, the export/import E2E job and the two sqlness KvBackend legs. Most diffs cannot affect them, so a `scope` job now classifies the pull request and tells those jobs whether to start. The classifier is deterministic and fail-open. Forced modes (merge queue, `schedule`, `workflow_dispatch`, `ci:full`, `CI_SCOPE_FORCE_ALL`) and three floors -- always-run paths, an uncovered `src/` change, and a PromQL/flow filter -- can only widen the result; everything else is a glob match against the suite catalog. Every step of the job is `continue-on-error` and every gate reads `needs.scope.outputs.<key> != 'false'`, so a classifier crash runs the jobs instead of skipping them. The rules are checked out from the pull request base, so a pull request cannot relax its own gate. The policy is data: `.github/ci/scope-rules.toml` holds the path groups, the suite catalog and the always-run list, with a `reason` on every exclusion. `ci_scope_rules.py` loads it with the stdlib `tomllib` and validates the shape (unknown or cyclic `@group` references, a `family` that disagrees with the suite id, an empty reason) and that every glob's literal prefix still exists, so a renamed crate cannot leave a rule that matches nothing. `make check-ci-scope` runs that check locally; the `CI Scope Rules` job runs it on `ubuntu-slim`, the same image the classifier uses. `.github/ci/scope-cases.toml` holds golden cases that `test_ci_scope.py` replays through the real classifier. The PostgreSQL and MySQL sqlness legs move into their own `sqlness-kvbackend` job so they can be gated: a job-level `if:` cannot read the matrix, and gating them inside `sqlness` would skip required checks and block the merge. They run the same cases as the required Basic leg, so only the backend itself matters. The verdict is visible where triage looks: one log line per suite, the exact gate values, `::warning::` when a lookup fails and the gate widens, and a job summary that lists each suite with the rule that decided it and the changed files that matched. Measured on 200 merged and open pull requests: 27.5% always run, 41% decided by path rules, 31.5% skip every gated job; 995 of 2600 suite selections are skipped, with no selection that a path rule makes. The classifier itself runs in about ten seconds on a single-vCPU runner. Signed-off-by: WenyXu <wenymedia@gmail.com> * fix(ci): let the scope job read pull requests The `scope` job declared `permissions: contents: read`, and an explicit block sets every unlisted permission to `none`. `GET /pulls/{n}` therefore answered 403, `build_plan` widened to a full run as designed, and every gate read an absent output as "run": the gate could never skip anything. - `pull-requests: read` on the `scope` job. - `tests/runner/**` joins `@kv-backend`: the runner implements `--setup-pg`/`--setup-mysql`, which only the KV-backend legs pass, so a change there must not skip the only job that exercises it. The `UNMAPPED_CRATES` excuse is gone with it. - The README no longer claims a queue failure blocks the merge: the gated jobs are not required checks. Signed-off-by: WenyXu <wenymedia@gmail.com> * fix(ci): run every suite when the kind registry script changes The distributed and chaos fuzz jobs start their cluster through `.github/actions/setup-kind`, which runs `.github/scripts/kind-with-registry.sh`. `.github/actions/**` is in `ALWAYS_RUN` but the script is not, so a change confined to it selected no suite at all and every gate stayed `false`: the jobs that exercise the changed cluster setup were skipped. The script joins `ALWAYS_RUN`, consistent with the action that calls it, and a golden case pins it. Signed-off-by: WenyXu <wenymedia@gmail.com> * fix(ci): widen the gate for the fuzz corpus seeding script `fuzz-test/action.yaml` runs `.github/scripts/prepare-fuzz-corpus.sh` before the cache restore in every fuzz job, but the script was not in `ALWAYS_RUN`. A change confined to it therefore selected no suite: `any_fuzz` stayed `false` and every fuzz job that runs it was skipped. The script joins `ALWAYS_RUN` next to the other scripts the fuzz jobs execute, with a golden case for it. Both misses so far (this one and `kind-with-registry.sh`) came through a composite action, which the workflow never names. `WorkflowContractTests` now resolves `uses: ./.github/actions/<name>` transitively for the gated jobs and fails when one of the scripts they run is not in `ALWAYS_RUN`. Signed-off-by: WenyXu <wenymedia@gmail.com> --------- Signed-off-by: WenyXu <wenymedia@gmail.com>
Integration CI admission gate
integration.yml runs its expensive jobs — fuzz, export/import E2E, the sqlness
KvBackend legs — on every non-draft pull request. Most pull requests cannot
affect any of them. This directory decides which of those jobs start, using only
the diff.
The gate can only skip work, never add it, and it fails open: when the verdict is missing or uncertain, every gated job runs.
| File | Role |
|---|---|
ci_scope.py |
the classifier: reads the diff, writes $GITHUB_OUTPUT |
scope-rules.toml |
the policy: which paths select which suite, as data |
ci_scope_rules.py |
loads and validates the policy; --check-paths |
tests/ |
unit tests, and fixtures/scope-cases.toml golden cases |
Two words appear everywhere below. A suite is one matrix leg of a gated job,
named <gate>/<leg>. A gate is one $GITHUB_OUTPUT key that switches a
whole job.
What is gated
Only integration.yml, and only these jobs:
| Gated job | Runs |
|---|---|
prepare-fuzz-targets |
the fuzz targets only |
fuzztest |
standalone fuzz, 2 legs |
unstable-fuzztest |
unstable standalone create-table fuzz, 1 leg |
distributed-fuzztest |
distributed fuzz with remote WAL, 4 legs |
distributed-fuzztest-with-chaos |
Chaos Mesh, 3 legs |
build-greptime-ci |
the profile-CI binary only |
export-import-v2-e2e |
CLI COPY DATABASE export/import against S3 |
sqlness-kvbackend |
sqlness with PostgreSQL and MySQL as the metadata store |
The legs themselves are the matrix entries in integration.yml; the rules
file repeats their ids so a verdict can name them.
Everything else always runs: rust.yml, checks.yml, docs.yml, the debug
build, the required sqlness job (Basic, Remote WAL, Flat format), compat
and compat-updater-check. None of the gated jobs is in the required-check
matrix in docs.yml, so a skipped job can never block a merge.
Two choices follow from that rule. The two KvBackend legs sit in their own
sqlness-kvbackend job because a job-level if: cannot read matrix, so
gating them inside sqlness would skip required checks and make the pull
request unmergeable. The multi-language SDK job stays ungated: it takes about
three minutes, less than the cost of getting its verdict wrong.
How a verdict is made
First match wins:
- Forced —
merge_group,schedule,workflow_dispatch, theci:fulllabel orCI_SCOPE_FORCE_ALL. Everything runs. - Too large to judge — more than 300 changed files. Everything runs.
- Always-run file changed —
Cargo.toml,Cargo.lock,tests-fuzz/**, this directory, or anything else that changes what the suites build or how they start. Everything runs. - Uncovered change — a path under
src/that no suite claims. This is the net for a crate added, split or renamed after the rules were written. Everything runs. - Path rules — the suites whose globs match the changed files, and only those.
The code is the source of truth for the details; its module docstring is worth reading before changing it.
Why a check was skipped
The run page's summary pane answers this without opening a log: one row per suite, with its verdict, the rule that decided it, and up to three of the changed files that matched.
The step log of the CI Scope job has the same information in text form. It
starts with CI scope: mode=… full=… (grep '^CI scope' finds it), then one
line per suite — run or skip, source, reason — then gates: with the exact
values the jobs read.
A degraded decision is never silent. A failed label or file lookup emits
::warning:: and widens the gate to every suite.
Forcing a full run
Add the ci:full label to the pull request and click "Re-run all jobs". The
label is read through the API at run time, not from the event payload, so one
added after the first run still counts. /ci dispatch
(.github/scripts/ci-slash.py), the CI_SCOPE_FORCE_ALL repository variable
and every merge-queue run also run everything: the classifier returns a forced
plan there, so a wrong skip is still exercised before the change lands. None of
the gated jobs is a required check, so a failure in the queue does not block the
merge by itself.
CI_SCOPE_FORCE_ALL is the switch to flip while debugging the rules themselves.
Changing the rules
scope-rules.toml is data, not code: ci_scope_rules.py loads it with the
standard library's tomllib. Two things are validated:
- the shape — an unknown or cyclic
@groupreference, agatethat disagrees with the suite id, a gate missing from[gates], or an exemption without areasonall raise; - that every glob still points at something that exists, so a renamed or deleted crate fails the check instead of silently matching nothing.
Run both with make check-ci-scope, or the path half alone with
python3 .github/ci/ci_scope_rules.py --check-paths. The same command runs in
the CI Scope Rules job of checks.yml, on ubuntu-slim — the image the
classifier itself uses, so a path that exists there also exists when the verdict
is computed.
A malformed file fails the classify step, and because every step of that job is
continue-on-error, every gated job runs instead.
[[matching.exempt]] lists paths outside the gate's remit: they select no suite
and never widen the gate. Each one carries a reason, and the loader rejects an
empty one — what CI never runs is the part a reader must be able to justify.
tests/fixtures/scope-cases.toml is test data, not configuration: a diff shape
and the suites it must start. ScopeCaseTests replays each case through the
classifier, so a rule edit that changes behaviour fails with the case name
instead of silently rerouting CI. The cases carry no pull request numbers;
git log has those.
Adding a suite
- Add a
[suites."<gate>/<leg>"]table toscope-rules.tomlwithgate,paths(globs or@groupreferences) and a one-linedescription. The id is<gate>/<matrix leg id>, andgateis that id with-replaced by_; the loader andtest_suite_metadataboth enforce it. - Add the matching matrix leg to the job in
integration.yml. - Gate the job's
if:with the matching output, and listscopein itsneeds. A new gate also needs a key inderive_outputsand in thescopejob'soutputs;test_every_gate_routes_to_an_outputfails when that routing is missing. - Add a case to
tests/fixtures/scope-cases.tomland runpython3 .github/ci/tests/test_ci_scope.py.CrateCoverageTestsseparately fails when a workspace crate matches no suite and is not excused inUNMAPPED_CRATES: the runtime net would run everything, but the rule table is what should be updated.
Ground rules for the workflow
These six rules keep the gate failing open. Break one and either CI runs jobs it should have skipped, or a classifier failure takes CI down with it.
- Read the output as
!= 'false'. An absent output means "run"; writing== 'true'inverts the failure direction. - Start every gate with
!cancelled(). Without a status function the condition carries an implicitsuccess()overneeds, so ascopejob that times out would skip the gates. Other dependencies are therefore required explicitly withneeds.<job>.result == 'success'. - Every fallible step of
scopeiscontinue-on-error: true. GitHub skips the dependents of a failed job, so a classifier crash must leave the job green with no outputs rather than take CI down with it. - Rules come from the base revision. The
scopejob checks outpull_request.base.sha(ormerge_group.base_sha), so a pull request cannot weaken its own gate. On the first pull request that introduces this directory the base has noci_scope.py: the step fails, no outputs are written, and every gate runs. - One gate per job, never per leg. GitHub does not expose
matrixtojobs.<job_id>.if. Per-suite verdicts stay visible in the log. - Pass the run's
head/baseSHAs and let the classifier compare them with the pull request's live revisions. A re-run keeps the original SHAs while GitHub serves the current file list; without the comparison the new diff would be judged against the old tree. With it, a mismatch runs everything.