generated from mathias/template-go-web
feat(atlas): Phase C increment 1 — live CI runs on the pipeline
The CI stage now shows the pipeline's latest real execution, read live from the in-cluster Gitea Actions API (public read, no token, gitea-http.gitea.svc): "▶ run #N · <state>" coloured by outcome, prepended to the generated job list. LatestRun + RunNode built test-first; cached in the same 30s liveOverlay; falls back cleanly when Gitea is unreachable. assessor-loop ledger / session_log deferred: no live CAD data exists for this repo yet (brain confirms). Gitea run history is the real available trace. Verified: build/vet/lint(0)/test green. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,70 @@
|
||||
package atlas_test
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"git.d-ma.be/mathias/cad-atlas/internal/atlas"
|
||||
)
|
||||
|
||||
func TestLatestRun_ReturnsNewestRun(t *testing.T) {
|
||||
tasks := []byte(`{"total_count":52,"workflow_runs":[
|
||||
{"run_number":27,"status":"success","conclusion":null,"head_sha":"633ba153f26","display_title":"Phase B tail","url":"https://git.d-ma.be/mathias/cad-atlas/actions/runs/27"},
|
||||
{"run_number":26,"status":"failure","head_sha":"aaa"}
|
||||
]}`)
|
||||
|
||||
r, err := atlas.LatestRun(tasks)
|
||||
if err != nil {
|
||||
t.Fatalf("LatestRun: %v", err)
|
||||
}
|
||||
if r.Number != 27 || r.SHA != "633ba153f26" || r.Title != "Phase B tail" {
|
||||
t.Fatalf("run = %+v", r)
|
||||
}
|
||||
if r.State() != "success" {
|
||||
t.Fatalf("State = %q, want success", r.State())
|
||||
}
|
||||
}
|
||||
|
||||
func TestLatestRun_ConclusionWinsOverStatus(t *testing.T) {
|
||||
tasks := []byte(`{"workflow_runs":[{"run_number":9,"status":"completed","conclusion":"failure"}]}`)
|
||||
r, err := atlas.LatestRun(tasks)
|
||||
if err != nil {
|
||||
t.Fatalf("LatestRun: %v", err)
|
||||
}
|
||||
if r.State() != "failure" {
|
||||
t.Fatalf("State = %q, want failure", r.State())
|
||||
}
|
||||
}
|
||||
|
||||
func TestRunNode_ColoursAndLabelsByOutcome(t *testing.T) {
|
||||
green := atlas.RunNode(atlas.Run{Number: 27, Status: "success", SHA: "633ba153f26abc", Title: "Phase B tail"})
|
||||
if green.Pill != "var(--green)" {
|
||||
t.Fatalf("success pill = %q, want var(--green)", green.Pill)
|
||||
}
|
||||
if green.Title != "▶ run #27 · success" {
|
||||
t.Fatalf("title = %q", green.Title)
|
||||
}
|
||||
if green.Desc != "Phase B tail" {
|
||||
t.Fatalf("desc = %q", green.Desc)
|
||||
}
|
||||
// short sha appears as a tag
|
||||
found := false
|
||||
for _, tag := range green.Tags {
|
||||
if tag == "633ba15" {
|
||||
found = true
|
||||
}
|
||||
}
|
||||
if !found {
|
||||
t.Fatalf("short sha tag missing: %v", green.Tags)
|
||||
}
|
||||
|
||||
red := atlas.RunNode(atlas.Run{Number: 5, Status: "completed", Conclusion: "failure"})
|
||||
if red.Pill != "var(--coral)" {
|
||||
t.Fatalf("failure pill = %q, want var(--coral)", red.Pill)
|
||||
}
|
||||
}
|
||||
|
||||
func TestLatestRun_ErrorsWhenNoRuns(t *testing.T) {
|
||||
if _, err := atlas.LatestRun([]byte(`{"workflow_runs":[]}`)); err == nil {
|
||||
t.Fatal("expected error on empty runs, got nil")
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user