generated from mathias/template-go-web
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3e28dcf69f |
@@ -73,20 +73,20 @@ func RecentRuns(tasksJSON []byte, n int) ([]RunDot, error) {
|
|||||||
|
|
||||||
// aggregateState folds per-job outcomes into a run outcome.
|
// aggregateState folds per-job outcomes into a run outcome.
|
||||||
func aggregateState(jobs []Job) string {
|
func aggregateState(jobs []Job) string {
|
||||||
allSucceeded := true
|
pending := false
|
||||||
for _, j := range jobs {
|
for _, j := range jobs {
|
||||||
switch j.State() {
|
switch j.State() {
|
||||||
case "failure", "cancelled", "error":
|
case "failure", "cancelled", "error":
|
||||||
return "failure"
|
return "failure"
|
||||||
case "success":
|
case "success", "skipped": // completed OK — skipped (e.g. deploy on a tag push) doesn't block
|
||||||
default:
|
default:
|
||||||
allSucceeded = false
|
pending = true // running / in_progress / waiting / queued / unknown
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if allSucceeded {
|
if pending {
|
||||||
return "success"
|
|
||||||
}
|
|
||||||
return "running"
|
return "running"
|
||||||
|
}
|
||||||
|
return "success"
|
||||||
}
|
}
|
||||||
|
|
||||||
// LatestRunJobs parses a Gitea `/actions/tasks` response (per-job entries,
|
// LatestRunJobs parses a Gitea `/actions/tasks` response (per-job entries,
|
||||||
|
|||||||
@@ -89,6 +89,16 @@ func TestRecentRuns_GroupsRunsNewestFirstWithAggregateState(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestRunState_SkippedJobsCountAsOK(t *testing.T) {
|
||||||
|
// A tag-push run skips the deploy job; the run still succeeded.
|
||||||
|
s := atlas.RunSummary{Jobs: []atlas.Job{
|
||||||
|
{Status: "skipped"}, {Status: "success"}, {Status: "success"},
|
||||||
|
}}
|
||||||
|
if s.State() != "success" {
|
||||||
|
t.Fatalf("skipped+success run state = %q, want success", s.State())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func TestLatestRunJobs_ErrorsWhenEmpty(t *testing.T) {
|
func TestLatestRunJobs_ErrorsWhenEmpty(t *testing.T) {
|
||||||
if _, err := atlas.LatestRunJobs([]byte(`{"workflow_runs":[]}`)); err == nil {
|
if _, err := atlas.LatestRunJobs([]byte(`{"workflow_runs":[]}`)); err == nil {
|
||||||
t.Fatal("expected error on empty, got nil")
|
t.Fatal("expected error on empty, got nil")
|
||||||
|
|||||||
Reference in New Issue
Block a user