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
1 change: 1 addition & 0 deletions changelog.d/fixed-ci-partial-ring-running.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- Activity Monitor: a CI ring that is not yet full now renders the CI chevron active ("CI 13/19 · running") beside a running Review instead of a silent part-green glyph; check-run motion on the head leads red, unreported or ambiguous neighbours, and icon-only green is reserved for a complete ring (hivecommons/hive#16631).
59 changes: 53 additions & 6 deletions src/pkg/dashboard/stage_tracker_activity.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ func stageTrackerCIActivity(pr github.PullRequest, now time.Time) *StageTrackerA
}
if !a.RequiredKnown || a.RequiredSource == "" || len(a.RequiredChecks) == 0 || len(a.Required) == 0 {
stageTrackerCountHeadChecks(out, a)
stageTrackerHeadChecksMotion(out, a, now)
return out
}
type requiredObservation struct {
Expand Down Expand Up @@ -104,14 +105,15 @@ func stageTrackerCIActivity(pr github.PullRequest, now time.Time) *StageTrackerA
}
if !found {
stageTrackerCountHeadChecks(out, a)
stageTrackerHeadChecksMotion(out, a, now)
return out
}
}
out.State, out.Caption = "passing", "CI green"
// Per required-check name: the leading state across its observations,
// for the passed / failed counts.
perName := map[string]string{}
running := false
running, queued, queuedName := false, false, ""
// Per required-check name: which have a final result, for the running count.
settled := map[string]bool{}
for _, name := range a.Required {
Expand All @@ -134,6 +136,8 @@ func stageTrackerCIActivity(pr github.PullRequest, now time.Time) *StageTrackerA
}
case check.State == "queued" || check.State == "waiting" || check.State == "pending" || check.State == "requested":
state = "queued"
queued = true
queuedName = name
case check.State == "in_progress":
state = "running"
running = true
Expand Down Expand Up @@ -170,6 +174,17 @@ func stageTrackerCIActivity(pr github.PullRequest, now time.Time) *StageTrackerA
if statusesMissing {
out.State, out.Blocker = "unknown", "commit statuses not observed"
}
// Motion on the head leads every settled word: while any required
// check still runs or waits for a runner the track is running, however
// red, unreported or ambiguous its neighbours are — a ring that is not
// yet full is a running ring, so the chevron stays active with its
// count (hivecommons/hive#16631). The red names ride in ChecksFailing.
switch {
case running:
out.State, out.Blocker = "running", ""
case queued && out.State != "queued":
out.State, out.Blocker = "queued", queuedName
}
done := 0
for _, name := range a.Required {
if settled[name] {
Expand Down Expand Up @@ -197,7 +212,11 @@ func stageTrackerCIActivity(pr github.PullRequest, now time.Time) *StageTrackerA
out.Detail = "Required check " + check + " finished without success (failed, timed out, was cancelled, or needs action) on the PR's current commit. A fix or a re-run has to turn it green before CI can pass."
case "running":
out.Caption = fmt.Sprintf("CI running · %d/%d checks done", done, total)
out.Detail = fmt.Sprintf("%d of the %s have a final result; the rest are still executing on the PR's current commit.", done, plural(total, "required check"))
out.Detail = fmt.Sprintf("%d of the %s have a final result; the rest are still executing or waiting for a runner on the PR's current commit.", done, plural(total, "required check"))
if out.ChecksFailed > 0 {
out.Caption += fmt.Sprintf(" · %d failing", out.ChecksFailed)
out.Detail += fmt.Sprintf(" %s already red: %s.", plural(out.ChecksFailed, "required check"), strings.Join(out.ChecksFailing, ", "))
}
case "queued":
out.Caption = "CI queued · " + check + " waiting for a runner"
out.Detail = "Required check " + check + " has been requested for the PR's current commit but has not started executing yet."
Expand Down Expand Up @@ -231,10 +250,7 @@ func stageTrackerCIActivity(pr github.PullRequest, now time.Time) *StageTrackerA
out.Caption = "CI skipped · check " + check + " skipped"
out.Detail = "Required check " + check + " finished as skipped or neutral on the PR's current commit, which branch protection does not count as a pass."
}
out.Active = running && a.ObservedAt != nil && !a.ObservedAt.After(now) && now.Sub(*a.ObservedAt) <= trackerActivityFreshWindow
if running && out.State != "running" {
out.Caption += " · other checks still running"
}
out.Active = out.State == "running" && a.ObservedAt != nil && !a.ObservedAt.After(now) && now.Sub(*a.ObservedAt) <= trackerActivityFreshWindow
return out
}

