diff --git a/contributing-docs/18_contribution_workflow.rst b/contributing-docs/18_contribution_workflow.rst
index 78b8a45eac8f8..c855ff63b6be5 100644
--- a/contributing-docs/18_contribution_workflow.rst
+++ b/contributing-docs/18_contribution_workflow.rst
@@ -192,6 +192,12 @@ does not run for 30 days is closed with an explanation; you can reopen it after
files that decide which CI jobs run and where, such as ``.github/``, the breeze sources or
``scripts/ci/prek/``, a green fork run is not enough: a maintainer reviews the change and runs project CI for it.
+Fork CI tests your branch as it is, while project CI tests it merged with the target branch. The
+``CI passed`` check that merging requires is therefore reported only when your branch is fewer than
+200 commits behind the target branch and the target branch has not changed any file your pull request
+changes since your branch's base. Otherwise the pull request comment lists those files and asks you
+to rebase on ``upstream/main`` (or the target branch) and push, which runs fork CI again.
+
**Joining the pilot.** Open a pull request that adds your GitHub login to the ``[pilot]`` table in
``.github/fork-ci-gate.toml``, with a join instant after the expected merge, for example the next day
at 00:00 UTC:
diff --git a/dev/breeze/doc/ci/08_fork_ci_for_external_contributors.md b/dev/breeze/doc/ci/08_fork_ci_for_external_contributors.md
index 5220187e34b0b..6bbe9ea97f10f 100644
--- a/dev/breeze/doc/ci/08_fork_ci_for_external_contributors.md
+++ b/dev/breeze/doc/ci/08_fork_ci_for_external_contributors.md
@@ -1051,6 +1051,8 @@ run.
pending or failing one would say, and it never competes with project CI's own check.
- `green_unverified` gets no `CI passed`: the fork run used CI files the pull request changed, so
it is not evidence. Once a maintainer adds `use project ci`, project CI reports the check.
+- A `green` run whose base is not current gets a `pending` `CI passed` asking to rebase, and one
+ whose base could not be compared gets none (see "Tested base").
- When the head commit leaves `green`, for example a re-run in the fork that fails, a `success`
posted earlier is overwritten with `pending` so the pull request cannot merge on it.
- A pull request carrying `use project ci` cannot merge on the fork result. GitHub requires both to
@@ -1164,14 +1166,46 @@ conditions: completed, first attempt, its commit does not change `.github/workfl
did project CI work by the tampering check's rules. Of its jobs only the gate and the jobs that
also run in a gated run started, none failed, and at least one was cancelled.
-### Far behind the base branch
-
-A fork run tests the pushed commit as it is, while project CI tests it merged with the base
-branch. When a head commit turns green, the reconciler counts the commits it is behind its base
-branch (`behind_by` of `GET /repos/apache/airflow/compare/...:`, once per
-head commit, stored in the marker). From 200 commits behind, about four days of `main`, the
-state comment says so and asks the contributor to rebase, since the merged result can still
-fail. The count is advisory and does not change the state.
+### Tested base
+
+A fork run tests the pushed commit as it is, while project CI's `pull_request` run tests GitHub's
+merge commit of the pull request into its base branch. A fork run on an old base could otherwise go
+green and merge although the merged result was never tested. So `CI passed` is only reported for a
+fork run whose base is close enough to the base branch that the merge changes nothing the pull
+request touches.
+
+When a head commit turns green, the reconciler compares it with the base branch, once per head
+commit, and stores the result in the marker as `"base": {"sha", "behind", "overlap"}`:
+
+- `GET /repos/apache/airflow/compare/...:` gives the merge base, the commit
+ of the base branch the fork run tested on top of (`sha`), the commits the base branch has since
+ (`behind`), and the files the pull request changes.
+- When `behind` is not zero, `GET /repos/apache/airflow/compare/...` gives the
+ files the base branch changed since. `overlap` is the paths in both lists, a renamed file
+ counting under both paths.
+
+`CI passed` is reported only when the base is current: fewer than `MAX_BEHIND_COMMITS` (200, about
+four days of `main`) commits behind and no overlap. Otherwise the state stays `green` (the pull
+request can be reviewed, and its status, labels and draft state are those of `green`), the state
+comment lists the overlapping files or says how far behind the base is and gives the rebase
+commands, and `CI passed` is posted as `pending` with a description saying to rebase. A rebase and
+push starts a new fork run, which is compared again when it turns green. Every green state comment
+names the base commit the run tested and how far behind it was, and the `CI passed` description
+names it as well.
+
+The compare API lists at most 300 files. A pull request with more is listed with
+`GET /repos/apache/airflow/pulls//files` instead (up to 3000); a base branch that changed 300 or
+more files since the merge base cannot be checked and counts as overlapping, which a rebase
+resolves. When the compare fails, `CI passed` is not reported, the failure is reported to Slack and
+the next run compares again. A marker written before this check, with no `base`, is compared again
+on the next run, so a pull request that already had `CI passed` loses it if its base turns out not
+to be current. A retarget compares again, as it decides green trust again.
+
+This narrows the gap to project CI without closing it. A base change in other files can still break
+the pull request, within at most 200 commits, which matches what project CI leaves open after its
+run: a `pull_request` run is not repeated when the base branch moves, so the merged result at merge
+time is not the one it tested either. Testing the merge commit in the fork itself was considered and
+rejected; see "Known limitations".
### Unknown failures and attention items go to Slack
@@ -1218,8 +1252,8 @@ Per run, with ~700 gated pull requests: ~28 GraphQL calls for pass 2, ~14 for fo
~1 for pass 1, plus one REST call per pull request in `setup_required`, a few paginated REST
calls for the recent `pull_request` runs, one REST call per base branch for its workflow
files, a jobs call and a compare call only per long `ci-amd.yml` run of a gated pull request,
-one changed-files call per head commit that turns green, plus one mutation per actual state
-change. Job statuses add a jobs call and a status call per pull request with a fork run in
+one changed-files call and one or two compare calls per head commit that turns green, plus one
+mutation per actual state change. Job statuses add a jobs call and a status call per pull request with a fork run in
progress or a completed run not yet reported, and up to two status mutations per job, at most
`MAX_JOB_STATUSES_PER_RUN` per run; see "Write budget". Pull requests that pass 1 labelled and
the search does not list yet add one GraphQL call per 25. Well inside
@@ -1426,6 +1460,17 @@ as a failed check rather than a crash.
- An external pull request that legitimately changes workflow files, was released with `use
project ci` and then had that label removed is closed on the next run, because both
signals hold. Keeping `use project ci` on such a pull request is the intended handling.
+- Fork CI tests the head commit, not the pull request merged into its base branch; "Tested base"
+ only bounds the difference. Testing the merged result in the fork was rejected because:
+ every job of the fork run checks out the pushed commit (about 60 `actions/checkout` steps across
+ `ci-amd.yml` and its reusable workflows, plus the image builds and caches keyed by the commit),
+ and each would have to check out one merge commit fixed for the whole run; the first push of a
+ branch happens before its pull request exists, so there is no `refs/pull//merge` to test yet;
+ GitHub computes that ref asynchronously after each push and replaces it whenever the base branch
+ moves, so a run would have to wait for it and could find its commit gone mid-run; and the
+ reconciler would have to trust the run's own report of which merge it tested. Merging the base
+ branch into the head in every job instead needs the shared history of both, which shallow
+ checkouts do not have.
## Testing
@@ -1442,7 +1487,8 @@ as a failed check rather than a crash.
close), a fork with a name other than `airflow`, marker round-trips, status
desired-vs-current comparison, the unknown-failure collection, green trust (a change to
CI-defining files keeps the status pending without drafting the pull request, decided once
- per commit) and the gate
+ per commit), the tested base (`CI passed` only on a current base, the marker and comment naming
+ the base, compared again for a new commit, a retarget or a marker without a base) and the gate
tampering check: a tampered run on an earlier commit is caught after a clean push, each
signal alone does not close, short runs and gate-only jobs do not count, an in-progress
non-gate job, a removed, duplicated or long-running gate job and an injected workflow with a
diff --git a/dev/breeze/src/airflow_breeze/utils/fork_ci_messages.py b/dev/breeze/src/airflow_breeze/utils/fork_ci_messages.py
index 845769d025f07..d6fe9f4d06b69 100644
--- a/dev/breeze/src/airflow_breeze/utils/fork_ci_messages.py
+++ b/dev/breeze/src/airflow_breeze/utils/fork_ci_messages.py
@@ -45,7 +45,6 @@
# CI's gate job reports it; for a gated pull request, which never runs project CI, the reconciler
# reports it from the fork run.
CI_PASSED_CONTEXT = "CI passed"
-CI_PASSED_DESCRIPTION = "Fork CI passed for this commit"
CI_PASSED_REVOKED_DESCRIPTION = "Fork CI result no longer trusted for this commit"
# Replaces a fork `success` on a pull request carrying `use project ci` until project CI has passed.
CI_PASSED_WAITING_PROJECT_CI_DESCRIPTION = "Waiting for project CI (use project ci)"
@@ -56,9 +55,12 @@
CI_RUN_STARTED_CONTEXT = "CI run started"
CI_RUN_STARTED_DESCRIPTION = "CI runs in the contributor's fork - details open the run"
CI_RUN_STARTED_PROJECT_DESCRIPTION = "Project CI runs in apache/airflow - details open the run"
-# A fork run tests the head commit as it is, not merged with the base branch. Further behind than
-# this, it says little about the result after merge.
-BEHIND_WARNING_COMMITS = 200
+# A fork run tests the head commit as it is, not merged with the base branch as project CI does. From
+# this many commits behind, `CI passed` is withheld until the branch is rebased, as it is when the
+# base branch changed any file the pull request changes.
+MAX_BEHIND_COMMITS = 200
+# Overlapping files named in the state comment; the marker keeps them all.
+OVERLAP_LISTED = 10
MARKER_PREFIX = "")
# Texts on pull requests are for their authors, so they link the contributor documentation; it links
@@ -87,13 +89,34 @@
)
+@dataclass(frozen=True)
+class BaseCheck:
+ """
+ The base a green fork run tested, compared with the base branch when the run turned green.
+
+ :param sha: the merge base of the head commit and the base branch, the base the run tested.
+ :param behind: commits on the base branch since ``sha``.
+ :param overlap: paths that both the pull request and the base branch since ``sha`` change;
+ None when GitHub listed too many changed files on either side to tell.
+ """
+
+ sha: str
+ behind: int
+ overlap: tuple[str, ...] | None = ()
+
+ @property
+ def is_current(self) -> bool:
+ """Whether the run tested close enough to the merged result for `CI passed`."""
+ return self.behind < MAX_BEHIND_COMMITS and self.overlap == ()
+
+
@dataclass(frozen=True)
class Marker:
state: str
sha: str
since: datetime
- # Commits the head commit was behind its base branch when its fork CI turned green.
- behind: int | None = None
+ # Set when the head commit's fork CI turned green and its base could be compared.
+ base: BaseCheck | None = None
# The completed fork run (``::``) whose jobs are all reported.
jobs: str | None = None
# The fork run (``:``) whose failed jobs the comment lists.
@@ -105,8 +128,12 @@ class Marker:
def render_marker(marker: Marker) -> str:
data: dict[str, object] = {"state": marker.state, "sha": marker.sha, "since": marker.since.isoformat()}
- if marker.behind is not None:
- data["behind"] = marker.behind
+ if marker.base is not None:
+ data["base"] = {
+ "sha": marker.base.sha,
+ "behind": marker.base.behind,
+ "overlap": None if marker.base.overlap is None else list(marker.base.overlap),
+ }
if marker.jobs is not None:
data["jobs"] = marker.jobs
if marker.failed_run is not None:
@@ -123,11 +150,19 @@ def parse_marker(body: str) -> Marker | None:
return None
try:
data = json.loads(match.group("payload"))
+ # A marker written before the base was checked carries only "behind"; its base is checked again.
+ base = data.get("base")
return Marker(
state=data["state"],
sha=data["sha"],
since=datetime.fromisoformat(data["since"]),
- behind=data.get("behind"),
+ base=None
+ if base is None
+ else BaseCheck(
+ sha=base["sha"],
+ behind=base["behind"],
+ overlap=None if base["overlap"] is None else tuple(base["overlap"]),
+ ),
jobs=data.get("jobs"),
failed_run=data.get("failed_run"),
gate_checked=data.get("gate_checked") is True,
@@ -248,11 +283,64 @@ def strip_failed_job_list(body: str) -> str:
return "\n\n".join(part for part in body.split("\n\n") if not part.startswith(FAILED_JOB_LIST_HEADING))
-def behind_warning(behind: int, *, base_ref: str) -> str:
+def tested_base_text(base: BaseCheck, *, base_ref: str) -> str:
+ text = (
+ f"Fork CI tested this branch on top of `{base_ref}` at "
+ f"[`{base.sha[:10]}`](https://github.com/apache/airflow/commit/{base.sha}), "
+ f"{base.behind} commits behind `{base_ref}` when the run turned green. Fork CI tests the branch "
+ f"as it is, while project CI would test it merged with the current `{base_ref}`."
+ )
+ if base.is_current:
+ return f"{text} No commit since changed a file this pull request changes."
+ if base.overlap is None:
+ reason = f"`{base_ref}` changed too many files since to tell whether it changed the same files."
+ elif base.overlap:
+ listed = ", ".join(f"`{path}`" for path in base.overlap[:OVERLAP_LISTED])
+ more = len(base.overlap) - OVERLAP_LISTED
+ reason = f"`{base_ref}` changed files this pull request changes since: {listed}" + (
+ f" and {more} more." if more > 0 else "."
+ )
+ else:
+ reason = "That is too far behind to say much about the merged result."
return (
- f"**This branch is {behind} commits behind `{base_ref}`.** Fork CI tests the branch as it is, "
- f"while the merged result also contains those commits, so it can still fail after the merge. "
- f"Rebase on `{base_ref}` and push to test it against the current code."
+ f"{text}\n\n**Rebase needed.** {reason} The `CI passed` check is not reported until fork CI is "
+ f"green for a branch rebased on `{base_ref}`:\n\n"
+ f"```bash\ngit fetch upstream\ngit rebase upstream/{base_ref}\ngit push --force-with-lease\n```"
+ )
+
+
+_FORK_CI_PASSED_PREFIX = "Fork CI passed"
+_REBASE_NEEDED_PREFIX = "Rebase on "
+
+
+def ci_passed_description(base: BaseCheck, *, base_ref: str) -> str:
+ return (
+ f"{_FORK_CI_PASSED_PREFIX}; base {base_ref}@{base.sha[:10]} was {base.behind} commits behind, "
+ "no overlap"
+ )
+
+
+def rebase_needed_description(base: BaseCheck, *, base_ref: str) -> str:
+ if base.overlap is None:
+ why = f"{base_ref} changed too many files since to check"
+ elif base.overlap:
+ why = f"{base_ref} changed {len(base.overlap)} of the same files since"
+ else:
+ why = f"base is {base.behind} commits behind"
+ return f"{_REBASE_NEEDED_PREFIX}{base_ref} and push: {why}"
+
+
+def is_fork_ci_passed_description(description: str | None) -> bool:
+ """
+ Whether a `CI passed` status description is one the reconciler wrote from a fork run.
+
+ The prefix also matches "Fork CI passed for this commit", written before the base was checked.
+ """
+ if not description:
+ return False
+ return description.startswith((_FORK_CI_PASSED_PREFIX, _REBASE_NEEDED_PREFIX)) or description in (
+ CI_PASSED_WAITING_PROJECT_CI_DESCRIPTION,
+ CI_PASSED_REVOKED_DESCRIPTION,
)
@@ -274,12 +362,8 @@ def state_comment(
if startup_failure:
text = STARTUP_FAILURE_TEXT
parts = [render_marker(marker), text or _STATE_TEXTS[marker.state], WHY_FORK_CI]
- if (
- marker.state in ("green", "green_unverified")
- and marker.behind is not None
- and marker.behind >= BEHIND_WARNING_COMMITS
- ):
- parts.append(behind_warning(marker.behind, base_ref=base_ref))
+ if marker.state in ("green", "green_unverified") and marker.base is not None:
+ parts.append(tested_base_text(marker.base, base_ref=base_ref))
if run_url:
parts.append(f"Latest run: {run_url}")
if marker.state == "failed" and failed_jobs:
diff --git a/dev/breeze/src/airflow_breeze/utils/fork_ci_reconcile.py b/dev/breeze/src/airflow_breeze/utils/fork_ci_reconcile.py
index f84e8ff2db222..ed01ce7ad9890 100644
--- a/dev/breeze/src/airflow_breeze/utils/fork_ci_reconcile.py
+++ b/dev/breeze/src/airflow_breeze/utils/fork_ci_reconcile.py
@@ -59,7 +59,6 @@
from airflow_breeze.utils.fork_ci_github import GitHubClient, GitHubError
from airflow_breeze.utils.fork_ci_messages import (
CI_PASSED_CONTEXT,
- CI_PASSED_DESCRIPTION,
CI_PASSED_PROJECT_DESCRIPTION,
CI_PASSED_REVOKED_DESCRIPTION,
CI_PASSED_WAITING_PROJECT_CI_DESCRIPTION,
@@ -71,14 +70,18 @@
STALE_JOB_STATUS,
STATUS_CONTEXT,
STATUS_STATES,
+ BaseCheck,
FailedJob,
Marker,
+ ci_passed_description,
fork_actions_url,
gate_modified_close_comment,
inactivity_close_comment,
+ is_fork_ci_passed_description,
job_status_context,
nudge_comment,
parse_marker,
+ rebase_needed_description,
released_comment,
state_comment,
status_description,
@@ -600,17 +603,24 @@ def _set_status(
plan.status = desired
-def _set_ci_passed(plan: Plan, pr: PullRequestSnapshot, *, passed: bool, target_url: str) -> None:
+def _set_ci_passed(
+ plan: Plan, pr: PullRequestSnapshot, state: ForkState, base: BaseCheck | None, *, target_url: str
+) -> None:
"""
Report fork CI to the `CI passed` check the merge ruleset requires.
- Only success is ever posted: a gated pull request without the status cannot merge, which is
- what a pending or failing one would say. A success that no longer holds for the head commit,
- such as a failed re-run in the fork, is overwritten so the pull request cannot merge on it.
+ Success is posted only for a trusted green run whose base is current enough; a gated pull
+ request without the status cannot merge. A green run on an old base gets a pending status that
+ says to rebase. A success that no longer holds for the head commit, such as a failed re-run in
+ the fork, is overwritten so the pull request cannot merge on it.
"""
- if passed and pr.ci_passed_state != "success":
- plan.ci_passed = ("success", target_url, CI_PASSED_DESCRIPTION)
- elif not passed and pr.ci_passed_state == "success":
+ if state == ForkState.GREEN and base is not None and base.is_current:
+ if pr.ci_passed_state != "success":
+ plan.ci_passed = ("success", target_url, ci_passed_description(base, base_ref=pr.base_ref))
+ elif state == ForkState.GREEN and base is not None:
+ if pr.ci_passed_state != "pending":
+ plan.ci_passed = ("pending", target_url, rebase_needed_description(base, base_ref=pr.base_ref))
+ elif pr.ci_passed_state == "success":
plan.ci_passed = ("pending", target_url, CI_PASSED_REVOKED_DESCRIPTION)
@@ -634,7 +644,7 @@ def classify(
repo: str,
find_bypass_run: Callable[[], str | None],
changes_ci_files: Callable[[], bool | None],
- count_behind: Callable[[], int | None] = lambda: None,
+ compare_base: Callable[[], BaseCheck | None] = lambda: None,
jobs_reported: str | None = None,
head_shared_across_bases: bool = False,
find_gate_change: Callable[[], str | None] = lambda: None,
@@ -651,8 +661,9 @@ def classify(
cannot be told for the snapshot's head commit; only called when a new head commit turns
green in the fork. On None nothing is changed, since the decision would be recorded on a
commit the answer may not belong to.
- :param count_behind: how many commits the head commit is behind the base branch, None when
- unknown; called at the same time as ``changes_ci_files``.
+ :param compare_base: compares the head commit's base with the base branch, None when that
+ cannot be read; called when a new head commit turns green, alongside ``changes_ci_files``,
+ and on later runs until it succeeds.
:param jobs_reported: the completed fork run whose jobs are all reported as statuses, recorded
in the marker so that later runs do not read its jobs again.
:param head_shared_across_bases: another gated pull request has the same head commit and a
@@ -789,7 +800,7 @@ def release(state: ForkState, comment: Callable[[Marker], str]) -> Plan:
plan.unknown.append(unknown_reason or "unknown fork state")
return plan
refresh_status = False
- behind = marker.behind if marker and marker.sha == pr.head_sha else None
+ base = marker.base if marker and marker.sha == pr.head_sha else None
if state == ForkState.GREEN:
# The decision is read back from the commit status on the head commit, which only
# apache/airflow's own tokens can write, never from a comment. The changed files depend
@@ -819,9 +830,16 @@ def release(state: ForkState, comment: Callable[[Marker], str]) -> Plan:
if changes is None:
return Plan()
unverified = changes
- behind = count_behind()
+ base = None
if unverified:
state = ForkState.GREEN_UNVERIFIED
+ if base is None:
+ base = compare_base()
+ if base is None and state == ForkState.GREEN:
+ plan.unknown.append(
+ f"fork CI is green, but the head commit could not be compared with `{pr.base_ref}`, "
+ "so `CI passed` waits for the next run"
+ )
plan.state = state
since = marker.since if marker and marker.state == state.value else now
@@ -860,7 +878,7 @@ def release(state: ForkState, comment: Callable[[Marker], str]) -> Plan:
_set_status(
plan, pr, "startup_failure" if startup_failure else state.value, target_url, force=refresh_status
)
- _set_ci_passed(plan, pr, passed=state == ForkState.GREEN, target_url=target_url)
+ _set_ci_passed(plan, pr, state, base, target_url=target_url)
_set_ci_run_started(plan, pr, fork)
green = state in (ForkState.GREEN, ForkState.GREEN_UNVERIFIED)
lists_failed_jobs = state == ForkState.FAILED and not startup_failure and fork.run_id is not None
@@ -868,7 +886,7 @@ def release(state: ForkState, comment: Callable[[Marker], str]) -> Plan:
state.value,
pr.head_sha,
since,
- behind=behind if green else None,
+ base=base if green else None,
jobs=jobs_reported,
failed_run=f"{fork.run_id}:{fork.run_attempt}" if lists_failed_jobs else None,
gate_checked=gate_checked,
@@ -1689,12 +1707,7 @@ def report_orphaned_ci_passed(
status = read_ci_passed_status(client, repo, node["headRefOid"])
if (
(status.get("state") or "").lower() in ("", "success")
- or status.get("description")
- not in (
- CI_PASSED_DESCRIPTION,
- CI_PASSED_WAITING_PROJECT_CI_DESCRIPTION,
- CI_PASSED_REVOKED_DESCRIPTION,
- )
+ or not is_fork_ci_passed_description(status.get("description"))
or len(written) >= MAX_PROJECT_CI_PASSED_PER_RUN
):
return
@@ -2463,17 +2476,37 @@ def pull_request_changes_ci_files(client: GitHubClient, repo: str, number: int,
return changes_ci_definition(changed_paths(files), file_count=len(files))
-def count_commits_behind(client: GitHubClient, repo: str, pr: PullRequestSnapshot) -> int | None:
- """Commits on the base branch that the head commit does not have; None when not readable."""
+def compare_with_base(client: GitHubClient, repo: str, pr: PullRequestSnapshot) -> BaseCheck | None:
+ """
+ Compare the base a fork run tested with the base branch; None when not readable.
+
+ The fork run tests the head commit, so its base is the merge base with the base branch. Two
+ three-dot compares from it give the files the pull request changes and the files the base branch
+ changed since; a file in both means the merged result differs from what the fork run tested
+ in a file the pull request changes. Compares list at most 300 files (on their first page, which
+ ``per_page`` does not limit): a pull request with more is listed with the files endpoint instead,
+ while a base branch that changed more cannot be checked until the branch is rebased.
+ """
owner = (pr.head_repo or "").split("/", 1)[0]
+ base_ref = quote(pr.base_ref, safe="")
try:
- compare = client.rest_get(
- f"repos/{repo}/compare/{quote(pr.base_ref, safe='')}...{owner}:{pr.head_sha}?per_page=1"
+ head_side = client.rest_get(f"repos/{repo}/compare/{base_ref}...{owner}:{pr.head_sha}?per_page=1")
+ merge_base = head_side["merge_base_commit"]["sha"]
+ behind = head_side["behind_by"]
+ base_side = (
+ client.rest_get(f"repos/{repo}/compare/{merge_base}...{base_ref}?per_page=1") if behind else {}
)
- except GitHubError as e:
- console_print(f"[warning]#{pr.number}: could not count commits behind {pr.base_ref}: {e}[/]")
+ head_files = head_side.get("files") or []
+ if len(head_files) >= COMPARE_FILES_CAP:
+ head_files = client.rest_get(f"repos/{repo}/pulls/{pr.number}/files?per_page=100", paginate=True)
+ except (GitHubError, KeyError, TypeError) as e:
+ console_print(f"[warning]#{pr.number}: could not compare with {pr.base_ref}: {e}[/]")
return None
- return compare.get("behind_by")
+ base_files = base_side.get("files") or []
+ if len(head_files) >= PULL_REQUEST_FILES_CAP or len(base_files) >= COMPARE_FILES_CAP:
+ return BaseCheck(merge_base, behind, None)
+ overlap = set(changed_paths(head_files)) & set(changed_paths(base_files))
+ return BaseCheck(merge_base, behind, tuple(sorted(overlap)))
def find_heads_shared_across_bases(prs: Iterable[PullRequestSnapshot]) -> set[str]:
@@ -2830,7 +2863,7 @@ def is_gated_base(base_ref: str) -> bool:
changes_ci_files=functools.partial(
pull_request_changes_ci_files, client, repo, pr.number, pr.head_sha
),
- count_behind=functools.partial(count_commits_behind, client, repo, pr),
+ compare_base=functools.partial(compare_with_base, client, repo, pr),
jobs_reported=jobs_reported,
head_shared_across_bases=pr.head_sha in shared_heads,
find_gate_change=functools.partial(gate_change_finder.find, pr),
diff --git a/dev/breeze/tests/test_fork_ci_messages.py b/dev/breeze/tests/test_fork_ci_messages.py
index 37b874b56d8bc..7cb6336e2416a 100644
--- a/dev/breeze/tests/test_fork_ci_messages.py
+++ b/dev/breeze/tests/test_fork_ci_messages.py
@@ -25,27 +25,31 @@
from airflow_breeze.utils.fork_ci_messages import (
_STATE_TEXTS,
_STATUS_DESCRIPTIONS,
- BEHIND_WARNING_COMMITS,
CI_CHANGE_MARKER,
CI_MODIFICATION_MARKER,
- CI_PASSED_DESCRIPTION,
CI_PASSED_REVOKED_DESCRIPTION,
CONTRIBUTING_URL,
FOOTER,
GATED_NOTE_SENTENCE,
JOB_NAME_MAX_LENGTH,
JOB_STATUS_CONTEXT_PREFIX,
+ MAX_BEHIND_COMMITS,
MAX_LISTED_CI_FILES,
MAX_LISTED_FAILED_JOBS,
+ OVERLAP_LISTED,
+ BaseCheck,
FailedJob,
Marker,
ci_change_approval_comment,
ci_modification_note_comment,
+ ci_passed_description,
gate_modified_close_comment,
inactivity_close_comment,
+ is_fork_ci_passed_description,
job_status_context,
nudge_comment,
parse_marker,
+ rebase_needed_description,
released_comment,
render_marker,
state_comment,
@@ -61,8 +65,9 @@
@pytest.mark.parametrize(
"marker",
[
- pytest.param(MARKER, id="without-behind"),
- pytest.param(replace(MARKER, behind=12), id="behind"),
+ pytest.param(MARKER, id="without-base"),
+ pytest.param(replace(MARKER, base=BaseCheck("def456", 12, ("a.py",))), id="base"),
+ pytest.param(replace(MARKER, base=BaseCheck("def456", 12, None)), id="base-unchecked"),
pytest.param(replace(MARKER, jobs="123:SUCCESS"), id="jobs"),
pytest.param(replace(MARKER, failed_run="123:2"), id="failed-run"),
pytest.param(replace(MARKER, gate_checked=True), id="gate-checked"),
@@ -72,27 +77,81 @@ def test_marker_round_trip(marker):
assert parse_marker(f"text before\n{render_marker(marker)}\ntext after") == marker
-def test_marker_without_behind_keeps_its_rendering():
- assert "behind" not in render_marker(MARKER)
+def test_marker_without_base_keeps_its_rendering():
+ assert "base" not in render_marker(MARKER)
assert "jobs" not in render_marker(MARKER)
+def test_marker_from_before_the_base_check_has_no_base():
+ marker = parse_marker(
+ ''
+ )
+
+ assert marker is not None
+ assert marker.base is None
+
+
@pytest.mark.parametrize(
- ("state", "behind", "warned"),
+ ("base", "current"),
[
- pytest.param("green", BEHIND_WARNING_COMMITS, True, id="green-far-behind"),
- pytest.param("green_unverified", BEHIND_WARNING_COMMITS + 1, True, id="unverified-far-behind"),
- pytest.param("green", BEHIND_WARNING_COMMITS - 1, False, id="green-close"),
- pytest.param("green", None, False, id="green-not-counted"),
- pytest.param("failed", BEHIND_WARNING_COMMITS, False, id="failed"),
+ pytest.param(BaseCheck("d", MAX_BEHIND_COMMITS - 1), True, id="close-no-overlap"),
+ pytest.param(BaseCheck("d", MAX_BEHIND_COMMITS), False, id="far-behind"),
+ pytest.param(BaseCheck("d", 1, ("a.py",)), False, id="overlap"),
+ pytest.param(BaseCheck("d", 1, None), False, id="unchecked"),
],
)
-def test_state_comment_warns_about_a_branch_far_behind(state, behind, warned):
+def test_base_check_is_current(base, current):
+ assert base.is_current is current
+
+
+@pytest.mark.parametrize(
+ ("state", "base", "expected", "unexpected"),
+ [
+ pytest.param(
+ "green",
+ BaseCheck("d" * 40, 3),
+ [
+ "`v3-1-test` at [`dddddddddd`](https://github.com/apache/airflow/commit/" + "d" * 40,
+ "3 commits",
+ ],
+ ["Rebase needed"],
+ id="current",
+ ),
+ pytest.param(
+ "green",
+ BaseCheck("d", MAX_BEHIND_COMMITS),
+ ["Rebase needed", "too far behind", "git rebase upstream/v3-1-test"],
+ [],
+ id="far-behind",
+ ),
+ pytest.param(
+ "green_unverified",
+ BaseCheck("d", 4, ("a.py", "b.py")),
+ ["Rebase needed", "`a.py`, `b.py`."],
+ [],
+ id="overlap",
+ ),
+ pytest.param(
+ "green",
+ BaseCheck("d", 4, tuple(f"f{i:02}.py" for i in range(OVERLAP_LISTED + 2))),
+ [f"`f{OVERLAP_LISTED - 1:02}.py` and 2 more."],
+ [f"`f{OVERLAP_LISTED:02}.py`"],
+ id="overlap-shortened",
+ ),
+ pytest.param(
+ "green", BaseCheck("d", 4, None), ["Rebase needed", "too many files"], [], id="unchecked"
+ ),
+ pytest.param("failed", BaseCheck("d", MAX_BEHIND_COMMITS), [], ["tested this branch"], id="failed"),
+ pytest.param("green", None, [], ["tested this branch"], id="not-compared"),
+ ],
+)
+def test_state_comment_says_which_base_was_tested(state, base, expected, unexpected):
text = state_comment(
- Marker(state, "a", MARKER.since, behind=behind), fork="u/airflow", run_url=None, base_ref="v3-1-test"
+ Marker(state, "a", MARKER.since, base=base), fork="u/airflow", run_url=None, base_ref="v3-1-test"
)
- assert ("commits behind `v3-1-test`" in text) is warned
+ assert all(part in text for part in expected)
+ assert not any(part in text for part in unexpected)
@pytest.mark.parametrize(
@@ -163,6 +222,23 @@ def test_strip_failed_job_list_leaves_the_comment_without_the_list():
assert strip_failed_job_list(listed) == state_comment(marker, fork="u/airflow", run_url="https://run")
+@pytest.mark.parametrize(
+ ("description", "expected"),
+ [
+ pytest.param("Fork CI passed for this commit", True, id="before-the-base-check"),
+ pytest.param(ci_passed_description(BaseCheck("a" * 40, 3), base_ref="main"), True, id="current-base"),
+ pytest.param(
+ rebase_needed_description(BaseCheck("a" * 40, 300), base_ref="main"), True, id="rebase-needed"
+ ),
+ pytest.param(CI_PASSED_REVOKED_DESCRIPTION, True, id="revoked"),
+ pytest.param("Project CI passed for this commit", False, id="project-ci"),
+ pytest.param(None, False, id="none"),
+ ],
+)
+def test_is_fork_ci_passed_description(description, expected):
+ assert is_fork_ci_passed_description(description) is expected
+
+
def test_parse_marker_absent():
assert parse_marker("just a comment") is None
@@ -220,7 +296,16 @@ def test_setup_texts_give_the_exact_command(text):
def test_status_descriptions_fit_github_limit():
- descriptions = [*_STATUS_DESCRIPTIONS.values(), CI_PASSED_DESCRIPTION, CI_PASSED_REVOKED_DESCRIPTION]
+ base_ref = "providers-cncf-kubernetes/v10-22"
+ descriptions = [
+ *_STATUS_DESCRIPTIONS.values(),
+ CI_PASSED_REVOKED_DESCRIPTION,
+ ci_passed_description(BaseCheck("d" * 40, 199), base_ref=base_ref),
+ *(
+ rebase_needed_description(BaseCheck("d" * 40, 9999, overlap), base_ref=base_ref)
+ for overlap in ((), ("a",) * 300, None)
+ ),
+ ]
assert all(len(description) < 140 for description in descriptions)
diff --git a/dev/breeze/tests/test_fork_ci_reconcile.py b/dev/breeze/tests/test_fork_ci_reconcile.py
index 519294739f3e9..fa1d432977e2a 100644
--- a/dev/breeze/tests/test_fork_ci_reconcile.py
+++ b/dev/breeze/tests/test_fork_ci_reconcile.py
@@ -32,7 +32,6 @@
from airflow_breeze.utils.fork_ci_github import GitHubClient, GitHubError
from airflow_breeze.utils.fork_ci_messages import (
CI_PASSED_CONTEXT,
- CI_PASSED_DESCRIPTION,
CI_PASSED_PROJECT_DESCRIPTION,
CI_PASSED_WAITING_PROJECT_CI_DESCRIPTION,
CI_RUN_STARTED_CONTEXT,
@@ -41,6 +40,7 @@
JOB_STATUS_CONTEXT_PREFIX,
STALE_JOB_STATUS,
STATUS_CONTEXT,
+ BaseCheck,
FailedJob,
Marker,
parse_marker,
@@ -73,8 +73,8 @@
build_slack_payload,
changes_ci_definition,
classify,
+ compare_with_base,
compute_projection,
- count_commits_behind,
discover,
drop_reported,
fetch_fork_observations,
@@ -114,9 +114,13 @@
JOINED = CREATED + timedelta(days=2)
CONFIG = GateConfig(enabled=True, enabled_since=datetime(2026, 10, 1, tzinfo=UTC), close_after_days=7)
RUN_URL = "https://github.com/someone/airflow/actions/runs/1"
+# A `CI passed` success the reconciler wrote for a green fork run.
+FORK_CI_PASSED_DESCRIPTION = "Fork CI passed; base main@0123456789 was 3 commits behind, no overlap"
PROJECT_RUN_URL = "https://github.com/apache/airflow/actions/runs/2"
PROJECT_PASSED_URL = "https://github.com/apache/airflow/actions/runs/5"
GREEN = ForkObservation(suite_status="COMPLETED", suite_conclusion="SUCCESS", run_url=RUN_URL)
+MERGE_BASE = "def4567890aa"
+CURRENT_BASE = BaseCheck(MERGE_BASE, 3)
def _pr(**overrides) -> PullRequestSnapshot:
@@ -149,7 +153,7 @@ def _classify(
bypass_run=None,
changes_ci_files=False,
config=CONFIG,
- behind=None,
+ base=CURRENT_BASE,
head_shared_across_bases=False,
gate_change=None,
):
@@ -163,7 +167,7 @@ def _classify(
repo=REPO,
find_bypass_run=find_bypass,
changes_ci_files=changes,
- count_behind=mock.Mock(return_value=behind),
+ compare_base=mock.Mock(return_value=base),
head_shared_across_bases=head_shared_across_bases,
find_gate_change=lambda: gate_change,
)
@@ -519,66 +523,116 @@ def test_needs_project_ci_label_is_removed_outside_green_unverified(
)
-CI_PASSED = ("success", RUN_URL, "Fork CI passed for this commit")
+CI_PASSED = ("success", RUN_URL, "Fork CI passed; base main@def4567890 was 3 commits behind, no overlap")
CI_PASSED_REVOKED = ("pending", RUN_URL, "Fork CI result no longer trusted for this commit")
+OVERLAPPING_BASE = BaseCheck(MERGE_BASE, 3, ("a.py",))
+REBASE_NEEDED = ("pending", RUN_URL, "Rebase on main and push: main changed 1 of the same files since")
@pytest.mark.parametrize(
- ("fork", "changes_ci_files", "ci_passed_state", "expected"),
+ ("fork", "changes_ci_files", "base", "ci_passed_state", "expected"),
[
- pytest.param(GREEN, False, None, CI_PASSED, id="green-posts-success"),
- pytest.param(GREEN, False, "success", None, id="green-already-posted"),
- pytest.param(GREEN, False, "pending", CI_PASSED, id="green-after-revoke"),
- pytest.param(GREEN, True, None, None, id="unverified-gets-none"),
+ pytest.param(GREEN, False, CURRENT_BASE, None, CI_PASSED, id="green-posts-success"),
+ pytest.param(GREEN, False, CURRENT_BASE, "success", None, id="green-already-posted"),
+ pytest.param(GREEN, False, CURRENT_BASE, "pending", CI_PASSED, id="green-after-revoke"),
+ pytest.param(GREEN, True, CURRENT_BASE, None, None, id="unverified-gets-none"),
+ pytest.param(GREEN, False, OVERLAPPING_BASE, None, REBASE_NEEDED, id="old-base-asks-to-rebase"),
+ pytest.param(GREEN, False, OVERLAPPING_BASE, "success", REBASE_NEEDED, id="old-base-revokes"),
+ pytest.param(GREEN, False, OVERLAPPING_BASE, "pending", None, id="old-base-already-pending"),
+ pytest.param(GREEN, False, None, None, None, id="base-not-compared-gets-none"),
+ pytest.param(GREEN, False, None, "success", CI_PASSED_REVOKED, id="base-not-compared-revokes"),
pytest.param(
ForkObservation(suite_status="COMPLETED", suite_conclusion="FAILURE", run_url=RUN_URL),
False,
+ CURRENT_BASE,
"success",
CI_PASSED_REVOKED,
id="failed-rerun-revokes",
),
- pytest.param(GREEN, True, "success", CI_PASSED_REVOKED, id="unverified-after-retarget-revokes"),
+ pytest.param(
+ GREEN, True, CURRENT_BASE, "success", CI_PASSED_REVOKED, id="unverified-after-retarget-revokes"
+ ),
pytest.param(
ForkObservation(suite_status="IN_PROGRESS", run_url=RUN_URL),
False,
+ CURRENT_BASE,
None,
None,
id="running-gets-none",
),
],
)
-def test_ci_passed_reports_trusted_green_only(fork, changes_ci_files, ci_passed_state, expected):
- plan, _, _ = _classify(_pr(ci_passed_state=ci_passed_state), fork, changes_ci_files=changes_ci_files)
+def test_ci_passed_reports_trusted_green_on_a_current_base_only(
+ fork, changes_ci_files, base, ci_passed_state, expected
+):
+ plan, _, _ = _classify(
+ _pr(ci_passed_state=ci_passed_state), fork, changes_ci_files=changes_ci_files, base=base
+ )
assert plan.ci_passed == expected
+def test_green_whose_base_cannot_be_compared_is_reported():
+ plan, _, _ = _classify(_pr(), GREEN, base=None)
+
+ assert plan.state == ForkState.GREEN
+ assert any("could not be compared with `main`" in item for item in plan.unknown)
+
+
+KEPT_BASE = BaseCheck("kept", 300, None)
+
+
@pytest.mark.parametrize(
- ("pr_overrides", "behind", "expected_behind", "warned"),
+ ("pr_overrides", "compared", "expected_base"),
[
- pytest.param({}, 250, 250, True, id="counted-on-decision"),
- pytest.param({}, 3, 3, False, id="close-to-base"),
+ pytest.param({}, True, CURRENT_BASE, id="compared-on-decision"),
pytest.param(
- {"current_status": GREEN_STATUS, "marker": Marker("green", "abc123", NOW, behind=300)},
- None,
- 300,
- True,
+ {"current_status": GREEN_STATUS, "marker": Marker("green", "abc123", NOW, base=KEPT_BASE)},
+ False,
+ KEPT_BASE,
id="kept-from-the-marker",
),
pytest.param(
- {"current_status": GREEN_STATUS, "marker": Marker("green", "old-sha", NOW, behind=300)},
- None,
- None,
- False,
+ {"current_status": GREEN_STATUS, "marker": Marker("green", "old-sha", NOW, base=KEPT_BASE)},
+ True,
+ CURRENT_BASE,
id="not-kept-for-another-commit",
),
+ pytest.param(
+ {"current_status": GREEN_STATUS, "marker": Marker("green", "abc123", NOW)},
+ True,
+ CURRENT_BASE,
+ id="compared-for-a-marker-without-base",
+ ),
+ pytest.param(
+ {
+ "current_status": GREEN_STATUS,
+ "marker": Marker("green", "abc123", NOW, base=KEPT_BASE),
+ "last_base_change_at": NOW,
+ "status_created_at": NOW - timedelta(hours=1),
+ },
+ True,
+ CURRENT_BASE,
+ id="compared-again-after-retarget",
+ ),
],
)
-def test_green_records_how_far_behind_the_base_branch(pr_overrides, behind, expected_behind, warned):
- plan, _, _ = _classify(_pr(**pr_overrides), GREEN, behind=behind)
+def test_green_records_the_base_it_tested(pr_overrides, compared, expected_base):
+ compare_base = mock.Mock(return_value=CURRENT_BASE)
+ plan = classify(
+ _pr(**pr_overrides),
+ GREEN,
+ config=CONFIG,
+ now=NOW,
+ repo=REPO,
+ find_bypass_run=lambda: None,
+ changes_ci_files=lambda: False,
+ compare_base=compare_base,
+ )
- assert parse_marker(plan.marker_comment).behind == expected_behind
- assert ("commits behind `main`" in plan.marker_comment) is warned
+ assert compare_base.called is compared
+ assert parse_marker(plan.marker_comment).base == expected_base
+ assert f"[`{expected_base.sha[:10]}`]" in plan.marker_comment
@pytest.mark.parametrize(
@@ -853,7 +907,7 @@ def test_release_with_use_project_ci():
@pytest.mark.parametrize(
("ci_passed_state", "ci_passed_description", "revoked"),
[
- pytest.param("success", CI_PASSED_DESCRIPTION, True, id="fork-success-is-revoked"),
+ pytest.param("success", FORK_CI_PASSED_DESCRIPTION, True, id="fork-success-is-revoked"),
pytest.param("success", None, True, id="success-without-description-is-revoked"),
pytest.param("success", CI_PASSED_PROJECT_DESCRIPTION, False, id="project-success-is-kept"),
pytest.param("pending", CI_PASSED_WAITING_PROJECT_CI_DESCRIPTION, False, id="pending-is-kept"),
@@ -2073,12 +2127,14 @@ def _ci_passed_commit(state, description, oid="sha1"):
id="ungated-waiting-project-ci-passed",
),
pytest.param(
- False, "PENDING", CI_PASSED_DESCRIPTION, PROJECT_PASSED_URL, [1], id="ungated-fork-status"
+ False, "PENDING", FORK_CI_PASSED_DESCRIPTION, PROJECT_PASSED_URL, [1], id="ungated-fork-status"
),
pytest.param(
False, "PENDING", CI_PASSED_WAITING_PROJECT_CI_DESCRIPTION, None, [], id="ungated-not-passed"
),
- pytest.param(False, "SUCCESS", CI_PASSED_DESCRIPTION, PROJECT_PASSED_URL, [], id="already-success"),
+ pytest.param(
+ False, "SUCCESS", FORK_CI_PASSED_DESCRIPTION, PROJECT_PASSED_URL, [], id="already-success"
+ ),
pytest.param(False, "PENDING", "someone else", PROJECT_PASSED_URL, [], id="foreign-status"),
pytest.param(
True,
@@ -2140,7 +2196,7 @@ def test_discover_reads_the_status_of_a_head_commit_the_search_did_not_list(mock
**_pr_node(1),
"headRefOid": "sha1",
"labels": {"nodes": []},
- "commits": _ci_passed_commit("SUCCESS", CI_PASSED_DESCRIPTION, oid="older"),
+ "commits": _ci_passed_commit("SUCCESS", FORK_CI_PASSED_DESCRIPTION, oid="older"),
}
mock_read.return_value = PROJECT_PASSED_URL
client.graphql.side_effect = [_search_result(node), _search_result()]
@@ -2739,18 +2795,64 @@ def test_apply_plan_posts_ci_passed_under_its_own_context(client):
assert mock.call(42, "abc123", *CI_PASSED, context="CI passed") in client.set_status.call_args_list
+def _compare(behind, files, merge_base=MERGE_BASE):
+ return {"merge_base_commit": {"sha": merge_base}, "behind_by": behind, "files": files}
+
+
+def _files(*paths):
+ return [{"filename": path} for path in paths]
+
+
+HEAD_COMPARE = f"repos/{REPO}/compare/providers-fab%2Fv1-5...someone:abc123?per_page=1"
+BASE_COMPARE = f"repos/{REPO}/compare/{MERGE_BASE}...providers-fab%2Fv1-5?per_page=1"
+PR_FILES = f"repos/{REPO}/pulls/42/files?per_page=100"
+
+
@pytest.mark.parametrize(
- ("side_effect", "expected"),
+ ("responses", "expected", "expected_calls"),
[
- pytest.param([{"behind_by": 17}], 17, id="counted"),
- pytest.param(GitHubError("gh api failed: HTTP 500"), None, id="unreadable"),
+ pytest.param(
+ [_compare(0, _files("a.py"))], BaseCheck(MERGE_BASE, 0, ()), [HEAD_COMPARE], id="up-to-date"
+ ),
+ pytest.param(
+ [_compare(5, _files("a.py", "b.py")), _compare(0, _files("c.py"))],
+ BaseCheck(MERGE_BASE, 5, ()),
+ [HEAD_COMPARE, BASE_COMPARE],
+ id="no-overlap",
+ ),
+ pytest.param(
+ [
+ _compare(5, [*_files("b.py"), {"filename": "new.py", "previous_filename": "a.py"}]),
+ _compare(0, _files("b.py", "a.py", "c.py")),
+ ],
+ BaseCheck(MERGE_BASE, 5, ("a.py", "b.py")),
+ [HEAD_COMPARE, BASE_COMPARE],
+ id="overlap-with-rename",
+ ),
+ pytest.param(
+ [_compare(5, _files("a.py")), _compare(0, _files(*(f"f{i}" for i in range(300))))],
+ BaseCheck(MERGE_BASE, 5, None),
+ [HEAD_COMPARE, BASE_COMPARE],
+ id="base-side-at-cap",
+ ),
+ pytest.param(
+ [
+ _compare(5, _files(*(f"f{i}" for i in range(300)))),
+ _compare(0, _files("g.py", "f301")),
+ _files(*(f"f{i}" for i in range(400))),
+ ],
+ BaseCheck(MERGE_BASE, 5, ("f301",)),
+ [HEAD_COMPARE, BASE_COMPARE, PR_FILES],
+ id="large-pull-request-listed-in-full",
+ ),
+ pytest.param(GitHubError("gh api failed: HTTP 500"), None, [HEAD_COMPARE], id="unreadable"),
],
)
-def test_count_commits_behind(client, side_effect, expected):
- client.rest_get.side_effect = side_effect
+def test_compare_with_base(client, responses, expected, expected_calls):
+ client.rest_get.side_effect = responses
- assert count_commits_behind(client, REPO, _pr(base_ref="v3-1-test")) == expected
- assert client.rest_get.call_args.args[0] == f"repos/{REPO}/compare/v3-1-test...someone:abc123?per_page=1"
+ assert compare_with_base(client, REPO, _pr(base_ref="providers-fab/v1-5")) == expected
+ assert [call.args[0] for call in client.rest_get.call_args_list] == expected_calls
def _fork_job(name, status="completed", conclusion="success", url=None):
@@ -3977,7 +4079,7 @@ def _passed_suite(
("node", "expected"),
[
pytest.param(
- _passed_node(state="SUCCESS", description=CI_PASSED_DESCRIPTION),
+ _passed_node(state="SUCCESS", description=FORK_CI_PASSED_DESCRIPTION),
WAITING,
id="fork-success-revoked",
),
@@ -3987,7 +4089,9 @@ def _passed_suite(
),
pytest.param(
_passed_node(
- state="SUCCESS", description=CI_PASSED_DESCRIPTION, suites=[_passed_suite(5, cancelled=1)]
+ state="SUCCESS",
+ description=FORK_CI_PASSED_DESCRIPTION,
+ suites=[_passed_suite(5, cancelled=1)],
),
PASSED,
id="rerun-passed-next-to-the-marker-of-its-first-attempt",
@@ -3995,7 +4099,7 @@ def _passed_suite(
pytest.param(
_passed_node(
state="SUCCESS",
- description=CI_PASSED_DESCRIPTION,
+ description=FORK_CI_PASSED_DESCRIPTION,
suites=[
_passed_suite(4, created="2026-11-10T09:00:00Z"),
_passed_suite(6, conclusion=None, running=True),
@@ -4007,7 +4111,7 @@ def _passed_suite(
pytest.param(
_passed_node(
state="SUCCESS",
- description=CI_PASSED_DESCRIPTION,
+ description=FORK_CI_PASSED_DESCRIPTION,
suites=[
_passed_suite(5, created="2026-11-10T09:00:00Z"),
_passed_suite(6, conclusion=None, suite_cancelled=True),
@@ -4019,7 +4123,7 @@ def _passed_suite(
pytest.param(
_passed_node(
state="SUCCESS",
- description=CI_PASSED_DESCRIPTION,
+ description=FORK_CI_PASSED_DESCRIPTION,
suites=[
_passed_suite(5, created="2026-11-10T09:00:00Z"),
_passed_suite(6, cancelled=1, conclusion=None),
@@ -4031,7 +4135,9 @@ def _passed_suite(
pytest.param(_passed_node(state="PENDING", description="x"), None, id="pending-left-alone"),
pytest.param(
_passed_node(
- state="SUCCESS", description=CI_PASSED_DESCRIPTION, suites=[_passed_suite(5, conclusion=None)]
+ state="SUCCESS",
+ description=FORK_CI_PASSED_DESCRIPTION,
+ suites=[_passed_suite(5, conclusion=None)],
),
WAITING,
id="project-ci-still-running",
@@ -4039,7 +4145,7 @@ def _passed_suite(
pytest.param(
_passed_node(
state="SUCCESS",
- description=CI_PASSED_DESCRIPTION,
+ description=FORK_CI_PASSED_DESCRIPTION,
suites=[_passed_suite(5, cancelled=1, conclusion=None)],
),
WAITING,
@@ -4048,7 +4154,7 @@ def _passed_suite(
pytest.param(
_passed_node(
state="SUCCESS",
- description=CI_PASSED_DESCRIPTION,
+ description=FORK_CI_PASSED_DESCRIPTION,
suites=[_passed_suite(5, not_run=1, conclusion=None)],
),
WAITING,
@@ -4057,7 +4163,7 @@ def _passed_suite(
pytest.param(
_passed_node(
state="SUCCESS",
- description=CI_PASSED_DESCRIPTION,
+ description=FORK_CI_PASSED_DESCRIPTION,
suites=[_passed_suite(5, event="push"), _passed_suite(6, path=".github/workflows/other.yml")],
),
WAITING,
@@ -4066,7 +4172,7 @@ def _passed_suite(
pytest.param(
_passed_node(
state="SUCCESS",
- description=CI_PASSED_DESCRIPTION,
+ description=FORK_CI_PASSED_DESCRIPTION,
suites=[
_passed_suite(4, created="2026-11-10T09:00:00Z"),
_passed_suite(5, conclusion="FAILURE"),
@@ -4076,7 +4182,7 @@ def _passed_suite(
id="latest-run-failed",
),
pytest.param(
- _passed_node(state="SUCCESS", description=CI_PASSED_DESCRIPTION, suites=[_passed_suite(5)]),
+ _passed_node(state="SUCCESS", description=FORK_CI_PASSED_DESCRIPTION, suites=[_passed_suite(5)]),
PASSED,
id="project-ci-passed",
),
@@ -4117,7 +4223,7 @@ def test_report_project_ci_passed(client, node, expected):
def test_report_project_ci_passed_limits_successes_but_not_revocations(client):
client.graphql.return_value = _search_result(
*(_passed_node(n, state="PENDING", description="x", suites=[_passed_suite(5)]) for n in (1, 2, 3)),
- _passed_node(4, state="SUCCESS", description=CI_PASSED_DESCRIPTION),
+ _passed_node(4, state="SUCCESS", description=FORK_CI_PASSED_DESCRIPTION),
)
assert report_project_ci_passed(client, repo=REPO, attention=[], budget=2) == [1, 2, 4]
@@ -4126,7 +4232,7 @@ def test_report_project_ci_passed_limits_successes_but_not_revocations(client):
def test_report_project_ci_passed_keeps_going_after_an_error(client):
client.graphql.return_value = _search_result(
- *(_passed_node(n, state="SUCCESS", description=CI_PASSED_DESCRIPTION) for n in (1, 2))
+ *(_passed_node(n, state="SUCCESS", description=FORK_CI_PASSED_DESCRIPTION) for n in (1, 2))
)
client.set_status.side_effect = [GitHubError("gh api failed: HTTP 502"), None]
attention: list[tuple[int, str]] = []
@@ -4221,10 +4327,10 @@ def test_report_project_ci_passed_reads_a_head_commit_the_search_did_not_list(
):
mock_read.return_value = PROJECT_PASSED_URL if passed else None
client.graphql.return_value = _search_result(
- _passed_node(state="SUCCESS", description=CI_PASSED_DESCRIPTION, oid="older")
+ _passed_node(state="SUCCESS", description=FORK_CI_PASSED_DESCRIPTION, oid="older")
)
client.rest_get.return_value = [
- {"context": CI_PASSED_CONTEXT, "state": "success", "description": CI_PASSED_DESCRIPTION}
+ {"context": CI_PASSED_CONTEXT, "state": "success", "description": FORK_CI_PASSED_DESCRIPTION}
]
report_project_ci_passed(client, repo=REPO, attention=[])
@@ -4248,7 +4354,7 @@ def _run_reconcile_with_green_pull_requests(
*numbers,
live=LIVE_PULL_REQUEST,
same_branch=(),
- ci_passed=("success", RUN_URL, CI_PASSED_DESCRIPTION),
+ ci_passed=("success", RUN_URL, FORK_CI_PASSED_DESCRIPTION),
state=ForkState.GREEN,
):
"""Reconcile gated, fork-green pull requests that all have head commit ``shared``."""
@@ -4389,7 +4495,7 @@ def test_report_project_ci_passed_revokes_a_pull_request_the_heads_search_missed
_search_result(),
_search_result(),
_search_result(),
- _search_result(_passed_node(state="SUCCESS", description=CI_PASSED_DESCRIPTION)),
+ _search_result(_passed_node(state="SUCCESS", description=FORK_CI_PASSED_DESCRIPTION)),
]
client.rest_get_pages.return_value = [{"total_count": 0, "workflow_runs": []}]