Skip to content
Open
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
49 changes: 34 additions & 15 deletions components/fleet-dashboard/pkg/sources/delivery.go
Original file line number Diff line number Diff line change
Expand Up @@ -972,15 +972,20 @@ func outsideOnly(builds []componentCheck, bundled map[string]bool) bool {
// changeFirstBundle returns the first bundle of the change at commit index i
// (FLT-DLV-06). A change with rebuilt components is contained by the oldest
// bundle whose revision of every rebuilt component it lists is the change or a
// later commit. A change with none keeps the manifest-revision rule. So does a
// bundle with no component revisions (an old lock) or one that lists none of
// the rebuilt components.
// later commit. A change that built only outside-bundle components is in no
// bundle, because its code never ships through one (FLT-DLV-06.08). A change
// with no builds keeps the manifest-revision rule. So does a bundle with no
// component revisions (an old lock) or one that lists none of the rebuilt
// components.
func changeFirstBundle(in deliveryInput, pl placement, i, pr int) int {
manifest := firstBundle(pl, in.commits, i, pr)
runs, ok := in.checks[in.commits[i].SHA]
if !ok {
return manifest
}
if builds, _ := classifyChecks(runs); outsideOnly(builds, pl.bundled) {
return -1
}
rebuilt := rebuiltComponents(runs, pl.bundled)
if len(rebuilt) == 0 {
return manifest
Expand Down Expand Up @@ -1335,6 +1340,10 @@ func buildChange(in deliveryInput, pl placement, groups []envGroup, l listedChan

// Release (FLT-DLV-06).
release := DeliveryStage{Key: stageRelease}
// A change that built only outside-bundle components never reaches the
// environment groups through the bundle: its stages end at Release, even
// when a later bundle was cut from a newer commit (FLT-DLV-06.08).
outside := l.first < 0 && outsideOnly(builds, pl.bundled)
if l.first >= 0 {
b := in.bundles[l.first]
pub := in.published[b.Tag]
Expand Down Expand Up @@ -1382,6 +1391,11 @@ func buildChange(in deliveryInput, pl placement, groups []envGroup, l listedChan
}
}

if outside {
ch.Stages = withStartTimes([]DeliveryStage{merged, build, policy, release})
return ch
}

// Renovate (FLT-DLV-07).
gitops := DeliveryStage{Key: stageGitOps}
switch {
Expand Down Expand Up @@ -1429,18 +1443,7 @@ func buildChange(in deliveryInput, pl placement, groups []envGroup, l listedChan
stages = append(stages, st)
ch.Envs = append(ch.Envs, envs...)
}
// Each stage starts when the closest earlier stage with an end finished.
prevEnd := ""
for i := range stages {
s := &stages[i]
if s.StartedAt == "" && prevEnd != "" && (s.State == StageRunning || s.State == StageWaiting || s.State == StagePassed || s.State == StageFailed) {
s.StartedAt = prevEnd
}
if s.FinishedAt != "" {
prevEnd = s.FinishedAt
}
}
ch.Stages = stages
ch.Stages = withStartTimes(stages)

// The delivery time is the last environment's finish; omitted when the
// history does not reach a group's finish (FLT-DLV-02).
Expand All @@ -1460,6 +1463,22 @@ func buildChange(in deliveryInput, pl placement, groups []envGroup, l listedChan
return ch
}

// withStartTimes starts each stage when the closest earlier stage with an end
// finished.
func withStartTimes(stages []DeliveryStage) []DeliveryStage {
prevEnd := ""
for i := range stages {
s := &stages[i]
if s.StartedAt == "" && prevEnd != "" && (s.State == StageRunning || s.State == StageWaiting || s.State == StagePassed || s.State == StageFailed) {
s.StartedAt = prevEnd
}
if s.FinishedAt != "" {
prevEnd = s.FinishedAt
}
}
return stages
}

// partlyStage marks a later stage of a partly shipped change: it cannot pass
// until a bundle with every component finished it (FLT-DLV-22).
func partlyStage(s DeliveryStage, p *DeliveryPartly) DeliveryStage {
Expand Down
40 changes: 40 additions & 0 deletions components/fleet-dashboard/pkg/sources/delivery_estimates_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package sources

import (
"slices"
"testing"
"time"
)
Expand Down Expand Up @@ -218,6 +219,45 @@ func TestDeliveryOutsideBundleComponent(t *testing.T) {
}
}

func TestDeliveryOutsideBundleStagesEndAtRelease(t *testing.T) {
// Verifies: FLT-DLV-06.08
f := newFixture(t)
withComponents(f)
f.gh.checks[f.repo.sha(10)] = []CheckRun{
konflux("demo-board-main-on-push", "completed", "success"),
konflux("demo-main-enterprise-contract / demo-board-main", "completed", "success"),
}
f.gh.checks[f.repo.sha(6)] = f.gh.checks[f.repo.sha(10)]
p := f.refresh(t)
c := change(t, p, f.repo.sha(10))
var keys []string
for _, s := range c.Stages {
keys = append(keys, s.Key)
}
if want := []string{stageMerged, stageBuild, stagePolicy, stageRelease}; !slices.Equal(keys, want) {
t.Errorf("stages = %v, want %v", keys, want)
}
if len(c.Envs) != 0 {
t.Errorf("environments = %+v, want none", c.Envs)
}
if c.Bundle != nil {
t.Errorf("bundle = %+v, want none", c.Bundle)
}
// A later bundle cut from a newer commit (b3, at sha(8)) does not carry
// an outside-only change either.
older := change(t, p, f.repo.sha(6))
if older.Bundle != nil || len(older.Stages) != 4 || len(older.Envs) != 0 {
t.Errorf("older outside-only change: bundle %+v, %d stages, %d envs; want no bundle, 4 stages, no envs", older.Bundle, len(older.Stages), len(older.Envs))
}
if r := older.Stages[3]; r.State != StageNotNeeded || r.Reason != reasonOutsideBundle {
t.Errorf("older release = %s/%s, want not-needed/outside-bundle", r.State, r.Reason)
}
// A change that built a bundled component keeps every stage.
if n := len(change(t, p, f.repo.sha(9)).Stages); n <= 4 {
t.Errorf("bundled change has %d stages, want the full pipeline", n)
}
}

func TestDeliveryReleaseDiagnostics(t *testing.T) {
// Verifies: FLT-DLV-20.01, FLT-DLV-12
f := newFixture(t)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -501,6 +501,18 @@ export const deliveryMessages = defineMessages({
defaultMessage: "A passing re-check or a new change resumes promotion",
description: "Next text after a failed environment gate.",
},
nextOutside: {
id: "fleet.delivery.nowNext.outside",
defaultMessage: "Ships outside the bundle when this stage passes",
description:
"Next text when the current stage is the last one before an outside-bundle change ships by its own route.",
},
nextThenOutside: {
id: "fleet.delivery.nowNext.thenOutside",
defaultMessage: "{text}, then ships outside the bundle",
description:
"Next text of an outside-bundle change: the next stage, then its own route.",
},
nextNone: {
id: "fleet.delivery.nowNext.none",
defaultMessage: "Delivered when this stage passes",
Expand Down Expand Up @@ -559,6 +571,13 @@ export const deliveryMessages = defineMessages({
defaultMessage: "No bundle contains this change yet.",
description: "Drawer text before a bundle contains the change.",
},
bundleOutside: {
id: "fleet.delivery.drawer.bundleOutside",
defaultMessage:
"Ships outside the bundle, so no bundle will contain this change.",
description:
"Drawer text when the change built only components no bundle lists (FLT-DLV-06.08).",
},
bundleAlias: {
id: "fleet.delivery.drawer.alias",
defaultMessage: "Version",
Expand Down Expand Up @@ -1068,6 +1087,12 @@ export const deliveryMessages = defineMessages({
description:
"Change panel: the change runs everywhere; no delivery time known.",
},
panelOutside: {
id: "fleet.delivery.panel.outside",
defaultMessage: "Done here - ships outside the bundle",
description:
"Change panel: every stage finished and the change ships outside the bundle (FLT-DLV-06.08).",
},
panelAllStages: {
id: "fleet.delivery.panel.allStages",
defaultMessage: "Every stage finished",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -531,6 +531,83 @@ describe("DeliveryView change panels (FLT-DLV-03, FLT-DLV-07, FLT-DLV-11)", () =
});
});

function renderOutside() {
const data = mapDelivery({
enabled: true,
stages: [
{ key: "merged", kind: "pipeline" },
{ key: "build", kind: "pipeline" },
{ key: "policy", kind: "pipeline" },
{ key: "release", kind: "pipeline" },
{ key: "gitops", kind: "pipeline" },
{ key: "env:int", kind: "group", group: "int" },
],
changes: [
{
sha: NEW_SHA,
shortSha: "b81f3e2",
pr: 1200,
mergedAt: "2026-11-25T18:42:00Z",
title: "Dashboard change",
stages: [
{
key: "merged",
state: "passed",
finishedAt: "2026-11-25T18:42:00Z",
},
{ key: "build", state: "passed", finishedAt: "2026-11-25T18:58:00Z" },
{
key: "policy",
state: "passed",
finishedAt: "2026-11-25T19:02:00Z",
},
{ key: "release", state: "not-needed", reason: "outside-bundle" },
],
builds: [{ component: "board", state: "passed", outsideBundle: true }],
},
],
});
render(
<IntlProvider locale="en" defaultLocale="en" timeZone="UTC">
<DeliveryView
state={{
status: "ready",
plane: {
data,
generatedAt: "2026-11-25T19:12:00Z",
stale: false,
error: null,
},
}}
selectedSha={null}
nowMs={Date.parse("2026-11-25T19:12:00Z")}
onNavigate={() => undefined}
onRefresh={() => undefined}
/>
</IntlProvider>,
);
}

describe("DeliveryView outside-bundle change (FLT-DLV-06.08)", () => {
// Verifies: FLT-DLV-06.08
it("ends the steps at Release and says it is done here", () => {
renderOutside();
const panel = panelOf("b81f3e2 (#1200)");
const steps = within(panel)
.getByRole("list", { name: /Delivery progress of/ })
.querySelectorAll(":scope > li");
// Merged, Build, Policy check, and Release only.
expect(steps).toHaveLength(4);
const text = panel.textContent.replace(/\s+/g, " ");
expect(text).toContain("Done here - ships outside the bundle");
expect(text).toContain(
"Ships outside the bundle, so no bundle will contain this change.",
);
expect(text).not.toContain("No bundle contains this change yet.");
expect(text).not.toContain("Renovate");
});
});

const SHIPPED_LABEL = "Shipped";

describe("DeliveryView layout (FLT-DLV-25)", () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ import {
changeNowNext,
changeSeverity,
progress,
shipsOutsideBundle,
whereToLook,
type Arrival,
type DeliveryChange,
Expand Down Expand Up @@ -844,6 +845,8 @@ function nextText(
);
case "none":
return intl.formatMessage(m.nextNone);
case "outside-bundle":
return intl.formatMessage(m.nextOutside);
case "bundle-restart": {
const text = intl.formatMessage(m.nextBundleRestart, {
gate: [
Expand All @@ -869,15 +872,17 @@ function nextText(
intl,
def ?? { key: next.stage.key, group: null },
);
if (row.now.overdue) {
return intl.formatMessage(m.nextOverdue, { stage });
}
return next.expectedAtMs !== null
? intl.formatMessage(m.nextStageAt, {
stage,
time: formatClock(intl, next.expectedAtMs, nowMs),
})
: stage;
const text = row.now.overdue
? intl.formatMessage(m.nextOverdue, { stage })
: next.expectedAtMs !== null
? intl.formatMessage(m.nextStageAt, {
stage,
time: formatClock(intl, next.expectedAtMs, nowMs),
})
: stage;
return next.thenOutside
? intl.formatMessage(m.nextThenOutside, { text })
: text;
}
}
}
Expand Down Expand Up @@ -933,6 +938,10 @@ function NowNextLines({
return (
<Content component="p">{intl.formatMessage(m.panelAllStages)}</Content>
);
case "outside-bundle":
return (
<Content component="p">{intl.formatMessage(m.panelOutside)}</Content>
);
default: {
const row = status.row;
return (
Expand Down Expand Up @@ -1384,10 +1393,12 @@ function PanelDetails({
{bundle === null ? (
<Content component="p">
{intl.formatMessage(
change.stages.find((st) => st.key === "release")?.state ===
"unknown"
? m.bundleUnknown
: m.bundleNone,
shipsOutsideBundle(change)
? m.bundleOutside
: change.stages.find((st) => st.key === "release")?.state ===
"unknown"
? m.bundleUnknown
: m.bundleNone,
)}
</Content>
) : (
Expand Down
Loading