Expand Down Expand Up @@ -300,6 +316,37 @@ func stageTrackerCountHeadChecks(out *StageTrackerActivity, a *github.PRCIActivi
}
}

// stageTrackerHeadChecksMotion turns the required-set-unknown count into a
// running track while any check run on the head is still executing or
// queued: the ring is not full, so the chevron must be active with its
// count rather than a silent part-green glyph (hivecommons/hive#16631).
func stageTrackerHeadChecksMotion(out *StageTrackerActivity, a *github.PRCIActivity, now time.Time) {
moving := 0
for _, check := range a.Checks {
if check.Head != "" && !strings.EqualFold(check.Head, a.Head) {
continue
}
switch check.State {
case "in_progress", "queued", "waiting", "pending", "requested":
moving++
}
}
if moving == 0 {
return
}
done := out.ChecksTotal - moving
if done < 0 {
done = 0
}
out.State, out.Blocker = "running", ""
out.Caption = fmt.Sprintf("CI running · %d/%d checks done", done, out.ChecksTotal)
out.Detail = fmt.Sprintf("%d of the %s observed on the PR's current commit have a final result; the rest are still executing or waiting for a runner. Which of them branch protection requires is not yet known.", done, plural(out.ChecksTotal, "check"))
if out.ChecksFailed > 0 {
out.Caption += fmt.Sprintf(" · %d failing", out.ChecksFailed)
}
out.Active = a.ObservedAt != nil && !a.ObservedAt.After(now) && now.Sub(*a.ObservedAt) <= trackerActivityFreshWindow
}

// stageTrackerExpectedPerspectives is the swarm's perspective set for this
// hive: the configured list (built-ins when empty), falling back to the
// built-ins when the configuration cannot be resolved.
Expand Down
4 changes: 2 additions & 2 deletions src/pkg/dashboard/stage_tracker_activity.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -766,7 +766,7 @@ test('the backend detail sentence rides in the track tooltip, not on the chevron
});

