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.

feat(eng-analytics): return job steps from the api (#111976)

Raúl Negrón-Otero8d42b78217e5
diff --git a/products/engineering_analytics/backend/facade/contracts.py b/products/engineering_analytics/backend/facade/contracts.py
index 525a8613eb13..ada987e9322a 100644
--- a/products/engineering_analytics/backend/facade/contracts.py
+++ b/products/engineering_analytics/backend/facade/contracts.py
@@ -436,6 +436,20 @@ class WorkflowRunActivity:
limit: int
+@dataclass(frozen=True)
+class WorkflowJobStep:
+ """One step of a job, in the order the job ran it."""
+
+ number: int
+ name: str
+ # Raw status / conclusion passthrough; conclusion is None until the step finishes.
+ status: str
+ conclusion: str | None
+ started_at: datetime | None
+ completed_at: datetime | None
+ duration_seconds: int | None
+
+
@dataclass(frozen=True)
class WorkflowJob:
"""One job within a workflow run, for the run's expandable job breakdown. ``estimated_cost_usd``
@@ -464,6 +478,8 @@ class WorkflowJob:
native_workflow_run_id: str | None = None
native_job_id: str | None = None
native_attempt_id: str | None = None
+ # Empty when the source reports no steps for the job, as for a Depot CI job.
+ steps: list[WorkflowJobStep] = field(default_factory=list)
@dataclass(frozen=True)
diff --git a/products/engineering_analytics/backend/logic/queries/_curated.py b/products/engineering_analytics/backend/logic/queries/_curated.py
index 8217eca63e68..4d04396c0f4e 100644
--- a/products/engineering_analytics/backend/logic/queries/_curated.py
+++ b/products/engineering_analytics/backend/logic/queries/_curated.py
@@ -250,17 +250,20 @@ class CuratedGitHubSource:
)
return f"({query})"
- def jobs_source(self, *, created_floor: bool = False) -> str | None:
+ def jobs_source(self, *, created_floor: bool = False, include_steps: bool = False) -> str | None:
"""Curated workflow-jobs ``SELECT`` subquery, or None when the optional jobs table isn't synced.
``created_floor`` adds the raw-string scan floor inside the builder — callers must register
{job_created_floor} (see run_started_floor_constant). A windowed caller needs it: the builder's
- ``is_rerun_copy`` duplicate scan reads no ``created_at_raw``, so only the floor bounds it."""
+ ``is_rerun_copy`` duplicate scan reads no ``created_at_raw``, so only the floor bounds it.
+
+ ``include_steps`` appends the raw ``steps`` JSON column, for a read bounded to one run."""
if not self._tables.workflow_jobs:
return None
- return (
- f"({workflow_jobs.build_query(self._jobs_table(self._tables.workflow_jobs), created_floor=created_floor)})"
+ query = workflow_jobs.build_query(
+ self._jobs_table(self._tables.workflow_jobs), created_floor=created_floor, include_steps=include_steps
)
+ return f"({query})"
def _depot_job_attempts(self) -> depot_ci.DepotJobAttempts | None:
"""The repository's synced Depot CI job attempts, or None. Resolved lazily and cached like the
diff --git a/products/engineering_analytics/backend/logic/queries/workflow_jobs.py b/products/engineering_analytics/backend/logic/queries/workflow_jobs.py
index ce42fe68e683..302ca2e798d6 100644
--- a/products/engineering_analytics/backend/logic/queries/workflow_jobs.py
+++ b/products/engineering_analytics/backend/logic/queries/workflow_jobs.py
@@ -16,11 +16,12 @@ attempts' jobs have synced — returning an empty breakdown rather than stale jo
"""
import json
+from datetime import UTC, datetime
from typing import Any
from posthog.hogql import ast
-from products.engineering_analytics.backend.facade.contracts import CIEngine, WorkflowJob
+from products.engineering_analytics.backend.facade.contracts import CIEngine, WorkflowJob, WorkflowJobStep
from products.engineering_analytics.backend.logic.cost import (
billed_elapsed_seconds,
estimate_job_cost_usd,
@@ -38,7 +39,7 @@ from products.engineering_analytics.backend.logic.queries._curated import Curate
# to buy a bound the run filter already provides.
_SELECT = """
SELECT id, run_id, run_attempt, name, status, conclusion, labels, runner_name, started_at, completed_at, duration_seconds, provisioning_seconds, is_rerun_copy,
- ci_engine, native_run_id, native_workflow_run_id, native_job_id, native_attempt_id
+ ci_engine, native_run_id, native_workflow_run_id, native_job_id, native_attempt_id, steps
FROM __JOBS_SOURCE__ AS j
WHERE run_id = {run_id} AND ({ci_engine} IS NULL OR ci_engine = {ci_engine})
ORDER BY started_at ASC, id ASC
@@ -56,7 +57,7 @@ _LATEST_ATTEMPT_SELECT = """
def query_workflow_jobs(
*, curated: CuratedGitHubSource, run_id: int, run_attempt: int | None = None, ci_engine: CIEngine | None = None
) -> list[WorkflowJob]:
- jobs_source = curated.jobs_source()
+ jobs_source = curated.jobs_source(include_steps=True)
if jobs_source is None:
# The optional job-level source isn't synced for this team yet.
return []
@@ -127,6 +128,7 @@ def _to_job(row: tuple[Any, ...]) -> WorkflowJob:
native_workflow_run_id,
native_job_id,
native_attempt_id,
+ steps_raw,
) = row
labels = _parse_labels(labels_raw)
duration_seconds = int(duration) if duration is not None else None
@@ -147,6 +149,7 @@ def _to_job(row: tuple[Any, ...]) -> WorkflowJob:
native_workflow_run_id=native_workflow_run_id,
native_job_id=native_job_id,
native_attempt_id=native_attempt_id,
+ steps=_parse_steps(steps_raw),
# Cost runs off the billed clock (wall-clock minus runner boot), not duration_seconds, which
# stays what the row displays. A row GitHub re-listed under this attempt without re-running it
# costs nothing — the attempt that actually ran carries the minutes (see the jobs builder).
@@ -166,3 +169,44 @@ def _parse_labels(raw: Any) -> list[str]:
except (TypeError, ValueError):
return []
return [str(item) for item in parsed] if isinstance(parsed, list) else []
+
+
+def _parse_steps(raw: Any) -> list[WorkflowJobStep]:
+ if not raw:
+ return []
+ try:
+ parsed = json.loads(raw)
+ except (TypeError, ValueError):
+ return []
+ if not isinstance(parsed, list):
+ return []
+ steps = [_to_step(item, position) for position, item in enumerate(parsed, start=1) if isinstance(item, dict)]
+ return sorted(steps, key=lambda step: step.number)
+
+
+def _to_step(item: dict[str, Any], position: int) -> WorkflowJobStep:
+ number = item.get("number")
+ started_at = _parse_timestamp(item.get("started_at"))
+ completed_at = _parse_timestamp(item.get("completed_at"))
+ return WorkflowJobStep(
+ number=number if isinstance(number, int) else position,
+ name=str(item.get("name") or ""),
+ status=str(item.get("status") or ""),
+ conclusion=str(item["conclusion"]) if item.get("conclusion") else None,
+ started_at=started_at,
+ completed_at=completed_at,
+ duration_seconds=(
+ max(int((completed_at - started_at).total_seconds()), 0) if started_at and completed_at else None
+ ),
+ )
+
+
+def _parse_timestamp(raw: Any) -> datetime | None:
+ if not isinstance(raw, str) or not raw:
+ return None
+ try:
+ parsed = datetime.fromisoformat(raw)
+ except ValueError:
+ return None
+ # A step duration subtracts two of these, and Python raises TypeError when only one of them has an offset.
+ return parsed if parsed.tzinfo else parsed.replace(tzinfo=UTC)
diff --git a/products/engineering_analytics/backend/logic/views/workflow_jobs.py b/products/engineering_analytics/backend/logic/views/workflow_jobs.py
index 3668c65c9a43..7bc25df12fc2 100644
--- a/products/engineering_analytics/backend/logic/views/workflow_jobs.py
+++ b/products/engineering_analytics/backend/logic/views/workflow_jobs.py
@@ -90,7 +90,10 @@ class JobsTable:
return cls(rows=table, duplicates=table)
-def build_query(table: JobsTable, *, created_floor: bool = False) -> str:
+def build_query(table: JobsTable, *, created_floor: bool = False, include_steps: bool = False) -> str:
+ """``include_steps`` appends the raw ``steps`` JSON as the last column. It is the widest column of
+ the table, so only a read bounded to one run asks for it."""
+
# The floor must live in its OWN innermost SELECT on the raw string column, like the runs
# builder's: the parsing SELECT below aliases parseDateTimeBestEffort(created_at) AS created_at,
# so a WHERE there would compare the parsed DateTime against the floor string. The jobs scan and
@@ -100,6 +103,8 @@ def build_query(table: JobsTable, *, created_floor: bool = False) -> str:
rows_source = floored(table.rows)
duplicates_source = floored(table.duplicates)
+ steps_column = ",\n job.steps AS steps" if include_steps else ""
+ parsed_steps_column = ",\n ifNull(toString(steps), '[]') AS steps" if include_steps else ""
return f"""
SELECT
job.id AS id,
@@ -137,7 +142,7 @@ def build_query(table: JobsTable, *, created_floor: bool = False) -> str:
job.native_run_id AS native_run_id,
job.native_workflow_run_id AS native_workflow_run_id,
job.native_job_id AS native_job_id,
- job.native_attempt_id AS native_attempt_id
+ job.native_attempt_id AS native_attempt_id{steps_column}
FROM (
SELECT
id,
@@ -158,7 +163,7 @@ def build_query(table: JobsTable, *, created_floor: bool = False) -> str:
created_at_raw,
parseDateTimeBestEffort(started_at) AS started_at,
parseDateTimeBestEffort(completed_at) AS completed_at,
- {_FIRST_STEP_STARTED_AT} AS first_step_started_at
+ {_FIRST_STEP_STARTED_AT} AS first_step_started_at{parsed_steps_column}
FROM (SELECT *, created_at AS created_at_raw FROM {rows_source})
) AS job
-- The duplicated (run_id, name, started_at, completed_at) groups: the re-run copies plus
diff --git a/products/engineering_analytics/backend/management/commands/seed_engineering_analytics.py b/products/engineering_analytics/backend/management/commands/seed_engineering_analytics.py
index 1258e39d9cca..ae80d83d0124 100644
--- a/products/engineering_analytics/backend/management/commands/seed_engineering_analytics.py
+++ b/products/engineering_analytics/backend/management/commands/seed_engineering_analytics.py
@@ -158,6 +158,132 @@ _RUNNER_LABELS = (
_TS_FMT = "%Y-%m-%d %H:%M:%S"
+_DEMO_BRANCH = "demo/multi-push-progression"
+
+# The demo pull request's workflows get job shapes like the real ones: jobs that start in waves,
+# and matrix jobs with many shards. Each entry is (job name, wave, shard count).
+_DEMO_JOB_SHAPES: dict[str, tuple[tuple[str, int, int], ...]] = {
+ "Backend CI": (
+ ("Detect changes", 0, 1),
+ ("Django tests – Core", 1, 12),
+ ("Django tests – Temporal", 1, 4),
+ ("Product tests", 1, 6),
+ ("Check migrations", 1, 1),
+ ("Async migrations", 1, 1),
+ ("Django Tests Pass", 2, 1),
+ ),
+ "Frontend CI": (
+ ("Detect changes", 0, 1),
+ ("Jest tests", 1, 8),
+ ("Typecheck", 1, 1),
+ ("Lint", 1, 1),
+ ("Frontend Tests Pass", 2, 1),
+ ),
+ "E2E Tests": (
+ ("Build image", 0, 1),
+ ("Playwright", 1, 6),
+ ("Upload report", 2, 1),
+ ),
+ "Rust CI": (
+ ("Build", 0, 1),
+ ("Test", 1, 4),
+ ("Clippy", 1, 1),
+ ),
+ "Storybook": (
+ ("Build Storybook", 0, 1),
+ ("Visual regression", 1, 10),
+ ("Upload snapshots", 2, 1),
+ ),
+}
+
+
+_STEP_TS_FMT = "%Y-%m-%dT%H:%M:%SZ"
+_MAIN_STEP = "Run"
+# Step name and its share of the job's wall-clock. The shares sum to 1.
+_STEP_SHAPE: tuple[tuple[str, float], ...] = (
+ ("Set up job", 0.04),
+ ("Checkout", 0.06),
+ ("Restore cache", 0.1),
+ (_MAIN_STEP, 0.7),
+ ("Post Restore cache", 0.05),
+ ("Post Checkout", 0.03),
+ ("Complete job", 0.02),
+)
+
+
+def _shaped_steps(job_name: str, job_start: datetime, job_end: datetime, conclusion: str | None) -> str:
+ """A job's steps as GitHub's JSON. A failed job fails on its main step; an unfinished job is still on it."""
+ seconds = (job_end - job_start).total_seconds()
+ steps: list[dict[str, Any]] = []
+ step_start = job_start
+ main_reached = False
+ for number, (name, share) in enumerate(_STEP_SHAPE, start=1):
+ is_main = name == _MAIN_STEP
+ step_end = step_start + timedelta(seconds=seconds * share)
+ step: dict[str, Any] = {
+ "number": number,
+ "name": f"Run {job_name}" if is_main else name,
+ "status": "completed",
+ "conclusion": "success",
+ "started_at": step_start.strftime(_STEP_TS_FMT),
+ "completed_at": step_end.strftime(_STEP_TS_FMT),
+ }
+ if conclusion is None and is_main:
+ step.update(status="in_progress", conclusion=None, completed_at=None)
+ elif conclusion is None and main_reached:
+ step.update(status="queued", conclusion=None, started_at=None, completed_at=None)
+ elif conclusion in _FAILING_CONCLUSIONS and is_main:
+ step["conclusion"] = "failure"
+ steps.append(step)
+ main_reached = main_reached or is_main
+ step_start = step_end
+ return json.dumps(steps)
+
+
+def _shaped_jobs(
+ run: dict[str, Any], shape: tuple[tuple[str, int, int], ...], run_start: datetime, window: float
+) -> list[dict[str, Any]]:
+ completed = run.get("status") == "completed"
+ failing = run.get("conclusion") in _FAILING_CONCLUSIONS
+ waves = max(wave for _name, wave, _shards in shape) + 1
+ segment = window / waves
+ widest_name, _wave, widest_shards = max(shape, key=lambda entry: entry[2])
+
+ jobs: list[dict[str, Any]] = []
+ for name, wave, shards in shape:
+ for shard in range(shards):
+ index = len(jobs)
+ # An unfinished run is still on its last wave.
+ finished = completed or wave < waves - 1
+ conclusion = "success" if finished else None
+ if failing and (name, shard) == (widest_name, widest_shards // 2):
+ conclusion = run["conclusion"]
+ job_start = run_start + timedelta(seconds=wave * segment)
+ # Shards end at different times, so their durations differ.
+ job_end = job_start + timedelta(seconds=segment * (0.55 + ((index * 37) % 10) / 22))
+ started_at = job_start.strftime(_TS_FMT)
+ jobs.append(
+ {
+ "id": run["id"] * 100 + index,
+ "run_id": run["id"],
+ "run_attempt": run.get("run_attempt", 1),
+ "name": f"{name} ({shard + 1}/{shards})" if shards > 1 else name,
+ "workflow_name": run.get("name"),
+ "status": "completed" if finished else "in_progress",
+ "conclusion": conclusion,
+ "head_sha": run.get("head_sha"),
+ "head_branch": run.get("head_branch"),
+ "labels": _RUNNER_LABELS[index % len(_RUNNER_LABELS)],
+ "runner_name": f"runner-{index + 1}",
+ "runner_group_name": "depot",
+ "created_at": started_at,
+ "started_at": started_at,
+ "completed_at": job_end.strftime(_TS_FMT) if finished else None,
+ "steps": _shaped_steps(name, job_start, job_end, conclusion),
+ }
+ )
+ return jobs
+
def _synthesize_jobs(runs: list[dict[str, Any]]) -> list[dict[str, Any]]:
jobs: list[dict[str, Any]] = []
@@ -178,6 +304,11 @@ def _synthesize_jobs(runs: list[dict[str, Any]]) -> list[dict[str, Any]]:
window = (run_end - run_start).total_seconds() if run_start and run_end and run_end > run_start else 0.0
segment = window / count if window else 0.0
+ shape = _DEMO_JOB_SHAPES.get(run.get("name") or "") if run.get("head_branch") == _DEMO_BRANCH else None
+ if shape and run_start and window:
+ jobs.extend(_shaped_jobs(run, shape, run_start, window))
+ continue
+
for idx in range(count):
is_last = idx == count - 1
# Healthy jobs pass; a failing run's failure surfaces on its last job.
@@ -207,7 +338,14 @@ def _synthesize_jobs(runs: list[dict[str, Any]]) -> list[dict[str, Any]]:
"created_at": started_at,
"started_at": started_at,
"completed_at": completed_at,
- "steps": "[]",
+ # Only an unfinished job gets steps, which show the in-progress and queued states.
+ "steps": (
+ _shaped_steps(
+ _JOB_NAMES[idx % len(_JOB_NAMES)], job_start, job_start + timedelta(seconds=segment), None
+ )
+ if job_start and segment and not completed
+ else "[]"
+ ),
}
)
return jobs
@@ -316,7 +454,8 @@ def _demo_master_commits(anchor: datetime, merged_prs: Sequence[dict[str, Any]])
"conclusion": conclusion,
"created_at": iso(start),
"run_started_at": iso(start),
- "updated_at": iso(start) if running else iso(start + duration),
+ # A running run was last updated part of the way through, which gives its jobs a time span.
+ "updated_at": iso(start + duration / 2) if running else iso(start + duration),
"run_attempt": 1,
"repository": {"full_name": "PostHog/posthog"},
"pull_requests": [{"number": _FORK_PR_NUMBER, "base": {"repo": {"id": _FORK_REPO_ID}}}],
@@ -478,6 +617,7 @@ def _issue_event_rows(prs: list[dict[str, Any]], anchor: datetime) -> list[dict[
"event": event,
"actor": json.dumps({"login": (pr.get("user") or {}).get("login") or "", "avatar_url": ""}),
"issue": json.dumps({"number": pr["number"]}),
+ "requested_team": None,
"created_at": at.strftime("%Y-%m-%dT%H:%M:%SZ"),
}
)
@@ -579,12 +719,12 @@ def _demo_multi_push(
"id": 9_900_000_000 + push_index * 100 + wf_index,
"name": workflow,
"head_sha": push_shas[push_index],
- "head_branch": "demo/multi-push-progression",
+ "head_branch": _DEMO_BRANCH,
"status": "in_progress" if running else "completed",
"conclusion": None if running else conclusion,
"created_at": iso(start),
"run_started_at": iso(start),
- "updated_at": iso(start) if running else iso(end),
+ "updated_at": iso(start + (end - start) / 2) if running else iso(end),
"run_attempt": 1,
"repository": {"full_name": "PostHog/posthog"},
"pull_requests": [{"number": _DEMO_PR_NUMBER}],
diff --git a/products/engineering_analytics/backend/presentation/serializers/workflows.py b/products/engineering_analytics/backend/presentation/serializers/workflows.py
index 75c1d317b14b..9915e99cf92f 100644
--- a/products/engineering_analytics/backend/presentation/serializers/workflows.py
+++ b/products/engineering_analytics/backend/presentation/serializers/workflows.py
@@ -18,6 +18,7 @@ from products.engineering_analytics.backend.facade.contracts import (
WorkflowHealthItem,
WorkflowJob,
WorkflowJobAggregate,
+ WorkflowJobStep,
WorkflowRunActivity,
WorkflowRunActivityPoint,
WorkflowRunDetail,
@@ -120,7 +121,33 @@ class WorkflowRunActivitySerializer(DataclassSerializer):
}
+class WorkflowJobStepSerializer(DataclassSerializer):
+ class Meta:
+ dataclass = WorkflowJobStep
+ extra_kwargs = {
+ "number": {"help_text": "1-based position of the step in the job."},
+ "name": {"help_text": "Step name."},
+ "status": {"help_text": "Raw step status: 'queued', 'in_progress', 'completed', etc."},
+ "conclusion": {
+ "help_text": "Step conclusion ('success', 'failure', 'cancelled', 'skipped', ...), or null until the "
+ "step finishes.",
+ "allow_null": True,
+ },
+ "started_at": {"help_text": "When the step started, or null if it has not started.", "allow_null": True},
+ "completed_at": {"help_text": "When the step finished, or null while it runs.", "allow_null": True},
+ "duration_seconds": {
+ "help_text": "Wall-clock duration in seconds; null until the step finishes.",
+ "allow_null": True,
+ },
+ }
+
+
class WorkflowJobSerializer(DataclassSerializer):
+ steps = WorkflowJobStepSerializer(
+ many=True,
+ help_text="The job's steps in run order. Empty when the source reports no steps, as for a Depot CI job.",
+ )
+
class Meta:
dataclass = WorkflowJob
extra_kwargs = {
diff --git a/products/engineering_analytics/backend/tests/_logic_helpers.py b/products/engineering_analytics/backend/tests/_logic_helpers.py
index 9120eee000f8..8ffb1adb0e90 100644
--- a/products/engineering_analytics/backend/tests/_logic_helpers.py
+++ b/products/engineering_analytics/backend/tests/_logic_helpers.py
@@ -112,6 +112,7 @@ def _job_row(
completed: str | None = None,
head_branch: str = "main",
head_sha: str = "sha60",
+ steps: str = "[]",
) -> 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
@@ -138,7 +139,7 @@ def _job_row(
"created_at": started,
"started_at": started,
"completed_at": completed,
- "steps": "[]",
+ "steps": steps,
}
diff --git a/products/engineering_analytics/backend/tests/test_logic_workflows.py b/products/engineering_analytics/backend/tests/test_logic_workflows.py
index cc387e00e5b5..29c3d3399938 100644
--- a/products/engineering_analytics/backend/tests/test_logic_workflows.py
+++ b/products/engineering_analytics/backend/tests/test_logic_workflows.py
@@ -1,4 +1,5 @@
-from datetime import datetime, timedelta
+import json
+from datetime import UTC, datetime, timedelta
from itertools import count
from types import SimpleNamespace
from typing import Any
@@ -1184,12 +1185,35 @@ class TestWorkflowEndpointsWarehouse(_EndpointsWarehouseMixin, BaseTest):
# No jobs table synced yet → empty, not an error (the graceful path).
assert api.list_workflow_jobs(team=self.team, run_id=9100) == []
+ unfinished_step = {
+ "number": 2,
+ "name": "Run tests",
+ "status": "in_progress",
+ "conclusion": None,
+ "started_at": "2026-01-05T10:00:30Z",
+ "completed_at": None,
+ }
+ finished_step = {
+ "number": 1,
+ "name": "Set up job",
+ "status": "completed",
+ "conclusion": "success",
+ "started_at": "2026-01-05T10:00:00Z",
+ "completed_at": "2026-01-05T10:00:30Z",
+ }
self._create_table(
"github_workflow_jobs",
WORKFLOW_JOBS_COLUMNS,
[
- _job_row(91000, 9100, "build", "success", labels='["depot-ubuntu-22.04-16"]'),
- _job_row(91001, 9100, "e2e", "failure", labels='["ubuntu-latest"]'),
+ _job_row(
+ 91000,
+ 9100,
+ "build",
+ "success",
+ labels='["depot-ubuntu-22.04-16"]',
+ steps=json.dumps([unfinished_step, "not a step", finished_step]),
+ ),
+ _job_row(91001, 9100, "e2e", "failure", labels='["ubuntu-latest"]', steps="not json"),
],
)
jobs = api.list_workflow_jobs(team=self.team, run_id=9100)
@@ -1197,9 +1221,16 @@ class TestWorkflowEndpointsWarehouse(_EndpointsWarehouseMixin, BaseTest):
build = next(j for j in jobs if j.name == "build")
assert build.runner_provider == "self_hosted" and build.runner_label == "16-core"
assert build.estimated_cost_usd is not None
+ set_up, run_tests = build.steps
+ assert (set_up.number, set_up.name, set_up.conclusion) == (1, "Set up job", "success")
+ assert set_up.started_at == datetime(2026, 1, 5, 10, 0, tzinfo=UTC)
+ assert set_up.duration_seconds == 30
+ assert (run_tests.status, run_tests.conclusion) == ("in_progress", None)
+ assert (run_tests.completed_at, run_tests.duration_seconds) == (None, None)
# github-hosted runner isn't billable → no cost estimate, and the provider reads as github_hosted.
e2e = next(j for j in jobs if j.name == "e2e")
assert e2e.runner_provider == "github_hosted" and e2e.estimated_cost_usd is None
+ assert e2e.steps == []
def test_job_aggregates_branch_filter_matches_depot_jobs_through_their_run(self) -> None:
started, completed = _ago_with_duration(1, 120)
@@ -1318,6 +1349,7 @@ class TestWorkflowEndpointsWarehouse(_EndpointsWarehouseMixin, BaseTest):
jobs = api.list_workflow_jobs(team=self.team, run_id=60, ci_engine=engine)
assert jobs and {job.ci_engine for job in jobs} == {engine}
assert all(job.native_attempt_id and job.native_workflow_run_id for job in jobs)
+ assert all(job.steps == [] for job in jobs)
def test_job_aggregates_rate_and_queue_time_use_verdicts(self) -> None:
self._create_table(
diff --git a/products/engineering_analytics/frontend/generated/api.schemas.ts b/products/engineering_analytics/frontend/generated/api.schemas.ts
index 178959d894e8..e94097d2db2e 100644
--- a/products/engineering_analytics/frontend/generated/api.schemas.ts
+++ b/products/engineering_analytics/frontend/generated/api.schemas.ts
@@ -2269,7 +2269,38 @@ export interface WorkflowHealthItemApi {
latest_ci_engine?: CIEngineEnumApi | null
}
+export interface WorkflowJobStepApi {
+ /** 1-based position of the step in the job. */
+ number: number
+ /** Step name. */
+ name: string
+ /** Raw step status: 'queued', 'in_progress', 'completed', etc. */
+ status: string
+ /**
+ * Step conclusion ('success', 'failure', 'cancelled', 'skipped', ...), or null until the step finishes.
+ * @nullable
+ */
+ conclusion: string | null
+ /**
+ * When the step started, or null if it has not started.
+ * @nullable
+ */
+ started_at: string | null
+ /**
+ * When the step finished, or null while it runs.
+ * @nullable
+ */
+ completed_at: string | null
+ /**
+ * Wall-clock duration in seconds; null until the step finishes.
+ * @nullable
+ */
+ duration_seconds: number | null
+}
+
export interface WorkflowJobApi {
+ /** The job's steps in run order. Empty when the source reports no steps, as for a Depot CI job. */
+ steps: WorkflowJobStepApi[]
/** Integer job id; unique only together with ci_engine. */
id: number
/** The workflow run id this job belongs to. */
diff --git a/products/engineering_analytics/frontend/scenes/PullRequestDetailScene.stories.tsx b/products/engineering_analytics/frontend/scenes/PullRequestDetailScene.stories.tsx
index 4dd28f502a9b..7bce14934207 100644
--- a/products/engineering_analytics/frontend/scenes/PullRequestDetailScene.stories.tsx
+++ b/products/engineering_analytics/frontend/scenes/PullRequestDetailScene.stories.tsx
@@ -192,6 +192,7 @@ const FAILED_GATE_JOBS: WorkflowJobApi[] = [
{
id: 2031,
run_id: 203,
+ steps: [],
name: 'Django tests (Core, 3/8)',
status: 'completed',
conclusion: 'failure',
diff --git a/products/engineering_analytics/frontend/scenes/WorkflowRunDetailScene.stories.tsx b/products/engineering_analytics/frontend/scenes/WorkflowRunDetailScene.stories.tsx
index ba6c476e9a9a..eabbbd61115f 100644
--- a/products/engineering_analytics/frontend/scenes/WorkflowRunDetailScene.stories.tsx
+++ b/products/engineering_analytics/frontend/scenes/WorkflowRunDetailScene.stories.tsx
@@ -35,6 +35,7 @@ function job(id: number, name: string, conclusion: string, startMinute: number,
return {
id,
run_id: RUN_ID,
+ steps: [],
name,
status: 'completed',
conclusion,
diff --git a/products/engineering_analytics/frontend/scenes/pullRequestDetailLogic.test.ts b/products/engineering_analytics/frontend/scenes/pullRequestDetailLogic.test.ts
index 4a80cb059667..92d524c385ba 100644
--- a/products/engineering_analytics/frontend/scenes/pullRequestDetailLogic.test.ts
+++ b/products/engineering_analytics/frontend/scenes/pullRequestDetailLogic.test.ts
@@ -54,6 +54,7 @@ describe('pullRequestDetailLogic', () => {
const job: WorkflowJobApi = {
id: 7,
run_id: 42,
+ steps: [],
ci_engine: ciEngine,
name: 'Python tests',
status: 'completed',
diff --git a/products/engineering_analytics/mcp/tools.yaml b/products/engineering_analytics/mcp/tools.yaml
index 4a5727af1354..eb5ae749e951 100644
--- a/products/engineering_analytics/mcp/tools.yaml
+++ b/products/engineering_analytics/mcp/tools.yaml
@@ -229,8 +229,10 @@ tools:
runner tier (runner_provider / runner_label), and estimated_cost_usd. Use this to see where a run spent its
time and money job-by-job, or to find the slow or expensive job in a run. Scoped to one run_attempt (the
latest unless you pass run_attempt) so a re-run's attempts don't merge. estimated_cost_usd is null for free
- GitHub-hosted, non-Linux, or unfinished jobs. Returns an empty list when the job-level source isn't synced
- yet. Pass ci_engine with run_id when following an engine-qualified run; ambiguous integer IDs return 400.
+ GitHub-hosted, non-Linux, or unfinished jobs. Each job carries its steps in run order (name, status,
+ conclusion, timestamps, duration_seconds), so you can find the step that failed or took the time; steps is
+ empty for a Depot CI job. Returns an empty list when the job-level source isn't synced yet. Pass ci_engine
+ with run_id when following an engine-qualified run; ambiguous integer IDs return 400.
feature_flag: engineering-analytics
engineering-analytics-workflow-runner-costs:
operation: engineering_analytics_workflow_runner_costs
diff --git a/services/mcp/schema/generated-tool-definitions.json b/services/mcp/schema/generated-tool-definitions.json
index 55a6dd2f6a12..69e39495f6b3 100644
--- a/services/mcp/schema/generated-tool-definitions.json
+++ b/services/mcp/schema/generated-tool-definitions.json
@@ -4417,7 +4417,7 @@
"feature_flag": "engineering-analytics"
},
"engineering-analytics-workflow-jobs": {
- "description": "The jobs of a single workflow run attempt, each with its status, conclusion, wall-clock duration_seconds, runner tier (runner_provider / runner_label), and estimated_cost_usd. Use this to see where a run spent its time and money job-by-job, or to find the slow or expensive job in a run. Scoped to one run_attempt (the latest unless you pass run_attempt) so a re-run's attempts don't merge. estimated_cost_usd is null for free GitHub-hosted, non-Linux, or unfinished jobs. Returns an empty list when the job-level source isn't synced yet. Pass ci_engine with run_id when following an engine-qualified run; ambiguous integer IDs return 400.",
+ "description": "The jobs of a single workflow run attempt, each with its status, conclusion, wall-clock duration_seconds, runner tier (runner_provider / runner_label), and estimated_cost_usd. Use this to see where a run spent its time and money job-by-job, or to find the slow or expensive job in a run. Scoped to one run_attempt (the latest unless you pass run_attempt) so a re-run's attempts don't merge. estimated_cost_usd is null for free GitHub-hosted, non-Linux, or unfinished jobs. Each job carries its steps in run order (name, status, conclusion, timestamps, duration_seconds), so you can find the step that failed or took the time; steps is empty for a Depot CI job. Returns an empty list when the job-level source isn't synced yet. Pass ci_engine with run_id when following an engine-qualified run; ambiguous integer IDs return 400.",
"category": "Engineering analytics",
"feature": "engineering_analytics",
"summary": "Jobs of a workflow run",
diff --git a/services/mcp/schema/tool-definitions-all.json b/services/mcp/schema/tool-definitions-all.json
index cb78e93719d5..721dbaed859d 100644
--- a/services/mcp/schema/tool-definitions-all.json
+++ b/services/mcp/schema/tool-definitions-all.json
@@ -4446,7 +4446,7 @@
"feature_flag": "engineering-analytics"
},
"engineering-analytics-workflow-jobs": {
- "description": "The jobs of a single workflow run attempt, each with its status, conclusion, wall-clock duration_seconds, runner tier (runner_provider / runner_label), and estimated_cost_usd. Use this to see where a run spent its time and money job-by-job, or to find the slow or expensive job in a run. Scoped to one run_attempt (the latest unless you pass run_attempt) so a re-run's attempts don't merge. estimated_cost_usd is null for free GitHub-hosted, non-Linux, or unfinished jobs. Returns an empty list when the job-level source isn't synced yet. Pass ci_engine with run_id when following an engine-qualified run; ambiguous integer IDs return 400.",
+ "description": "The jobs of a single workflow run attempt, each with its status, conclusion, wall-clock duration_seconds, runner tier (runner_provider / runner_label), and estimated_cost_usd. Use this to see where a run spent its time and money job-by-job, or to find the slow or expensive job in a run. Scoped to one run_attempt (the latest unless you pass run_attempt) so a re-run's attempts don't merge. estimated_cost_usd is null for free GitHub-hosted, non-Linux, or unfinished jobs. Each job carries its steps in run order (name, status, conclusion, timestamps, duration_seconds), so you can find the step that failed or took the time; steps is empty for a Depot CI job. Returns an empty list when the job-level source isn't synced yet. Pass ci_engine with run_id when following an engine-qualified run; ambiguous integer IDs return 400.",
"category": "Engineering analytics",
"feature": "engineering_analytics",
"summary": "Jobs of a workflow run",
diff --git a/services/mcp/src/api/generated.ts b/services/mcp/src/api/generated.ts
index 888f58e2d666..471c3eb12bd3 100644
--- a/services/mcp/src/api/generated.ts
+++ b/services/mcp/src/api/generated.ts
@@ -112056,7 +112056,38 @@ export namespace Schemas {
latest_ci_engine?: CIEngineEnum | null;
}
+ export interface WorkflowJobStep {
+ /** 1-based position of the step in the job. */
+ number: number;
+ /** Step name. */
+ name: string;
+ /** Raw step status: 'queued', 'in_progress', 'completed', etc. */
+ status: string;
+ /**
+ * Step conclusion ('success', 'failure', 'cancelled', 'skipped', ...), or null until the step finishes.
+ * @nullable
+ */
+ conclusion: string | null;
+ /**
+ * When the step started, or null if it has not started.
+ * @nullable
+ */
+ started_at: string | null;
+ /**
+ * When the step finished, or null while it runs.
+ * @nullable
+ */
+ completed_at: string | null;
+ /**
+ * Wall-clock duration in seconds; null until the step finishes.
+ * @nullable
+ */
+ duration_seconds: number | null;
+ }
+
export interface WorkflowJob {
+ /** The job's steps in run order. Empty when the source reports no steps, as for a Depot CI job. */
+ steps: WorkflowJobStep[];
/** Integer job id; unique only together with ci_engine. */
id: number;
/** The workflow run id this job belongs to. */