diff --git a/appview/models/pipeline.go b/appview/models/pipeline.go
--- a/appview/models/pipeline.go
+++ b/appview/models/pipeline.go
@@ -3,6 +3,7 @@
import (
"fmt"
"slices"
+ "strings"
"time"
"github.com/bluesky-social/indigo/atproto/syntax"
@@ -56,6 +57,43 @@ return end.Sub(*start)
}
return 0
+}
+
+// produces short summary of successes:
+// - "0/4" when zero successes of 4 workflows
+// - "4/4" when all successes of 4 workflows
+// - "0/0" when no workflows run in this pipeline
+func (p Pipeline) ShortStatusSummary() string {
+ counts := make(map[spindle.StatusKind]int)
+ for _, w := range p.Statuses {
+ counts[w.Latest().Status] += 1
+ }
+
+ total := len(p.Statuses)
+ successes := counts[spindle.StatusKindSuccess]
+
+ return fmt.Sprintf("%d/%d", successes, total)
+}
+
+// produces a string of the form "3/4 success, 2/4 failed, 1/4 pending"
+func (p Pipeline) LongStatusSummary() string {
+ counts := make(map[spindle.StatusKind]int)
+ for _, w := range p.Statuses {
+ counts[w.Latest().Status] += 1
+ }
+
+ total := len(p.Statuses)
+
+ var result []string
+ // finish states first, followed by start states
+ states := append(spindle.FinishStates[:], spindle.StartStates[:]...)
+ for _, state := range states {
+ if count, ok := counts[state]; ok {
+ result = append(result, fmt.Sprintf("%d/%d %s", count, total, state.String()))
+ }
+ }
+
+ return strings.Join(result, ", ")
}
func (p Pipeline) Counts() map[string]int {
diff --git a/appview/pages/templates/repo/pipelines/fragments/pipelineSymbol.html b/appview/pages/templates/repo/pipelines/fragments/pipelineSymbol.html
--- a/appview/pages/templates/repo/pipelines/fragments/pipelineSymbol.html
+++ b/appview/pages/templates/repo/pipelines/fragments/pipelineSymbol.html
@@ -1,74 +1,65 @@
{{ define "repo/pipelines/fragments/pipelineSymbol" }}
-
- {{ $c := .Counts }}
- {{ $statuses := .Statuses }}
- {{ $total := len $statuses }}
- {{ $success := index $c "success" }}
- {{ $fail := index $c "failed" }}
- {{ $timeout := index $c "timeout" }}
- {{ $empty := eq $total 0 }}
- {{ $allPass := eq $success $total }}
- {{ $allFail := eq $fail $total }}
- {{ $allTimeout := eq $timeout $total }}
-
- {{ if $empty }}
-
- {{ i "hourglass" "size-4 text-gray-600 dark:text-gray-400 " }}
- 0/{{ $total }}
-
- {{ else if $allPass }}
-
- {{ i "check" "size-4 text-green-600" }}
- {{ $total }}/{{ $total }}
-
- {{ else if $allFail }}
-
- {{ i "x" "size-4 text-red-500" }}
- 0/{{ $total }}
-
- {{ else if $allTimeout }}
-
- {{ i "clock-alert" "size-4 text-orange-500" }}
- 0/{{ $total }}
-
+
+ {{ template "symbol" .Pipeline }}
+ {{ if .ShortSummary }}
+ {{ .Pipeline.ShortStatusSummary }}
{{ else }}
- {{ $radius := f64 8 }}
- {{ $circumference := mulf64 2.0 (mulf64 3.1416 $radius) }}
- {{ $offset := 0.0 }}
-
-
+{{ end }}
- {{ range $kind, $count := $c }}
- {{ $color := "" }}
- {{ if or (eq $kind "pending") (eq $kind "running") }}
- {{ $color = "#eab308" }} {{/* amber-500 */}}
- {{ else if eq $kind "success" }}
- {{ $color = "#10b981" }} {{/* green-500 */}}
- {{ else if eq $kind "cancelled" }}
- {{ $color = "#6b7280" }} {{/* gray-500 */}}
- {{ else if eq $kind "timeout" }}
- {{ $color = "#fb923c" }} {{/* orange-400 */}}
- {{ else }}
- {{ $color = "#ef4444" }} {{/* red-500 for failed or unknown */}}
- {{ end }}
+{{ define "symbol" }}
+ {{ $c := .Counts }}
+ {{ $statuses := .Statuses }}
+ {{ $total := len $statuses }}
+ {{ $success := index $c "success" }}
+ {{ $fail := index $c "failed" }}
+ {{ $timeout := index $c "timeout" }}
+ {{ $empty := eq $total 0 }}
+ {{ $allPass := eq $success $total }}
+ {{ $allFail := eq $fail $total }}
+ {{ $allTimeout := eq $timeout $total }}
- {{ $percent := divf64 (f64 $count) (f64 $total) }}
- {{ $length := mulf64 $percent $circumference }}
-
-
- {{ $offset = addf64 $offset $length }}
- {{ end }}
-
-
{{ $success }}/{{ $total }}
-
- {{ end }}
-
+ {{ if $empty }}
+ {{ i "hourglass" "size-4 text-gray-600 dark:text-gray-400 " }}
+ {{ else if $allPass }}
+ {{ i "check" "size-4 text-green-600 dark:text-green-500" }}
+ {{ else if $allFail }}
+ {{ i "x" "size-4 text-red-600 dark:text-red-500" }}
+ {{ else if $allTimeout }}
+ {{ i "clock-alert" "size-4 text-orange-500" }}
+ {{ else }}
+ {{ $radius := f64 8 }}
+ {{ $circumference := mulf64 2.0 (mulf64 3.1416 $radius) }}
+ {{ $offset := 0.0 }}
+
+ {{ end }}
{{ end }}
diff --git a/appview/pages/templates/repo/pipelines/fragments/pipelineSymbolLong.html b/appview/pages/templates/repo/pipelines/fragments/pipelineSymbolLong.html
--- a/appview/pages/templates/repo/pipelines/fragments/pipelineSymbolLong.html
+++ b/appview/pages/templates/repo/pipelines/fragments/pipelineSymbolLong.html
@@ -4,7 +4,7 @@ {{ $repoinfo := .RepoInfo }}
- {{ template "repo/pipelines/fragments/pipelineSymbol" .Pipeline }}
+ {{ template "repo/pipelines/fragments/pipelineSymbol" (dict "Pipeline" $pipeline "ShortSummary" true) }}
{{ template "repo/pipelines/fragments/tooltip" $ }}