Skip to content

: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.

fix(eng-analytics): drop ci hand-off shell runs (#107849)

Raúl Negrón-Otero3139c69771c0
diff --git a/products/engineering_analytics/SPEC.md b/products/engineering_analytics/SPEC.md
index 8b9e8d14ff37..1e28975ca6af 100644
--- a/products/engineering_analytics/SPEC.md
+++ b/products/engineering_analytics/SPEC.md
@@ -164,6 +164,7 @@ Engineering-specific decisions. Product-level decisions live in README → Locke
- The flag comes from a duplicate-key join, never a window function: a five-column scan aggregates the duplicated `(run_id, name, started_at, completed_at)` groups, and each job LEFT JOINs against them. A window function would sort the whole scan in memory, and the exposed views have no floor to bound it. A caller's outer `created_at_raw` predicate never reaches the duplicate scan, so windowed callers pass `created_floor=True`, which floors both scans (see the `workflow_jobs` builder); `job_costs.build_query` and `_curated.job_cost_source()` thread it through for the cost surfaces.
- The floor's slack depends on which clock the query windows (`_workflow_filters`). One day when it filters the job's own `created_at` — that only absorbs a timezone offset. A week when it filters the RUN's start, which every cost surface does: a re-run's runs row carries only its newest attempt's `run_started_at`, so its earlier attempts' job rows — the ones that actually ran — were created before the window. A tight floor there would cut them and silently under-report the re-run, undoing the `run_id`-only join above.
- Two cost queries stay unfloored on purpose: single-PR cost and the PR-list cost rollup are keyed by PR number, not a window, and no cheap date bound exists for either (see `pr_cost.py`). The per-run job breakdown is unfloored too: it filters `run_id`, which prunes the jobs scan, and the five-column duplicate scan is cheap even unbounded.
+- **A successful CI hand-off shell is filtered at the substrate, unlike a re-run copy — defined once in `logic/views/depot_ci.py`.** A copy belongs to a run that executed, and a red/green read still wants it. A successful shell executed no tests; a Depot shell otherwise reads as a false green run. Defining suppression once keeps every consumer consistent. Failed and unsettled relays stay because the source tables have no exact event link: another event's Depot verdict must not erase a relay failure. This can count a failed relay alongside a failed Depot execution until explicit event correlation exists. The rows stay in the raw GitHub and Depot tables, so a migration-progress read can still count hand-offs there. §7 has the detection rule.
- **Warehouse columns are strings + Nullable JSON; the builders parse and `ifNull`-guard.** Timestamps parse via `parseDateTimeBestEffort`; Nullable columns unwrap before any array function (ClickHouse rejects an Array inside a Nullable). `source_schema.py` mirrors the real landed types so seed and tests exercise the real path; violating this 500'd every endpoint on real data while idealized fixtures stayed green.
- **The warehouse views are managed data, not code registration.** "No global HogQL views" locks out `Database.create_for` (core importing the product, every team's per-query hot path). A per-team `DataWarehouseSavedQuery`, synced only for qualifying teams, reopens nothing: it exists so cost and CI history are queryable by insights, subscriptions, and `execute-sql`.
- **Workflow pass rate uses verdicts, not every completed run.** `success` is a pass. `failure`, `timed_out`, `startup_failure`, and `stale` are decisive failures. Skipped, cancelled, neutral, action-required, unsettled, and unknown outcomes reached no pass-or-fail verdict, so they stay in run volume but not the rate. The backend query layer owns this classification; frontend summaries over raw run rows mirror it in `lifecycle.ts`.
@@ -195,6 +196,7 @@ Warehouse tables (GitHub source):
Warehouse table (Depot source):
- `depot_job_attempts`: one row per Depot CI job attempt, for the repository the Depot source names. Reads keep only that repository's rows, because a source moved to another repository keeps what it synced before. Depot CI is its own engine, so these runs never reach the GitHub tables. `logic/views/depot_ci.py` reshapes the attempts into rows of the GitHub runs and jobs contracts and unions them onto those tables, so every builder reads both engines. Each Depot workflow is one runs row. A run with one workflow decodes its id to the integer `GITHUB_RUN_ID` Depot CI gives its jobs, which joins them to the CI test spans; a run with several workflows keys each by its own decoded workflow id, so no join fans out. The PR number comes from the run's `refs/pull/<n>/merge` ref, and the run's branch from that PR's snapshot. Job rows carry no branch, because a PR snapshot lookup in the jobs builder would add two full PR scans to every jobs read; a read that joins a job to its run takes the branch through `workflow_jobs.branch`, which falls back to the run's. Depot numbers attempts per job, not per run, so a job's last attempt is listed again under each later attempt of its run, as GitHub lists a job it did not re-run; the jobs builder flags those rows as `is_rerun_copy`. Depot's API reports no `runs-on`, so every attempt is costed as the default `depot-ubuntu-24.04` sandbox. Optional, and reads degrade to GitHub-only CI when unsynced.
+ - While a workflow moves to Depot CI, GitHub Actions routes each pull request to one engine, and both engines record a run of the commit. The union suppresses a successful Depot workflow whose `wait-for-handoff` job ran alone. A GitHub run is suppressed only when it succeeded, its `Hand off backend tests to Depot CI` job succeeded, its latest `Django Tests Pass` job succeeded, no synced job attempt decisively failed, and a successful Depot workflow took the hand-off for the same PR number and `head_sha`. Missing association or replacement data leaves the GitHub run visible. Failed, cancelled and unsettled GitHub relays and Depot waits stay visible. A relay that recovered retains its earlier failure history. Suppression applies to both runs and jobs; raw source rows remain available for full runner-cost accounting.
Other products read as sources:
diff --git a/products/engineering_analytics/backend/logic/queries/_curated.py b/products/engineering_analytics/backend/logic/queries/_curated.py
index fd3828b84f4e..1de608f94b39 100644
--- a/products/engineering_analytics/backend/logic/queries/_curated.py
+++ b/products/engineering_analytics/backend/logic/queries/_curated.py
@@ -272,11 +272,14 @@ class CuratedGitHubSource:
def _runs_table(self) -> str:
return depot_ci.with_depot_runs(
- self._tables.workflow_runs, self._depot_job_attempts(), self._tables.pull_requests
+ self._tables.workflow_runs,
+ self._depot_job_attempts(),
+ self._tables.pull_requests,
+ self._tables.workflow_jobs,
)
def _jobs_table(self, workflow_jobs_table: str) -> str:
- return depot_ci.with_depot_jobs(workflow_jobs_table, self._depot_job_attempts())
+ return depot_ci.with_depot_jobs(workflow_jobs_table, self._depot_job_attempts(), self._tables.workflow_runs)
def trunk_merge_queue_source(self) -> str | None:
"""Curated Trunk merge-queue ``SELECT`` subquery, or None when no TrunkIo source has the
diff --git a/products/engineering_analytics/backend/logic/sources.py b/products/engineering_analytics/backend/logic/sources.py
index dc197d328233..5b38438daee0 100644
--- a/products/engineering_analytics/backend/logic/sources.py
+++ b/products/engineering_analytics/backend/logic/sources.py
@@ -222,12 +222,14 @@ class JobSourceTables:
@property
def runs_source(self) -> str:
"""The runs to read: the GitHub runs table plus this repo's Depot CI runs when synced."""
- return depot_ci.with_depot_runs(self.github_workflow_runs, self.depot_job_attempts, self.pull_requests)
+ return depot_ci.with_depot_runs(
+ self.github_workflow_runs, self.depot_job_attempts, self.pull_requests, self.github_workflow_jobs
+ )
@property
def jobs_source(self) -> str:
"""The jobs to read: the GitHub jobs table plus this repo's Depot CI job attempts when synced."""
- return depot_ci.with_depot_jobs(self.github_workflow_jobs, self.depot_job_attempts)
+ return depot_ci.with_depot_jobs(self.github_workflow_jobs, self.depot_job_attempts, self.github_workflow_runs)
def resolve_job_source_tables(team: Team) -> list[JobSourceTables]:
diff --git a/products/engineering_analytics/backend/logic/views/depot_ci.py b/products/engineering_analytics/backend/logic/views/depot_ci.py
index 1a9e61af5a5b..1c9cd84b1ea7 100644
--- a/products/engineering_analytics/backend/logic/views/depot_ci.py
+++ b/products/engineering_analytics/backend/logic/views/depot_ci.py
@@ -11,12 +11,22 @@ are strings. Depot CI sets ``GITHUB_RUN_ID`` to the run id read as a base-30 num
``_ID_ALPHABET``, which the per-test traces its jobs emit confirm. A run with one workflow therefore
takes its decoded run id, which joins those traces to its jobs. A run with several workflows takes
each workflow's decoded id instead, because one shared id would fan every join on it out.
+
+While a repository moves a workflow to Depot CI, GitHub Actions decides per pull request which engine
+runs it, and both engines record a run of the same commit. The engine that did not run the tests
+leaves a hand-off shell: a GitHub run whose hand-off job succeeded and whose gate only relays Depot's
+verdict, or a Depot workflow that waited for a hand-off that never came and skipped everything else.
+The union drops successful shells with their jobs. A GitHub relay stays unless a successful Depot
+workflow took the hand-off for the same PR and commit. Failed and unsettled relays stay because the
+synced tables carry no exact event link, and another event's Depot verdict cannot replace theirs.
"""
import re
from posthog.dataclasses import frozen
+from products.engineering_analytics.backend.logic.queries._workflow_filters import DECISIVE_FAILURE_CONCLUSIONS_SQL
+from products.engineering_analytics.backend.logic.views import workflow_runs
from products.engineering_analytics.backend.logic.views.source_schema import (
WORKFLOW_JOBS_COLUMNS,
WORKFLOW_RUNS_COLUMNS,
@@ -59,6 +69,12 @@ _DEFAULT_SANDBOX_LABELS = '["depot-ubuntu-24.04"]'
# pull request association as the run's own.
_REPOSITORY_ID = 1
+# The hand-off between the engines, as .github/workflows/ci-backend.yml and .depot/workflows/ci-backend.yml
+# name its two ends.
+_GITHUB_HANDOFF_JOB = "Hand off backend tests to Depot CI"
+_GITHUB_RELAY_JOB = "Django Tests Pass"
+_DEPOT_WAIT_JOB_KEY_SUFFIX = ":wait-for-handoff"
+
def _is_id(column: str) -> str:
return f"match(ifNull({column}, ''), '^[{_ID_ALPHABET}]{{1,{_MAX_ID_LENGTH}}}$')"
@@ -201,26 +217,91 @@ def _jobs(attempts: str) -> str:
"""
-def _union(github_table: str, columns: dict[str, dict[str, str]], depot_select: str) -> str:
+def _handoff_workflows(depot: DepotJobAttempts) -> str:
+ # Depot lists no attempt for a skipped job, so a workflow that declined the hand-off holds the wait job alone.
+ is_wait = f"endsWith(ifNull(job_key, ''), '{_DEPOT_WAIT_JOB_KEY_SUFFIX}')"
+ return f"""(
+ SELECT
+ github_run_id,
+ any(head_sha) AS head_sha,
+ any(pr_number) AS pr_number,
+ any(workflow_status) AS workflow_status,
+ min(parseDateTimeBestEffort(workflow_created_at)) AS created_at,
+ countIf(NOT {is_wait}) > 0 AS took_handoff
+ FROM {_attempts(depot, pull_requests_table=None)}
+ GROUP BY github_run_id
+ HAVING countIf({is_wait}) > 0
+ )"""
+
+
+def _executed_attempts(depot: DepotJobAttempts, handoffs: str, pull_requests_table: str | None) -> str:
+ return f"""(
+ SELECT * FROM {_attempts(depot, pull_requests_table)}
+ WHERE github_run_id NOT IN (
+ SELECT github_run_id FROM {handoffs} WHERE NOT took_handoff AND workflow_status = 'finished'
+ )
+ )"""
+
+
+def _github_shells(jobs_table: str, runs_table: str, handoffs: str) -> str:
+ # No hand-off job predates Depot's first hand-off, so the day before it floors the scan of the jobs table.
+ return f"""
+ SELECT j.run_id FROM (
+ SELECT run_id
+ FROM {jobs_table}
+ WHERE created_at >= (SELECT toString(subtractDays(toDate(min(created_at)), 1)) FROM {handoffs})
+ GROUP BY run_id
+ HAVING countIf(name = '{_GITHUB_HANDOFF_JOB}' AND conclusion = 'success') > 0
+ AND argMaxIf(ifNull(conclusion, ''), tuple(run_attempt, id), name = '{_GITHUB_RELAY_JOB}') = 'success'
+ ) AS j
+ INNER JOIN ({workflow_runs.build_query(runs_table)}) AS r ON j.run_id = r.id
+ WHERE r.status = 'completed' AND r.conclusion = 'success'
+ -- A run can recover weeks after its failed attempt, so the failure check has no date floor.
+ AND j.run_id NOT IN (
+ SELECT run_id FROM {jobs_table} WHERE conclusion IN ({DECISIVE_FAILURE_CONCLUSIONS_SQL})
+ )
+ AND (r.head_sha, r.pr_number) IN (
+ SELECT head_sha, pr_number FROM {handoffs}
+ WHERE took_handoff AND pr_number > 0 AND workflow_status = 'finished'
+ )
+ """
+
+
+def _union(github_table: str, columns: dict[str, dict[str, str]], depot_select: str, where: str) -> str:
# UNION ALL matches columns by position, so the GitHub side names them in the contract order the
# Depot side follows.
- return f"(SELECT {', '.join(columns)} FROM {github_table} UNION ALL {depot_select})"
+ return f"(SELECT {', '.join(columns)} FROM {github_table} WHERE {where} UNION ALL {depot_select})"
-def with_depot_runs(runs_table: str, depot: DepotJobAttempts | None, pull_requests_table: str | None) -> str:
- """The GitHub runs table, or a subquery that also holds the Depot CI runs when they are synced."""
+def with_depot_runs(
+ runs_table: str, depot: DepotJobAttempts | None, pull_requests_table: str | None, jobs_table: str | None
+) -> str:
+ """The GitHub runs table, or a subquery that also holds the Depot CI runs when they are synced.
+
+ Successful hand-off shells are left out. Without ``jobs_table`` the GitHub shells stay.
+ """
if depot is None:
return runs_table
- return _union(runs_table, WORKFLOW_RUNS_COLUMNS, _runs(_attempts(depot, pull_requests_table)))
+ handoffs = _handoff_workflows(depot)
+ where = f"id NOT IN ({_github_shells(jobs_table, runs_table, handoffs)})" if jobs_table else "1"
+ return _union(
+ runs_table, WORKFLOW_RUNS_COLUMNS, _runs(_executed_attempts(depot, handoffs, pull_requests_table)), where
+ )
-def with_depot_jobs(jobs_table: str, depot: DepotJobAttempts | None) -> str:
+def with_depot_jobs(jobs_table: str, depot: DepotJobAttempts | None, runs_table: str) -> str:
"""The GitHub jobs table, or a subquery that also holds the Depot CI job attempts when they are synced.
- Depot job rows carry no branch: the jobs builder scans its source twice, so a PR snapshot lookup here
- would cost two PR scans per jobs read. A reader that joins a job to its run reads the branch through
- ``workflow_jobs.branch``, which falls back to the run's.
+ Hand-off shells are left out, as in ``with_depot_runs``. Depot job rows carry no branch: the jobs builder
+ scans its source twice, so a PR snapshot lookup here would cost two PR scans per jobs read. A reader that
+ joins a job to its run reads the branch through ``workflow_jobs.branch``, which falls back to the run's.
"""
if depot is None:
return jobs_table
- return _union(jobs_table, WORKFLOW_JOBS_COLUMNS, _jobs(_attempts(depot, pull_requests_table=None)))
+ handoffs = _handoff_workflows(depot)
+ return _union(
+ jobs_table,
+ WORKFLOW_JOBS_COLUMNS,
+ _jobs(_executed_attempts(depot, handoffs, pull_requests_table=None)),
+ f"run_id NOT IN ({_github_shells(jobs_table, runs_table, handoffs)})",
+ )
diff --git a/products/engineering_analytics/backend/tests/_logic_helpers.py b/products/engineering_analytics/backend/tests/_logic_helpers.py
index 3973eb703309..9120eee000f8 100644
--- a/products/engineering_analytics/backend/tests/_logic_helpers.py
+++ b/products/engineering_analytics/backend/tests/_logic_helpers.py
@@ -111,6 +111,7 @@ def _job_row(
started: str | None = None,
completed: str | None = None,
head_branch: str = "main",
+ head_sha: str = "sha60",
) -> dict[str, Any]:
# Default to the same relative anchor the seeded runs use, not a fixed calendar date. GitHub
# creates a job when its run attempt starts, so a job's created_at tracks its run's start — and
@@ -129,7 +130,7 @@ def _job_row(
"workflow_name": "CI",
"status": "completed",
"conclusion": conclusion,
- "head_sha": "sha60",
+ "head_sha": head_sha,
"head_branch": head_branch,
"labels": labels,
"runner_name": "runner-1",
diff --git a/products/engineering_analytics/backend/tests/test_views.py b/products/engineering_analytics/backend/tests/test_views.py
index 0d53bfd65c4f..bdc2ac407ff2 100644
--- a/products/engineering_analytics/backend/tests/test_views.py
+++ b/products/engineering_analytics/backend/tests/test_views.py
@@ -43,6 +43,7 @@ from products.engineering_analytics.backend.tests._github_fixtures import (
pr_association_entry,
repo_id,
)
+from products.engineering_analytics.backend.tests._logic_helpers import _job_row
class TestListGithubSourcesAccessControl(BaseTest):
@@ -240,8 +241,67 @@ class TestEngineeringAnalyticsViews(ClickhouseTestMixin, BaseTest):
assert rows[4][6:] == (9002, 0)
def test_depot_ci_attempts_read_as_runs_jobs_and_cost(self) -> None:
- runs_table = self._create_table("github_workflow_runs", WORKFLOW_RUNS_COLUMNS, [])
- jobs_table = self._create_table("github_workflow_jobs", WORKFLOW_JOBS_COLUMNS, [])
+ # Run 901 handed its commit to Depot, which ran it, so only Depot's run of that commit counts.
+ # Run 902 handed off a commit Depot never ran, so its relayed verdict is the only record of it.
+ runs_table = self._create_table(
+ "github_workflow_runs",
+ WORKFLOW_RUNS_COLUMNS,
+ [
+ _run_row(
+ run_id,
+ "Backend CI",
+ sha,
+ "completed",
+ conclusion,
+ "2026-09-24 14:50:00",
+ "2026-09-24 15:05:00",
+ pr_number=pr_number,
+ run_attempt=run_attempt,
+ )
+ for run_id, sha, pr_number, conclusion, run_attempt in (
+ (901, "abc123", 101991, "success", 1),
+ (902, "def456", 101991, "success", 1),
+ (903, "fed789", 101991, "success", 1),
+ (904, "abc123", 101992, "success", 1),
+ (905, "abc123", 101991, "failure", 1),
+ (906, "abc123", 101991, "failure", 2),
+ (907, "abc123", 101991, "success", 1),
+ (908, "abc123", 101991, "success", 2),
+ )
+ ],
+ )
+ jobs_table = self._create_table(
+ "github_workflow_jobs",
+ WORKFLOW_JOBS_COLUMNS,
+ [
+ _job_row(9011, 901, "Hand off backend tests to Depot CI", "success", head_sha="abc123"),
+ _job_row(9012, 901, "Django Tests Pass", "success", head_sha="abc123"),
+ _job_row(9021, 902, "Hand off backend tests to Depot CI", "success", head_sha="def456"),
+ _job_row(9031, 903, "Hand off backend tests to Depot CI", "skipped", head_sha="fed789"),
+ _job_row(9041, 904, "Hand off backend tests to Depot CI", "success", head_sha="abc123"),
+ _job_row(9042, 904, "Django Tests Pass", "success", head_sha="abc123"),
+ _job_row(9051, 905, "Hand off backend tests to Depot CI", "success", head_sha="abc123"),
+ _job_row(9052, 905, "Django Tests Pass", "failure", head_sha="abc123"),
+ _job_row(9061, 906, "Hand off backend tests to Depot CI", "success", head_sha="abc123"),
+ _job_row(9062, 906, "Django Tests Pass", "success", head_sha="abc123"),
+ _job_row(9063, 906, "Django Tests Pass", "failure", head_sha="abc123", run_attempt=2),
+ _job_row(9071, 907, "Hand off backend tests to Depot CI", "success", head_sha="abc123"),
+ _job_row(9072, 907, "Django Tests Pass", "success", head_sha="abc123"),
+ _job_row(9073, 907, "Django Tests Pass", "", head_sha="abc123", run_attempt=2)
+ | {"status": "in_progress", "conclusion": None},
+ _job_row(9081, 908, "Hand off backend tests to Depot CI", "success", head_sha="abc123"),
+ _job_row(
+ 9082,
+ 908,
+ "Django Tests Pass",
+ "failure",
+ head_sha="abc123",
+ started="2026-09-01 14:00:00",
+ completed="2026-09-01 14:02:00",
+ ),
+ _job_row(9083, 908, "Django Tests Pass", "success", head_sha="abc123", run_attempt=2),
+ ],
+ )
prs_table = self._create_table(
"github_pull_requests",
@@ -261,17 +321,19 @@ class TestEngineeringAnalyticsViews(ClickhouseTestMixin, BaseTest):
run_workflow_count: int = 1,
workflow_id: str = "6n4tghls33",
workflow_name: str = "Backend CI on Depot",
- workflow_status: str = "failed",
+ workflow_status: str = "finished",
ref: str = "refs/pull/101991/merge",
display_name: str = "Product tests (experiments)",
repo: str = "PostHog/posthog",
+ job_key: str = "ci-backend.yml:turbo-tests:matrix-38",
+ head_sha: str = "abc123",
) -> dict[str, str | int]:
return {
"run_id": run_id,
"run_workflow_count": run_workflow_count,
"repo": repo,
"ref": ref,
- "head_sha": "abc123",
+ "head_sha": head_sha,
"workflow_id": workflow_id,
"workflow_name": workflow_name,
"workflow_status": workflow_status,
@@ -279,7 +341,7 @@ class TestEngineeringAnalyticsViews(ClickhouseTestMixin, BaseTest):
"workflow_started_at": "2026-09-24T14:51:18.000Z",
"workflow_finished_at": "2026-09-24T15:01:18.000Z",
"job_id": job_id,
- "job_key": "ci-backend.yml:turbo-tests:matrix-38",
+ "job_key": job_key,
"job_display_name": display_name,
"attempt_id": attempt_id,
"attempt": attempt,
@@ -289,11 +351,27 @@ class TestEngineeringAnalyticsViews(ClickhouseTestMixin, BaseTest):
"sandbox_id": "sandbox",
}
- schedule: dict[str, Any] = {"run_id": "bbbbbbbbbb", "run_workflow_count": 2, "ref": "refs/heads/master"}
+ # A workflow that is not the handed-off one shares shell 902's commit, which must not pair them.
+ schedule: dict[str, Any] = {
+ "run_id": "bbbbbbbbbb",
+ "run_workflow_count": 2,
+ "ref": "refs/heads/master",
+ "head_sha": "def456",
+ }
depot_table = self._create_table(
"depot_job_attempts",
DEPOT_JOB_ATTEMPTS_COLUMNS,
[
+ attempt(
+ "c2d3f4g5h6",
+ 1,
+ "finished",
+ "2026-09-24T14:51:20.000Z",
+ "2026-09-24T14:51:30.000Z",
+ job_id="j2k3l4m5n6",
+ display_name="Wait for GitHub Actions to hand off backend tests",
+ job_key="ci-backend.yml:wait-for-handoff",
+ ),
attempt("zf6sbbn2wh", 1, "failed", "2026-09-24T14:53:00.000Z", "2026-09-24T14:55:00.000Z"),
attempt("3v4pbsqvfc", 2, "finished", "2026-09-24T14:56:00.000Z", "2026-09-24T14:59:00.000Z"),
# A job with no display name falls back to its key.
@@ -331,6 +409,31 @@ class TestEngineeringAnalyticsViews(ClickhouseTestMixin, BaseTest):
workflow_status="failed",
**schedule,
),
+ # Depot waited for a hand-off GitHub never made. It lists no attempt for the jobs it skipped.
+ attempt(
+ "m4n5p6q7r8",
+ 1,
+ "finished",
+ "2026-09-24T14:52:00.000Z",
+ "2026-09-24T14:52:02.000Z",
+ job_id="s4t5v6w7x8",
+ run_id="5555555555",
+ workflow_id="6666666666",
+ workflow_status="finished",
+ job_key="ci-backend.yml:wait-for-handoff",
+ ),
+ attempt(
+ "m4n5p6q7r9",
+ 1,
+ "failed",
+ "2026-09-24T14:52:00.000Z",
+ "2026-09-24T14:52:02.000Z",
+ job_id="s4t5v6w7x9",
+ run_id="5555555556",
+ workflow_id="6666666667",
+ workflow_status="failed",
+ job_key="ci-backend.yml:wait-for-handoff",
+ ),
# Synced before the source moved to another repository, so no read of this one keeps it.
attempt(
"k3w9v2rq8b",
@@ -345,22 +448,47 @@ class TestEngineeringAnalyticsViews(ClickhouseTestMixin, BaseTest):
],
)
depot = depot_ci.DepotJobAttempts(table=depot_table, repository="PostHog/posthog")
- runs = depot_ci.with_depot_runs(runs_table, depot, prs_table)
- jobs = depot_ci.with_depot_jobs(jobs_table, depot)
+ runs = depot_ci.with_depot_runs(runs_table, depot, prs_table, jobs_table)
+ jobs = depot_ci.with_depot_jobs(jobs_table, depot, runs_table)
# 80213453736890 is the GITHUB_RUN_ID Depot CI gave run 427q556wmn, as its per-test traces report it.
assert self._select(
"SELECT id, workflow_name, conclusion, pr_number, head_branch, duration_seconds, repo_owner, run_attempt "
f"FROM ({workflow_runs.build_query(runs)}) AS r ORDER BY id"
) == [
- (80213453736890, "Backend CI on Depot", "failure", 101991, "feature/depot", 600, "PostHog", 2),
+ (902, "Backend CI", "success", 101991, "main", 900, "PostHog", 1),
+ (903, "Backend CI", "success", 101991, "main", 900, "PostHog", 1),
+ (904, "Backend CI", "success", 101992, "main", 900, "PostHog", 1),
+ (905, "Backend CI", "failure", 101991, "main", 900, "PostHog", 1),
+ (906, "Backend CI", "failure", 101991, "main", 900, "PostHog", 2),
+ (907, "Backend CI", "success", 101991, "main", 900, "PostHog", 1),
+ (908, "Backend CI", "success", 101991, "main", 900, "PostHog", 2),
+ (80213453736890, "Backend CI on Depot", "success", 101991, "feature/depot", 600, "PostHog", 2),
+ (101808620689656, "Backend CI on Depot", "failure", 101991, "feature/depot", 600, "PostHog", 1),
(223978965517241, "Monitor", "success", 0, None, 600, "PostHog", 1),
(244340689655172, "Timing", "failure", 0, None, 600, "PostHog", 1),
]
+ assert self._select(
+ f"SELECT DISTINCT run_id FROM ({workflow_jobs.build_query(jobs)}) AS j ORDER BY run_id"
+ ) == [
+ (902,),
+ (903,),
+ (904,),
+ (905,),
+ (906,),
+ (907,),
+ (908,),
+ (80213453736890,),
+ (101808620689656,),
+ (223978965517241,),
+ (244340689655172,),
+ ]
assert self._select(
"SELECT run_id, run_attempt, name, conclusion, duration_seconds, is_rerun_copy "
f"FROM ({workflow_jobs.build_query(jobs)}) AS j WHERE run_id = 80213453736890 ORDER BY started_at, run_attempt"
) == [
+ (80213453736890, 1, "Wait for GitHub Actions to hand off backend tests", "success", 10, 0),
+ (80213453736890, 2, "Wait for GitHub Actions to hand off backend tests", "success", 10, 1),
(80213453736890, 1, "ci-backend.yml:turbo-tests:matrix-38", "success", 30, 0),
# Listed again under the run's second attempt, like a job GitHub did not re-run.
(80213453736890, 2, "ci-backend.yml:turbo-tests:matrix-38", "success", 30, 1),