Skip to content

Commit e9ceb37

Browse files
committed
fix: T3-327 SlipJay box reads staging's live deploy and newer attempt (pingdotgg#5901)
fix: T3-327 Staging row shows what staging is live on (pingdotgg#5901) Build: pingdotgg#5901
1 parent 51ef07a commit e9ceb37

3 files changed

Lines changed: 122 additions & 52 deletions

File tree

‎apps/web/src/components/SlipJayBox.logic.test.ts‎

Lines changed: 53 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ describe("the SlipJay box", () => {
237237
expect(resolveBoxFooter(overview()).queue).toBe("no queue");
238238
});
239239

240-
it("shows staging from its latest deploy when staging is not skipped", () => {
240+
it("falls back to the latest deploys when the runner does not report release.staging", () => {
241241
const now = Date.parse("2026-10-30T13:00:00Z");
242242
const deploy = (
243243
status: string,
@@ -280,4 +280,56 @@ describe("the SlipJay box", () => {
280280
status: "nothing deployed",
281281
});
282282
});
283+
284+
it("builds staging from release.staging like production: live A stays the state beside a failed B", () => {
285+
const now = Date.parse("2026-10-30T13:00:00Z");
286+
const staging = (value: NonNullable<SlipJayRunnerRelease["staging"]> | null) =>
287+
resolveEnvironmentRows(release({ stagingSkipped: false, staging: value }), now, []).find(
288+
(row) => row.key === "staging",
289+
);
290+
expect(
291+
staging({
292+
live: { commitId: "aaaaaaa1", deployedAt: "2026-10-30T10:00:00Z", healthy: true },
293+
latestAttempt: {
294+
commitId: "bbbbbbb2",
295+
status: "failed",
296+
at: "2026-10-30T12:30:00Z",
297+
reason: "health check",
298+
},
299+
}),
300+
).toMatchObject({
301+
sha: "aaaaaaa",
302+
tone: "ok",
303+
status: "live · healthy · 3h",
304+
note: "Last attempt bbbbbbb failed 30m ago (health check)",
305+
});
306+
expect(
307+
staging({
308+
live: { commitId: "aaaaaaa1", deployedAt: "2026-10-30T10:00:00Z", healthy: null },
309+
latestAttempt: null,
310+
}),
311+
).toMatchObject({ sha: "aaaaaaa", tone: "ok", status: "live · 3h", note: null });
312+
expect(
313+
staging({
314+
live: null,
315+
latestAttempt: {
316+
commitId: "bbbbbbb2",
317+
status: "running",
318+
at: "2026-10-30T12:50:00Z",
319+
reason: null,
320+
},
321+
}),
322+
).toMatchObject({
323+
sha: "none",
324+
tone: "dim",
325+
status: "nothing deployed",
326+
note: "Deploying bbbbbbb · 10m",
327+
});
328+
expect(staging(null)).toMatchObject({ tone: "dim", status: "nothing deployed" });
329+
});
330+
331+
it("keeps the skipped row even when release.staging is reported", () => {
332+
const rows = resolveEnvironmentRows(release({ staging: { live: null, latestAttempt: null } }));
333+
expect(rows.at(-1)).toMatchObject({ status: "skipped (development mode)", tone: "dim" });
334+
});
283335
});

‎apps/web/src/components/SlipJayBox.logic.ts‎

Lines changed: 43 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import type {
22
SlipJayRunnerDeploy,
3+
SlipJayRunnerEnvironment,
34
SlipJayRunnerOperation,
45
SlipJayRunnerOverview,
56
SlipJayRunnerRelease,
@@ -188,35 +189,8 @@ export function resolveEnvironmentRows(
188189
deploys: ReadonlyArray<SlipJayRunnerDeploy> = [],
189190
): SlipJayEnvironmentRow[] {
190191
const age = (iso: string) => formatElapsedDurationLabel(iso, now);
191-
const { live, latestAttempt } = release.production;
192-
const attemptNote =
193-
latestAttempt === null
194-
? null
195-
: `${
196-
latestAttempt.status === "running"
197-
? `Deploying ${sha7(latestAttempt.commitId)} · ${age(latestAttempt.at)}`
198-
: `Last attempt ${sha7(latestAttempt.commitId)} ${
199-
latestAttempt.status === "failed" ? "failed" : "rolled back"
200-
} ${age(latestAttempt.at)} ago`
201-
}${latestAttempt.reason ? ` (${latestAttempt.reason})` : ""}`;
202192
const rows: SlipJayEnvironmentRow[] = [
203-
live === null
204-
? {
205-
key: "production",
206-
name: "Production",
207-
sha: "none",
208-
tone: "dim",
209-
status: "nothing deployed",
210-
note: attemptNote,
211-
}
212-
: {
213-
key: "production",
214-
name: "Production",
215-
sha: sha7(live.commitId),
216-
tone: live.healthy === false ? "bad" : "ok",
217-
status: `live · ${live.healthy === null ? "" : live.healthy ? "healthy · " : "unhealthy · "}${age(live.deployedAt)}`,
218-
note: attemptNote,
219-
},
193+
environmentRow("production", "Production", release.production, age),
220194
];
221195
const { images } = release;
222196
if (images !== null) {
@@ -254,7 +228,16 @@ export function resolveEnvironmentRows(
254228
note: null,
255229
});
256230
} else {
257-
rows.push(stagingRow(deploys, age));
231+
rows.push(
232+
release.staging === undefined
233+
? stagingRowFromDeploys(deploys, age)
234+
: environmentRow(
235+
"staging",
236+
"Staging",
237+
release.staging ?? { live: null, latestAttempt: null },
238+
age,
239+
),
240+
);
258241
}
259242
return rows;
260243
}
@@ -273,8 +256,37 @@ export function resolveBoxFooter(overview: SlipJayRunnerOverview): {
273256
};
274257
}
275258

276-
/** Staging as its latest deploy: a failed one is the row's state only when no deploy succeeded before it. */
277-
function stagingRow(
259+
/** An environment as what is live there; a newer attempt is only ever the note under it. */
260+
function environmentRow(
261+
key: "production" | "staging",
262+
name: string,
263+
{ live, latestAttempt }: SlipJayRunnerEnvironment,
264+
age: (iso: string) => string,
265+
): SlipJayEnvironmentRow {
266+
const attemptNote =
267+
latestAttempt === null
268+
? null
269+
: `${
270+
latestAttempt.status === "running"
271+
? `Deploying ${sha7(latestAttempt.commitId)} · ${age(latestAttempt.at)}`
272+
: `Last attempt ${sha7(latestAttempt.commitId)} ${
273+
latestAttempt.status === "failed" ? "failed" : "rolled back"
274+
} ${age(latestAttempt.at)} ago`
275+
}${latestAttempt.reason ? ` (${latestAttempt.reason})` : ""}`;
276+
return live === null
277+
? { key, name, sha: "none", tone: "dim", status: "nothing deployed", note: attemptNote }
278+
: {
279+
key,
280+
name,
281+
sha: sha7(live.commitId),
282+
tone: live.healthy === false ? "bad" : "ok",
283+
status: `live · ${live.healthy === null ? "" : live.healthy ? "healthy · " : "unhealthy · "}${age(live.deployedAt)}`,
284+
note: attemptNote,
285+
};
286+
}
287+
288+
/** Staging from the latest staging deploy, for a runner that does not report `release.staging`. A failed one is the row's state only when no deploy succeeded before it. */
289+
function stagingRowFromDeploys(
278290
deploys: ReadonlyArray<SlipJayRunnerDeploy>,
279291
age: (iso: string) => string,
280292
): SlipJayEnvironmentRow {

‎packages/contracts/src/git.ts‎

Lines changed: 26 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -333,6 +333,29 @@ export const SlipJayRunnerDeploy = Schema.Struct({
333333
});
334334
export type SlipJayRunnerDeploy = typeof SlipJayRunnerDeploy.Type;
335335

336+
/** One environment the runner deploys: what it serves, and a newer attempt that is not live. */
337+
export const SlipJayRunnerEnvironment = Schema.Struct({
338+
/** What it serves: its latest successful deploy. */
339+
live: Schema.NullOr(
340+
Schema.Struct({
341+
commitId: Schema.String,
342+
deployedAt: Schema.String,
343+
/** Null when the runner has no health signal. */
344+
healthy: Schema.NullOr(Schema.Boolean),
345+
}),
346+
),
347+
/** The newest deploy attempt when it is not what is live: running, failed or rolled back. */
348+
latestAttempt: Schema.NullOr(
349+
Schema.Struct({
350+
commitId: Schema.String,
351+
status: Schema.Literals(["running", "failed", "rolled_back"]),
352+
at: Schema.String,
353+
reason: Schema.NullOr(Schema.String),
354+
}),
355+
),
356+
});
357+
export type SlipJayRunnerEnvironment = typeof SlipJayRunnerEnvironment.Type;
358+
336359
/** Where a repository's integration branch stands against production, as the runner reports it. */
337360
export const SlipJayRunnerRelease = Schema.Struct({
338361
/** The branch landings publish to, such as `develop`. */
@@ -341,26 +364,9 @@ export const SlipJayRunnerRelease = Schema.Struct({
341364
candidate: Schema.NullOr(Schema.Struct({ commitId: Schema.String, landedAt: Schema.String })),
342365
/** The process level skips staging (`development`). */
343366
stagingSkipped: Schema.Boolean,
344-
production: Schema.Struct({
345-
/** What production serves: its latest successful deploy. */
346-
live: Schema.NullOr(
347-
Schema.Struct({
348-
commitId: Schema.String,
349-
deployedAt: Schema.String,
350-
/** Null when the runner has no health signal. */
351-
healthy: Schema.NullOr(Schema.Boolean),
352-
}),
353-
),
354-
/** The newest deploy attempt when it is not what is live: running, failed or rolled back. */
355-
latestAttempt: Schema.NullOr(
356-
Schema.Struct({
357-
commitId: Schema.String,
358-
status: Schema.Literals(["running", "failed", "rolled_back"]),
359-
at: Schema.String,
360-
reason: Schema.NullOr(Schema.String),
361-
}),
362-
),
363-
}),
367+
production: SlipJayRunnerEnvironment,
368+
/** Null when staging is skipped or not declared; absent from a runner older than SlipJay's staging report. */
369+
staging: Schema.optionalKey(Schema.NullOr(SlipJayRunnerEnvironment)),
364370
/** The release images of the candidate; null for a repository that builds none. */
365371
images: Schema.NullOr(
366372
Schema.Struct({

0 commit comments

Comments
 (0)