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

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 19 additions & 2 deletions dashboard/e2e/analytics.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ function analytics(period: string, repo: string | null, deployState: DeployState
};
}

interface Backend { calls: string[]; fail: boolean; empty: boolean; oldServer: boolean; estimated: number; recovered: number; deliveries?: "ok" | "refused"; deployState?: DeployState; noAccess?: string[]; sourceNote?: string | null; notRead?: { repo: string; reason: string }[]; progress?: { read: number; total: number; resumes_at?: string | null } | null }
interface Backend { endedWrong?: boolean; calls: string[]; fail: boolean; empty: boolean; oldServer: boolean; estimated: number; recovered: number; deliveries?: "ok" | "refused"; deployState?: DeployState; noAccess?: string[]; sourceNote?: string | null; notRead?: { repo: string; reason: string }[]; progress?: { read: number; total: number; resumes_at?: string | null } | null }

async function mockApi(page: Page, init: Partial<Backend> = {}): Promise<Backend> {
const db: Backend = { calls: [], fail: false, empty: false, oldServer: false, estimated: 0, recovered: 0, ...init };
Expand All @@ -174,7 +174,10 @@ async function mockApi(page: Page, init: Partial<Backend> = {}): Promise<Backend
const period = url.searchParams.get("period") === "mtd" ? "mtd" : url.searchParams.get("days") || "30";
const { comparison: base, ...older } = analytics(period, url.searchParams.get("repo"), db.deployState, db.noAccess, db.sourceNote ?? null);
const comparison = { ...base, deploys_not_read: db.notRead ?? [], deploys_backfill_progress: db.progress ?? null };
const body = db.oldServer ? older : { ...older, comparison };
const shown = db.endedWrong
? { ...older, ci: { ...older.ci, ended_wrong: { completed_with_red_ci: 1, completed_red_runs: ["01RUNREDDONE0000000000000A"], completed_after_stop: 2, completed_after_stop_runs: ["01RUNSTOPPED000000000000A"] } } }
: older;
const body = db.oldServer ? shown : { ...shown, comparison };
if (db.empty) {
const zero = Object.fromEntries(Object.keys(SUMMARY).map((k) => [k, typeof (SUMMARY as Record<string, unknown>)[k] === "number" ? 0 : null]));
return json(route, { ...body, summary: zero, previous: zero, reviews: { ...body.reviews, posted: 0 }, lookups: { ...body.lookups, total: 0 } });
Expand Down Expand Up @@ -317,6 +320,20 @@ test("where it struggles places every red CI run in one outcome, base-branch fai
await shot(page, "analytics-ci-outcomes");
});

test("runs that ended done with red CI or after a stop are counted, so a regression shows", async ({ page }) => {
await mockApi(page);
await page.goto("/analytics?tab=reliability");
await expect(page.getByTestId("ci-line")).toBeVisible();
await expect(page.getByTestId("ended-wrong")).toHaveCount(0);
await page.unrouteAll({ behavior: "ignoreErrors" });
await mockApi(page, { endedWrong: true });
await page.goto("/analytics?tab=reliability");
const line = page.getByTestId("ended-wrong");
await expect(line).toContainText("1 run ended done with its CI still red");
await expect(line).toContainText("2 runs ended done after stopping with work left");
await expect(line.getByRole("link", { name: "newest" }).first()).toHaveAttribute("href", /\/runs\/detail\/?\?id=01RUNREDDONE0000000000000A$/);
});

test("period and repository filters reload, and a chart can be read as a table", async ({ page }) => {
const db = await mockApi(page);
await page.goto("/analytics");
Expand Down
6 changes: 5 additions & 1 deletion dashboard/e2e/integrations-page.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -489,7 +489,11 @@ test("on the AWS page members see Integrations lit, and no AWS item", async ({ p
await mockApi(page, { role: "member" });
await page.goto("/settings/integrations/aws");
const nav = page.getByRole("navigation", { name: "Settings" });
await expect(nav.getByRole("link", { name: "Integrations", exact: true })).toHaveAttribute("aria-current", "page");
// The link's name gains "Needs attention: ..." once the integrations' status
// arrives, so it is matched by its start and its address, never the exact name.
const integrations = nav.getByRole("link", { name: /^Integrations/ });
await expect(integrations).toHaveAttribute("href", /\/settings\/integrations\/?$/);
await expect(integrations).toHaveAttribute("aria-current", "page");
await expect(nav.getByRole("link", { name: "AWS" })).toHaveCount(0);
await expect(nav.getByRole("link", { name: "Data sources" })).toHaveCount(0);
});
Expand Down
37 changes: 37 additions & 0 deletions dashboard/e2e/run-draft-hold.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,43 @@ test("a held run that also asked something shows its questions, not only the hol
await expect(outcome.getByTestId("run-question")).toContainText("Should the limit apply to signed-in people too?");
});

test("a run whose pull request's CI fails reads CI failing, with the check and the error, never Done", async ({ page }) => {
const ci = {
what: "CI is failing on this head: `Deploy Preview`",
todo: "Fix the failing checks on this branch (Coderhelm decides again on the push), or re-run them if the failure isn't the change's; the pull request leaves draft once CI is green.",
};
await mockApi(page, run({
waiting_on: {
action: "Review pull request #318",
detail: "CI is failing: Deploy Preview: Error: expect(received).toBeLessThanOrEqual(expected). Coderhelm made 3 fix attempt(s) without getting it green. The pull request stays a draft until CI passes",
url: "https://github.com/your-team/web/pull/318",
since: iso(5),
},
draft_hold: { kind: "held", summary: `Finished, but pull request #318 stays a draft: ${ci.what}.`, reasons: [ci], pr_number: 318, since: iso(5) },
}));
await page.goto("/runs/detail?id=01RUNHOLD");
await expect(page.getByTestId("page-header").getByText("CI failing", { exact: true })).toBeVisible();
await expect(page.getByTestId("page-header").getByText("Done", { exact: true })).toHaveCount(0);
await expect(page.getByTestId("draft-hold-reasons")).toContainText("CI is failing on this head: Deploy Preview");
await expect(page.getByTestId("run-outcome")).toHaveAttribute("data-tone", "waiting");
await noSideways(page);
await shot(page, "run-ci-failing");
});

test("a run stopped with planned work left reads Stopped, not finished", async ({ page }) => {
await mockApi(page, run({
waiting_on: {
action: "Review pull request #318",
detail: "Stopped: steps 2 and 3 made no progress. The branch stayed at a8c8814 and the run was stuck at the implement work (planned tasks) while working on task 8 of 8.",
url: "https://github.com/your-team/web/pull/318",
since: iso(5),
},
draft_hold: null,
}));
await page.goto("/runs/detail?id=01RUNHOLD");
await expect(page.getByTestId("page-header").getByText("Stopped, not finished", { exact: true })).toBeVisible();
});

test("a run with no hold still reads as before", async ({ page }) => {
await mockApi(page, run({ status: "completed", waiting_on: null, draft_hold: null }));
await page.goto("/runs/detail?id=01RUNHOLD");
Expand Down
23 changes: 23 additions & 0 deletions dashboard/src/app/analytics/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,29 @@ function Body({ data, loading, stats, tab }: { data: Analytics; loading: boolean
</p>
)}
{data.ci.outcomes && <CiOutcomes ci={data.ci} outcomes={data.ci.outcomes} />}
{!!((data.ci.ended_wrong?.completed_with_red_ci ?? 0) + (data.ci.ended_wrong?.completed_after_stop ?? 0)) && (
<p className="mt-3 text-sm text-red-300" data-testid="ended-wrong" role="status">
{(data.ci.ended_wrong?.completed_with_red_ci ?? 0) > 0 && (
<>
{plural(data.ci.ended_wrong?.completed_with_red_ci ?? 0, "run")} ended done with its CI still red
{data.ci.ended_wrong?.completed_red_runs?.[0] && (
<> (<Link href={`/runs/detail?id=${data.ci.ended_wrong.completed_red_runs[0]}`} className="underline-offset-2 hover:underline">newest</Link>)</>
)}
.{" "}
</>
)}
{(data.ci.ended_wrong?.completed_after_stop ?? 0) > 0 && (
<>
{plural(data.ci.ended_wrong?.completed_after_stop ?? 0, "run")} ended done after stopping with work left
{data.ci.ended_wrong?.completed_after_stop_runs?.[0] && (
<> (<Link href={`/runs/detail?id=${data.ci.ended_wrong.completed_after_stop_runs[0]}`} className="underline-offset-2 hover:underline">newest</Link>)</>
)}
.{" "}
</>
)}
Neither should happen: tell Coderhelm support.
</p>
)}
{!!data.loops_stopped?.total && <LoopsStopped stopped={data.loops_stopped} />}
{!!data.waiting?.total && <Waiting waiting={data.waiting} />}
</Section>
Expand Down
3 changes: 2 additions & 1 deletion dashboard/src/app/runs/detail/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
import { InlineMarkdown, Markdown } from "@/components/markdown";
import { buttonClass, dangerButton, focusRing, fullWidthOnPhone, primaryButton, secondaryButton } from "@/components/ui";
import { Page, PageHeader, SectionHeading } from "@/components/page";
import { RunStatusBadge, runCanClose, runCloseIsLikely, runIsLive, runStatusLabel } from "@/components/run-status";
import { RunStatusBadge, runCanClose, runCloseIsLikely, runHeldOn, runIsLive, runStatusLabel } from "@/components/run-status";
import { CloseRunDialog } from "@/components/close-run-dialog";
import { Chip, Time, formatDuration as sharedDuration, formatMs } from "@/components/list";
import { usePaletteActions, type PageAction } from "@/components/command-palette";
Expand Down Expand Up @@ -296,7 +296,7 @@
if (idx > max) max = idx;
});
return max;
}, [run?.current_pass, run?.pass_history]);

Check warning on line 299 in dashboard/src/app/runs/detail/page.tsx

View workflow job for this annotation

GitHub Actions / Lint & Build

React Hook useMemo has a missing dependency: 'run'. Either include it or remove the dependency array

if (!runId) {
return (
Expand Down Expand Up @@ -1050,6 +1050,7 @@
status={run.status}
draftHold={hold?.kind}
waitingOn={!run.questions?.length && !!run.waiting_on?.action}
heldOn={run.status === "needs_input" || hold ? runHeldOn([...(hold?.reasons ?? []).map((r) => r.what), run.status === "needs_input" ? run.waiting_on?.detail : null]) : null}
unfinishedRound={!!run.round_incomplete && ["completed", "success"].includes(run.status)}
/>
}
Expand Down
21 changes: 20 additions & 1 deletion dashboard/src/components/run-status.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -77,23 +77,42 @@ const UNFINISHED_ROUND: RunLook = { label: "PR open, fix unfinished", tone: "att
const DRAFT_HELD: RunLook = { label: "PR held", tone: "waiting", group: "waiting" };
/** The same, when GitHub refused every try to mark it ready. */
const DRAFT_NOT_MARKED: RunLook = { label: "PR held", tone: "attention", group: "waiting" };
/** The pull request is held because its CI fails: named so, never "Done". */
const CI_FAILING: RunLook = { label: "CI failing", tone: "attention", group: "waiting" };
/** The run stopped before its planned work was done; its draft says what is left. */
const STOPPED_UNFINISHED: RunLook = { label: "Stopped, not finished", tone: "attention", group: "waiting" };
/** Waiting on a person for something that isn't a question (`waiting_on`): reviewing the pull request, say. */
const WAITING_ON_YOU: RunLook = { label: "Waiting on you", tone: "waiting", group: "waiting" };

/** What a run that needs a person is held on, from its hold reasons and its wait: CI failing, or work left unfinished. */
export function runHeldOn(whats: (string | null | undefined)[]): "ci_failing" | "unfinished" | null {
const w = whats.map((s) => (s ?? "").trim());
if (w.some((s) => s.startsWith("CI is failing"))) return "ci_failing";
if (w.some((s) => s.startsWith("Planned work is not done") || s.startsWith("Stopped:"))) return "unfinished";
return null;
}

export function RunStatusBadge({
status,
unfinishedRound,
draftHold,
waitingOn,
heldOn,
}: {
status: string | null | undefined;
unfinishedRound?: boolean;
/** The run's `draft_hold.kind`, when its pull request is still a draft. */
draftHold?: string | null;
/** A `needs_input` run waits for a named action, not an answer. */
waitingOn?: boolean;
/** What holds it, when that is CI failing or unfinished work (`runHeldOn`). */
heldOn?: "ci_failing" | "unfinished" | null;
}) {
const look = draftHold
const look = heldOn === "ci_failing"
? CI_FAILING
: heldOn === "unfinished"
? STOPPED_UNFINISHED
: draftHold
? draftHold === "failed"
? DRAFT_NOT_MARKED
: DRAFT_HELD
Expand Down
7 changes: 7 additions & 0 deletions dashboard/src/lib/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3801,6 +3801,13 @@ export interface Analytics {
outcomes?: AnalyticsCiOutcomes;
/** Why Coderhelm left a red PR to a person, most common first. */
gave_up_reasons?: { reason: string; count: number }[];
/** Runs that ended in a state Coderhelm must never leave (both should be zero). Missing from older backends. */
ended_wrong?: {
completed_with_red_ci: number;
completed_red_runs: string[];
completed_after_stop: number;
completed_after_stop_runs: string[];
};
};
/** Runs the run guard ended for making no progress. Missing from older backends. */
loops_stopped?: { total: number; reasons: { reason: string; count: number }[] };
Expand Down
Loading