:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
chore(ci): name the depot test results check (#111014)
Raúl Negrón-Otero3e7db716f1c1
diff --git a/.depot/workflows/ci-backend.yml b/.depot/workflows/ci-backend.ymlindex 1083032460b7..03169918e9e2 100644--- a/.depot/workflows/ci-backend.yml+++ b/.depot/workflows/ci-backend.yml@@ -345,7 +345,8 @@ jobs:fiecho "handed_off=$handed_off" >> "$GITHUB_OUTPUT"# Mirrors Depot's own checks for .github/scripts/ci_backend_relay.py (see MIRROR_APP_ID).- # A declined event also gets the gate's skipped check, as Depot posts it.+ # A declined event also gets the gate's skipped check, as Depot posts it. The mirrored+ # gate has its own name (see MIRRORED_GATE_CHECK), which differs from the gate job's name.- name: Post the hand-off checks for the relayif: github.event_name == 'pull_request' && steps.handoff-token.outputs.token != ''continue-on-error: true@@ -354,7 +355,7 @@ jobs:REPO: ${{ github.repository }}SHA: ${{ github.event.pull_request.head.sha }}WAIT_CHECK: Backend CI on Depot / Wait for GitHub Actions to hand off backend tests (PR ${{ github.event.pull_request.number }}, event ${{ github.event.pull_request.updated_at }})- GATE_CHECK: Backend CI on Depot / Django Tests Pass on Depot+ GATE_CHECK: Backend CI on Depot / Test resultsHANDED_OFF: ${{ steps.handoff.outputs.handed_off }}run: |post() {@@ -4427,7 +4428,8 @@ jobs:client-id: ${{ secrets.GH_APP_POSTHOG_TESTS_APP_ID }}private-key: ${{ secrets.GH_APP_POSTHOG_TESTS_PRIVATE_KEY }}permission-checks: write- # Mirrors Depot's own check for .github/scripts/ci_backend_relay.py (see MIRROR_APP_ID).+ # Mirrors Depot's own check for .github/scripts/ci_backend_relay.py (see MIRROR_APP_ID),+ # under the name in MIRRORED_GATE_CHECK so that the two rows on a pull request differ.# Depot's own checks carry no output and their pages need a Depot login, so this# check carries the gate summary: GitHub shows the title on the PR's check row# and the summary on the Checks tab.@@ -4438,7 +4440,7 @@ jobs:GH_TOKEN: ${{ steps.gate-token.outputs.token }}REPO: ${{ github.repository }}SHA: ${{ github.event.pull_request.head.sha }}- GATE_CHECK: Backend CI on Depot / Django Tests Pass on Depot+ GATE_CHECK: Backend CI on Depot / Test resultsCONCLUSION: ${{ job.status == 'cancelled' && 'cancelled' || (steps.verdict.outcome == 'success' && 'success' || 'failure') }}RELAY_RUN_URL: ${{ needs.wait-for-handoff.outputs.github_run_url }}run: |diff --git a/.github/scripts/ci_backend_relay.py b/.github/scripts/ci_backend_relay.pyindex 3dd4b1cf81de..1be10119e087 100644--- a/.github/scripts/ci_backend_relay.py+++ b/.github/scripts/ci_backend_relay.py@@ -46,7 +46,7 @@ from ci_backend_depot_failures import depot_ci, explainDEPOT_APP_ID = 219785DEPOT_ORG = "ntsdt08fpt"-# The PostHog tests GitHub App. Depot's wait and gate jobs post the same checks with it, because+# The PostHog tests GitHub App. Depot's wait and gate jobs post their verdicts with it too, because# Depot posts its own checks from a budget that runs out at peak and then delivers them late.MIRROR_APP_ID = 2492437# The Trunk merge queue tests each batch through a draft pull request on this branch.@@ -65,6 +65,11 @@ EVENT_SUFFIX = " (PR {pr}, event {event_at})"EVENT_TIME = "%Y-%m-%dT%H:%M:%SZ"RACING_EVENT_SECONDS = 2GATE_CHECK = f"{DEPOT_WORKFLOW} / Django Tests Pass on Depot"+# The mirror posts the gate under its own name, so that a pull request does not show two rows with one name.+MIRRORED_GATE_CHECK = f"{DEPOT_WORKFLOW} / Test results"+# Every name the mirror posts a check under. A Depot run on a workflow revision without the+# mirror's gate name posts Depot's name from the mirror.+MIRROR_NAMES = {GATE_CHECK: (GATE_CHECK, MIRRORED_GATE_CHECK)}DEPOT_RUN_URL = re.compile(r"^https://depot\.dev/orgs/([^/?]+)/workflows/([a-z0-9]+)(?:[?/]|$)")PENDING_STATES = frozenset({"queued", "in_progress", "pending", "waiting", "requested"})CONCLUSIONS = frozenset(@@ -261,16 +266,19 @@ class CheckRunReader:return error.code, "", {}def read(self, name: str) -> list[CheckRun]:- """Every app's checks of `name`. `current_check` picks the current one per workflow.+ """Every app's checks of `name`, under each name the app posts it with.+ `current_check` picks the current one per workflow.A failed read of any app raises, because the other app's checks alone can hold a stale attempt."""runs: list[CheckRun] = []for app_id in self._app_ids:- app_runs = self._read_app(name, app_id)- if app_runs is None:- raise ReadFailedError(f"Cannot read {name}")- runs.extend(app_runs)+ app_names = MIRROR_NAMES.get(name, (name,)) if app_id == MIRROR_APP_ID else (name,)+ for app_name in app_names:+ app_runs = self._read_app(app_name, app_id)+ if app_runs is None:+ raise ReadFailedError(f"Cannot read {app_name}")+ runs.extend(app_runs)return runsdef _read_app(self, name: str, app_id: int) -> list[CheckRun] | None:diff --git a/.github/scripts/test_ci_backend_relay.py b/.github/scripts/test_ci_backend_relay.pyindex 0d40458cfb15..fca19bffe1d7 100644--- a/.github/scripts/test_ci_backend_relay.py+++ b/.github/scripts/test_ci_backend_relay.py@@ -6,7 +6,8 @@ import http.clientimport urllib.errorimport urllib.parseimport importlib.util-from collections.abc import Sequence+import urllib.request+from collections.abc import Callable, Mapping, Sequencefrom pathlib import Pathfrom typing import Any@@ -72,7 +73,7 @@ def test_mirrored_checks_carry_the_names_the_relay_reads() -> None:.replace("${{ github.event.pull_request.updated_at }}", EVENT_AT))assert wait_check == EVENT_WAIT- assert handoff["env"]["GATE_CHECK"] == gate["env"]["GATE_CHECK"] == relay.GATE_CHECK+ assert handoff["env"]["GATE_CHECK"] == gate["env"]["GATE_CHECK"] == relay.MIRRORED_GATE_CHECK@pytest.mark.parametrize(@@ -478,6 +479,21 @@ class FakeResponse:return None+def checks_opener(+ checks: Mapping[int, Mapping[str, Sequence[dict[str, Any]] | None]],+) -> Callable[[urllib.request.Request, int], FakeResponse]:+ def opener(request: urllib.request.Request, timeout: int) -> FakeResponse:+ query = urllib.parse.parse_qs(urllib.parse.urlparse(request.full_url).query)+ name = query["check_name"][0]+ runs = checks[int(query["app_id"][0])][name]+ if runs is None:+ raise urllib.error.HTTPError(request.full_url, 502, "Bad Gateway", {}, None) # type: ignore[arg-type]+ body = [{**check, "name": name, "head_sha": EVENT.sha} for check in runs]+ return FakeResponse(json.dumps({"check_runs": body}).encode(), "")++ return opener++def test_reader_reuses_its_answer_on_304_and_stops_on_repeated_refusals() -> None:sent: list[dict[str, str]] = []answers: list[Any] = [@@ -708,22 +724,19 @@ def test_relay_reads_the_current_attempt_across_apps(depot_gate: list[tuple[int, str, str]] | None,expected: tuple[Any, str] | None,) -> None:- mirror = {EVENT_WAIT: [api_run(1, "success", "w1", "w")], relay.GATE_CHECK: [api_run(*c) for c in mirror_gate]}+ mirror = {+ EVENT_WAIT: [api_run(1, "success", "w1", "w")],+ relay.GATE_CHECK: [],+ relay.MIRRORED_GATE_CHECK: [api_run(*c) for c in mirror_gate],+ }depot = {EVENT_WAIT: [api_run(3, "success", "w1")],relay.GATE_CHECK: None if depot_gate is None else [api_run(*c) for c in depot_gate],}- def opener(request: Any, timeout: int) -> FakeResponse:- query = urllib.parse.parse_qs(urllib.parse.urlparse(request.full_url).query)- name, app_id = query["check_name"][0], int(query["app_id"][0])- runs = (mirror if app_id == relay.MIRROR_APP_ID else depot)[name]- if runs is None:- raise urllib.error.HTTPError(request.full_url, 502, "Bad Gateway", {}, None) # type: ignore[arg-type]- body = [{**check, "name": name, "head_sha": EVENT.sha} for check in runs]- return FakeResponse(json.dumps({"check_runs": body}).encode(), "")-- reader = relay.CheckRunReader(EVENT.repo, EVENT.sha, "token", opener=opener)+ reader = relay.CheckRunReader(+ EVENT.repo, EVENT.sha, "token", opener=checks_opener({relay.MIRROR_APP_ID: mirror, relay.DEPOT_APP_ID: depot})+ )wait = relay.newest_live(reader.read(EVENT_WAIT))if expected is None:with pytest.raises(relay.ReadFailedError):@@ -731,3 +744,57 @@ def test_relay_reads_the_current_attempt_across_apps(returncurrent = relay.progress(wait, reader.read(relay.GATE_CHECK))assert (current.phase, current.state) == expected+++ "posted,unreadable,expected",+ [+ pytest.param([(relay.GATE_CHECK, "success")], None, "success", id="an older workflow revision"),+ pytest.param(+ [(relay.GATE_CHECK, "success")],+ relay.MIRRORED_GATE_CHECK,+ None,+ id="a failed read of the mirror's new name",+ ),+ pytest.param(+ [(relay.MIRRORED_GATE_CHECK, "success")],+ relay.GATE_CHECK,+ None,+ id="a failed read of the mirror's old name",+ ),+ pytest.param(+ [(relay.GATE_CHECK, "success"), (relay.MIRRORED_GATE_CHECK, "failure")],+ None,+ "failure",+ id="a newer failed attempt under the new name",+ ),+ pytest.param(+ [(relay.MIRRORED_GATE_CHECK, "success"), (relay.GATE_CHECK, "failure")],+ None,+ "failure",+ id="a newer failed attempt under the old name",+ ),+ ],+)+def test_reader_reads_the_mirrored_gate_under_both_names(+ posted: Sequence[tuple[str, str]], unreadable: str | None, expected: str | None+) -> None:+ mirror: dict[str, list[dict[str, Any]] | None] = {relay.GATE_CHECK: [], relay.MIRRORED_GATE_CHECK: []}+ for index, (name, state) in enumerate(posted, start=1):+ mirror[name] = [api_run(index, state, "w1", f"a{index}")]+ if unreadable:+ mirror[unreadable] = None+ reader = relay.CheckRunReader(+ EVENT.repo,+ EVENT.sha,+ "token",+ opener=checks_opener({relay.MIRROR_APP_ID: mirror}),+ app_ids=(relay.MIRROR_APP_ID,),+ )+ if expected is None:+ with pytest.raises(relay.ReadFailedError):+ reader.read(relay.GATE_CHECK)+ return+ current = relay.current_check(reader.read(relay.GATE_CHECK), "w1")+ assert current is not None+ assert current.state == expected