Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -98,14 +98,16 @@ jobs:
- name: Choose the lanes this change needs
id: plan
env:
# A merge queue group names the main commit it starts from.
# A merge queue group names the commit it starts from: main, or the
# group queued ahead of it.
BASE: ${{ github.event.merge_group.base_sha || 'HEAD^1' }}
GH_TOKEN: ${{ github.token }}
# The crate graph comes from `cargo metadata`, which needs no build. A
# push compares from the last main commit whose push run passed, not
# from `before`: GitHub replaces a pending run, and the replaced run's
# merges are this run's to check. Its base and a group's can be
# several merges back, past the checkout's depth, so they are fetched;
# merges are this run's to check. Its base can be several merges
# back and a group's is a queue commit, both past the checkout's
# depth, so they are fetched;
# one that cannot be leaves the comparison unavailable, and the plan
# runs every lane. The queue lookup's answer is written only when the
# API answers, and a missing one also plans every lane.
Expand Down
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Use [docs/README.md](docs/README.md) to find current guides and distinguish hist

Run the same required lanes CI runs.
These are the local equivalents; the remote `verify` result still depends on the actual CI run.
CI's `plan` job picks the lanes a pull request needs from the paths it changes, and `verify` requires exactly those; a merge queue group (`merge_group`) plans from every change between main and the group, a push to main runs no lane when the queue verified its commit and every lane when it changed a cache key, nightly runs every lane, and [docs/TESTING.md](docs/TESTING.md#which-lanes-a-pull-request-runs) owns the rules.
CI's `plan` job picks the lanes a pull request needs from the paths it changes, and `verify` requires exactly those; a merge queue group (`merge_group`) plans from its own pull request's changes on top of the groups queued ahead of it, a push to main runs no lane when the queue verified its commit and every lane when it changed a cache key, nightly runs every lane, and [docs/TESTING.md](docs/TESTING.md#which-lanes-a-pull-request-runs) owns the rules.
Across its lanes CI runs the Rust suite, the unit suites, the invariant checks and the whole web end-to-end (six shards) on Linux, where the Herdr schema comparison and the web end-to-end use the pinned release's Linux asset; two jobs on macOS, the platform hide ships on: the Electron end-to-end and the web end-to-end's `@platform` tests; and on Windows `windows check` (compile, daemon and unit suites) and `windows e2e` (the browser `@platform` tests).
`.github/workflows/pr.yml` says why; `nightly.yml` configures full web and desktop suites and package checks on Linux, macOS and Windows, where a test fails the nightly only when it fails its retry too.
Read the executed jobs and their skips before claiming an OS is verified; a configured matrix is not execution evidence.
Expand Down
4 changes: 3 additions & 1 deletion docs/TESTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,9 @@ Marking the pull request ready (`ready_for_review`) starts the run that plans an
Keep `ready_for_review` in `pr.yml`'s `types`, and keep `verify` running on a draft; `scripts/tests/test_ci_plan.py` reads the workflow for both.
A hand run of `nightly.yml` takes a `lane` (`all`, `linux`, `macos`, `windows`): one system's web and desktop suites, with `verify`, `os contract` and `package` for `all` only; the schedule runs everything.
A plan that cannot be computed plans every lane: a missing base, a checkout that is not the merge commit, a diff that does not parse, or a crate graph `cargo metadata` cannot read.
A merge queue group (`merge_group`) plans from the paths between the main commit it starts from (`merge_group.base_sha`) and the group's commit, the tree main becomes, so a group queued behind others plans for their changes too; a base the `plan` job cannot fetch is a missing base.
A merge queue group (`merge_group`) plans from the paths between the commit it starts from (`merge_group.base_sha`) and the group's commit; that base is main for the first group and the commit of the group queued ahead for every later one, so each group plans its own pull request's changes on the tree the groups ahead make, and a base the `plan` job cannot fetch is a missing base.
That is enough because each group's run checks its own lanes on a tree that already holds every group ahead: a lane is checked by the run of the last group that touched its inputs, on the same inputs as the tree main finally becomes, which assumes the path rules are right, as a pull request's plan does.
The queue merges a group only when every group ahead of it passed, and one that fails is removed and the groups behind it are rebuilt on a new base.
A push to main plans no lane when a merge queue run of `verify` succeeded on its commit, which the `plan` job asks the Actions API, and `verify` passes with every lane skipped.
The exception is a push that changed a file a CI cache key hashes (`CACHE_KEYS` in the script: `Cargo.lock`, a `Cargo.toml`, a toolchain file, `.cargo/`, `pnpm-lock.yaml`, `.github/workflows/`), compared from the last main commit whose push run passed, so a run GitHub replaced while it waited still has its merges checked: the caches save only from main and only under a new key, so that push runs every lane.
A lookup that fails, no merge queue run on the commit, or a comparison it cannot make also plans every lane, and the plan's output says which.
Expand Down
9 changes: 5 additions & 4 deletions scripts/ci-plan.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
step: a planned lane must have succeeded and an unplanned one must have been
skipped, so a lane whose `if:` is wrong fails `verify` instead of passing it.

A merge queue group plans from the paths between its base and its head. A
A merge queue group plans from the paths between its base (main, or the
group queued ahead of it) and its head. A
push to main plans no lane when a merge queue run already verified that
commit and the push changed no file a CI cache key hashes; otherwise it plans
every lane, as do a comparison that cannot be computed, a path no rule claims
Expand Down Expand Up @@ -372,9 +373,9 @@ def plan(event, base, head, root=ROOT, crates=None, draft=False, queue_runs=None
).split()
if len(parents) != 3:
raise ValueError(f"{head} is not a merge commit")
# A merge queue group names its base (`merge_group.base_sha`), so the
# comparison needs no parent: base..head is every pull request queued
# up to and including this one, the tree main becomes.
# A merge queue group names its base (`merge_group.base_sha`): main,
# or the commit of the group queued ahead of it. base..head is then
# this group's own pull request, on the tree the ones ahead make.
entries = changed_entries(base, head, root)
except subprocess.CalledProcessError as error:
detail = error.stderr.strip() if isinstance(error.stderr, str) else (error.stderr or b"").decode(errors="replace").strip()
Expand Down
42 changes: 25 additions & 17 deletions scripts/tests/test_ci_plan.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,37 +165,45 @@ def git(*args):
result = ci.plan("pull_request", "HEAD^1", "HEAD", repo, CRATES)
self.assertEqual(result["lanes"], ["policy"])

def test_a_merge_group_plans_every_queued_change_from_its_base(self):
def test_a_merge_group_plans_its_own_change_on_the_groups_ahead(self):
with tempfile.TemporaryDirectory() as directory:
repo = Path(directory)
def git(*args):
return subprocess.run(["git", *args], cwd=repo, check=True, capture_output=True, text=True).stdout.strip()
def group(name, path, on):
# The queue builds a group commit by merging the pull request
# onto its base: main, or the group queued ahead.
git("checkout", "-qb", f"pr-{name}", main)
(repo / path).parent.mkdir(parents=True, exist_ok=True)
(repo / path).write_text(f"{name}\n")
git("add", ".")
git("commit", "-qm", name)
git("checkout", "-q", "--detach", on)
git("merge", "-q", "--no-ff", "-m", f"group {name}", f"pr-{name}")
return git("rev-parse", "HEAD")
git("init", "-q", "-b", "main")
git("config", "user.email", "ci@example.invalid")
git("config", "user.name", "ci")
(repo / "docs").mkdir()
(repo / "docs/a.md").write_text("a\n")
git("add", ".")
git("commit", "-qm", "base")
base = git("rev-parse", "HEAD")
# Two queued pull requests, each merged onto the group ahead of it
# as the queue does with merge commits: a desktop change, then docs.
for branch, path in (("first", "desktop/src/preload/index.ts"), ("second", "docs/b.md")):
git("checkout", "-qb", branch, base)
(repo / path).parent.mkdir(parents=True, exist_ok=True)
(repo / path).write_text(f"{branch}\n")
git("add", ".")
git("commit", "-qm", branch)
git("checkout", "-q", "main")
git("merge", "-q", "--no-ff", "-m", f"merge {branch}", branch)
# The second group's own merge is documentation only, but main
# becomes both changes, so its plan has the first one's lanes too.
self.assertEqual(ci.plan("pull_request", "HEAD^1", "HEAD", repo, CRATES)["lanes"], ["policy"])
result = ci.plan("merge_group", base, "HEAD", repo, CRATES)
main = git("rev-parse", "HEAD")
# Two pull requests queued in order: a desktop change, then docs.
# The second group's base is the first group's commit, not main.
first = group("desktop", "desktop/src/preload/index.ts", main)
second = group("docs", "docs/b.md", first)
result = ci.plan("merge_group", main, first, repo, CRATES)
self.assertFalse(result["full"])
self.assertEqual(set(result["lanes"]), {"policy", "desktop-checks", "desktop-e2e"})
# The second group checks only its own change; the desktop lanes
# were checked by the first group's run on the same desktop files.
self.assertEqual(ci.plan("merge_group", first, second, repo, CRATES)["lanes"], ["policy"])
# When the first group fails, the queue rebuilds the second on main.
rebuilt = group("docs-again", "docs/c.md", main)
self.assertEqual(ci.plan("merge_group", main, rebuilt, repo, CRATES)["lanes"], ["policy"])
# A base the checkout does not have runs every lane.
missing = ci.plan("merge_group", "0" * 40, "HEAD", repo, CRATES)
missing = ci.plan("merge_group", "0" * 40, second, repo, CRATES)
self.assertTrue(missing["full"])
self.assertIn("comparison unavailable", missing["reasons"]["rust"][0])

Expand Down
Loading