Skip to content

Commit 0fa7332

Browse files
authored
[CRCR] Add relay health card to crcr-test per-repo page (#8520)
## Summary - Adds the Healthy/Degraded relay health indicator to the `pytorch/crcr-test` per-repo page (PR view only) - Reuses the existing `crcr_health_last_prs` ClickHouse query (last 5 PRs) already powering the summary page health card - Only fetched and rendered when viewing `pytorch/crcr-test` in PR mode; other repos and nightly view are unaffected ## Test plan - [ ] Verify the health card appears on https://hud.pytorch.org/crcr/pytorch/crcr-test (PR view) - [ ] Verify it does NOT appear on the nightly view (`?event=nightly`) - [ ] Verify it does NOT appear on other repo pages (e.g., `TorchedHat/pytorch-redhat-ci`)
1 parent 6f37b78 commit 0fa7332

1 file changed

Lines changed: 64 additions & 0 deletions

File tree

torchci/pages/crcr/[org]/[repo].tsx

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,14 @@ const CrcrPinnedContext = createContext<[Highlight, any]>([
3838

3939
// ---- Types ----
4040

41+
interface HealthPrRow {
42+
pr_number: number;
43+
last_run: string;
44+
successes: number;
45+
total: number;
46+
pass_rate: number;
47+
}
48+
4149
interface CrcrJobRow {
4250
upstream_repo: string;
4351
pr_number?: number;
@@ -224,6 +232,44 @@ function NightlySummaryCards({ data }: { data: CrcrJobRow[] }) {
224232
);
225233
}
226234

235+
// ---- Relay Health Card (for pytorch/crcr-test) ----
236+
237+
const HEALTH_COUNT = 5;
238+
239+
function RelayHealthCard({
240+
healthPrs,
241+
}: {
242+
healthPrs: HealthPrRow[] | undefined;
243+
}) {
244+
if (!healthPrs || healthPrs.length === 0) return null;
245+
const allPassed = healthPrs.every((pr) => pr.pass_rate >= 1.0);
246+
const passedCount = healthPrs.filter((pr) => pr.pass_rate >= 1.0).length;
247+
const borderColor = allPassed ? "#2e7d32" : "#ed6c02";
248+
const label = allPassed ? "Healthy" : "Degraded";
249+
return (
250+
<Paper
251+
elevation={1}
252+
sx={{
253+
p: 2,
254+
borderTop: `3px solid ${borderColor}`,
255+
textAlign: "center",
256+
minWidth: 200,
257+
flex: 1,
258+
}}
259+
>
260+
<Typography variant="caption" color="text.secondary">
261+
CRCR Relay Health
262+
</Typography>
263+
<Typography variant="h5" sx={{ fontWeight: 600, color: borderColor }}>
264+
{label}
265+
</Typography>
266+
<Typography variant="caption" color="text.secondary">
267+
{passedCount}/{healthPrs.length} recent PRs passed
268+
</Typography>
269+
</Paper>
270+
);
271+
}
272+
227273
// ---- Job Cell (colored character, matching main HUD style) ----
228274

229275
const conclusionCssColor: Record<string, string> = {
@@ -1166,6 +1212,19 @@ export default function CrcrBackendPage() {
11661212
);
11671213
const stats = summaryData?.[0] ?? null;
11681214

1215+
const isCrcrTest = repoFullName === "pytorch/crcr-test";
1216+
const healthUrl =
1217+
isCrcrTest && !isNightly
1218+
? `/api/clickhouse/crcr_health_last_prs?parameters=${encodeURIComponent(
1219+
JSON.stringify({ count: String(HEALTH_COUNT) })
1220+
)}`
1221+
: null;
1222+
const { data: healthPrs } = useSWR<HealthPrRow[]>(
1223+
healthUrl,
1224+
fetcherHandleError,
1225+
{ refreshInterval: 60_000 }
1226+
);
1227+
11691228
const [pinnedTooltip, setPinnedTooltip] = useState<Highlight>({
11701229
sha: undefined,
11711230
name: undefined,
@@ -1270,6 +1329,11 @@ export default function CrcrBackendPage() {
12701329

12711330
{!isNightly && (
12721331
<>
1332+
{isCrcrTest && (
1333+
<Box sx={{ display: "flex", gap: 2, flexWrap: "wrap" }}>
1334+
<RelayHealthCard healthPrs={healthPrs} />
1335+
</Box>
1336+
)}
12731337
{stats ? (
12741338
<SummaryCards stats={stats} />
12751339
) : (

0 commit comments

Comments
 (0)