mirror of
https://github.com/GreptimeTeam/greptimedb.git
synced 2026-11-29 14:14:13 +00:00
chore(ci): merge main and preserve helper tooling tests
Signed-off-by: WenyXu <wenymedia@gmail.com>
This commit is contained in:
@@ -0,0 +1,53 @@
|
||||
name: GitHub Script Tests
|
||||
description: Validate CI scripts before starting expensive jobs
|
||||
runs:
|
||||
using: composite
|
||||
steps:
|
||||
- uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: 24
|
||||
- name: Run Node GitHub script tests
|
||||
shell: bash
|
||||
run: node --test .github/scripts/query-regression-comment.test.cjs .github/scripts/heavy-ci-policy.test.cjs .github/scripts/tests/nightly-merge.test.cjs
|
||||
- name: Setup uv
|
||||
uses: astral-sh/setup-uv@v3
|
||||
with:
|
||||
version: "latest"
|
||||
- name: Run check-version script tests
|
||||
shell: bash
|
||||
run: uv run --no-project python .github/scripts/check-version-test.py
|
||||
- name: Run release Linux architecture tests
|
||||
shell: bash
|
||||
run: python3 .github/scripts/release-linux-architectures-test.py
|
||||
- name: Run previous-release-tag script tests
|
||||
shell: bash
|
||||
run: python3 .github/scripts/previous-release-tag-test.py
|
||||
- name: Run enterprise license check tests
|
||||
shell: bash
|
||||
run: python3 scripts/check-enterprise-license-test.py
|
||||
- name: Run fuzz orchestration script tests
|
||||
shell: bash
|
||||
run: .github/scripts/run-fuzz-targets-test.sh
|
||||
- name: Run CI comment-command tests
|
||||
shell: bash
|
||||
run: python3 .github/scripts/tests/test_ci_slash.py
|
||||
- name: Run CI scope gate tests
|
||||
shell: bash
|
||||
run: python3 .github/ci/tests/test_ci_scope.py
|
||||
- name: Run metric snapshot benchmark tests
|
||||
shell: bash
|
||||
run: python3 -m unittest discover -s .github/scripts/tests -p 'test_metric_snapshot*.py'
|
||||
- name: Run query-regression Python tooling tests
|
||||
shell: bash
|
||||
run: |
|
||||
python3 tests/perf/test_query_regression_runner_compaction_toctou.py
|
||||
python3 tests/perf/test_query_regression_runner_otlp_trace_load.py
|
||||
python3 tests/perf/test_query_regression_summary_otlp.py
|
||||
python3 tests/perf/test_query_regression_case_selection.py
|
||||
python3 tests/perf/test_query_regression_helpers.py
|
||||
python3 tests/perf/test_query_regression_nightly_refs.py
|
||||
python3 tests/perf/test_query_regression_slash.py
|
||||
python3 tests/perf/test_aliyun_ecs_runner_scripts.py
|
||||
python3 tests/perf/test_ci_runner_scripts.py
|
||||
python3 tests/perf/test_agent_observability_summary.py
|
||||
python3 tests/perf/test_tracesbench_summary.py
|
||||
@@ -0,0 +1,170 @@
|
||||
# Integration CI admission gate
|
||||
|
||||
`integration.yml` filters its expensive jobs — fuzz, export/import E2E, and the
|
||||
sqlness KvBackend legs — by the diff. Fuzz additionally follows the event policy
|
||||
in [Heavy CI scheduling](../heavy-ci.md): PR opening or ready-for-review events,
|
||||
scheduled runs, and explicit manual profiles. A scope verdict cannot override
|
||||
that event policy.
|
||||
|
||||
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:
|
||||
|
||||
1. **Forced** — `merge_group`, `schedule`, `workflow_dispatch`, the `ci:full`
|
||||
label or `CI_SCOPE_FORCE_ALL`. All scope outputs allow execution; job event
|
||||
conditions and manual profile selection still apply.
|
||||
2. **Too large to judge** — more than 300 changed files. Everything runs.
|
||||
3. **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.
|
||||
4. **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.
|
||||
5. **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 `@group` reference, a `gate` that disagrees
|
||||
with the suite id, a gate missing from `[gates]`, or an exemption without a
|
||||
`reason` all 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
|
||||
|
||||
1. Add a `[suites."<gate>/<leg>"]` table to `scope-rules.toml` with `gate`,
|
||||
`paths` (globs or `@group` references) and a one-line `description`. The id
|
||||
is `<gate>/<matrix leg id>`, and `gate` is that id with `-` replaced by `_`;
|
||||
the loader and `test_suite_metadata` both enforce it.
|
||||
2. Add the matching matrix leg to the job in `integration.yml`.
|
||||
3. Gate the job's `if:` with the matching output, and list `scope` in its
|
||||
`needs`. A new gate also needs a key in `derive_outputs` and in the `scope`
|
||||
job's `outputs`; `test_every_gate_routes_to_an_output` fails when that
|
||||
routing is missing.
|
||||
4. Add a case to `tests/fixtures/scope-cases.toml` and run
|
||||
`python3 .github/ci/tests/test_ci_scope.py`. `CrateCoverageTests` separately
|
||||
fails when a workspace crate matches no suite and is not excused in
|
||||
`UNMAPPED_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 implicit `success()` over `needs`, so a `scope` job that
|
||||
times out would skip the gates. Other dependencies are therefore required
|
||||
explicitly with `needs.<job>.result == 'success'`.
|
||||
- **Every fallible step of `scope` is `continue-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 `scope` job checks out
|
||||
`pull_request.base.sha` (or `merge_group.base_sha`), so a pull request cannot
|
||||
weaken its own gate. On the first pull request that introduces this directory
|
||||
the base has no `ci_scope.py`: the step fails, no outputs are written, and
|
||||
every gate runs.
|
||||
- **One gate per job, never per leg.** GitHub does not expose `matrix` to
|
||||
`jobs.<job_id>.if`. Per-suite verdicts stay visible in the log.
|
||||
- **Pass the run's `head`/`base` SHAs 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.
|
||||
Executable
+623
@@ -0,0 +1,623 @@
|
||||
#!/usr/bin/env python3
|
||||
# Copyright 2023 Greptime Team
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
"""Decide which integration CI suites must run for one pull request.
|
||||
|
||||
Pipeline, in priority order:
|
||||
|
||||
1. forced mode -- `merge_group`, `schedule`, `workflow_dispatch`,
|
||||
`CI_SCOPE_FORCE_ALL`, or the `ci:full` label. Every suite runs.
|
||||
2. always-run floor -- a changed file matches `ALWAYS_RUN`. Every suite runs.
|
||||
3. uncovered build change -- a path under `SRC_TREE` that no suite claims, so a
|
||||
crate added or renamed later still runs everything.
|
||||
4. static path matches -- glob match of the changed files against the suite
|
||||
catalog in `scope-rules.toml`. Paths under `EXEMPT_TREES` are outside the
|
||||
gate's remit and are dropped first: `@server` claims `src/query/**`, which
|
||||
would otherwise put a PromQL-only change through the whole fleet.
|
||||
|
||||
The verdict is deterministic: the same diff always produces the same plan, and
|
||||
a change that no rule explains falls through to "run everything".
|
||||
|
||||
The plan maps to `$GITHUB_OUTPUT` keys that the `integration.yml` gate jobs
|
||||
consume; `--dry-run` prints them as JSON.
|
||||
"""
|
||||
|
||||
import argparse
|
||||
import json
|
||||
import os
|
||||
import re
|
||||
import sys
|
||||
import urllib.error
|
||||
import urllib.request
|
||||
|
||||
from ci_scope_rules import (
|
||||
ALWAYS_RUN,
|
||||
EXEMPT_TREES,
|
||||
SRC_TREE,
|
||||
SUITES,
|
||||
suite_group,
|
||||
suite_paths,
|
||||
)
|
||||
|
||||
MAX_FILES = 300
|
||||
HTTP_TIMEOUT = 45
|
||||
FORCED_EVENTS = {"merge_group", "schedule", "workflow_dispatch"}
|
||||
# A diff with no code, config or workflow file never needs a suite.
|
||||
CODE_FILE = re.compile(
|
||||
r"\.(rs|toml|lock|sh|ya?ml)$|(^|/)Makefile$|(^|/)Cargo\.toml$|\.sql$"
|
||||
)
|
||||
FUZZ_GATES = ("fuzz_standalone", "fuzz_distributed", "fuzz_chaos")
|
||||
|
||||
|
||||
class ScopeError(Exception):
|
||||
"""A handled failure: the caller falls back instead of crashing."""
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# HTTP seam (tests replace `_request`)
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
|
||||
def _request(method, url, headers, body=None, timeout=HTTP_TIMEOUT):
|
||||
request = urllib.request.Request(url, data=body, headers=headers, method=method)
|
||||
try:
|
||||
with urllib.request.urlopen(request, timeout=timeout) as response:
|
||||
return response.status, response.read()
|
||||
except urllib.error.HTTPError as err:
|
||||
return err.code, err.read()
|
||||
except (urllib.error.URLError, TimeoutError, OSError) as err:
|
||||
raise ScopeError(f"{method} {url}: {err}") from err
|
||||
|
||||
|
||||
def _get(url, headers, timeout=HTTP_TIMEOUT):
|
||||
return _request("GET", url, headers, None, timeout)
|
||||
|
||||
|
||||
def _post(url, headers, body, timeout=HTTP_TIMEOUT):
|
||||
return _request("POST", url, headers, body, timeout)
|
||||
|
||||
|
||||
def get_json(url, headers, timeout=HTTP_TIMEOUT):
|
||||
"""GET returning (status, parsed json); transport failures raise `ScopeError`."""
|
||||
status, raw = _get(url, headers, timeout)
|
||||
try:
|
||||
payload = json.loads(raw.decode("utf-8", "replace")) if raw else None
|
||||
except json.JSONDecodeError:
|
||||
payload = None
|
||||
return status, payload
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# Path matching
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
|
||||
def glob_to_regex(pattern):
|
||||
"""Translate a repo glob into an anchored regexp.
|
||||
|
||||
`**/` also matches zero directories, `**` spans `/`, `*` and `?` do not.
|
||||
"""
|
||||
out = ["^"]
|
||||
index = 0
|
||||
while index < len(pattern):
|
||||
char = pattern[index]
|
||||
if char == "*":
|
||||
end = index
|
||||
while end < len(pattern) and pattern[end] == "*":
|
||||
end += 1
|
||||
if end - index >= 2:
|
||||
if end < len(pattern) and pattern[end] == "/":
|
||||
out.append("(?:.*/)?")
|
||||
index = end + 1
|
||||
continue
|
||||
out.append(".*")
|
||||
else:
|
||||
out.append("[^/]*")
|
||||
index = end
|
||||
elif char == "?":
|
||||
out.append("[^/]")
|
||||
index += 1
|
||||
else:
|
||||
out.append(re.escape(char))
|
||||
index += 1
|
||||
out.append("$")
|
||||
return re.compile("".join(out))
|
||||
|
||||
|
||||
def compile_patterns(patterns):
|
||||
return [glob_to_regex(pattern) for pattern in patterns]
|
||||
|
||||
|
||||
def matches_any(filename, compiled):
|
||||
return any(regex.match(filename) for regex in compiled)
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# GitHub API
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
|
||||
def github_api(method, path, token, payload=None):
|
||||
base = os.environ.get("GITHUB_API_URL", "https://api.github.com").rstrip("/")
|
||||
url = base + path
|
||||
headers = {
|
||||
"Accept": "application/vnd.github+json",
|
||||
"User-Agent": "greptimedb-ci-scope",
|
||||
}
|
||||
if token:
|
||||
headers["Authorization"] = "Bearer " + token
|
||||
body = None
|
||||
if payload is not None:
|
||||
body = json.dumps(payload).encode()
|
||||
headers["Content-Type"] = "application/json"
|
||||
if method == "GET":
|
||||
return get_json(url, headers)
|
||||
status, raw = _request(method, url, headers, body, HTTP_TIMEOUT)
|
||||
try:
|
||||
parsed = json.loads(raw.decode("utf-8", "replace")) if raw else None
|
||||
except json.JSONDecodeError:
|
||||
parsed = None
|
||||
return status, parsed
|
||||
|
||||
|
||||
def fetch_changed_files(repo, number, token):
|
||||
"""Return (files, truncated). `truncated` means the PR has more than MAX_FILES."""
|
||||
files = []
|
||||
page = 1
|
||||
while True:
|
||||
status, payload = github_api(
|
||||
"GET", f"/repos/{repo}/pulls/{number}/files?per_page=100&page={page}", token
|
||||
)
|
||||
if status != 200 or not isinstance(payload, list):
|
||||
raise ScopeError(f"cannot list pull request files (HTTP {status})")
|
||||
for item in payload:
|
||||
if not isinstance(item, dict):
|
||||
continue
|
||||
patch = item.get("patch")
|
||||
files.append(
|
||||
{
|
||||
"filename": item.get("filename", ""),
|
||||
"previous_filename": item.get("previous_filename") or "",
|
||||
"status": item.get("status", "modified"),
|
||||
"additions": item.get("additions", 0),
|
||||
"deletions": item.get("deletions", 0),
|
||||
"patch": patch if isinstance(patch, str) else "",
|
||||
"patch_included": isinstance(patch, str) and bool(patch),
|
||||
}
|
||||
)
|
||||
if len(payload) < 100:
|
||||
return files, False
|
||||
if len(files) >= MAX_FILES:
|
||||
# Keep `per_page=100`: with `per_page=1`, page N is item N, so the
|
||||
# probe would answer "is there a file 4?" instead of "file 301?".
|
||||
status, extra = github_api(
|
||||
"GET",
|
||||
f"/repos/{repo}/pulls/{number}/files?per_page=100&page={page + 1}",
|
||||
token,
|
||||
)
|
||||
if status != 200 or not isinstance(extra, list):
|
||||
raise ScopeError(
|
||||
"cannot confirm the changed file list is complete "
|
||||
f"(HTTP {status})"
|
||||
)
|
||||
del files[MAX_FILES:]
|
||||
return files, bool(extra)
|
||||
page += 1
|
||||
|
||||
|
||||
def fetch_pull(repo, number, token):
|
||||
"""Return (labels, head sha, base sha) for one pull request."""
|
||||
status, payload = github_api("GET", f"/repos/{repo}/pulls/{number}", token)
|
||||
if status != 200 or not isinstance(payload, dict):
|
||||
raise ScopeError(f"cannot read pull request (HTTP {status})")
|
||||
labels = payload.get("labels") or []
|
||||
head = ((payload.get("head") or {}).get("sha") or "").strip()
|
||||
base = ((payload.get("base") or {}).get("sha") or "").strip()
|
||||
names = {label.get("name", "") for label in labels if isinstance(label, dict)}
|
||||
return names, head, base
|
||||
|
||||
|
||||
def revision_drift(args, head, base):
|
||||
"""Return a note when the tested revisions are no longer the live ones.
|
||||
|
||||
A re-run keeps the run's original SHAs while the file list served by GitHub
|
||||
is the pull request's current one. After a force-push the classifier would
|
||||
judge the new diff for the old tree, so a mismatch runs every suite instead.
|
||||
"""
|
||||
for supplied, live, name in (
|
||||
(args.head_sha, head, "head"),
|
||||
(args.base_sha, base, "base"),
|
||||
):
|
||||
if supplied and live and supplied.lower() != live.lower():
|
||||
return (
|
||||
f"pull request {name} moved from {supplied[:12]} to "
|
||||
f"{live[:12]} after this run started"
|
||||
)
|
||||
return ""
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# Decisions
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
|
||||
def file_paths(item):
|
||||
"""Every path the change touched; a rename keeps the deleted side too."""
|
||||
names = [item["filename"]]
|
||||
previous = item.get("previous_filename")
|
||||
if previous and previous != item["filename"]:
|
||||
names.append(previous)
|
||||
return names
|
||||
|
||||
|
||||
def gated_paths(item):
|
||||
"""The paths of one changed file that the gate judges.
|
||||
|
||||
A path under `EXEMPT_TREES` is outside the remit: it selects no suite, and
|
||||
it is not a change that "no rule covers", so it cannot widen the gate.
|
||||
"""
|
||||
return [name for name in file_paths(item) if not name.startswith(EXEMPT_TREES)]
|
||||
|
||||
|
||||
def path_matches(files):
|
||||
"""Return (always_run_hits, {suite_id: [matching file paths]})."""
|
||||
always_compiled = compile_patterns(ALWAYS_RUN)
|
||||
suite_matchers = {
|
||||
suite_id: compile_patterns(suite_paths(suite))
|
||||
for suite_id, suite in SUITES.items()
|
||||
}
|
||||
always_hits = set()
|
||||
matches = {suite_id: set() for suite_id in SUITES}
|
||||
for item in files:
|
||||
for name in file_paths(item):
|
||||
if matches_any(name, always_compiled):
|
||||
always_hits.add(name)
|
||||
for name in gated_paths(item):
|
||||
for suite_id, compiled in suite_matchers.items():
|
||||
if matches_any(name, compiled):
|
||||
matches[suite_id].add(name)
|
||||
return sorted(always_hits), {
|
||||
suite_id: sorted(matched) for suite_id, matched in matches.items()
|
||||
}
|
||||
|
||||
|
||||
def uncovered_changes(files, matches):
|
||||
"""True when a change can reach code that no suite path claims.
|
||||
|
||||
This is the net for a crate that was added, split or renamed after the rules
|
||||
were written: without it such a change matches no suite and would skip every
|
||||
gated job. A single unmatched path is enough, even when other paths in the
|
||||
same diff match a suite.
|
||||
"""
|
||||
return first_uncovered(files, matches) is not None
|
||||
|
||||
|
||||
def first_uncovered(files, matches):
|
||||
"""The first changed path that no suite claims, or None.
|
||||
|
||||
Naming it is what makes the widening explainable in the log.
|
||||
"""
|
||||
matched = {name for names in matches.values() for name in names}
|
||||
return next(
|
||||
(
|
||||
name
|
||||
for item in files
|
||||
for name in gated_paths(item)
|
||||
if name.startswith(SRC_TREE) and name not in matched
|
||||
),
|
||||
None,
|
||||
)
|
||||
|
||||
|
||||
def has_meaningful_changes(files):
|
||||
return any(CODE_FILE.search(item["filename"]) for item in files)
|
||||
|
||||
|
||||
def finalize(plan):
|
||||
"""`full` means every gated suite runs, whatever produced the decision."""
|
||||
plan["full"] = all(entry["run"] for entry in plan["suites"].values())
|
||||
return plan
|
||||
|
||||
|
||||
def all_suites(run, reason, source):
|
||||
return {
|
||||
suite_id: {"run": run, "source": source, "reason": reason}
|
||||
for suite_id in SUITES
|
||||
}
|
||||
|
||||
|
||||
def full_plan(plan, reason, source, mode="static"):
|
||||
"""Every suite runs; `finalize` derives `full` from the verdicts."""
|
||||
plan.update(mode=mode, suites=all_suites(True, reason, source))
|
||||
return finalize(plan)
|
||||
|
||||
|
||||
def forced_reason(args, labels):
|
||||
"""Return why every suite must run, or an empty string."""
|
||||
event = args.event or os.environ.get("GITHUB_EVENT_NAME") or "pull_request"
|
||||
if event in FORCED_EVENTS:
|
||||
return f"event={event}"
|
||||
if os.environ.get("CI_SCOPE_FORCE_ALL", "").strip().lower() in {
|
||||
"1",
|
||||
"true",
|
||||
"yes",
|
||||
"on",
|
||||
}:
|
||||
return "CI_SCOPE_FORCE_ALL"
|
||||
if "ci:full" in labels:
|
||||
return "label ci:full"
|
||||
return ""
|
||||
|
||||
|
||||
def build_plan(args, token):
|
||||
notes = []
|
||||
plan = {
|
||||
"mode": "static",
|
||||
"head_sha": args.head_sha or "",
|
||||
"base_sha": args.base_sha or "",
|
||||
"full": False,
|
||||
"suites": {},
|
||||
"matching": {},
|
||||
"notes": notes,
|
||||
}
|
||||
|
||||
# Events and variables that force a run need no GitHub call at all; the
|
||||
# `ci:full` label is the only reason to read the pull request early.
|
||||
forced = forced_reason(args, set())
|
||||
labels, head_live, base_live = set(), "", ""
|
||||
if args.pr and not forced:
|
||||
try:
|
||||
labels, head_live, base_live = fetch_pull(
|
||||
args.repo, args.pr, token
|
||||
)
|
||||
except ScopeError as err:
|
||||
# A failed lookup must widen the gate, never narrow it.
|
||||
notes.append(f"pull request lookup failed: {err}")
|
||||
return full_plan(plan, "pull request lookup failed", "always-run")
|
||||
forced = forced_reason(args, labels)
|
||||
|
||||
if forced:
|
||||
notes.append(f"forced: {forced}")
|
||||
return full_plan(plan, f"forced by {forced}", "forced", mode="forced")
|
||||
|
||||
if not args.pr:
|
||||
raise ScopeError("--pr is required unless the event forces every suite")
|
||||
|
||||
drift = revision_drift(args, head_live, base_live)
|
||||
if drift:
|
||||
notes.append(drift)
|
||||
return full_plan(plan, drift, "always-run")
|
||||
|
||||
files, truncated = fetch_changed_files(args.repo, args.pr, token)
|
||||
if truncated:
|
||||
notes.append(f"changed file list truncated at {MAX_FILES}")
|
||||
return full_plan(
|
||||
plan,
|
||||
f"pull request has more than {MAX_FILES} changed files",
|
||||
"always-run",
|
||||
)
|
||||
|
||||
always_hits, matches = path_matches(files)
|
||||
# Keep the evidence: the step summary explains a verdict by naming the files
|
||||
# that matched, which is what triage asks for first.
|
||||
plan["matching"] = {suite_id: sorted(names) for suite_id, names in matches.items()}
|
||||
if always_hits:
|
||||
notes.append(f"always-run: {', '.join(sorted(always_hits)[:5])}")
|
||||
return full_plan(
|
||||
plan,
|
||||
"always-run path: " + ", ".join(sorted(always_hits)[:3]),
|
||||
"always-run",
|
||||
)
|
||||
|
||||
first = first_uncovered(files, matches)
|
||||
if first is not None:
|
||||
notes.append(f"uncovered build change: {first}")
|
||||
return full_plan(plan, f"uncovered build change: {first}", "uncovered")
|
||||
|
||||
static_run = {suite_id: bool(matched) for suite_id, matched in matches.items()}
|
||||
|
||||
if not has_meaningful_changes(files) and not any(static_run.values()):
|
||||
plan.update(
|
||||
mode="static",
|
||||
full=False,
|
||||
suites={
|
||||
suite_id: {
|
||||
"run": False,
|
||||
"source": "static",
|
||||
"reason": "no code, config or workflow file changed",
|
||||
}
|
||||
for suite_id in SUITES
|
||||
},
|
||||
)
|
||||
notes.append("no meaningful changes: skip every suite")
|
||||
return finalize(plan)
|
||||
|
||||
plan.update(
|
||||
mode="static",
|
||||
suites={
|
||||
suite_id: {
|
||||
"run": static_run[suite_id],
|
||||
"source": "static",
|
||||
"reason": ("path rule: " + ", ".join(matches[suite_id][:3]))
|
||||
if matches[suite_id]
|
||||
else "no path rule matched",
|
||||
}
|
||||
for suite_id in SUITES
|
||||
},
|
||||
)
|
||||
return finalize(plan)
|
||||
|
||||
|
||||
def derive_outputs(plan):
|
||||
"""Flatten the plan into the `$GITHUB_OUTPUT` keys the workflow gates on.
|
||||
|
||||
|
||||
Every gate in `SUITES` must route to a key here, otherwise its suites are
|
||||
classified but never switch a job; `test_every_gate_routes_to_an_output`
|
||||
asks this function directly, so a new gate fails there until it is routed.
|
||||
|
||||
|
||||
Job-level `if:` cannot read the `matrix` context, so the workflow gates a
|
||||
whole fuzz gate instead of individual matrix legs; the per-suite verdicts
|
||||
stay visible in the step log.
|
||||
"""
|
||||
|
||||
def suites_of(gate):
|
||||
return [
|
||||
suite_id
|
||||
for suite_id, entry in plan["suites"].items()
|
||||
if entry["run"] and SUITES[suite_id]["gate"] == gate
|
||||
]
|
||||
|
||||
outputs = {}
|
||||
legs = {}
|
||||
for gate in FUZZ_GATES:
|
||||
running = suites_of(gate)
|
||||
legs[gate] = [suite_group(suite_id) for suite_id in running]
|
||||
legs[gate] = [leg for leg in legs[gate] if leg]
|
||||
outputs[gate] = "true" if running else "false"
|
||||
unstable = bool(suites_of("fuzz_unstable"))
|
||||
# Every gate outside the fuzz group switches exactly one job of its own.
|
||||
for gate in sorted({suite["gate"] for suite in SUITES.values()}):
|
||||
if gate not in FUZZ_GATES:
|
||||
outputs[gate] = "true" if suites_of(gate) else "false"
|
||||
outputs["any_fuzz"] = (
|
||||
"true"
|
||||
if unstable or any(outputs[gate] == "true" for gate in FUZZ_GATES)
|
||||
else "false"
|
||||
)
|
||||
distributed = outputs["fuzz_distributed"] == "true" or outputs["fuzz_chaos"] == "true"
|
||||
outputs["build_ci_needed"] = "true" if unstable or distributed else "false"
|
||||
return outputs, legs
|
||||
|
||||
|
||||
def render_log(plan):
|
||||
"""One line per suite plus the emitted gates, for the step log.
|
||||
|
||||
Triage starts in the run log, so the verdict has to be readable there
|
||||
without any other artifact.
|
||||
"""
|
||||
head = f"CI scope: mode={plan['mode']} full={'true' if plan['full'] else 'false'}"
|
||||
lines = [head]
|
||||
width = max((len(suite_id) for suite_id in plan["suites"]), default=0)
|
||||
for suite_id, entry in plan["suites"].items():
|
||||
lines.append(
|
||||
f" {'run ' if entry['run'] else 'skip'} {suite_id:<{width}} "
|
||||
f"{entry['source']:<12} {entry['reason']}"
|
||||
)
|
||||
outputs, _ = derive_outputs(plan)
|
||||
lines.append(
|
||||
" gates: " + " ".join(f"{key}={value}" for key, value in outputs.items())
|
||||
)
|
||||
for note in plan["notes"]:
|
||||
lines.append(f" note: {note}")
|
||||
return "\n".join(lines)
|
||||
|
||||
|
||||
SUMMARY_MAX_FILES = 3
|
||||
|
||||
|
||||
def render_summary(plan):
|
||||
"""Markdown for the job summary: the matching evidence behind each verdict.
|
||||
|
||||
The step log answers "what ran"; this answers "why", which is the question
|
||||
when a pull request unexpectedly skips or starts a suite.
|
||||
"""
|
||||
lines = [
|
||||
f"### CI scope: mode={plan['mode']}, full={'true' if plan['full'] else 'false'}",
|
||||
"",
|
||||
"| suite | verdict | rule | matched files |",
|
||||
"| --- | --- | --- | --- |",
|
||||
]
|
||||
matching = plan.get("matching") or {}
|
||||
for suite_id, entry in plan["suites"].items():
|
||||
matched = matching.get(suite_id) or []
|
||||
shown = ", ".join(f"`{name}`" for name in matched[:SUMMARY_MAX_FILES])
|
||||
if len(matched) > SUMMARY_MAX_FILES:
|
||||
shown += f" +{len(matched) - SUMMARY_MAX_FILES} more"
|
||||
lines.append(
|
||||
f"| `{suite_id}` | {'run' if entry['run'] else 'skip'} | "
|
||||
f"{entry['source']} | {shown or '—'} |"
|
||||
)
|
||||
if plan["notes"]:
|
||||
lines += ["", "<details><summary>notes</summary>", ""]
|
||||
lines += [f"- {note}" for note in plan["notes"]]
|
||||
lines += ["", "</details>"]
|
||||
return "\n".join(lines)
|
||||
|
||||
|
||||
def log_annotations(plan):
|
||||
"""Workflow-run annotations for every degraded decision.
|
||||
|
||||
A lookup failure widens the gate; it must be visible in the run list without
|
||||
opening the job log, otherwise it looks like a confident verdict.
|
||||
"""
|
||||
annotations = []
|
||||
for note in plan["notes"]:
|
||||
if note.startswith("pull request lookup failed"):
|
||||
suffix = "every suite runs"
|
||||
level = "warning"
|
||||
else:
|
||||
continue
|
||||
message = f"CI scope: {note}; {suffix}"[:300]
|
||||
annotations.append(f"::{level}::{message}")
|
||||
return annotations
|
||||
|
||||
|
||||
def emit(plan, args):
|
||||
outputs, _ = derive_outputs(plan)
|
||||
if args.dry_run:
|
||||
print(json.dumps(outputs, indent=2))
|
||||
elif args.github_output:
|
||||
with open(args.github_output, "a", encoding="utf-8") as handle:
|
||||
for key, value in outputs.items():
|
||||
handle.write(f"{key}={value}\n")
|
||||
if args.summary:
|
||||
with open(args.summary, "a", encoding="utf-8") as handle:
|
||||
handle.write(render_summary(plan) + "\n")
|
||||
|
||||
|
||||
def parse_args(argv):
|
||||
parser = argparse.ArgumentParser(description=__doc__.splitlines()[0])
|
||||
parser.add_argument("--repo", default=os.environ.get("GITHUB_REPOSITORY", ""))
|
||||
parser.add_argument("--pr", type=int)
|
||||
parser.add_argument("--head-sha", default="")
|
||||
parser.add_argument("--base-sha", default="")
|
||||
parser.add_argument(
|
||||
"--event",
|
||||
choices=["pull_request", "merge_group", "schedule", "workflow_dispatch"],
|
||||
)
|
||||
parser.add_argument("--github-output")
|
||||
parser.add_argument(
|
||||
"--summary",
|
||||
help="append the markdown matching table to this file ($GITHUB_STEP_SUMMARY)",
|
||||
)
|
||||
parser.add_argument("--dry-run", action="store_true")
|
||||
return parser.parse_args(argv)
|
||||
|
||||
|
||||
def main(argv=None):
|
||||
args = parse_args(argv)
|
||||
token = os.environ.get("GITHUB_TOKEN") or os.environ.get("GH_TOKEN") or ""
|
||||
plan = build_plan(args, token)
|
||||
for annotation in log_annotations(plan):
|
||||
print(annotation)
|
||||
print(render_log(plan))
|
||||
emit(plan, args)
|
||||
return 0
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
sys.exit(main())
|
||||
Executable
+277
@@ -0,0 +1,277 @@
|
||||
#!/usr/bin/env python3
|
||||
# Copyright 2023 Greptime Team
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
"""Policy for the integration CI admission gate.
|
||||
|
||||
The rules are data and live in `.github/ci/scope-rules.toml` so they can be
|
||||
reviewed and changed without touching the classifier. This module parses that
|
||||
file once at import, validates it, and exposes the names `ci_scope.py` uses.
|
||||
|
||||
A malformed file raises at import: the classifier job's steps are
|
||||
`continue-on-error`, so a broken rules file leaves the gate outputs empty and
|
||||
every gated job runs.
|
||||
"""
|
||||
|
||||
import argparse
|
||||
import pathlib
|
||||
import sys
|
||||
import tomllib
|
||||
|
||||
RULES_PATH = pathlib.Path(__file__).resolve().with_name("scope-rules.toml")
|
||||
# `.github/ci/scope-rules.toml`: parents[0] is `.github/ci`, parents[2] the repo.
|
||||
REPO_ROOT = RULES_PATH.parents[2]
|
||||
|
||||
|
||||
|
||||
class RulesError(ValueError):
|
||||
"""The rules file is missing, malformed or internally inconsistent."""
|
||||
|
||||
|
||||
def _require(table, key, where):
|
||||
if key not in table:
|
||||
raise RulesError(f"{where} is missing `{key}`")
|
||||
return table[key]
|
||||
|
||||
|
||||
def _strings(value, where):
|
||||
if not isinstance(value, list) or not all(isinstance(item, str) for item in value):
|
||||
raise RulesError(f"{where} must be an array of strings")
|
||||
return list(value)
|
||||
|
||||
|
||||
def _trees(entries, where):
|
||||
"""Normalise `[[matching.*_tree]]` tables into bare path prefixes.
|
||||
|
||||
Each entry carries a `reason`: the exclusions decide what CI never runs, so
|
||||
the justification is part of the contract, not a comment.
|
||||
"""
|
||||
if not isinstance(entries, list):
|
||||
raise RulesError(f"{where} must be an array of tables")
|
||||
paths = []
|
||||
for index, entry in enumerate(entries):
|
||||
if not isinstance(entry, dict):
|
||||
raise RulesError(f"{where}[{index}] is not a table")
|
||||
path = _require(entry, "path", f"{where}[{index}]")
|
||||
if not isinstance(path, str) or not path:
|
||||
raise RulesError(f"{where}[{index}].path must be a non-empty string")
|
||||
reason = _require(entry, "reason", f"{where}[{index}]")
|
||||
if not isinstance(reason, str) or not reason.strip():
|
||||
raise RulesError(f"{where}[{index}].reason must explain the exclusion")
|
||||
paths.append(path)
|
||||
return paths
|
||||
|
||||
|
||||
def validate(data):
|
||||
"""Check the shape of a parsed rules document and return it normalised."""
|
||||
if not isinstance(data, dict):
|
||||
raise RulesError("rules document is not a table")
|
||||
matching = _require(data, "matching", "the rules file")
|
||||
gates_in = _require(data, "gates", "the rules file")
|
||||
groups_in = _require(data, "groups", "the rules file")
|
||||
suites_in = _require(data, "suites", "the rules file")
|
||||
|
||||
groups = {}
|
||||
for name, paths in groups_in.items():
|
||||
groups[name] = _strings(paths, f"groups.{name}")
|
||||
|
||||
def expand(entries, stack=()):
|
||||
out = []
|
||||
for entry in entries:
|
||||
if not entry.startswith("@"):
|
||||
out.append(entry)
|
||||
continue
|
||||
name = entry[1:]
|
||||
if name not in groups:
|
||||
raise RulesError(f"unknown path group `{entry}`")
|
||||
if name in stack:
|
||||
raise RulesError(f"path group cycle: {' -> '.join(stack + (name,))}")
|
||||
out.extend(expand(groups[name], stack + (name,)))
|
||||
return out
|
||||
|
||||
for name in groups:
|
||||
expand([f"@{name}"]) # every group must resolve on its own
|
||||
|
||||
suites = {}
|
||||
for suite_id, suite in suites_in.items():
|
||||
if not isinstance(suite, dict):
|
||||
raise RulesError(f"suites.{suite_id} is not a table")
|
||||
gate = _require(suite, "gate", f"suites.{suite_id}")
|
||||
paths = _strings(
|
||||
_require(suite, "paths", f"suites.{suite_id}"), f"suites.{suite_id}.paths"
|
||||
)
|
||||
description = _require(suite, "description", f"suites.{suite_id}")
|
||||
if not isinstance(description, str) or not description.strip():
|
||||
raise RulesError(f"suites.{suite_id}.description is empty")
|
||||
# `gate/leg` for a matrix job, or a bare gate for a single-leg job.
|
||||
prefix = suite_id.split("/", 1)[0].replace("-", "_")
|
||||
if prefix != gate:
|
||||
raise RulesError(
|
||||
f"suites.{suite_id}.gate is `{gate}`, expected `{prefix}`"
|
||||
)
|
||||
expand(paths)
|
||||
suites[suite_id] = {
|
||||
"gate": gate,
|
||||
"paths": paths,
|
||||
"description": description,
|
||||
}
|
||||
|
||||
gate_jobs = {}
|
||||
for gate, job in gates_in.items():
|
||||
if not isinstance(job, str) or not job:
|
||||
raise RulesError(f"gates.{gate} must name a job id")
|
||||
gate_jobs[gate] = job
|
||||
used = {suite["gate"] for suite in suites.values()}
|
||||
unknown = sorted(used - set(gate_jobs))
|
||||
if unknown:
|
||||
raise RulesError(f"suites use gates missing from [gates]: {', '.join(unknown)}")
|
||||
dead = sorted(set(gate_jobs) - used)
|
||||
if dead:
|
||||
raise RulesError(f"[gates] names gates no suite uses: {', '.join(dead)}")
|
||||
|
||||
return {
|
||||
"always_run": _strings(
|
||||
_require(matching, "always_run", "matching"), "matching.always_run"
|
||||
),
|
||||
"src_tree": _require(matching, "src_tree", "matching"),
|
||||
"exempt_trees": _trees(
|
||||
_require(matching, "exempt", "matching"), "matching.exempt"
|
||||
),
|
||||
"gates": gate_jobs,
|
||||
"groups": groups,
|
||||
"suites": suites,
|
||||
}
|
||||
|
||||
|
||||
def load(path=None):
|
||||
"""Parse and validate the rules file."""
|
||||
path = RULES_PATH if path is None else path
|
||||
try:
|
||||
raw = pathlib.Path(path).read_bytes()
|
||||
except OSError as err:
|
||||
raise RulesError(f"cannot read {path}: {err}") from err
|
||||
try:
|
||||
data = tomllib.loads(raw.decode("utf-8"))
|
||||
except (tomllib.TOMLDecodeError, UnicodeDecodeError) as err:
|
||||
raise RulesError(f"{path} is not valid TOML: {err}") from err
|
||||
return validate(data)
|
||||
|
||||
|
||||
_RULES = load()
|
||||
|
||||
ALWAYS_RUN = _RULES["always_run"]
|
||||
SRC_TREE = _RULES["src_tree"]
|
||||
EXEMPT_TREES = tuple(_RULES["exempt_trees"])
|
||||
GATE_JOBS = _RULES["gates"]
|
||||
PATH_GROUPS = _RULES["groups"]
|
||||
SUITES = _RULES["suites"]
|
||||
|
||||
|
||||
def main(argv=None):
|
||||
"""Validate the rules file and print what it holds; non-zero on failure."""
|
||||
parser = argparse.ArgumentParser(description="Validate the CI scope rules.")
|
||||
parser.add_argument(
|
||||
"--check-paths",
|
||||
action="store_true",
|
||||
help="also fail when a pattern's literal prefix does not exist",
|
||||
)
|
||||
args = parser.parse_args(argv)
|
||||
try:
|
||||
rules = load()
|
||||
except RulesError as err:
|
||||
print(f"scope rules invalid: {err}", file=sys.stderr)
|
||||
return 1
|
||||
if args.check_paths:
|
||||
missing = missing_paths(rules)
|
||||
for pattern, prefix in missing:
|
||||
print(f"missing path: {pattern} (nothing under {prefix})", file=sys.stderr)
|
||||
return 1 if missing else 0
|
||||
print(
|
||||
f"scope rules ok: {len(rules['suites'])} suites, "
|
||||
f"{len(rules['groups'])} path groups, "
|
||||
f"{len(rules['always_run'])} always-run entries"
|
||||
)
|
||||
return 0
|
||||
|
||||
|
||||
def suite_group(suite_id):
|
||||
"""Return the matrix group id encoded in a suite id, or None."""
|
||||
_, _, group = suite_id.partition("/")
|
||||
return group or None
|
||||
|
||||
|
||||
def expand_paths(entries, groups=None):
|
||||
"""Expand `@group` references, including groups nested in other groups."""
|
||||
groups = PATH_GROUPS if groups is None else groups
|
||||
patterns = []
|
||||
for entry in entries:
|
||||
if entry.startswith("@"):
|
||||
patterns.extend(expand_paths(groups[entry[1:]], groups))
|
||||
else:
|
||||
patterns.append(entry)
|
||||
return patterns
|
||||
|
||||
|
||||
def suite_paths(suite):
|
||||
"""Expand `@group` references in one suite definition into globs."""
|
||||
return expand_paths(suite["paths"])
|
||||
|
||||
|
||||
def _literal_prefix(pattern):
|
||||
"""Return the longest leading path that the glob cannot vary.
|
||||
|
||||
Everything from the first `*`, `?` or `[` onwards is variable. When that
|
||||
wildcard sits inside a segment the incomplete segment is dropped, so
|
||||
`src/a/foo*.rs` yields `src/a/`; a wildcard in the very first segment (for
|
||||
example `*.md`) yields `""` because the whole path is variable.
|
||||
"""
|
||||
cuts = [pattern.find(ch) for ch in "*?[" if ch in pattern]
|
||||
if not cuts:
|
||||
return pattern
|
||||
prefix = pattern[: min(cuts)]
|
||||
if "/" not in prefix:
|
||||
return ""
|
||||
return prefix.rsplit("/", 1)[0] + "/"
|
||||
|
||||
|
||||
def _all_patterns(rules):
|
||||
"""Every glob the rules mention, with `@group` references expanded."""
|
||||
patterns = []
|
||||
for key in ("always_run", "exempt_trees"):
|
||||
patterns.extend(expand_paths(rules[key], rules["groups"]))
|
||||
for suite in rules["suites"].values():
|
||||
patterns.extend(expand_paths(suite["paths"], rules["groups"]))
|
||||
return patterns
|
||||
|
||||
|
||||
def missing_paths(rules=None, root=None):
|
||||
"""Return `(pattern, prefix)` for patterns whose literal prefix is absent.
|
||||
|
||||
A rule that names a directory nobody renamed would otherwise match nothing
|
||||
forever, silently narrowing the gate. A pattern with no fixed prefix is
|
||||
skipped: there is nothing on disk to check.
|
||||
"""
|
||||
rules = _RULES if rules is None else rules
|
||||
root = pathlib.Path(REPO_ROOT if root is None else root)
|
||||
missing = set()
|
||||
for pattern in _all_patterns(rules):
|
||||
prefix = _literal_prefix(pattern)
|
||||
if prefix and not (root / prefix).exists():
|
||||
missing.add((pattern, prefix))
|
||||
return sorted(missing)
|
||||
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
sys.exit(main())
|
||||
@@ -0,0 +1,285 @@
|
||||
# Rules for the integration CI admission gate.
|
||||
#
|
||||
# Data only: `ci_scope_rules.py` loads this file with the stdlib `tomllib`, and
|
||||
# `ci_scope.py` matches diffs against it. Edit this file, not the code, when a
|
||||
# suite's paths change.
|
||||
#
|
||||
# Conventions
|
||||
# -----------
|
||||
# - `**` crosses directories, `*` does not; a trailing `/**` covers everything
|
||||
# under a directory.
|
||||
# - `@name` inside `suites.*.paths` expands `[groups].name`, and groups may
|
||||
# reference other groups. Expansion is recursive.
|
||||
# - A suite id is `<gate>/<matrix group id>`; `gate` is the `$GITHUB_OUTPUT`
|
||||
# key that switches the job, and it must equal the id prefix with `-`
|
||||
# replaced by `_`.
|
||||
# - Everything here is a floor, never a filter: an unmatched `src/` path runs
|
||||
# every suite, and a malformed file fails the classifier job, whose steps are
|
||||
# `continue-on-error`, so the gated jobs run.
|
||||
|
||||
[matching]
|
||||
# A changed file matching one of these runs every suite.
|
||||
# Put here anything that changes what the suites build or how they start.
|
||||
always_run = [
|
||||
"Cargo.toml",
|
||||
"Cargo.lock",
|
||||
"rust-toolchain.toml",
|
||||
".cargo/**",
|
||||
"tests-fuzz/**",
|
||||
"tests-integration/**",
|
||||
"config/**",
|
||||
"docker/**",
|
||||
".github/ci/**",
|
||||
".github/workflows/integration.yml",
|
||||
".github/actions/**",
|
||||
# Both run through a composite action, so neither appears in the workflow:
|
||||
# `setup-kind` starts the cluster for the distributed and chaos jobs, and
|
||||
# `fuzz-test` seeds the corpus every fuzz job starts from.
|
||||
".github/scripts/kind-with-registry.sh",
|
||||
".github/scripts/prepare-fuzz-corpus.sh",
|
||||
".github/scripts/run-fuzz-targets.sh",
|
||||
".github/scripts/collect-fuzz-target-artifacts.sh",
|
||||
".github/scripts/wait-kafka-ready.sh",
|
||||
".github/scripts/pull-test-deps-images.sh",
|
||||
]
|
||||
|
||||
# A change under `src/` that no suite claims runs every suite: that is the net
|
||||
# for a crate added, split or renamed after these rules were written.
|
||||
src_tree = "src/"
|
||||
|
||||
# Paths outside the gate's remit. They select no suite, and they do not count as
|
||||
# "no rule covers this" either, so they never widen the gate. Each needs a
|
||||
# `reason`: what CI covers them instead.
|
||||
[[matching.exempt]]
|
||||
path = "src/promql/"
|
||||
reason = "PromQL crate: rust.yml and the promql sqlness cases own it; the fuzz suites speak SQL."
|
||||
|
||||
[[matching.exempt]]
|
||||
path = "src/query/src/promql/"
|
||||
reason = "PromQL module inside `src/query`, which `@server` claims as `src/query/**`."
|
||||
|
||||
[[matching.exempt]]
|
||||
path = "src/flow/"
|
||||
reason = "Flow engine: rust.yml and the flow sqlness cases own it; no fuzz suite loads it."
|
||||
|
||||
# Which job each gate switches. The keys are `$GITHUB_OUTPUT` names; the values
|
||||
# are job ids in `integration.yml`. The classifier cannot read YAML, so the
|
||||
# mapping is data here, and a test proves both directions line up.
|
||||
[gates]
|
||||
fuzz_standalone = "fuzztest"
|
||||
fuzz_unstable = "unstable-fuzztest"
|
||||
fuzz_distributed = "distributed-fuzztest"
|
||||
fuzz_chaos = "distributed-fuzztest-with-chaos"
|
||||
export_import_v2 = "export-import-v2-e2e"
|
||||
sqlness_kvbackend = "sqlness-kvbackend"
|
||||
|
||||
[groups]
|
||||
server = [
|
||||
"src/operator/**",
|
||||
"src/sql/**",
|
||||
"src/catalog/**",
|
||||
"src/datatypes/**",
|
||||
"src/table/**",
|
||||
"src/store-api/**",
|
||||
"src/session/**",
|
||||
"src/api/**",
|
||||
"src/servers/**",
|
||||
"src/frontend/**",
|
||||
# Also covers `src/query/src/promql/`, which is exempt (see
|
||||
# `[[matching.exempt]]`): a PromQL-only change must not run the fuzz fleet.
|
||||
"src/query/**",
|
||||
"src/partition/**",
|
||||
"src/index/**",
|
||||
"src/object-store/**",
|
||||
"src/cache/**",
|
||||
"src/puffin/**",
|
||||
"src/auth/**",
|
||||
"src/client/**",
|
||||
"src/log-query/**",
|
||||
"src/pipeline/**",
|
||||
"src/plugins/**",
|
||||
"src/cmd/**",
|
||||
"src/standalone/**",
|
||||
"src/datanode/**",
|
||||
"src/common/base/**",
|
||||
"src/common/batcher/**",
|
||||
"src/common/cache/**",
|
||||
"src/common/catalog/**",
|
||||
"src/common/config/**",
|
||||
"src/common/datasource/**",
|
||||
"src/common/decimal/**",
|
||||
"src/common/error/**",
|
||||
"src/common/event-recorder/**",
|
||||
"src/common/frontend/**",
|
||||
"src/common/function/**",
|
||||
"src/common/grpc/**",
|
||||
"src/common/grpc-expr/**",
|
||||
"src/common/greptimedb-telemetry/**",
|
||||
"src/common/macro/**",
|
||||
"src/common/mem-prof/**",
|
||||
"src/common/memory-manager/**",
|
||||
"src/common/options/**",
|
||||
"src/common/plugins/**",
|
||||
"src/common/pprof/**",
|
||||
"src/common/query/**",
|
||||
"src/common/recordbatch/**",
|
||||
"src/common/runtime/**",
|
||||
"src/common/session/**",
|
||||
"src/common/sql/**",
|
||||
"src/common/stat/**",
|
||||
"src/common/substrait/**",
|
||||
"src/common/telemetry/**",
|
||||
"src/common/test-util/**",
|
||||
"src/common/time/**",
|
||||
"src/common/version/**",
|
||||
"src/common/workload/**",
|
||||
]
|
||||
|
||||
# Storage engines and WAL.
|
||||
engine = [
|
||||
"src/mito2/**",
|
||||
"src/mito-codec/**",
|
||||
"src/metric-engine/**",
|
||||
"src/file-engine/**",
|
||||
"src/log-store/**",
|
||||
"src/common/wal/**",
|
||||
]
|
||||
|
||||
# DDL and procedure code standalone executes in-process: it builds a
|
||||
# `DdlManager` and runs `LocalProcedureExecutor` without any metasrv.
|
||||
meta-core = [
|
||||
"src/common/meta/**",
|
||||
"src/common/procedure/**",
|
||||
"src/common/procedure-test/**",
|
||||
]
|
||||
|
||||
# Everything that sits on the KV backend the two sqlness KvBackend legs
|
||||
# exercise: the backend implementations, the metadata service and the startup
|
||||
# wiring that picks a backend.
|
||||
kv-backend = [
|
||||
# The runner implements `--setup-pg`/`--setup-mysql`, which only these legs pass.
|
||||
"tests/runner/**",
|
||||
"src/common/meta/**",
|
||||
"src/meta-srv/**",
|
||||
"src/meta-client/**",
|
||||
"src/common/procedure/**",
|
||||
"src/cmd/**",
|
||||
"src/common/config/**",
|
||||
"src/common/options/**",
|
||||
]
|
||||
|
||||
# Adds the metasrv/meta-client crates on top of the in-process DDL code.
|
||||
meta = [
|
||||
"src/meta-srv/**",
|
||||
"src/meta-client/**",
|
||||
"@meta-core",
|
||||
]
|
||||
|
||||
[suites."fuzz-standalone/database-and-regular-table"]
|
||||
gate = "fuzz_standalone"
|
||||
paths = [
|
||||
"@server",
|
||||
"@engine",
|
||||
"@meta-core",
|
||||
]
|
||||
description = "Standalone-server black-box fuzz of CREATE DATABASE/TABLE, ALTER, INSERT over MySQL."
|
||||
|
||||
[suites."fuzz-standalone/logical-table"]
|
||||
gate = "fuzz_standalone"
|
||||
paths = [
|
||||
"@server",
|
||||
"@engine",
|
||||
"@meta-core",
|
||||
]
|
||||
description = "Standalone logical-table DDL/INSERT fuzz (mito2 logical tables)."
|
||||
|
||||
[suites."fuzz-unstable/standalone"]
|
||||
gate = "fuzz_unstable"
|
||||
paths = [
|
||||
"@server",
|
||||
"@engine",
|
||||
"@meta-core",
|
||||
]
|
||||
description = "Unstable standalone create-table fuzz (nix build feature)."
|
||||
|
||||
[suites."fuzz-distributed/database-and-regular-table"]
|
||||
gate = "fuzz_distributed"
|
||||
paths = [
|
||||
"@server",
|
||||
"@engine",
|
||||
"@meta",
|
||||
]
|
||||
description = "Distributed (frontend/datanode/metasrv, remote WAL) DDL/DML fuzz."
|
||||
|
||||
[suites."fuzz-distributed/logical-table"]
|
||||
gate = "fuzz_distributed"
|
||||
paths = [
|
||||
"@server",
|
||||
"@engine",
|
||||
"@meta",
|
||||
]
|
||||
description = "Distributed logical-table fuzz."
|
||||
|
||||
[suites."fuzz-distributed/repartition"]
|
||||
gate = "fuzz_distributed"
|
||||
paths = [
|
||||
"@server",
|
||||
"@engine",
|
||||
"@meta",
|
||||
]
|
||||
description = "Distributed repartition ALTER TABLE + GC fuzz."
|
||||
|
||||
[suites."fuzz-distributed/logical-pruning"]
|
||||
gate = "fuzz_distributed"
|
||||
paths = [
|
||||
"@engine",
|
||||
"@meta",
|
||||
]
|
||||
description = "Remote-WAL logical table pruning of stale manifests."
|
||||
|
||||
[suites."fuzz-chaos/migration"]
|
||||
gate = "fuzz_chaos"
|
||||
paths = [
|
||||
"@server",
|
||||
"@engine",
|
||||
"@meta",
|
||||
]
|
||||
description = "Region migration under Chaos Mesh, mito and metric engines."
|
||||
|
||||
[suites."fuzz-chaos/failover"]
|
||||
gate = "fuzz_chaos"
|
||||
paths = [
|
||||
"@server",
|
||||
"@engine",
|
||||
"@meta",
|
||||
]
|
||||
description = "Region failover under Chaos Mesh, mito and metric engines."
|
||||
|
||||
[suites."fuzz-chaos/repartition"]
|
||||
gate = "fuzz_chaos"
|
||||
paths = [
|
||||
"@server",
|
||||
"@engine",
|
||||
"@meta",
|
||||
]
|
||||
description = "Repartition + GC under Chaos Mesh."
|
||||
|
||||
[suites."export-import-v2"]
|
||||
gate = "export_import_v2"
|
||||
paths = [
|
||||
"src/cli/**",
|
||||
"@server",
|
||||
"@engine",
|
||||
"@meta-core",
|
||||
]
|
||||
description = "CLI COPY DATABASE export/import v2 end-to-end against S3."
|
||||
|
||||
[suites."sqlness-kvbackend/metasrv-postgres"]
|
||||
gate = "sqlness_kvbackend"
|
||||
paths = ["@kv-backend"]
|
||||
description = "Sqlness with PostgreSQL as the metadata KV backend."
|
||||
|
||||
[suites."sqlness-kvbackend/metasrv-mysql"]
|
||||
gate = "sqlness_kvbackend"
|
||||
paths = ["@kv-backend"]
|
||||
description = "Sqlness with MySQL as the metadata KV backend."
|
||||
@@ -0,0 +1,158 @@
|
||||
# Golden cases for the admission gate.
|
||||
#
|
||||
# `tests/test_ci_scope.py` replays every case through the real classifier,
|
||||
# so an edit to `scope-rules.toml` that changes behaviour fails with the case
|
||||
# name here. The cases encode intent, not implementation: each one says which
|
||||
# suites a kind of change must start.
|
||||
#
|
||||
# `suites` is a list of globs over suite ids; `["*"]` means every suite and
|
||||
# `[]` means none.
|
||||
|
||||
[[case]]
|
||||
name = "server crate: the whole fuzz fleet except the pruning suite"
|
||||
note = "A change to `src/api` reaches every suite that builds the server binary."
|
||||
paths = [
|
||||
"src/api/src/lib.rs",
|
||||
]
|
||||
suites = [
|
||||
"fuzz-standalone/database-and-regular-table",
|
||||
"fuzz-standalone/logical-table",
|
||||
"fuzz-unstable/standalone",
|
||||
"fuzz-distributed/database-and-regular-table",
|
||||
"fuzz-distributed/logical-table",
|
||||
"fuzz-distributed/repartition",
|
||||
"fuzz-chaos/migration",
|
||||
"fuzz-chaos/failover",
|
||||
"fuzz-chaos/repartition",
|
||||
"export-import-v2",
|
||||
]
|
||||
|
||||
[[case]]
|
||||
name = "storage engine: every fuzz suite, including remote-WAL pruning"
|
||||
note = "logical-pruning needs engine and DDL code, so an engine change starts it."
|
||||
paths = [
|
||||
"src/mito2/src/lib.rs",
|
||||
]
|
||||
suites = [
|
||||
"fuzz-standalone/*",
|
||||
"fuzz-unstable/*",
|
||||
"fuzz-distributed/*",
|
||||
"fuzz-chaos/*",
|
||||
"export-import-v2",
|
||||
]
|
||||
|
||||
[[case]]
|
||||
name = "in-process DDL code registers the procedures standalone executes"
|
||||
paths = [
|
||||
"src/common/meta/src/lib.rs",
|
||||
]
|
||||
suites = [
|
||||
"fuzz-standalone/*",
|
||||
"fuzz-unstable/*",
|
||||
"fuzz-distributed/*",
|
||||
"fuzz-chaos/*",
|
||||
"export-import-v2",
|
||||
"sqlness-kvbackend/*",
|
||||
]
|
||||
|
||||
[[case]]
|
||||
name = "metasrv only: distributed and chaos families"
|
||||
note = "Standalone builds a DdlManager in-process and never links a metasrv."
|
||||
paths = [
|
||||
"src/meta-srv/src/discovery/lease.rs",
|
||||
]
|
||||
suites = [
|
||||
"fuzz-distributed/database-and-regular-table",
|
||||
"fuzz-distributed/logical-table",
|
||||
"fuzz-distributed/repartition",
|
||||
"fuzz-distributed/logical-pruning",
|
||||
"fuzz-chaos/migration",
|
||||
"fuzz-chaos/failover",
|
||||
"fuzz-chaos/repartition",
|
||||
"sqlness-kvbackend/*",
|
||||
]
|
||||
|
||||
[[case]]
|
||||
name = "CLI only touches the export/import path"
|
||||
paths = [
|
||||
"src/cli/src/lib.rs",
|
||||
]
|
||||
suites = [
|
||||
"export-import-v2",
|
||||
]
|
||||
|
||||
[[case]]
|
||||
name = "PromQL crate: no suite"
|
||||
note = "rust.yml and the promql sqlness cases own it; the fuzz suites speak SQL."
|
||||
paths = [
|
||||
"src/promql/src/lib.rs",
|
||||
]
|
||||
suites = []
|
||||
|
||||
[[case]]
|
||||
name = "PromQL module inside the query crate is not fuzzable either"
|
||||
note = "`@server` claims `src/query/**`, so the module must be exempt."
|
||||
paths = [
|
||||
"src/query/src/promql/src/lib.rs",
|
||||
]
|
||||
suites = []
|
||||
|
||||
[[case]]
|
||||
name = "flow engine: no suite"
|
||||
paths = [
|
||||
"src/flow/src/lib.rs",
|
||||
]
|
||||
suites = []
|
||||
|
||||
[[case]]
|
||||
name = "mixed diff: the PromQL file subtracts nothing"
|
||||
note = "The engine change still starts every suite."
|
||||
paths = [
|
||||
"src/mito2/src/lib.rs",
|
||||
"src/promql/src/lib.rs",
|
||||
]
|
||||
suites = [
|
||||
"fuzz-standalone/*",
|
||||
"fuzz-unstable/*",
|
||||
"fuzz-distributed/*",
|
||||
"fuzz-chaos/*",
|
||||
"export-import-v2",
|
||||
]
|
||||
|
||||
[[case]]
|
||||
name = "crate added after the rules were written"
|
||||
note = "No suite claims it, so the gate widens instead of skipping everything."
|
||||
paths = [
|
||||
"src/brand-new/src/lib.rs",
|
||||
]
|
||||
suites = ["*"]
|
||||
|
||||
[[case]]
|
||||
name = "integration harness change"
|
||||
paths = [
|
||||
"tests-integration/tests/fuzz.rs",
|
||||
]
|
||||
suites = ["*"]
|
||||
|
||||
[[case]]
|
||||
name = "documentation only"
|
||||
paths = [
|
||||
"docs/readme.md",
|
||||
]
|
||||
suites = []
|
||||
|
||||
[[case]]
|
||||
name = "kind registry setup: every suite"
|
||||
note = "The distributed and chaos fuzz jobs start their cluster with this script."
|
||||
paths = [
|
||||
".github/scripts/kind-with-registry.sh",
|
||||
]
|
||||
suites = ["*"]
|
||||
|
||||
[[case]]
|
||||
name = "fuzz corpus seeding: every suite"
|
||||
note = "Every fuzz job seeds its corpus through the `fuzz-test` action first."
|
||||
paths = [
|
||||
".github/scripts/prepare-fuzz-corpus.sh",
|
||||
]
|
||||
suites = ["*"]
|
||||
Executable
+1018
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,28 @@
|
||||
# Heavy CI scheduling
|
||||
|
||||
Checks, Rust CI, and Integration CI each run the shared GitHub script test
|
||||
action before expensive builds and tests. A failed, skipped, or cancelled
|
||||
script-test job blocks those jobs, including manually dispatched runs. Each
|
||||
workflow runs its own preflight so it does not wait on another workflow run.
|
||||
|
||||
Rust CI keeps the Windows compilation check on PRs and merge groups. Windows
|
||||
nextest and Windows SQLness run in the existing Nightly CI workflow, which also
|
||||
supports manual dispatch. Its existing schedule is Tuesday through Friday at
|
||||
07:00 Asia/Shanghai, not every day. No new Windows test job is added.
|
||||
|
||||
Integration CI admits fuzz when a non-draft PR is opened or marked ready for
|
||||
review, selecting suites with the existing diff-scope classifier. Its weekday
|
||||
schedule (23:00 Asia/Shanghai, Monday through Friday) runs all fuzz suites. Ordinary pushes and reopening do not run fuzz; core
|
||||
integration checks still run. Merge groups continue to skip fuzz.
|
||||
|
||||
Re-running an ordinary push-triggered Integration CI run does not enable fuzz.
|
||||
A new push can cancel an earlier ready-for-review run. Use an explicit fuzz
|
||||
profile through the CI entry points below when later changes need fuzz coverage.
|
||||
|
||||
For a same-repository branch, use **Run workflow** and select `fuzz_profile`
|
||||
(`standalone`, `distributed`, `chaos`, or `all`). The default `none` runs core
|
||||
integration without fuzz. The existing `/ci fuzz ...` commands remain available
|
||||
for same-repository draft PRs with their existing authorization rules.
|
||||
|
||||
Validate job admission with `node --test .github/scripts/heavy-ci-policy.test.cjs`.
|
||||
These tests verify triggering decisions, not runner availability or performance.
|
||||
@@ -0,0 +1,45 @@
|
||||
# Nightly merge
|
||||
|
||||
The PR template opts new PRs into the `merge nightly` label. The Nightly Merge
|
||||
workflow reconciles the label on PR creation, edits, and reopening. Existing PRs
|
||||
without the checkbox can opt in by adding the label manually; label sync leaves
|
||||
their labels unchanged. Unchecking removes the label; it does not
|
||||
request an immediate merge or cancel an existing queue entry/auto-merge request.
|
||||
|
||||
Every day at 02:10, 03:10, 04:10, 05:10, 06:10, 07:10, and 08:10
|
||||
Asia/Shanghai (UTC+8), the workflow enqueues up to five eligible PRs targeting
|
||||
`main` per run, oldest first. Already queued PRs do not count toward this limit.
|
||||
GitHub may delay scheduled runs.
|
||||
The label alone controls nightly opt-in; the enqueue job does not check the PR
|
||||
body. PRs must be approved and clean, and have all
|
||||
review threads resolved. Drafts are skipped.
|
||||
Already queued PRs and manually enabled auto-merge requests are left alone;
|
||||
Maintainers can use **Merge when ready** to proceed earlier. Unready PRs wait for a later
|
||||
scheduled run; this workflow never enables auto-merge on their behalf.
|
||||
|
||||
## Repository setup
|
||||
|
||||
- Create the `merge nightly` label before enabling the workflow.
|
||||
- Require the merge queue, reviews, status checks, and conversation resolution
|
||||
on `main`. Conversation resolution must also be enforced by GitHub to cover
|
||||
new comments arriving between the script's check and enqueueing.
|
||||
- Ensure the existing `GH_PERSONAL_ACCESS_TOKEN` automation secret can read PRs
|
||||
and review threads and enqueue PRs in this repository. Do not grant it a
|
||||
branch-rule bypass. This credential is already referenced by other workflows;
|
||||
its actual permissions have not been validated by the local tests.
|
||||
- Run **Nightly Merge** manually with the default `dry_run: true` first and
|
||||
inspect its job summary. Setting it to false explicitly enqueues outside the
|
||||
scheduled time as well. Merge queue build concurrency is configured separately
|
||||
in GitHub; this workflow does not change it.
|
||||
|
||||
The workflow never checks out or executes PR code. Label reconciliation uses
|
||||
`GITHUB_TOKEN`; enqueueing uses the automation credential so downstream CI can
|
||||
run. No runner remains allocated while waiting for the nightly schedule.
|
||||
|
||||
## Local validation
|
||||
|
||||
Run `actionlint .github/workflows/nightly-merge.yml .github/workflows/checks.yml`
|
||||
and `node --test .github/scripts/tests/nightly-merge.test.cjs`.
|
||||
The tests execute the actual inline workflow scripts with mocked GitHub APIs,
|
||||
including one-factor comparisons against an eligible PR. They do not validate
|
||||
live GitHub permissions, branch rules, or runner savings.
|
||||
@@ -25,3 +25,14 @@ Please convert it to a draft if some of the following conditions are not met.
|
||||
- [ ] API changes are backward compatible.
|
||||
- [ ] Schema or data changes are backward compatible.
|
||||
- [ ] This PR needs to be backported to release branches, and I have added the `backport-<target>` labels (e.g. `backport-v1.3` targets `release/v1.3`).
|
||||
|
||||
## Merge timing
|
||||
|
||||
- [x] Merge during the nightly window <!-- nightly-merge -->
|
||||
|
||||
<!--
|
||||
Eligible PRs enter the merge queue hourly from 02:10 through 08:10 Beijing time (UTC+8), up to five per run.
|
||||
Uncheck to opt out and remove the `merge nightly` label; this does not enable immediate merging.
|
||||
Maintainers can use **Merge when ready** to merge earlier.
|
||||
Changing this checkbox does not cancel an existing queue entry or manually enabled auto-merge.
|
||||
-->
|
||||
|
||||
@@ -0,0 +1,105 @@
|
||||
const { readFileSync } = require('node:fs');
|
||||
const { resolve } = require('node:path');
|
||||
const assert = require('node:assert/strict');
|
||||
const { test } = require('node:test');
|
||||
const workflows = resolve(__dirname, '../workflows');
|
||||
const integration = readFileSync(resolve(workflows, 'integration.yml'), 'utf8');
|
||||
const suites = ['fuzztest', 'unstable-fuzztest', 'distributed-fuzztest', 'distributed-fuzztest-with-chaos'];
|
||||
const prerequisites = ['prepare-fuzz-targets', 'build-greptime-ci'];
|
||||
function enabled(job, { event = 'pull_request', action = 'synchronize', draft = false, attempt = 1, profile = 'none', repository = 'GreptimeTeam/greptimedb', outputs = {}, results = {}, cancelled = false, workflow = integration } = {}) {
|
||||
const block = workflow.split(` ${job}:\n`)[1].split(/\n [a-z][\w-]*:/)[0];
|
||||
if (block.includes("needs['github-script-tests']")) {
|
||||
assert.match(block, /^ needs: \[.*github-script-tests.*\]/m);
|
||||
}
|
||||
const expression = block.match(/^ if: \$\{\{ (.+) \}\}/m)[1];
|
||||
// These job guards use only operators whose semantics match JS for this fixture.
|
||||
return new Function('github', 'inputs', 'needs', 'cancelled', `return (${expression});`)(
|
||||
{ repository, event_name: event, event: { action, pull_request: { draft } }, run_attempt: attempt },
|
||||
{ fuzz_profile: profile, ci_command: false },
|
||||
{ scope: { outputs }, ...Object.fromEntries(['github-script-tests', 'build', ...prerequisites].map(name => [name, { result: results[name] || 'success' }])) },
|
||||
() => cancelled
|
||||
);
|
||||
}
|
||||
test('fuzz event policy on ready PR admission and schedule, not every update', () => {
|
||||
for (const job of [...suites, ...prerequisites]) {
|
||||
for (const action of ['opened', 'ready_for_review']) assert.equal(enabled(job, { action }), true, job);
|
||||
for (const action of ['synchronize', 'reopened']) assert.equal(enabled(job, { action }), false, job);
|
||||
assert.equal(enabled(job, { event: 'schedule' }), true, job);
|
||||
assert.equal(enabled(job, { event: 'merge_group' }), false, job);
|
||||
assert.equal(enabled(job, { attempt: 2 }), false, job);
|
||||
assert.equal(enabled(job, { action: 'opened', draft: true }), false, job);
|
||||
assert.equal(enabled(job, { attempt: 2, draft: true }), false, job);
|
||||
assert.equal(enabled(job, { event: 'schedule', repository: 'fork/greptimedb' }), false, job);
|
||||
}
|
||||
});
|
||||
test('manual profiles select only their suite and all required build jobs', () => {
|
||||
const expected = { none: [], standalone: suites.slice(0, 2), distributed: [suites[2]], chaos: [suites[3]], all: suites };
|
||||
for (const [profile, jobs] of Object.entries(expected)) {
|
||||
assert.deepEqual(suites.filter(job => enabled(job, { event: 'workflow_dispatch', profile })), jobs);
|
||||
for (const job of prerequisites) assert.equal(enabled(job, { event: 'workflow_dispatch', profile }), profile !== 'none');
|
||||
}
|
||||
});
|
||||
test('core integration tests still run on PR updates and merge groups', () => {
|
||||
for (const job of ['build', 'sqlness', 'export-import-v2-e2e', 'run-multi-lang-tests']) {
|
||||
assert.equal(enabled(job), true, job);
|
||||
assert.equal(enabled(job, { event: 'merge_group' }), true, job);
|
||||
}
|
||||
});
|
||||
test('Windows compilation stays in Rust CI; test coverage remains in Nightly CI', () => {
|
||||
const rust = readFileSync(resolve(workflows, 'rust.yml'), 'utf8');
|
||||
const nightly = readFileSync(resolve(workflows, 'nightly-ci.yml'), 'utf8');
|
||||
assert.match(rust, /^ check-windows:/m);
|
||||
assert.doesNotMatch(rust, /^ test-windows:/m);
|
||||
assert.match(nightly, /^ test-on-windows:/m);
|
||||
assert.match(nightly, /^ sqlness-windows:/m);
|
||||
assert.match(nightly, /cargo nextest run -F dashboard/);
|
||||
assert.match(nightly, /^ workflow_dispatch:/m);
|
||||
});
|
||||
|
||||
test('scope exclusions and dependency failures compose with the event policy', () => {
|
||||
const gates = {
|
||||
'prepare-fuzz-targets': 'any_fuzz', 'build-greptime-ci': 'build_ci_needed',
|
||||
fuzztest: 'fuzz_standalone', 'unstable-fuzztest': 'fuzz_unstable',
|
||||
'distributed-fuzztest': 'fuzz_distributed', 'distributed-fuzztest-with-chaos': 'fuzz_chaos'
|
||||
};
|
||||
for (const [job, gate] of Object.entries(gates)) {
|
||||
assert.equal(enabled(job, { action: 'opened', outputs: { [gate]: 'false' } }), false, job);
|
||||
assert.equal(enabled(job, { action: 'opened', outputs: {} }), true, job);
|
||||
assert.equal(enabled(job, { outputs: { [gate]: 'true' } }), false, job);
|
||||
assert.equal(enabled(job, { action: 'opened', cancelled: true }), false, job);
|
||||
}
|
||||
for (const job of suites) {
|
||||
for (const result of ['failure', 'skipped', 'cancelled']) {
|
||||
assert.equal(enabled(job, { action: 'opened', results: { 'prepare-fuzz-targets': result } }), false, job);
|
||||
const build = job === 'fuzztest' ? 'build' : 'build-greptime-ci';
|
||||
assert.equal(enabled(job, { action: 'opened', results: { [build]: result } }), false, job);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
test('script tests must pass before any expensive integration job can start', () => {
|
||||
const jobs = ['build', 'sqlness', 'sqlness-kvbackend', 'export-import-v2-e2e',
|
||||
'run-multi-lang-tests', 'compat', ...prerequisites, ...suites];
|
||||
for (const job of jobs) {
|
||||
assert.equal(enabled(job, { action: 'opened' }), true, job);
|
||||
for (const result of ['failure', 'skipped', 'cancelled']) {
|
||||
assert.equal(enabled(job, { action: 'opened', results: { 'github-script-tests': result } }), false, job);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
test('script tests gate expensive Rust and Checks jobs', () => {
|
||||
for (const [file, jobs] of [
|
||||
['rust.yml', ['clippy', 'check-riscv64', 'check-windows', 'test', 'coverage']],
|
||||
['checks.yml', ['check']]
|
||||
]) {
|
||||
const workflow = readFileSync(resolve(workflows, file), 'utf8');
|
||||
for (const job of jobs) {
|
||||
const event = job === 'coverage' ? 'merge_group' : 'workflow_dispatch';
|
||||
assert.equal(enabled(job, { workflow, event }), true, job);
|
||||
for (const result of ['failure', 'skipped', 'cancelled']) {
|
||||
assert.equal(enabled(job, { workflow, event, results: { 'github-script-tests': result } }), false, job);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -0,0 +1,125 @@
|
||||
// Copyright 2023 Greptime Team
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
// Run with: node --test .github/scripts/tests/nightly-merge.test.cjs
|
||||
const { readFileSync } = require('node:fs');
|
||||
const { resolve } = require('node:path');
|
||||
const assert = require('node:assert/strict');
|
||||
const { test } = require('node:test');
|
||||
const AsyncFunction = Object.getPrototypeOf(async function () {}).constructor;
|
||||
const workflow = readFileSync(resolve(__dirname, '../../workflows/nightly-merge.yml'), 'utf8');
|
||||
const scripts = [...workflow.matchAll(/ script: \|\n((?: .*\n|\n)+)/g)]
|
||||
.map(match => new AsyncFunction('github', 'context', 'core', 'process', match[1].replace(/^ /gm, '')));
|
||||
assert.equal(scripts.length, 2);
|
||||
const checked = '- [x] Merge during the nightly window <!-- nightly-merge -->';
|
||||
|
||||
async function run({ sync = false, body = checked, labels = ['merge nightly'],
|
||||
detail = {}, current = {}, threads = [[true]], count = 1, dryRun = false,
|
||||
failFirst = false } = {}) {
|
||||
const calls = [];
|
||||
let page = 0;
|
||||
const github = {
|
||||
rest: {
|
||||
pulls: { get: async () => ({ data: { state: 'open', draft: false, base: { ref: 'main' },
|
||||
body, labels: labels.map(name => ({ name })), ...current } }) },
|
||||
issues: {
|
||||
listForRepo: () => {},
|
||||
addLabels: async args => calls.push(['add', args.labels]),
|
||||
removeLabel: async args => calls.push(['remove', args.name])
|
||||
}
|
||||
},
|
||||
paginate: async () => Array.from({ length: count }, (_, i) => ({ number: i + 1, pull_request: {} })),
|
||||
graphql: async (query, args) => {
|
||||
if (query.includes('mutation')) {
|
||||
calls.push(['enqueue', args]);
|
||||
if (failFirst && calls.filter(call => call[0] === 'enqueue').length === 1) throw Error('head changed');
|
||||
return {};
|
||||
}
|
||||
if (query.includes('reviewThreads')) {
|
||||
const index = page++ % threads.length;
|
||||
calls.push(['threads', args.cursor]);
|
||||
return { repository: { pullRequest: { reviewThreads: {
|
||||
nodes: threads[index].map(isResolved => ({ isResolved })),
|
||||
pageInfo: { hasNextPage: index + 1 < threads.length, endCursor: `page-${index}` }
|
||||
} } } };
|
||||
}
|
||||
return { repository: { pullRequest: { id: `PR_${args.number}`, headRefOid: 'abc',
|
||||
reviewDecision: 'APPROVED', mergeStateStatus: 'CLEAN', ...detail } } };
|
||||
}
|
||||
};
|
||||
const summary = { addHeading() { return this; }, addTable(rows) { calls.push(['summary', rows]); return this; }, async write() {} };
|
||||
await scripts[sync ? 0 : 1](github,
|
||||
{ repo: { owner: 'GreptimeTeam', repo: 'greptimedb' }, payload: { pull_request: { number: 1 } } },
|
||||
{ summary, info() {}, warning() {}, setFailed: message => calls.push(['failed', message]) },
|
||||
{ env: { DRY_RUN: String(dryRun) } });
|
||||
return calls;
|
||||
}
|
||||
|
||||
test('label sync grants PR label write permission without checking out PR code', () => {
|
||||
const syncJob = workflow.split(' sync-label:\n')[1].split(' enqueue:\n')[0];
|
||||
assert.match(syncJob, /^ pull-requests: write$/m);
|
||||
assert.doesNotMatch(syncJob, /uses: actions\/checkout/);
|
||||
});
|
||||
|
||||
test('template opts in and checkbox edits reconcile only the nightly label', async () => {
|
||||
assert.ok(readFileSync(resolve(__dirname, '../../pull_request_template.md'), 'utf8').includes(checked));
|
||||
assert.deepEqual(await run({ sync: true, labels: ['bug'] }), [['add', ['merge nightly']]]);
|
||||
assert.deepEqual(await run({ sync: true }), []);
|
||||
for (const body of [checked.replace('[x]', '[ ]')]) {
|
||||
assert.deepEqual(await run({ sync: true, body }), [['remove', 'merge nightly']]);
|
||||
}
|
||||
assert.deepEqual(await run({ sync: true, body: checked.replace('[x]', '[X]'), labels: [] }), [['add', ['merge nightly']]]);
|
||||
});
|
||||
|
||||
test('eligible PR is enqueued with its checked head; dry run performs no mutation', async () => {
|
||||
assert.deepEqual((await run()).filter(c => c[0] === 'enqueue'), [['enqueue', { id: 'PR_1', sha: 'abc' }]]);
|
||||
assert.equal((await run({ dryRun: true })).some(c => c[0] === 'enqueue'), false);
|
||||
});
|
||||
|
||||
test('each eligibility gate independently prevents enqueueing', async () => {
|
||||
for (const options of [
|
||||
{ labels: [] },
|
||||
{ current: { draft: true } }, { current: { state: 'closed' } }, { current: { base: { ref: 'release/v1.3' } } },
|
||||
{ detail: { reviewDecision: 'REVIEW_REQUIRED' } }, { detail: { reviewDecision: 'CHANGES_REQUESTED' } },
|
||||
{ detail: { mergeStateStatus: 'BLOCKED' } }, { detail: { mergeStateStatus: 'UNKNOWN' } },
|
||||
{ detail: { mergeQueueEntry: { id: 'entry' } } }, { detail: { autoMergeRequest: { enabledAt: 'now' } } },
|
||||
{ threads: [[false]] }, { threads: [[true], [false]] }
|
||||
]) {
|
||||
assert.equal((await run(options)).some(c => c[0] === 'enqueue'), false, JSON.stringify(options));
|
||||
}
|
||||
});
|
||||
|
||||
test('all thread pages are checked before enqueueing', async () => {
|
||||
const calls = await run({ threads: [[true], [true]] });
|
||||
assert.deepEqual(calls.filter(c => c[0] === 'threads'), [['threads', null], ['threads', 'page-0']]);
|
||||
assert.equal(calls.filter(c => c[0] === 'enqueue').length, 1);
|
||||
});
|
||||
|
||||
test('per-run cap and individual failures do not prevent later candidates', async () => {
|
||||
assert.equal((await run({ count: 8 })).filter(c => c[0] === 'enqueue').length, 5);
|
||||
const calls = await run({ count: 2, failFirst: true });
|
||||
assert.equal(calls.filter(c => c[0] === 'enqueue').length, 2);
|
||||
assert.equal(calls.filter(c => c[0] === 'failed').length, 1);
|
||||
});
|
||||
|
||||
test('label-only opt-in survives PRs without a template and does not require a checkbox', async () => {
|
||||
for (const body of ['', null, 'Existing PR description', `> ${checked}`]) {
|
||||
assert.deepEqual(await run({ sync: true, body }), []);
|
||||
assert.deepEqual(await run({ sync: true, body, labels: [] }), []);
|
||||
assert.equal((await run({ body })).filter(call => call[0] === 'enqueue').length, 1);
|
||||
assert.equal((await run({ body, labels: [] })).some(call => call[0] === 'enqueue'), false);
|
||||
}
|
||||
// The label is authoritative for admission, even before checkbox synchronization.
|
||||
assert.equal((await run({ body: checked.replace('[x]', '[ ]') })).some(call => call[0] === 'enqueue'), true);
|
||||
});
|
||||
@@ -136,7 +136,7 @@ class CiSlashTest(unittest.TestCase):
|
||||
|
||||
def test_fork_rerun_gates_cover_standard_jobs(self):
|
||||
import re
|
||||
for name, count in [("rust", 7), ("integration", 5), ("checks", 5), ("docs", 3)]:
|
||||
for name, count in [("rust", 6), ("integration", 8), ("checks", 6), ("docs", 3)]:
|
||||
workflow = (SCRIPT.parents[1] / "workflows" / (name + ".yml")).read_text()
|
||||
gates = re.findall(r"^ if:.*github.run_attempt > 1.*$", workflow, re.MULTILINE)
|
||||
self.assertEqual(len(gates), count, name)
|
||||
|
||||
@@ -71,45 +71,28 @@ jobs:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
persist-credentials: false
|
||||
- uses: actions/setup-node@v4
|
||||
- uses: ./.github/actions/github-script-tests
|
||||
|
||||
scope-rules:
|
||||
if: ${{ github.repository == 'GreptimeTeam/greptimedb' && (github.event_name != 'pull_request' || github.event.pull_request.draft == false || github.run_attempt > 1) }}
|
||||
name: CI Scope Rules
|
||||
# Same runner image as the `scope` job in integration.yml: if the rules file
|
||||
# stops parsing there, the gate silently runs every job, so this check exists
|
||||
# to fail the pull request instead.
|
||||
runs-on: ubuntu-slim
|
||||
timeout-minutes: 5
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
node-version: 24
|
||||
- name: Run Node GitHub script tests
|
||||
run: node --test .github/scripts/query-regression-comment.test.cjs
|
||||
- name: Setup uv
|
||||
uses: astral-sh/setup-uv@v3
|
||||
with:
|
||||
version: "latest"
|
||||
- name: Run check-version script tests
|
||||
run: uv run --no-project python .github/scripts/check-version-test.py
|
||||
- name: Run release Linux architecture tests
|
||||
run: python3 .github/scripts/release-linux-architectures-test.py
|
||||
- name: Run previous-release-tag script tests
|
||||
run: python3 .github/scripts/previous-release-tag-test.py
|
||||
- name: Run enterprise license check tests
|
||||
run: python3 scripts/check-enterprise-license-test.py
|
||||
- name: Run fuzz orchestration script tests
|
||||
run: .github/scripts/run-fuzz-targets-test.sh
|
||||
- name: Run CI comment-command tests
|
||||
run: python3 .github/scripts/tests/test_ci_slash.py
|
||||
- name: Run metric snapshot benchmark tests
|
||||
run: python3 -m unittest discover -s .github/scripts/tests -p 'test_metric_snapshot*.py'
|
||||
- name: Run query-regression Python tooling tests
|
||||
run: |
|
||||
python3 tests/perf/test_query_regression_runner_compaction_toctou.py
|
||||
python3 tests/perf/test_query_regression_runner_otlp_trace_load.py
|
||||
python3 tests/perf/test_query_regression_summary_otlp.py
|
||||
python3 tests/perf/test_query_regression_case_selection.py
|
||||
python3 tests/perf/test_query_regression_helpers.py
|
||||
python3 tests/perf/test_query_regression_nightly_refs.py
|
||||
python3 tests/perf/test_query_regression_slash.py
|
||||
python3 tests/perf/test_aliyun_ecs_runner_scripts.py
|
||||
python3 tests/perf/test_ci_runner_scripts.py
|
||||
python3 tests/perf/test_agent_observability_summary.py
|
||||
python3 tests/perf/test_tracesbench_summary.py
|
||||
persist-credentials: false
|
||||
- name: Show the interpreter
|
||||
run: python3 -VV
|
||||
- name: Validate .github/ci/scope-rules.toml
|
||||
run: python3 .github/ci/ci_scope_rules.py --check-paths
|
||||
|
||||
check:
|
||||
if: ${{ github.repository == 'GreptimeTeam/greptimedb' && (github.event_name != 'pull_request' || github.event.pull_request.draft == false || github.run_attempt > 1) }}
|
||||
if: ${{ needs['github-script-tests'].result == 'success' && github.repository == 'GreptimeTeam/greptimedb' && (github.event_name != 'pull_request' || github.event.pull_request.draft == false || github.run_attempt > 1) }}
|
||||
needs: [github-script-tests]
|
||||
name: Check
|
||||
runs-on: ${{ matrix.os }}
|
||||
strategy:
|
||||
|
||||
@@ -21,7 +21,7 @@ on:
|
||||
default: false
|
||||
type: boolean
|
||||
fuzz_profile:
|
||||
description: Fuzz profile selected by /ci fuzz
|
||||
description: Fuzz profile for a manual run or /ci fuzz
|
||||
required: false
|
||||
default: none
|
||||
type: choice
|
||||
@@ -42,8 +42,71 @@ concurrency:
|
||||
cancel-in-progress: true
|
||||
|
||||
jobs:
|
||||
build:
|
||||
github-script-tests:
|
||||
if: ${{ github.repository == 'GreptimeTeam/greptimedb' && (github.event_name != 'pull_request' || github.event.pull_request.draft == false || github.run_attempt > 1) }}
|
||||
name: GitHub Script Tests (Integration CI)
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 5
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
persist-credentials: false
|
||||
- uses: ./.github/actions/github-script-tests
|
||||
|
||||
# Which jobs this gate skips, and why: .github/ci/README.md.
|
||||
scope:
|
||||
name: CI Scope
|
||||
if: ${{ github.repository == 'GreptimeTeam/greptimedb' && (github.event_name != 'pull_request' || github.event.pull_request.draft == false || github.run_attempt > 1) }}
|
||||
# ubuntu-slim ships python3, git and curl; this job only classifies.
|
||||
runs-on: ubuntu-slim
|
||||
timeout-minutes: 10
|
||||
permissions:
|
||||
contents: read
|
||||
# `/pulls/{n}` and `/pulls/{n}/files`. An explicit block sets every
|
||||
# unlisted permission to none, and a 403 here would silently widen every
|
||||
# gate instead of classifying.
|
||||
pull-requests: read
|
||||
outputs:
|
||||
any_fuzz: ${{ steps.classify.outputs.any_fuzz }}
|
||||
build_ci_needed: ${{ steps.classify.outputs.build_ci_needed }}
|
||||
fuzz_standalone: ${{ steps.classify.outputs.fuzz_standalone }}
|
||||
fuzz_distributed: ${{ steps.classify.outputs.fuzz_distributed }}
|
||||
fuzz_chaos: ${{ steps.classify.outputs.fuzz_chaos }}
|
||||
fuzz_unstable: ${{ steps.classify.outputs.fuzz_unstable }}
|
||||
export_import_v2: ${{ steps.classify.outputs.export_import_v2 }}
|
||||
sqlness_kvbackend: ${{ steps.classify.outputs.sqlness_kvbackend }}
|
||||
steps:
|
||||
# Rules come from the pull request base (the queue base on merge_group),
|
||||
# so a pull request cannot weaken its own gate. If this job or the Classify
|
||||
# step fails, the outputs stay empty and every gate below treats an absent
|
||||
# value as "run", which keeps CI fail-open.
|
||||
- uses: actions/checkout@v4
|
||||
# A checkout failure leaves the outputs empty, which every gate treats
|
||||
# as "run"; letting the step fail would skip the gates instead.
|
||||
continue-on-error: true
|
||||
with:
|
||||
ref: ${{ github.event.pull_request.base.sha || github.event.merge_group.base_sha || github.sha }}
|
||||
persist-credentials: false
|
||||
- name: Classify
|
||||
id: classify
|
||||
continue-on-error: true
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
CI_SCOPE_FORCE_ALL: ${{ vars.CI_SCOPE_FORCE_ALL || 'false' }}
|
||||
run: |
|
||||
args=(--repo "$GITHUB_REPOSITORY" --event "$GITHUB_EVENT_NAME"
|
||||
--github-output "$GITHUB_OUTPUT"
|
||||
--summary "$GITHUB_STEP_SUMMARY")
|
||||
if [[ "${GITHUB_EVENT_NAME}" == "pull_request" ]]; then
|
||||
args+=(--pr "${{ github.event.pull_request.number }}"
|
||||
--head-sha "${{ github.event.pull_request.head.sha }}"
|
||||
--base-sha "${{ github.event.pull_request.base.sha }}")
|
||||
fi
|
||||
python3 .github/ci/ci_scope.py "${args[@]}"
|
||||
|
||||
build:
|
||||
if: ${{ needs['github-script-tests'].result == 'success' && github.repository == 'GreptimeTeam/greptimedb' && (github.event_name != 'pull_request' || github.event.pull_request.draft == false || github.run_attempt > 1) }}
|
||||
needs: [github-script-tests]
|
||||
name: Build GreptimeDB binaries
|
||||
runs-on: ${{ matrix.os }}
|
||||
strategy:
|
||||
@@ -104,9 +167,9 @@ jobs:
|
||||
version: current
|
||||
|
||||
sqlness:
|
||||
if: ${{ github.repository == 'GreptimeTeam/greptimedb' && (github.event_name != 'pull_request' || github.event.pull_request.draft == false || github.run_attempt > 1) }}
|
||||
if: ${{ needs['github-script-tests'].result == 'success' && github.repository == 'GreptimeTeam/greptimedb' && (github.event_name != 'pull_request' || github.event.pull_request.draft == false || github.run_attempt > 1) }}
|
||||
name: Sqlness Test (${{ matrix.mode.name }})
|
||||
needs: build
|
||||
needs: [github-script-tests, build]
|
||||
runs-on: ${{ matrix.os }}
|
||||
strategy:
|
||||
fail-fast: false
|
||||
@@ -116,28 +179,12 @@ jobs:
|
||||
- name: "Basic"
|
||||
opts: ""
|
||||
kafka: false
|
||||
postgres: false
|
||||
mysql: false
|
||||
- name: "Remote WAL"
|
||||
opts: "-w kafka -k 127.0.0.1:9092"
|
||||
kafka: true
|
||||
postgres: false
|
||||
mysql: false
|
||||
- name: "PostgreSQL KvBackend"
|
||||
opts: "--setup-pg postgresql://greptimedb:admin@127.0.0.1:5432/postgres"
|
||||
kafka: false
|
||||
postgres: true
|
||||
mysql: false
|
||||
- name: "MySQL KvBackend"
|
||||
opts: "--setup-mysql mysql://greptimedb:admin@127.0.0.1:3306/mysql"
|
||||
kafka: false
|
||||
postgres: false
|
||||
mysql: true
|
||||
- name: "Flat format"
|
||||
opts: "--enable-flat-format"
|
||||
kafka: false
|
||||
postgres: false
|
||||
mysql: false
|
||||
timeout-minutes: 60
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
@@ -149,16 +196,6 @@ jobs:
|
||||
working-directory: tests-integration/fixtures
|
||||
run: ../../.github/scripts/pull-test-deps-images.sh && docker compose up -d --wait kafka
|
||||
|
||||
- if: matrix.mode.postgres
|
||||
name: Setup PostgreSQL
|
||||
working-directory: tests-integration/fixtures
|
||||
run: ../../.github/scripts/pull-test-deps-images.sh && docker compose up -d --wait postgres
|
||||
|
||||
- if: matrix.mode.mysql
|
||||
name: Setup MySQL
|
||||
working-directory: tests-integration/fixtures
|
||||
run: ../../.github/scripts/pull-test-deps-images.sh && docker compose up -d --wait mysql
|
||||
|
||||
- name: Download pre-built binaries
|
||||
uses: actions/download-artifact@v4
|
||||
with:
|
||||
@@ -183,10 +220,68 @@ jobs:
|
||||
/tmp/sqlness*
|
||||
retention-days: 3
|
||||
|
||||
sqlness-kvbackend:
|
||||
# The two foreign KV backends are the only sqlness legs that are not
|
||||
# required checks, so they are the only ones this gate may skip. They run
|
||||
# the same cases as the `Basic` leg, so the diff only matters when it can
|
||||
# reach the backend itself; the merge queue runs them regardless.
|
||||
if: ${{ !cancelled() && needs['github-script-tests'].result == 'success' && github.repository == 'GreptimeTeam/greptimedb' && (github.event_name != 'pull_request' || github.event.pull_request.draft == false || github.run_attempt > 1) && needs.build.result == 'success' && needs.scope.outputs.sqlness_kvbackend != 'false' }}
|
||||
name: Sqlness Test (${{ matrix.mode.name }})
|
||||
needs: [github-script-tests, scope, build]
|
||||
runs-on: ${{ matrix.os }}
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
os: [ ubuntu-latest ]
|
||||
mode:
|
||||
- name: "Metasrv on PostgreSQL"
|
||||
id: "metasrv-postgres"
|
||||
opts: "--setup-pg postgresql://greptimedb:admin@127.0.0.1:5432/postgres"
|
||||
postgres: true
|
||||
mysql: false
|
||||
- name: "Metasrv on MySQL"
|
||||
id: "metasrv-mysql"
|
||||
opts: "--setup-mysql mysql://greptimedb:admin@127.0.0.1:3306/mysql"
|
||||
postgres: false
|
||||
mysql: true
|
||||
timeout-minutes: 60
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
persist-credentials: false
|
||||
|
||||
- if: matrix.mode.postgres
|
||||
name: Setup PostgreSQL
|
||||
working-directory: tests-integration/fixtures
|
||||
run: ../../.github/scripts/pull-test-deps-images.sh && docker compose up -d --wait postgres
|
||||
|
||||
- if: matrix.mode.mysql
|
||||
name: Setup MySQL
|
||||
working-directory: tests-integration/fixtures
|
||||
run: ../../.github/scripts/pull-test-deps-images.sh && docker compose up -d --wait mysql
|
||||
|
||||
- name: Download pre-built binaries
|
||||
uses: actions/download-artifact@v4
|
||||
with:
|
||||
name: bins
|
||||
path: .
|
||||
- name: Unzip binaries
|
||||
run: tar -xvf ./bins.tar.gz
|
||||
- name: Run sqlness
|
||||
run: RUST_BACKTRACE=1 ./bins/sqlness-runner bare ${{ matrix.mode.opts }} -c ./tests/cases --bins-dir ./bins --preserve-state
|
||||
- name: Upload sqlness logs
|
||||
if: failure()
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: sqlness-logs-${{ matrix.mode.name }}
|
||||
path: |
|
||||
/tmp/sqlness*
|
||||
retention-days: 3
|
||||
|
||||
export-import-v2-e2e:
|
||||
if: ${{ github.repository == 'GreptimeTeam/greptimedb' && (github.event_name != 'pull_request' || github.event.pull_request.draft == false || github.run_attempt > 1) }}
|
||||
if: ${{ !cancelled() && needs['github-script-tests'].result == 'success' && github.repository == 'GreptimeTeam/greptimedb' && (github.event_name != 'pull_request' || github.event.pull_request.draft == false || github.run_attempt > 1) && needs.build.result == 'success' && needs.scope.outputs.export_import_v2 != 'false' }}
|
||||
name: Export/Import V2 E2E Test
|
||||
needs: build
|
||||
needs: [github-script-tests, scope, build]
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 60
|
||||
steps:
|
||||
@@ -254,9 +349,9 @@ jobs:
|
||||
retention-days: 3
|
||||
|
||||
run-multi-lang-tests:
|
||||
if: ${{ github.repository == 'GreptimeTeam/greptimedb' && (github.event_name != 'pull_request' || github.event.pull_request.draft == false || github.run_attempt > 1) }}
|
||||
if: ${{ needs['github-script-tests'].result == 'success' && github.repository == 'GreptimeTeam/greptimedb' && (github.event_name != 'pull_request' || github.event.pull_request.draft == false || github.run_attempt > 1) }}
|
||||
name: Run Multi-language SDK Tests
|
||||
needs: build
|
||||
needs: [github-script-tests, build]
|
||||
uses: ./.github/workflows/run-multi-lang-tests.yml
|
||||
with:
|
||||
artifact-name: bins
|
||||
@@ -279,9 +374,9 @@ jobs:
|
||||
run: python3 .github/scripts/update-compat-versions.py --check --published-only --check-anchors
|
||||
|
||||
compat:
|
||||
if: ${{ github.repository == 'GreptimeTeam/greptimedb' && (github.event_name == 'merge_group' || github.event_name == 'workflow_dispatch' || github.event_name == 'schedule' || (github.event_name == 'pull_request' && (github.event.action == 'ready_for_review' || (github.event.action == 'opened' && github.event.pull_request.draft == false)))) }}
|
||||
if: ${{ needs['github-script-tests'].result == 'success' && github.repository == 'GreptimeTeam/greptimedb' && (github.event_name == 'merge_group' || github.event_name == 'workflow_dispatch' || github.event_name == 'schedule' || (github.event_name == 'pull_request' && (github.event.action == 'ready_for_review' || (github.event.action == 'opened' && github.event.pull_request.draft == false)))) }}
|
||||
name: Compatibility Test (recent releases)
|
||||
needs: build
|
||||
needs: [github-script-tests, build]
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 30
|
||||
steps:
|
||||
@@ -318,9 +413,12 @@ jobs:
|
||||
path: /tmp/sqlness-compat*
|
||||
retention-days: 3
|
||||
|
||||
# Fuzz runs on opening a ready PR, marking it ready, manual dispatch, and
|
||||
# the scheduled main run. Synchronize events keep the core integration tests.
|
||||
prepare-fuzz-targets:
|
||||
if: ${{ github.repository == 'GreptimeTeam/greptimedb' && ((github.event_name == 'pull_request' && github.event.pull_request.draft == false) || (github.event_name == 'workflow_dispatch' && inputs.ci_command)) && (github.event_name == 'pull_request' || inputs.fuzz_profile != 'none') }}
|
||||
if: ${{ !cancelled() && needs['github-script-tests'].result == 'success' && github.repository == 'GreptimeTeam/greptimedb' && (github.event_name == 'schedule' || (github.event_name == 'pull_request' && github.event.pull_request.draft == false && (github.event.action == 'opened' || github.event.action == 'ready_for_review')) || (github.event_name == 'workflow_dispatch' && (inputs.fuzz_profile != 'none'))) && needs.scope.outputs.any_fuzz != 'false' }}
|
||||
name: Prepare Fuzz Targets
|
||||
needs: [github-script-tests, scope]
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 60
|
||||
steps:
|
||||
@@ -433,9 +531,9 @@ jobs:
|
||||
if-no-files-found: error
|
||||
|
||||
fuzztest:
|
||||
if: ${{ github.repository == 'GreptimeTeam/greptimedb' && ((github.event_name == 'pull_request' && github.event.pull_request.draft == false) || (github.event_name == 'workflow_dispatch' && inputs.ci_command)) && (github.event_name == 'pull_request' || inputs.fuzz_profile == 'standalone' || inputs.fuzz_profile == 'all') }}
|
||||
if: ${{ !cancelled() && needs['github-script-tests'].result == 'success' && github.repository == 'GreptimeTeam/greptimedb' && (github.event_name == 'schedule' || (github.event_name == 'pull_request' && github.event.pull_request.draft == false && (github.event.action == 'opened' || github.event.action == 'ready_for_review')) || (github.event_name == 'workflow_dispatch' && (inputs.fuzz_profile == 'standalone' || inputs.fuzz_profile == 'all'))) && needs.build.result == 'success' && needs['prepare-fuzz-targets'].result == 'success' && needs.scope.outputs.fuzz_standalone != 'false' }}
|
||||
name: Fuzz Test (Standalone, ${{ matrix.group.name }})
|
||||
needs: [build, prepare-fuzz-targets]
|
||||
needs: [github-script-tests, build, prepare-fuzz-targets, scope]
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 60
|
||||
strategy:
|
||||
@@ -514,9 +612,9 @@ jobs:
|
||||
artifact-name: fuzz-standalone-${{ matrix.group.id }}
|
||||
|
||||
unstable-fuzztest:
|
||||
if: ${{ github.repository == 'GreptimeTeam/greptimedb' && ((github.event_name == 'pull_request' && github.event.pull_request.draft == false) || (github.event_name == 'workflow_dispatch' && inputs.ci_command)) && (github.event_name == 'pull_request' || inputs.fuzz_profile == 'standalone' || inputs.fuzz_profile == 'all') }}
|
||||
if: ${{ !cancelled() && needs['github-script-tests'].result == 'success' && github.repository == 'GreptimeTeam/greptimedb' && (github.event_name == 'schedule' || (github.event_name == 'pull_request' && github.event.pull_request.draft == false && (github.event.action == 'opened' || github.event.action == 'ready_for_review')) || (github.event_name == 'workflow_dispatch' && (inputs.fuzz_profile == 'standalone' || inputs.fuzz_profile == 'all'))) && needs['build-greptime-ci'].result == 'success' && needs['prepare-fuzz-targets'].result == 'success' && needs.scope.outputs.fuzz_unstable != 'false' }}
|
||||
name: Unstable Fuzz Test
|
||||
needs: [build-greptime-ci, prepare-fuzz-targets]
|
||||
needs: [github-script-tests, build-greptime-ci, prepare-fuzz-targets, scope]
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 60
|
||||
steps:
|
||||
@@ -574,8 +672,9 @@ jobs:
|
||||
artifact-name: fuzz-unstable-standalone
|
||||
|
||||
build-greptime-ci:
|
||||
if: ${{ github.repository == 'GreptimeTeam/greptimedb' && ((github.event_name == 'pull_request' && github.event.pull_request.draft == false) || (github.event_name == 'workflow_dispatch' && inputs.ci_command && inputs.fuzz_profile != 'none')) }}
|
||||
if: ${{ !cancelled() && needs['github-script-tests'].result == 'success' && github.repository == 'GreptimeTeam/greptimedb' && (github.event_name == 'schedule' || (github.event_name == 'pull_request' && github.event.pull_request.draft == false && (github.event.action == 'opened' || github.event.action == 'ready_for_review')) || (github.event_name == 'workflow_dispatch' && (inputs.fuzz_profile != 'none'))) && needs.scope.outputs.build_ci_needed != 'false' }}
|
||||
name: Build GreptimeDB binary (profile-CI)
|
||||
needs: [github-script-tests, scope]
|
||||
runs-on: ${{ matrix.os }}
|
||||
strategy:
|
||||
matrix:
|
||||
@@ -634,10 +733,10 @@ jobs:
|
||||
version: current
|
||||
|
||||
distributed-fuzztest:
|
||||
if: ${{ github.repository == 'GreptimeTeam/greptimedb' && ((github.event_name == 'pull_request' && github.event.pull_request.draft == false) || (github.event_name == 'workflow_dispatch' && inputs.ci_command)) && (github.event_name == 'pull_request' || inputs.fuzz_profile == 'distributed' || inputs.fuzz_profile == 'all') }}
|
||||
if: ${{ !cancelled() && needs['github-script-tests'].result == 'success' && github.repository == 'GreptimeTeam/greptimedb' && (github.event_name == 'schedule' || (github.event_name == 'pull_request' && github.event.pull_request.draft == false && (github.event.action == 'opened' || github.event.action == 'ready_for_review')) || (github.event_name == 'workflow_dispatch' && (inputs.fuzz_profile == 'distributed' || inputs.fuzz_profile == 'all'))) && needs['build-greptime-ci'].result == 'success' && needs['prepare-fuzz-targets'].result == 'success' && needs.scope.outputs.fuzz_distributed != 'false' }}
|
||||
name: Fuzz Test (Distributed, ${{ matrix.mode.name }}, ${{ matrix.group.name }})
|
||||
runs-on: ubuntu-latest
|
||||
needs: [build-greptime-ci, prepare-fuzz-targets]
|
||||
needs: [github-script-tests, build-greptime-ci, prepare-fuzz-targets, scope]
|
||||
timeout-minutes: 60
|
||||
strategy:
|
||||
fail-fast: false
|
||||
@@ -873,10 +972,10 @@ jobs:
|
||||
docker system prune -f
|
||||
|
||||
distributed-fuzztest-with-chaos:
|
||||
if: ${{ github.repository == 'GreptimeTeam/greptimedb' && ((github.event_name == 'pull_request' && github.event.pull_request.draft == false) || (github.event_name == 'workflow_dispatch' && inputs.ci_command)) && (github.event_name == 'pull_request' || inputs.fuzz_profile == 'chaos' || inputs.fuzz_profile == 'all') }}
|
||||
if: ${{ !cancelled() && needs['github-script-tests'].result == 'success' && github.repository == 'GreptimeTeam/greptimedb' && (github.event_name == 'schedule' || (github.event_name == 'pull_request' && github.event.pull_request.draft == false && (github.event.action == 'opened' || github.event.action == 'ready_for_review')) || (github.event_name == 'workflow_dispatch' && (inputs.fuzz_profile == 'chaos' || inputs.fuzz_profile == 'all'))) && needs['build-greptime-ci'].result == 'success' && needs['prepare-fuzz-targets'].result == 'success' && needs.scope.outputs.fuzz_chaos != 'false' }}
|
||||
name: Fuzz Test with Chaos (Distributed, ${{ matrix.mode.name }}, ${{ matrix.group.name }})
|
||||
runs-on: ubuntu-latest
|
||||
needs: [build-greptime-ci, prepare-fuzz-targets]
|
||||
needs: [github-script-tests, build-greptime-ci, prepare-fuzz-targets, scope]
|
||||
timeout-minutes: 60
|
||||
strategy:
|
||||
fail-fast: false
|
||||
|
||||
@@ -0,0 +1,142 @@
|
||||
# Setup and behavior: .github/nightly-merge.md
|
||||
name: Nightly Merge
|
||||
|
||||
on:
|
||||
pull_request_target:
|
||||
types: [opened, edited, reopened]
|
||||
schedule:
|
||||
# Hourly from 02:10 through 08:10 Asia/Shanghai (UTC+8), inclusive.
|
||||
# GitHub may delay scheduled runs.
|
||||
- cron: '10 0,18-23 * * *'
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
dry_run:
|
||||
description: List eligible PRs without adding them to the merge queue
|
||||
type: boolean
|
||||
default: true
|
||||
|
||||
permissions: {}
|
||||
|
||||
jobs:
|
||||
sync-label:
|
||||
if: github.repository == 'GreptimeTeam/greptimedb' && github.event_name == 'pull_request_target'
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 5
|
||||
permissions:
|
||||
# PR label mutations require pull-request write permission.
|
||||
pull-requests: write
|
||||
issues: write
|
||||
concurrency:
|
||||
group: nightly-merge-label-${{ github.event.pull_request.number }}
|
||||
cancel-in-progress: false
|
||||
steps:
|
||||
# No checkout: PR contents are untrusted data, never executable code.
|
||||
- uses: actions/github-script@v7
|
||||
with:
|
||||
script: |
|
||||
const { owner, repo } = context.repo;
|
||||
const issue_number = context.payload.pull_request.number;
|
||||
const { data: pr } = await github.rest.pulls.get({ owner, repo, pull_number: issue_number });
|
||||
const checkbox = /^- \[([ xX])\] Merge during the nightly window <!-- nightly-merge -->\s*$/m.exec(pr.body || '');
|
||||
// PRs without the template manage their opt-in through the label.
|
||||
if (!checkbox) return;
|
||||
const selected = checkbox[1].toLowerCase() === 'x';
|
||||
const label = 'merge nightly';
|
||||
const labeled = pr.labels.some(item => item.name === label);
|
||||
if (selected && !labeled) {
|
||||
await github.rest.issues.addLabels({ owner, repo, issue_number, labels: [label] });
|
||||
} else if (!selected && labeled) {
|
||||
await github.rest.issues.removeLabel({ owner, repo, issue_number, name: label });
|
||||
}
|
||||
|
||||
enqueue:
|
||||
if: github.repository == 'GreptimeTeam/greptimedb' && github.event_name != 'pull_request_target'
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 10
|
||||
concurrency:
|
||||
group: nightly-merge-enqueue
|
||||
cancel-in-progress: false
|
||||
steps:
|
||||
# Reuses the automation credential used by backport and compat updates.
|
||||
# A PAT (or App token) lets subsequent merge_group workflows run.
|
||||
- uses: actions/github-script@v7
|
||||
env:
|
||||
DRY_RUN: ${{ github.event_name == 'workflow_dispatch' && inputs.dry_run }}
|
||||
with:
|
||||
github-token: ${{ secrets.GH_PERSONAL_ACCESS_TOKEN }}
|
||||
script: |
|
||||
const { owner, repo } = context.repo;
|
||||
const dryRun = process.env.DRY_RUN === 'true';
|
||||
const candidates = await github.paginate(github.rest.issues.listForRepo, {
|
||||
owner, repo, state: 'open', labels: 'merge nightly',
|
||||
sort: 'created', direction: 'asc', per_page: 100
|
||||
});
|
||||
const rows = [];
|
||||
let enqueued = 0;
|
||||
for (const candidate of candidates) {
|
||||
if (!candidate.pull_request || enqueued >= 5) continue;
|
||||
const number = candidate.number;
|
||||
try {
|
||||
// Fetch current labels and PR state, not the earlier list snapshot.
|
||||
const { data: current } = await github.rest.pulls.get({ owner, repo, pull_number: number });
|
||||
if (current.state !== 'open' || current.draft || current.base.ref !== 'main' ||
|
||||
!current.labels.some(label => label.name === 'merge nightly')) {
|
||||
rows.push([String(number), 'Skipped: not opted in, draft, closed, or not targeting main']);
|
||||
continue;
|
||||
}
|
||||
const { repository: { pullRequest: pr } } = await github.graphql(`
|
||||
query($owner: String!, $repo: String!, $number: Int!) {
|
||||
repository(owner: $owner, name: $repo) {
|
||||
pullRequest(number: $number) {
|
||||
id headRefOid reviewDecision mergeStateStatus
|
||||
mergeQueueEntry { id }
|
||||
autoMergeRequest { enabledAt }
|
||||
}
|
||||
}
|
||||
}`, { owner, repo, number });
|
||||
if (pr.mergeQueueEntry || pr.autoMergeRequest ||
|
||||
pr.reviewDecision !== 'APPROVED' || pr.mergeStateStatus !== 'CLEAN') {
|
||||
rows.push([String(number), 'Skipped: already queued/auto-merge enabled, or not approved and clean']);
|
||||
continue;
|
||||
}
|
||||
let cursor = null;
|
||||
let unresolved = false;
|
||||
do {
|
||||
const { repository: { pullRequest: { reviewThreads } } } = await github.graphql(`
|
||||
query($owner: String!, $repo: String!, $number: Int!, $cursor: String) {
|
||||
repository(owner: $owner, name: $repo) {
|
||||
pullRequest(number: $number) {
|
||||
reviewThreads(first: 100, after: $cursor) {
|
||||
nodes { isResolved }
|
||||
pageInfo { hasNextPage endCursor }
|
||||
}
|
||||
}
|
||||
}
|
||||
}`, { owner, repo, number, cursor });
|
||||
unresolved = reviewThreads.nodes.some(thread => !thread.isResolved);
|
||||
cursor = reviewThreads.pageInfo.hasNextPage ? reviewThreads.pageInfo.endCursor : null;
|
||||
} while (cursor && !unresolved);
|
||||
if (unresolved) {
|
||||
rows.push([String(number), 'Skipped: unresolved review threads']);
|
||||
continue;
|
||||
}
|
||||
if (!dryRun) {
|
||||
// GitHub enforces branch rules; never bypass or enable auto-merge.
|
||||
await github.graphql(`
|
||||
mutation($id: ID!, $sha: GitObjectID!) {
|
||||
enqueuePullRequest(input: {pullRequestId: $id, expectedHeadOid: $sha}) {
|
||||
mergeQueueEntry { id }
|
||||
}
|
||||
}`, { id: pr.id, sha: pr.headRefOid });
|
||||
}
|
||||
enqueued++;
|
||||
rows.push([String(number), dryRun ? 'Would enqueue' : 'Enqueued']);
|
||||
} catch (error) {
|
||||
core.warning(`PR #${number}: ${error.message}`);
|
||||
rows.push([String(number), 'Failed: see workflow logs']);
|
||||
core.setFailed('Some PRs could not be processed; see workflow logs.');
|
||||
}
|
||||
}
|
||||
for (const [number, result] of rows) core.info(`PR #${number}: ${result}`);
|
||||
await core.summary.addHeading(dryRun ? 'Nightly merge (dry run)' : 'Nightly merge')
|
||||
.addTable([['PR', 'Result'], ...rows]).write();
|
||||
+23
-48
@@ -31,6 +31,17 @@ concurrency:
|
||||
cancel-in-progress: true
|
||||
|
||||
jobs:
|
||||
github-script-tests:
|
||||
if: ${{ github.repository == 'GreptimeTeam/greptimedb' && (github.event_name != 'pull_request' || github.event.pull_request.draft == false || github.run_attempt > 1) }}
|
||||
name: GitHub Script Tests (Rust CI)
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 5
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
persist-credentials: false
|
||||
- uses: ./.github/actions/github-script-tests
|
||||
|
||||
fmt:
|
||||
if: ${{ github.repository == 'GreptimeTeam/greptimedb' && (github.event_name != 'pull_request' || github.event.pull_request.draft == false || github.run_attempt > 1) }}
|
||||
name: Rustfmt
|
||||
@@ -50,7 +61,8 @@ jobs:
|
||||
run: make fmt-check
|
||||
|
||||
clippy:
|
||||
if: ${{ github.repository == 'GreptimeTeam/greptimedb' && (github.event_name != 'pull_request' || github.event.pull_request.draft == false || github.run_attempt > 1) }}
|
||||
if: ${{ needs['github-script-tests'].result == 'success' && github.repository == 'GreptimeTeam/greptimedb' && (github.event_name != 'pull_request' || github.event.pull_request.draft == false || github.run_attempt > 1) }}
|
||||
needs: [github-script-tests]
|
||||
name: Clippy
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 60
|
||||
@@ -94,7 +106,9 @@ jobs:
|
||||
run: make check-udeps
|
||||
|
||||
check-riscv64:
|
||||
if: ${{ github.repository == 'GreptimeTeam/greptimedb' && (github.event_name != 'pull_request' || github.event.pull_request.draft == false || github.run_attempt > 1) }}
|
||||
# Keep platform coverage on the weekday schedule and allow manual checks.
|
||||
if: ${{ needs['github-script-tests'].result == 'success' && github.repository == 'GreptimeTeam/greptimedb' && (github.event_name == 'schedule' || github.event_name == 'workflow_dispatch') }}
|
||||
needs: [github-script-tests]
|
||||
name: Check riscv64 build
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 90
|
||||
@@ -120,7 +134,9 @@ jobs:
|
||||
run: cargo check --locked --workspace --all-targets --features servers/dashboard --target riscv64gc-unknown-linux-gnu
|
||||
|
||||
check-windows:
|
||||
if: ${{ github.repository == 'GreptimeTeam/greptimedb' && (github.event_name != 'pull_request' || github.event.pull_request.draft == false || github.run_attempt > 1) }}
|
||||
# Keep platform coverage on the weekday schedule and allow manual checks.
|
||||
if: ${{ needs['github-script-tests'].result == 'success' && github.repository == 'GreptimeTeam/greptimedb' && (github.event_name == 'schedule' || github.event_name == 'workflow_dispatch') }}
|
||||
needs: [github-script-tests]
|
||||
name: Check Windows build
|
||||
runs-on: windows-2022
|
||||
timeout-minutes: 60
|
||||
@@ -148,48 +164,6 @@ jobs:
|
||||
env:
|
||||
RUSTFLAGS: "-D warnings"
|
||||
|
||||
test-windows:
|
||||
if: ${{ github.repository == 'GreptimeTeam/greptimedb' && (github.event_name != 'pull_request' || github.event.pull_request.draft == false) }}
|
||||
name: Test Windows
|
||||
runs-on: windows-2022
|
||||
timeout-minutes: 90
|
||||
env:
|
||||
CARGO_INCREMENTAL: 0
|
||||
CARGO_PROFILE_DEV_DEBUG: 0
|
||||
CARGO_PROFILE_TEST_DEBUG: 0
|
||||
RUSTFLAGS: "-D warnings -C linker=lld-link"
|
||||
RUST_BACKTRACE: 1
|
||||
RUST_MIN_STACK: 8388608 # 8MB
|
||||
steps:
|
||||
- run: git config --global core.autocrlf false
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
persist-credentials: false
|
||||
- uses: ./.github/actions/setup-cyborg
|
||||
- uses: taiki-e/install-action@v2
|
||||
with:
|
||||
tool: protoc@3.23.4
|
||||
- uses: KyleMayes/install-llvm-action@v1
|
||||
with:
|
||||
version: "14.0"
|
||||
- uses: actions-rust-lang/setup-rust-toolchain@v1
|
||||
with:
|
||||
cache: false
|
||||
- name: Rust Cache
|
||||
uses: Swatinem/rust-cache@v2
|
||||
with:
|
||||
shared-key: "test-windows"
|
||||
cache-all-crates: "true"
|
||||
save-if: ${{ github.ref == 'refs/heads/main' }}
|
||||
- name: Install Cargo Nextest
|
||||
uses: taiki-e/install-action@nextest
|
||||
- name: Install WSL distribution
|
||||
uses: Vampire/setup-wsl@v2
|
||||
with:
|
||||
distribution: Ubuntu-22.04
|
||||
- name: Run Windows tests
|
||||
run: cargo nextest run --locked --workspace -F dashboard --no-fail-fast
|
||||
|
||||
conflict-check:
|
||||
if: ${{ github.repository == 'GreptimeTeam/greptimedb' && (github.event_name != 'pull_request' || github.event.pull_request.draft == false || github.run_attempt > 1) }}
|
||||
name: Check for conflict
|
||||
@@ -202,10 +176,10 @@ jobs:
|
||||
uses: olivernybroe/action-conflict-finder@v4.0
|
||||
|
||||
test:
|
||||
if: ${{ github.repository == 'GreptimeTeam/greptimedb' && github.event_name != 'merge_group' && (github.event_name != 'pull_request' || github.event.pull_request.draft == false || github.run_attempt > 1) }}
|
||||
if: ${{ needs['github-script-tests'].result == 'success' && github.repository == 'GreptimeTeam/greptimedb' && github.event_name != 'merge_group' && (github.event_name != 'pull_request' || github.event.pull_request.draft == false || github.run_attempt > 1) }}
|
||||
runs-on: ubuntu-22.04-arm
|
||||
timeout-minutes: 60
|
||||
needs: [conflict-check, clippy, fmt, check-udeps]
|
||||
needs: [github-script-tests, conflict-check, clippy, fmt, check-udeps]
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
@@ -258,7 +232,8 @@ jobs:
|
||||
UNITTEST_LOG_DIR: "__unittest_logs"
|
||||
|
||||
coverage:
|
||||
if: ${{ github.repository == 'GreptimeTeam/greptimedb' && github.event_name == 'merge_group' }}
|
||||
if: ${{ needs['github-script-tests'].result == 'success' && github.repository == 'GreptimeTeam/greptimedb' && github.event_name == 'merge_group' }}
|
||||
needs: [github-script-tests]
|
||||
runs-on: ubuntu-22.04-8-cores
|
||||
timeout-minutes: 60
|
||||
steps:
|
||||
|
||||
Reference in New Issue
Block a user