test('#16484: count grammar — CI passed/total and Review done/total across every state', () => {
const word = new Function(trackConsts + '\n' + fn(strip, 'stageTrackerWorkflowApprovalPending') + fn(strip, 'stageTrackerQueueAheadWord') + fn(strip, 'stageTrackerHiveOwnsRepair') + fn(strip, 'stageTrackerTrackWord') + ';return stageTrackerTrackWord;')();
const word = new Function(trackConsts + '\n' + fn(strip, 'stageTrackerWorkflowApprovalPending') + fn(strip, 'stageTrackerQueueAheadWord') + fn(strip, 'stageTrackerHiveOwnsRepair') + fn(strip, 'stageTrackerWaitingOnPerson') + fn(strip, 'stageTrackerTrackRunning') + fn(strip, 'stageTrackerTrackWord') + ';return stageTrackerTrackWord;')();
const ci = (state, extra = {}) => word({ head: 'h', ci_activity: { head: 'h', state, ...extra } }, 'ci', true);
assert.equal(ci('passing', { checks_passed: 14, checks_total: 14 }), 'CI 14/14 passed');
assert.equal(ci('failing', { checks_passed: 11, checks_total: 14, checks_failed: 1, checks_failing: ['lint'] }), 'CI 11/14 · 1 failing (lint)');
Expand All @@ -779,7 +779,7 @@ test('#16484: count grammar — CI passed/total and Review done/total across eve
assert.equal(ci('missing', { checks_passed: 13, checks_total: 14, blocker: 'test' }), 'CI 13/14 · test not reported');
assert.equal(ci('skipped', { checks_passed: 13, checks_total: 14, blocker: 'build' }), 'CI 13/14 · build skipped');
assert.equal(ci('unknown'), 'CI ?/? · no checks reported yet');
assert.equal(ci('unknown', { checks_passed: 51, checks_total: 68 }), 'CI 51/68 · no verdict yet', 'unprotected base: head-wide counts without a required verdict');
assert.equal(ci('unknown', { checks_passed: 51, checks_total: 68 }), 'CI 51/68 · running', 'unprotected base: an unfinished head-wide ring is still running (#16631)');
assert.equal(word({ head: 'h' }, 'ci', true), 'CI ?/? · no checks reported yet', 'no evidence at all in the current phase');
assert.equal(word({ head: 'h' }, 'ci', false), '', 'no evidence outside the current phase: not started, glyph alone');
assert.equal(word({ head: 'h', ci_activity: { head: 'old', state: 'passing', checks_passed: 14, checks_total: 14 } }, 'ci', true), 'CI ?/? · no checks reported yet', 'old-head evidence counts for nothing');
Expand Down
79 changes: 71 additions & 8 deletions src/pkg/dashboard/stage_tracker_activity_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package dashboard

import (
"fmt"
"os/exec"
"strings"
"testing"
Expand All @@ -23,7 +24,9 @@ func TestStageTrackerActivityRequiredCI(t *testing.T) {
{"failure", "completed", "failure", "failing", true},
{"success", "completed", "success", "passing", true},
{"conditional skip", "completed", "skipped", "skipped", true},
{"unknown required set", "completed", "failure", "unknown", false},
// A queued neighbour keeps an ambiguous-required ring in motion
// (hivecommons/hive#16631).
{"unknown required set", "completed", "failure", "running", false},
} {
t.Run(tc.name, func(t *testing.T) {
pr := github.PullRequest{HeadSHA: "head", CIActivity: &github.PRCIActivity{
Expand Down Expand Up @@ -274,13 +277,17 @@ func TestStageTrackerActivityCIRetryAndMixedChecks(t *testing.T) {
RequiredKnown: true, Required: []string{"build", "lint"}, Checks: []github.PRActivityCheck{
{Name: "build", State: "completed", Conclusion: "failure"}, {Name: "lint", State: "in_progress"},
}}
if got := stageTrackerCIActivity(pr, now); got.State != "failing" || !got.Active {
if got := stageTrackerCIActivity(pr, now); got.State != "running" || !got.Active || got.ChecksFailed != 1 || !strings.Contains(got.Caption, "1 failing") {
t.Fatalf("failing required check hid simultaneous running CI: %+v", got)
}
pr.CIActivity.Checks = append(pr.CIActivity.Checks, github.PRActivityCheck{Name: "build", State: "completed", Conclusion: "success"})
if got := stageTrackerCIActivity(pr, now); got.State != "unknown" {
if got := stageTrackerCIActivity(pr, now); got.State != "running" || got.ChecksPassed != 0 || got.ChecksFailed != 0 {
t.Fatalf("ambiguous check apps manufactured success: %+v", got)
}
pr.CIActivity.Checks[1] = github.PRActivityCheck{Name: "lint", State: "completed", Conclusion: "success"}
if got := stageTrackerCIActivity(pr, now); got.State != "unknown" {
t.Fatalf("ambiguous check apps manufactured success once settled: %+v", got)
}
dispatch.Fixes = []review.PendingFix{{Repo: pr.Repo, Number: pr.Number, HeadSHA: pr.HeadSHA, Agent: "fixer", Dispatched: now}}
status.Agents[1].AwaitingCI = true
it := StageTrackerItem{Repo: pr.Repo, Kind: "pr", Number: pr.Number, Head: pr.HeadSHA, Stage: trackerNumberFixing}
Expand Down Expand Up @@ -366,9 +373,27 @@ func TestStageTrackerActivityCICaptionsReadInPlainLanguage(t *testing.T) {
t.Fatalf("%s: want %s %q (detail mentioning %q), got %+v", tc.name, tc.state, tc.want, tc.detailMention, got)
}
}
mixed := ci(done("build"), chk("lint", "completed", "failure"), chk("test", "in_progress", ""))
if got := stageTrackerCIActivity(mixed, now); got.Caption != `CI failing · "lint" red · other checks still running` {
t.Fatalf("mixed red+running caption: %+v", got)
// Motion leads a settled word: a ring that is not full is running,
// however red, unreported or ambiguous its neighbours (hivecommons/hive#16631).
motion := []struct {
name string
pr github.PullRequest
want string
}{
{"red+running", ci(done("build"), chk("lint", "completed", "failure"), chk("test", "in_progress", "")), "CI running · 2/3 checks done · 1 failing"},
{"missing+running", ci(done("build"), chk("lint", "in_progress", "")), "CI running · 1/3 checks done"},
}
for _, tc := range motion {
got := stageTrackerCIActivity(tc.pr, now)
if got.State != "running" || got.Caption != tc.want || !got.Active {
t.Fatalf("%s: want running %q active, got %+v", tc.name, tc.want, got)
}
}
if got := stageTrackerCIActivity(ci(done("build"), done("lint"), done("lint"), chk("test", "queued", "")), now); got.State != "queued" || got.Caption != `CI queued · "test" waiting for a runner` {
t.Fatalf("ambiguous+queued: a waiting runner keeps the ring queued, not unknown: %+v", got)
}
if got := stageTrackerCIActivity(ci(done("build"), chk("lint", "completed", "failure"), done("test")), now); got.State != "failing" || got.Active {
t.Fatalf("settled red head must not read as running: %+v", got)
}
if got := stageTrackerCIActivity(github.PullRequest{Repo: pr.Repo, Number: pr.Number, HeadSHA: pr.HeadSHA}, now); got.Caption != "CI unknown · no check results observed for this head yet" || got.Detail == "" {
t.Fatalf("no-evidence caption: %+v", got)
Expand Down Expand Up @@ -422,8 +447,8 @@ func TestStageTrackerActivityCICheckCounts(t *testing.T) {
{Name: "other-head", State: "completed", Conclusion: "success", Head: "old-head"},
}
got = stageTrackerCIActivity(pr, now)
if got.State != "unknown" || got.ChecksTotal != 3 || got.ChecksPassed != 1 || got.ChecksFailed != 1 || strings.Join(got.ChecksFailing, ",") != "flaky" {
t.Fatalf("head-wide counts = %d/%d failed %d %v (state %s), want 1/3 failed 1 [flaky] unknown: a red run of a name stays red", got.ChecksPassed, got.ChecksTotal, got.ChecksFailed, got.ChecksFailing, got.State)
if got.State != "running" || got.ChecksTotal != 3 || got.ChecksPassed != 1 || got.ChecksFailed != 1 || strings.Join(got.ChecksFailing, ",") != "flaky" {
t.Fatalf("head-wide counts = %d/%d failed %d %v (state %s), want 1/3 failed 1 [flaky] running: a red run of a name stays red while the queued one keeps the ring in motion", got.ChecksPassed, got.ChecksTotal, got.ChecksFailed, got.ChecksFailing, got.State)
}
// No evidence for the head at all: no count ("CI ?/?").
pr.CIActivity.Checks = nil
Expand Down Expand Up @@ -485,3 +510,41 @@ func TestStageTrackerActivityReviewPerspectiveCounts(t *testing.T) {
t.Fatalf("old-head evidence leaked into counts: %d/%d", got.PerspectivesDone, got.PerspectivesTotal)
}
}

func TestStageTrackerActivityCIPartialRingIsRunning(t *testing.T) {
now := time.Date(2026, 11, 4, 18, 0, 0, 0, time.UTC)
name := func(i int) string { return fmt.Sprintf("check-%02d", i) }
build := func(passed, pending int) github.PullRequest {
var required []string
var bindings []github.PRRequiredCheck
var checks []github.PRActivityCheck
for i := 0; i < passed+pending; i++ {
required = append(required, name(i))
bindings = append(bindings, github.PRRequiredCheck{Name: name(i), AppKnown: true})
if i < passed {
checks = append(checks, github.PRActivityCheck{Name: name(i), State: "completed", Conclusion: "success"})
} else if i%2 == 0 {
checks = append(checks, github.PRActivityCheck{Name: name(i), State: "in_progress"})
}
// Odd pending checks are not reported at all (a job that only
// starts after the shards finish), as on hivecommons/hive#16628.
}
return github.PullRequest{HeadSHA: "head", CIActivity: &github.PRCIActivity{
Head: "head", Source: "github-check-runs", ObservedAt: &now, RequiredKnown: true, StatusesKnown: true,
Required: required, RequiredSource: "protection", RequiredChecks: bindings, Checks: checks}}
}
got := stageTrackerCIActivity(build(13, 6), now)
if got.State != "running" || !got.Active || got.ChecksPassed != 13 || got.ChecksTotal != 19 || got.Caption != "CI running · 13/19 checks done" {
t.Fatalf("13/19 with 6 pending must be an active running track: %+v", got)
}
full := stageTrackerCIActivity(build(19, 0), now)
if full.State != "passing" || full.Active || full.ChecksPassed != 19 || full.ChecksTotal != 19 {
t.Fatalf("19/19 is a complete green ring: %+v", full)
}
// Required set unknown: the head-wide count still reads motion.
loose := build(13, 6)
loose.CIActivity.RequiredKnown, loose.CIActivity.Required, loose.CIActivity.RequiredChecks = false, nil, nil
if got := stageTrackerCIActivity(loose, now); got.State != "running" || !got.Active || got.Caption != "CI running · 13/16 checks done" {
t.Fatalf("head-wide count with checks in progress must run: %+v", got)
}
}
24 changes: 24 additions & 0 deletions src/pkg/dashboard/stage_tracker_remediation_chevron.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -229,3 +229,27 @@ test('#16539 shape: a queued swarm reads 0/5 and, as the stage\'s own track, is
assert.doesNotMatch(c[5], /data-motion=/, 'queued is lit but still');
assert.equal(litCount(c.join('')), 1, 'the Review column is where the item is: the one lit chevron');
});

// hivecommons/hive#16631: a CI ring that is not full is a running ring.
// 13/19 with checks still pending is active with its count beside the
// running Review; only a complete 19/19 ring is the silent green glyph.
test('#16628 shape: CI 13/19 with pending checks + review in progress → both tracks active with words', () => {
const review = { head: 'abc1234def', state: 'reviewing', active: true, caption: 'Review 0/5 · in progress', perspectives_done: 0, perspectives_total: 5, source: 'dispatch', observed_at: seen };
for (const state of ['running', 'unknown', 'queued']) {
const c = cells(redPR({ display_column: 50, stage: 50,
ci_activity: { head: 'abc1234def', state, caption: 'CI ' + state, checks_passed: 13, checks_total: 19, source: 'checks', observed_at: seen },
review_activity: review }));
assert.match(c[4], /class="ham-seg ham-activity-track active ham-current"/, state + ': a part-filled ring is lit');
assert.match(c[4], /CI 13\/19 · (running|queued)</, state + ': words carry the count');
assert.match(c[5], /class="ham-seg ham-activity-track active ham-current"[^]*Review 0\/5 · in progress</);
assert.equal(litCount(c.join('')), 2, state + ': CI and Review both in motion');
}
const full = cells(redPR({ display_column: 50, stage: 50,
ci_activity: { head: 'abc1234def', state: 'passing', caption: 'CI green', checks_passed: 19, checks_total: 19, source: 'checks', observed_at: seen },
review_activity: review }));
assert.match(full[4], /class="ham-seg ham-activity-track done ham-current"/, 'a complete ring is the green glyph');
assert.match(full[4], /ham-track-verdict/);
assert.doesNotMatch(full[4], /CI 19\/19 passed</, 'no words on the inactive track');
assert.match(full[4], /data-ring-done="19" data-ring-failed="0"/);
assert.equal(litCount(full.join('')), 1, 'only Review is in motion');
});
Loading
Loading