Pipelines page: every branch's newest together, filtered only by a module
The operator found a pipelines view filtered by branch name makes no sense: the page and the terminal view now list the newest pipelines of every branch together, newest first, the branch a column, and offer one filter, a module (the pipelines that carry it). A delivery still links to its pipeline from its branch's list, or from every branch's list by the row's branch. Builds: design 47 H2 H-A-533 (hq 1b1e1984)
This commit is contained in:
@@ -3,8 +3,8 @@
|
||||
// to write the operator's answer to an ask that needs no proof of who answered (the view refuses the merge's Approve). `holds`
|
||||
// lists every fingerprint the assigner holds with its node, cause and answer; `hold-release <module> <fingerprint> [words]` and
|
||||
// `hold-keep <module> <fingerprint> [words]` answer its hold ask, again when the operator changes their mind (issue 1906).
|
||||
// `pipelines [branch]` and `pipeline <pipeline> [mover]` are the pipelines page (design 47 H2 H-A-467): a branch's newest
|
||||
// pipelines, one pipeline's mover rows or one mover's steps; with -follow printed again at each change the runner's events say.
|
||||
// `pipelines [module]` and `pipeline <pipeline> [mover]` are the pipelines page (design 47 H2 H-A-467, H-A-533): every
|
||||
// branch's newest pipelines (of a module when named), one pipeline by tier and stage, or one mover's steps; with -follow printed again at each change the runner's events say.
|
||||
package main
|
||||
|
||||
import (
|
||||
@@ -36,7 +36,7 @@ func run(args []string, socket string, out, errOut io.Writer) int {
|
||||
asJSON := fs.Bool("json", false, "print the rows as JSON")
|
||||
follow := fs.Bool("follow", false, "pipelines and pipeline: print again at each change the runner's events say, until interrupted")
|
||||
next := fs.String("next", "", "pipeline: the cursor of the next page a pipeline's answer named")
|
||||
limit := fs.Int("limit", view.DefaultPipelinesLimit, "pipelines: the newest this many pipelines of the branch")
|
||||
limit := fs.Int("limit", view.DefaultPipelinesLimit, "pipelines: the newest this many pipelines")
|
||||
if err := fs.Parse(args); err != nil {
|
||||
return 2
|
||||
}
|
||||
@@ -66,7 +66,7 @@ func run(args []string, socket string, out, errOut io.Writer) int {
|
||||
}
|
||||
if fs.NArg() > 0 {
|
||||
if fs.Arg(0) != "answer" || fs.NArg() < 3 {
|
||||
fmt.Fprintln(errOut, "mesh-delivery-cli shows the rows, or answers: mesh-delivery-cli answer <ask key> <option> [words]; holds; hold-release|hold-keep <module> <fingerprint> [words]; [-follow] [-limit <n>] pipelines [branch]; [-follow] [-next <cursor>] pipeline <pipeline> [mover]")
|
||||
fmt.Fprintln(errOut, "mesh-delivery-cli shows the rows, or answers: mesh-delivery-cli answer <ask key> <option> [words]; holds; hold-release|hold-keep <module> <fingerprint> [words]; [-follow] [-limit <n>] pipelines [module]; [-follow] [-next <cursor>] pipeline <pipeline> [mover]")
|
||||
return 2
|
||||
}
|
||||
key, option := fs.Arg(1), fs.Arg(2)
|
||||
@@ -95,14 +95,14 @@ func run(args []string, socket string, out, errOut io.Writer) int {
|
||||
return 0
|
||||
}
|
||||
|
||||
// pipelines prints the pipelines page (design 47 H2 H-A-467): `pipelines [branch]` the newest pipelines of a branch (main by
|
||||
// default), `pipeline <pipeline> [mover]` one pipeline's mover rows or one mover's steps; with -follow again at each change.
|
||||
// pipelines prints the pipelines page (design 47 H2 H-A-467, H-A-533): `pipelines [module]` the newest pipelines of every
|
||||
// branch, of those carrying the module when named, `pipeline <pipeline> [mover]` one pipeline's mover rows or one mover's steps; with -follow again at each change.
|
||||
func pipelines(socket string, args []string, next string, limit int, follow, asJSON bool, out, errOut io.Writer) int {
|
||||
var branch, pipeline, mover string
|
||||
var module, pipeline, mover string
|
||||
switch {
|
||||
case args[0] == "pipelines" && len(args) <= 2:
|
||||
if len(args) == 2 {
|
||||
branch = args[1]
|
||||
module = args[1]
|
||||
}
|
||||
case args[0] == "pipeline" && (len(args) == 2 || len(args) == 3):
|
||||
pipeline = args[1]
|
||||
@@ -110,11 +110,11 @@ func pipelines(socket string, args []string, next string, limit int, follow, asJ
|
||||
mover = args[2]
|
||||
}
|
||||
default:
|
||||
fmt.Fprintln(errOut, "mesh-delivery-cli [-follow] [-limit <n>] pipelines [branch]; mesh-delivery-cli [-follow] [-next <cursor>] pipeline <pipeline> [mover]")
|
||||
fmt.Fprintln(errOut, "mesh-delivery-cli [-follow] [-limit <n>] pipelines [module]; mesh-delivery-cli [-follow] [-next <cursor>] pipeline <pipeline> [mover]")
|
||||
return 2
|
||||
}
|
||||
var failed error
|
||||
err := view.AskPipelines(socket, branch, limit, pipeline, mover, next, follow, func(page view.PipelinesPage, show *seatShow) bool {
|
||||
err := view.AskPipelines(socket, module, limit, pipeline, mover, next, follow, func(page view.PipelinesPage, show *seatShow) bool {
|
||||
if follow {
|
||||
fmt.Fprintf(out, "--- %s ---\n", time.Now().Format("15:04:05"))
|
||||
}
|
||||
|
||||
@@ -314,11 +314,11 @@ func TestThePipelinesCommands(t *testing.T) {
|
||||
switch key {
|
||||
case view.PipelinesListVerb:
|
||||
in := body.(pseat.ListInput)
|
||||
if in.Branch != "next" {
|
||||
if in.Branch != "" || (in.Module != "" && in.Module != "alpha") { // every branch's, of a module when named (H-A-533)
|
||||
return json.Marshal(pseat.ListAnswer{})
|
||||
}
|
||||
rows := []pseat.PipelineRow{{Pipeline: "next.3", Source: 2, Revision: 3, Outcome: "passed", MoverCount: 1, Steps: map[string]int64{"passed": 4}},
|
||||
{Pipeline: "next.2", Source: 2, Revision: 2, Outcome: "superseded", MoverCount: 1}}
|
||||
rows := []pseat.PipelineRow{{Pipeline: "next.3", Branch: "next", Source: 2, Revision: 3, Outcome: "passed", MoverCount: 1, Steps: map[string]int64{"passed": 4}},
|
||||
{Pipeline: "next.2", Branch: "next", Source: 2, Revision: 2, Outcome: "superseded", MoverCount: 1}}
|
||||
return json.Marshal(pseat.ListAnswer{Rows: rows[:min(int(in.Limit), len(rows))]})
|
||||
case view.PipelinesShowVerb:
|
||||
return json.Marshal(pseat.ShowAnswer{Pipeline: pseat.Pipeline{Pipeline: "next.3", Outcome: "passed", Movers: []pseat.Mover{{Module: "alpha", Fingerprint: "src2:aa", Version: "0.2.1"}}},
|
||||
@@ -344,9 +344,12 @@ func TestThePipelinesCommands(t *testing.T) {
|
||||
args []string
|
||||
want string
|
||||
}{
|
||||
{[]string{"pipelines", "next"}, "next.3 3 2 passed 1 4 0 0 0 0 0 0 0"},
|
||||
{[]string{"pipelines", "next"}, "next.2"}, // the newest 20 by default
|
||||
{[]string{"-limit", "1", "pipelines", "next"}, "next.3"},
|
||||
{[]string{"pipelines"}, "PIPELINES PIPELINE BRANCH REVISION"},
|
||||
{[]string{"pipelines"}, "next.3 next 3 2 passed 1 4 0 0 0 0 0 0 0"},
|
||||
{[]string{"pipelines"}, "next.2"}, // the newest 20 by default
|
||||
{[]string{"pipelines", "alpha"}, "PIPELINES CARRYING alpha"},
|
||||
{[]string{"pipelines", "alpha"}, "next.3 next"},
|
||||
{[]string{"-limit", "1", "pipelines"}, "next.3"},
|
||||
{[]string{"pipeline", "next.3"}, "TIER 1 MOVER OUTCOME BUILD LINT UNIT INTEGRATION VALIDATE COMPOSITION CODE REVIEW APPROVAL alpha passed - - - - - - - -"},
|
||||
{[]string{"pipeline", "next.3"}, "PIPELINE next.3: passed; 0 of 1 movers run their build on every node they are placed on; 1 is placed on none"},
|
||||
{[]string{"-json", "pipeline", "next.3"}, `"fingerprint": "src2:aa"`},
|
||||
@@ -357,7 +360,11 @@ func TestThePipelinesCommands(t *testing.T) {
|
||||
}
|
||||
}
|
||||
var out, errOut bytes.Buffer
|
||||
if code := run([]string{"-limit", "1", "pipelines", "next"}, path, &out, &errOut); code != 0 || strings.Contains(out.String(), "next.2") {
|
||||
if code := run([]string{"pipelines", "zeta"}, path, &out, &errOut); code != 0 || strings.Contains(out.String(), "next.3") {
|
||||
t.Errorf("pipelines zeta = %d %q, want none: no pipeline carries zeta", code, out.String())
|
||||
}
|
||||
out.Reset()
|
||||
if code := run([]string{"-limit", "1", "pipelines"}, path, &out, &errOut); code != 0 || strings.Contains(out.String(), "next.2") {
|
||||
t.Errorf("-limit 1 = %d %q, want only the newest", code, out.String())
|
||||
}
|
||||
for _, args := range [][]string{{"pipeline"}, {"-limit", "0", "pipelines"}} {
|
||||
|
||||
@@ -896,7 +896,7 @@ func TestProcessWholeSaysTheSourceRevisionIsDelivered(t *testing.T) {
|
||||
pipelines.set(pseat.PipelineRow{Pipeline: "release.9", Source: rev, Revision: 9, Outcome: "passed", MoverCount: 1},
|
||||
pseat.PipelineRow{Pipeline: "release.8", Source: rev, Revision: 8, Outcome: "superseded", MoverCount: 1})
|
||||
var seen [][]string
|
||||
err = view.AskPipelines(env["MESH_DELIVERY_SOCKET"], catalogBranch, 0, "", "", "", true, func(page view.PipelinesPage, _ *view.PipelineAnswer) bool {
|
||||
err = view.AskPipelines(env["MESH_DELIVERY_SOCKET"], "", 0, "", "", "", true, func(page view.PipelinesPage, _ *view.PipelineAnswer) bool {
|
||||
var keys []string
|
||||
for _, r := range page.Rows {
|
||||
keys = append(keys, r.Pipeline)
|
||||
@@ -949,8 +949,8 @@ func pipelinesRunner(t *testing.T, nc *nats.Conn) *fakeList {
|
||||
_ = json.Unmarshal(m.Data, &in)
|
||||
f.mu.Lock()
|
||||
a := pseat.ListAnswer{}
|
||||
if in.Branch == catalogBranch && in.Limit == view.DefaultPipelinesLimit {
|
||||
a.Rows = f.rows
|
||||
if (in.Branch == catalogBranch || in.Branch == "") && in.Module == "" && in.Limit == view.DefaultPipelinesLimit {
|
||||
a.Rows = f.rows // the one watched branch's, which are every branch's too (design 47 H2 H-A-533)
|
||||
}
|
||||
f.mu.Unlock()
|
||||
raw, _ := json.Marshal(map[string]any{"result": a, "node": "n0"})
|
||||
|
||||
@@ -19,10 +19,9 @@ const (
|
||||
PipelinesShowVerb = "seat:" + seat.Seat + "." + seat.VerbShow
|
||||
)
|
||||
|
||||
// The pipelines page's defaults (design 47 H2 H-A-467 (1)): the branch main and the newest 20.
|
||||
// The pipelines page's default (design 47 H2 H-A-467 (1)): the newest 20, of every branch (H-A-533).
|
||||
const (
|
||||
DefaultPipelinesBranch = "main"
|
||||
DefaultPipelinesLimit = 20
|
||||
DefaultPipelinesLimit = 20
|
||||
// DefaultPipelinesHeard is the default of the setting pipelines-heard: how many pipelines' last changes the view keeps
|
||||
// for its pages before it forgets them all (principle 11).
|
||||
DefaultPipelinesHeard = 1024
|
||||
@@ -41,9 +40,11 @@ func PipelineEventPatterns() []string {
|
||||
return out
|
||||
}
|
||||
|
||||
// PipelinesPage is one branch's list as the page shows it: the rows list answered, or why it could not be read.
|
||||
// PipelinesPage is the list as the page shows it (design 47 H2 H-A-533): the newest pipelines of every branch together,
|
||||
// each row naming its branch, or only those that carry Module when one is named; the rows list answered, or why it could not
|
||||
// be read.
|
||||
type PipelinesPage struct {
|
||||
Branch string `json:"branch"`
|
||||
Module string `json:"module,omitempty"`
|
||||
Rows []seat.PipelineRow `json:"rows"`
|
||||
Error string `json:"error,omitempty"`
|
||||
}
|
||||
@@ -53,21 +54,21 @@ type PipelinesPage struct {
|
||||
// of the view's own: what it read is read again at each event.
|
||||
type Pipelines struct {
|
||||
call func(key string, body any) (json.RawMessage, error)
|
||||
branches func() []string // the watched branches followed beside the default; nil for none
|
||||
branches func() []string // the watched branches whose lists the deliveries' links read; nil for none
|
||||
logf func(string, ...any)
|
||||
dirty chan struct{}
|
||||
|
||||
mu sync.Mutex
|
||||
lists map[string]PipelinesPage // by branch, the branches followed
|
||||
all *PipelinesPage // every branch's newest, as last read; nil before the first reading
|
||||
lists map[string]PipelinesPage // by branch, the watched branches, for the deliveries' links
|
||||
subs map[chan string]struct{}
|
||||
version uint64
|
||||
heard map[string]uint64 // the version of the last change of each pipeline heard
|
||||
most int // the pipelines heard kept before heard is forgotten whole: the setting pipelines-heard
|
||||
}
|
||||
|
||||
// NewPipelines is a reader of the pipelines through call; branches, when given, names the watched branches whose list is
|
||||
// followed beside the default branch's, for the deliveries' links (design 47 H2 H-A-467 (3)); heard is the setting
|
||||
// pipelines-heard, its default below one.
|
||||
// NewPipelines is a reader of the pipelines through call; branches, when given, names the watched branches whose lists are
|
||||
// read for the deliveries' links (design 47 H2 H-A-467 (3)); heard is the setting pipelines-heard, its default below one.
|
||||
func NewPipelines(call func(key string, body any) (json.RawMessage, error), branches func() []string, heard int, logf func(string, ...any)) *Pipelines {
|
||||
if logf == nil {
|
||||
logf = func(string, ...any) {}
|
||||
@@ -79,23 +80,30 @@ func NewPipelines(call func(key string, body any) (json.RawMessage, error), bran
|
||||
lists: map[string]PipelinesPage{}, subs: map[chan string]struct{}{}, heard: map[string]uint64{}, most: heard}
|
||||
}
|
||||
|
||||
// List asks the seat's verb list for one branch's newest limit pipelines in its short form; a limit below one is the
|
||||
// default's.
|
||||
func (p *Pipelines) List(branch string, limit int) ([]seat.PipelineRow, error) {
|
||||
// List asks the seat's verb list for the newest limit pipelines in its short form: of one branch when named, of every
|
||||
// branch when not (H-A-533), and only those carrying module when named; a limit below one is the default's.
|
||||
func (p *Pipelines) List(branch, module string, limit int) ([]seat.PipelineRow, error) {
|
||||
if limit < 1 {
|
||||
limit = DefaultPipelinesLimit
|
||||
}
|
||||
raw, err := p.call(PipelinesListVerb, seat.ListInput{Branch: branch, Limit: int64(limit)})
|
||||
of := "every branch"
|
||||
if branch != "" {
|
||||
of = branch
|
||||
}
|
||||
if module != "" {
|
||||
of += " carrying " + module
|
||||
}
|
||||
raw, err := p.call(PipelinesListVerb, seat.ListInput{Branch: branch, Module: module, Limit: int64(limit)})
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("%s of %s: %w", PipelinesListVerb, branch, err)
|
||||
return nil, fmt.Errorf("%s of %s: %w", PipelinesListVerb, of, err)
|
||||
}
|
||||
answer, said, ok := buscalls.Unwrap(raw)
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("%s of %s answered: %s", PipelinesListVerb, branch, said)
|
||||
return nil, fmt.Errorf("%s of %s answered: %s", PipelinesListVerb, of, said)
|
||||
}
|
||||
var a seat.ListAnswer
|
||||
if err := json.Unmarshal(answer, &a); err != nil {
|
||||
return nil, fmt.Errorf("the answer of %s of %s is not a list: %w", PipelinesListVerb, branch, err)
|
||||
return nil, fmt.Errorf("the answer of %s of %s is not a list: %w", PipelinesListVerb, of, err)
|
||||
}
|
||||
return a.Rows, nil
|
||||
}
|
||||
@@ -123,9 +131,9 @@ func showAnswer(raw json.RawMessage, err error, pipeline string) (seat.ShowAnswe
|
||||
return a, nil
|
||||
}
|
||||
|
||||
// followed is the default branch and the watched branches, each once.
|
||||
// followed is the watched branches, each once, whose lists the deliveries' links read.
|
||||
func (p *Pipelines) followed() []string {
|
||||
out := []string{DefaultPipelinesBranch}
|
||||
var out []string
|
||||
if p.branches != nil {
|
||||
for _, b := range p.branches() {
|
||||
if b != "" && !slices.Contains(out, b) {
|
||||
@@ -136,29 +144,27 @@ func (p *Pipelines) followed() []string {
|
||||
return out
|
||||
}
|
||||
|
||||
// Page is one branch's newest limit pipelines (the default's below one): a followed branch's at the default limit as last
|
||||
// read, any other branch or limit read now.
|
||||
func (p *Pipelines) Page(branch string, limit int) PipelinesPage {
|
||||
if branch = strings.TrimSpace(branch); branch == "" {
|
||||
branch = DefaultPipelinesBranch
|
||||
}
|
||||
// Page is the newest limit pipelines of every branch (the default's below one), of those carrying module when named
|
||||
// (design 47 H2 H-A-533): with no module at the default limit as last read, else read now.
|
||||
func (p *Pipelines) Page(module string, limit int) PipelinesPage {
|
||||
module = strings.TrimSpace(module)
|
||||
if limit < 1 {
|
||||
limit = DefaultPipelinesLimit
|
||||
}
|
||||
if limit == DefaultPipelinesLimit {
|
||||
if module == "" && limit == DefaultPipelinesLimit {
|
||||
p.mu.Lock()
|
||||
page, ok := p.lists[branch]
|
||||
all := p.all
|
||||
p.mu.Unlock()
|
||||
if ok {
|
||||
return page
|
||||
if all != nil {
|
||||
return *all
|
||||
}
|
||||
}
|
||||
return p.read(branch, limit)
|
||||
return p.read("", module, limit)
|
||||
}
|
||||
|
||||
func (p *Pipelines) read(branch string, limit int) PipelinesPage {
|
||||
rows, err := p.List(branch, limit)
|
||||
page := PipelinesPage{Branch: branch, Rows: rows}
|
||||
func (p *Pipelines) read(branch, module string, limit int) PipelinesPage {
|
||||
rows, err := p.List(branch, module, limit)
|
||||
page := PipelinesPage{Module: module, Rows: rows}
|
||||
if err != nil {
|
||||
page.Error = err.Error()
|
||||
}
|
||||
@@ -168,23 +174,28 @@ func (p *Pipelines) read(branch string, limit int) PipelinesPage {
|
||||
return page
|
||||
}
|
||||
|
||||
// Refresh reads the list of every followed branch again and says the lists changed.
|
||||
// Refresh reads the list of every branch, and of each watched branch for the deliveries' links, again and says the lists
|
||||
// changed.
|
||||
func (p *Pipelines) Refresh() {
|
||||
all := p.read("", "", DefaultPipelinesLimit)
|
||||
if all.Error != "" {
|
||||
p.logf("the pipelines are not read (read again at the runner's next event): %s", all.Error)
|
||||
}
|
||||
lists := map[string]PipelinesPage{}
|
||||
for _, b := range p.followed() {
|
||||
page := p.read(b, DefaultPipelinesLimit)
|
||||
page := p.read(b, "", DefaultPipelinesLimit)
|
||||
if page.Error != "" {
|
||||
p.logf("the pipelines of %s are not read (read again at the runner's next event): %s", b, page.Error)
|
||||
}
|
||||
lists[b] = page
|
||||
}
|
||||
p.mu.Lock()
|
||||
p.lists = lists
|
||||
p.all, p.lists = &all, lists
|
||||
p.mu.Unlock()
|
||||
p.notify("")
|
||||
}
|
||||
|
||||
// Of is the pipeline of a delivery: of the branch's followed list, the newest whose source is the delivery's source
|
||||
// Of is the pipeline of a delivery: of the branch's list, then of every branch's, the newest whose source is the delivery's source
|
||||
// revision (design 47 H2 H-A-467 (3)); "" when none. A branch whose list is not read yet (a watched branch the reader
|
||||
// learnt of after its last reading) has the lists read again, once.
|
||||
func (p *Pipelines) Of(branch string, source uint64) string {
|
||||
@@ -194,11 +205,21 @@ func (p *Pipelines) Of(branch string, source uint64) string {
|
||||
if !ok {
|
||||
p.owe()
|
||||
}
|
||||
if source == 0 {
|
||||
return ""
|
||||
}
|
||||
for _, r := range page.Rows { // newest first, as list answers them
|
||||
if source != 0 && r.Source == int64(source) {
|
||||
if r.Source == int64(source) {
|
||||
return r.Pipeline
|
||||
}
|
||||
}
|
||||
if p.all != nil {
|
||||
for _, r := range p.all.Rows { // every branch's newest, each naming its branch (H-A-533)
|
||||
if r.Branch == branch && r.Source == int64(source) {
|
||||
return r.Pipeline
|
||||
}
|
||||
}
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
|
||||
@@ -6,8 +6,10 @@ import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"maps"
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
"slices"
|
||||
"strings"
|
||||
"sync"
|
||||
"testing"
|
||||
@@ -40,6 +42,21 @@ func (f *fakeRunner) call(key string, body any) (json.RawMessage, error) {
|
||||
}
|
||||
f.lists++
|
||||
rows := f.rows[in.Branch]
|
||||
if in.Branch == "" { // every branch's, each row naming its branch, newest first (design 47 H2 H-A-533)
|
||||
rows = nil
|
||||
for _, b := range slices.Sorted(maps.Keys(f.rows)) {
|
||||
for _, r := range f.rows[b] {
|
||||
carries := in.Module == ""
|
||||
for _, mv := range f.shows[r.Pipeline].Pipeline.Movers {
|
||||
carries = carries || mv.Module == in.Module
|
||||
}
|
||||
if r.Branch = b; carries {
|
||||
rows = append(rows, r)
|
||||
}
|
||||
}
|
||||
}
|
||||
slices.SortStableFunc(rows, func(a, b seat.PipelineRow) int { return int(b.Revision - a.Revision) })
|
||||
}
|
||||
return json.Marshal(seat.ListAnswer{Rows: rows[:min(int(in.Limit), len(rows))]})
|
||||
case PipelinesShowVerb:
|
||||
in := body.(seat.ShowInput)
|
||||
@@ -155,8 +172,8 @@ func TestThePipelinesPage(t *testing.T) {
|
||||
}{
|
||||
{"the terminal view's list counts the steps per outcome", func() string {
|
||||
return text(func(b *bytes.Buffer) { PipelinesTable(b, p.Page("", 0)) })
|
||||
}, []string{"PIPELINES OF main", "PASSED FAILED COULD NOT RUN NOT ASKED WAITING WAITING FOR A BUILD NODE BYPASSED NOTHING TO RUN",
|
||||
"main.12 12 9 2026-10-18", "failed 2 5 1 1 0 0 2 0 0"}},
|
||||
}, []string{"PIPELINES PIPELINE BRANCH REVISION", "PASSED FAILED COULD NOT RUN NOT ASKED WAITING WAITING FOR A BUILD NODE BYPASSED NOTHING TO RUN",
|
||||
"main.12 main 12 9 2026-10-18", "release.8 release 8 4", "failed 2 5 1 1 0 0 2 0 0"}},
|
||||
{"the web list links each pipeline and reloads on the view's changes, never a timer", func() string { return web("/pipelines") }, []string{
|
||||
`<a href="/pipelines/show?pipeline=main.12">main.12</a>`, `new EventSource("/pipelines/changes?since=`}},
|
||||
{"a pipeline's page is its header, then a block per tier, a row per mover with a cell per stage and per node", func() string {
|
||||
@@ -216,10 +233,23 @@ func TestThePipelinesPage(t *testing.T) {
|
||||
"delta passed - - - - - - - - - - -", "TIER 2",
|
||||
"beta failed - - could not run 1/2 - - - - waiting wanted applying no want written",
|
||||
"gamma passed - - - - - - - - held: connection refused held: health failed on n1 -"}},
|
||||
{"the web list asks the newest limit of a branch", func() string { return web("/pipelines?branch=" + testBranch + "&limit=1") }, []string{
|
||||
"release.8", `name="limit" value="1"`}},
|
||||
{"the web list is the newest 20 by default", func() string { return web("/pipelines?branch=" + testBranch) }, []string{
|
||||
"release.8", "release.7", `name="limit" value="20"`}},
|
||||
{"the web list asks the newest limit of every branch", func() string { return web("/pipelines?limit=1") }, []string{
|
||||
"main.12", `name="limit" value="1"`}},
|
||||
{"the web list is every branch's newest 20 by default, the branch a column", func() string { return web("/pipelines") }, []string{
|
||||
"<h1>PIPELINES</h1>", `module <input name="module" value="">`, "<th>BRANCH</th>", "main.12</a></td><td>main</td>",
|
||||
"release.8</a></td><td>release</td>", "release.7", `name="limit" value="20"`}},
|
||||
{"the only filter is a module: the pipelines that carry it", func() string {
|
||||
got := web("/pipelines?module=beta")
|
||||
if strings.Contains(got, "release.8") {
|
||||
return "release.8 does not carry beta: " + got
|
||||
}
|
||||
return got
|
||||
}, []string{"<h1>PIPELINES CARRYING beta</h1>", "main.12</a></td><td>main</td>"}},
|
||||
{"a delivery of a branch the view reads no list of links through every branch's list", func() string {
|
||||
q := NewPipelines(runner.call, nil, 0, nil)
|
||||
q.Refresh()
|
||||
return q.Of(testBranch, 4) + " " + q.Of("main", 4)
|
||||
}, []string{"release.8 "}},
|
||||
{"a pipeline the runner does not hold says so", func() string { return web("/pipelines/show?pipeline=main.99") }, []string{"unreadable: ", "no pipeline main.99"}},
|
||||
{"a delivery links to the newest pipeline of its source revision", func() string {
|
||||
return text(func(b *bytes.Buffer) { Table(b, m.Snapshot()) }) + web("/")
|
||||
@@ -235,8 +265,8 @@ func TestThePipelinesPage(t *testing.T) {
|
||||
}
|
||||
})
|
||||
}
|
||||
if got := web("/pipelines?branch=" + testBranch + "&limit=1"); strings.Contains(got, "release.7") {
|
||||
t.Errorf("the newest 1 shows release.7: %s", got)
|
||||
if got := web("/pipelines?limit=1"); strings.Contains(got, "release.8") {
|
||||
t.Errorf("the newest 1 shows release.8: %s", got)
|
||||
}
|
||||
for _, l := range []string{"0", "x"} {
|
||||
rec := httptest.NewRecorder()
|
||||
|
||||
@@ -20,7 +20,7 @@ var PipelineCountOutcomes = []string{seat.StepResultOutcomePassed, seat.StepResu
|
||||
seat.StepResultOutcomeBypassed, seat.StepResultOutcomeNothingToRun}
|
||||
|
||||
// PipelinesHead is the head of the list's rows.
|
||||
var PipelinesHead = append([]string{"PIPELINE", "REVISION", "SOURCE", "STARTED", "OUTCOME", "MOVERS"}, upper(PipelineCountOutcomes)...)
|
||||
var PipelinesHead = append([]string{"PIPELINE", "BRANCH", "REVISION", "SOURCE", "STARTED", "OUTCOME", "MOVERS"}, upper(PipelineCountOutcomes)...)
|
||||
|
||||
// MoversHead is the head of one pipeline's mover rows, StepsHead of one mover's steps (design 47 H2 H-A-467 (2)).
|
||||
var (
|
||||
@@ -77,7 +77,7 @@ func number(n int64) string {
|
||||
|
||||
// PipelineRowText is one list row's cells, in PipelinesHead's order.
|
||||
func PipelineRowText(r seat.PipelineRow) []string {
|
||||
out := []string{r.Pipeline, number(r.Revision), number(r.Source), timeOf(r.Started), r.Outcome, strconv.FormatInt(r.MoverCount, 10)}
|
||||
out := []string{r.Pipeline, r.Branch, number(r.Revision), number(r.Source), timeOf(r.Started), r.Outcome, strconv.FormatInt(r.MoverCount, 10)}
|
||||
for _, o := range PipelineCountOutcomes {
|
||||
out = append(out, strconv.FormatInt(r.Steps[o], 10))
|
||||
}
|
||||
@@ -139,9 +139,14 @@ func table(w io.Writer, head []string, rows [][]string) {
|
||||
tw.Flush()
|
||||
}
|
||||
|
||||
// PipelinesTable prints one branch's newest pipelines, the terminal view's pipelines page.
|
||||
// PipelinesTable prints the newest pipelines of every branch, of a module when named, the terminal view's pipelines page
|
||||
// (design 47 H2 H-A-533).
|
||||
func PipelinesTable(w io.Writer, p PipelinesPage) {
|
||||
fmt.Fprintf(w, "PIPELINES OF %s\n", p.Branch)
|
||||
if p.Module != "" {
|
||||
fmt.Fprintf(w, "PIPELINES CARRYING %s\n", p.Module)
|
||||
} else {
|
||||
fmt.Fprintln(w, "PIPELINES")
|
||||
}
|
||||
if p.Error != "" {
|
||||
fmt.Fprintf(w, "unreadable: %s\n", p.Error)
|
||||
return
|
||||
@@ -214,9 +219,9 @@ const pipelinesStyle = `<style>body{font:14px sans-serif;margin:1em}table{border
|
||||
const changesScript = `<script>new EventSource({{.Changes}}).onmessage=function(){location.reload()}</script>`
|
||||
|
||||
var pipelinesPage = template.Must(template.New("pl").Parse(`<!doctype html><html><head><meta charset="utf-8">
|
||||
<title>Pipelines of {{.Branch}}</title>` + pipelinesStyle + `</head>
|
||||
<body><p><a href="/">What each node runs</a></p><h1>PIPELINES OF {{.Branch}}</h1>
|
||||
<form method="get" action="/pipelines">branch <input name="branch" value="{{.Branch}}"> newest <input name="limit" value="{{.Limit}}" size="4"> <button>show</button></form>
|
||||
<title>Pipelines{{with .Module}} carrying {{.}}{{end}}</title>` + pipelinesStyle + `</head>
|
||||
<body><p><a href="/">What each node runs</a></p><h1>PIPELINES{{with .Module}} CARRYING {{.}}{{end}}</h1>
|
||||
<form method="get" action="/pipelines">module <input name="module" value="{{.Module}}"> newest <input name="limit" value="{{.Limit}}" size="4"> <button>show</button></form>
|
||||
{{if .Error}}<p>unreadable: {{.Error}}</p>{{else}}<table><tr>{{range .Head}}<th>{{.}}</th>{{end}}</tr>
|
||||
{{range .Rows}}<tr><td><a href="{{.Link}}">{{index .Cells 0}}</a></td>{{range slice .Cells 1}}<td>{{.}}</td>{{end}}</tr>{{end}}</table>{{end}}
|
||||
` + changesScript + `</body></html>`))
|
||||
@@ -225,7 +230,7 @@ var pipelinesPage = template.Must(template.New("pl").Parse(`<!doctype html><html
|
||||
// cell per stage (each artifact's waited, ran and why on hover) and a cell per node its module is placed on.
|
||||
var pipelineViewPage = template.Must(template.New("pv").Funcs(template.FuncMap{"word": cellWord, "moverLink": PipelineLink}).Parse(`<!doctype html><html><head><meta charset="utf-8">
|
||||
<title>Pipeline {{.Pipeline}}</title>` + pipelinesStyle + `</head>
|
||||
<body><p><a href="/">What each node runs</a> · <a href="{{.Back}}">Pipelines of {{.Branch}}</a></p>
|
||||
<body><p><a href="/">What each node runs</a> · <a href="/pipelines">Pipelines</a></p>
|
||||
<h1>PIPELINE {{.Pipeline}}</h1>
|
||||
{{if .Error}}<p>unreadable: {{.Error}}</p>{{else}}{{with .View}}<p class="{{word .Outcome}}">{{.Header}}</p>
|
||||
{{range .Unread}}<p>unreadable: {{.}}</p>{{end}}{{$v := .}}{{range .Tiers}}<h2>TIER {{.Tier}}</h2>
|
||||
@@ -255,7 +260,7 @@ func cellWord(s string) string {
|
||||
|
||||
var pipelinePage = template.Must(template.New("p1").Parse(`<!doctype html><html><head><meta charset="utf-8">
|
||||
<title>Pipeline {{.Pipeline}}</title>` + pipelinesStyle + `</head>
|
||||
<body><p><a href="/">What each node runs</a> · <a href="{{.Back}}">Pipelines of {{.Branch}}</a>{{if .Mover}} · <a href="{{.Up}}">Pipeline {{.Pipeline}}</a>{{end}}</p>
|
||||
<body><p><a href="/">What each node runs</a> · <a href="/pipelines">Pipelines</a>{{if .Mover}} · <a href="{{.Up}}">Pipeline {{.Pipeline}}</a>{{end}}</p>
|
||||
<h1>PIPELINE {{.Pipeline}}{{if .Mover}}: {{.Mover}}{{end}}</h1>
|
||||
{{if .Error}}<p>unreadable: {{.Error}}</p>{{else}}<p>{{.Line}}</p>{{if .Why}}<p>why: {{.Why}}</p>{{end}}
|
||||
<table><tr>{{range .Head}}<th>{{.}}</th>{{end}}</tr>
|
||||
@@ -315,7 +320,6 @@ func webPipelines(m *Model, w http.ResponseWriter, r *http.Request) {
|
||||
data["Error"] = err.Error()
|
||||
} else {
|
||||
data["Branch"] = a.Pipeline.Branch
|
||||
data["Back"] = "/pipelines?" + url.Values{"branch": {a.Pipeline.Branch}}.Encode()
|
||||
}
|
||||
w.Header().Set("Content-Type", "text/html; charset=utf-8")
|
||||
pipelineViewPage.Execute(w, data)
|
||||
@@ -326,7 +330,6 @@ func webPipelines(m *Model, w http.ResponseWriter, r *http.Request) {
|
||||
} else {
|
||||
pl := a.Pipeline
|
||||
data["Branch"] = pl.Branch
|
||||
data["Back"] = "/pipelines?" + url.Values{"branch": {pl.Branch}}.Encode()
|
||||
data["Line"] = fmt.Sprintf("%s, source %d, revision %d, started %s, ended %s", pl.Outcome, pl.Source, pl.Revision, timeOf(pl.Started), timeOf(pl.Ended))
|
||||
data["Why"] = pl.Why
|
||||
var rows []linkedRow
|
||||
@@ -363,13 +366,13 @@ func webPipelines(m *Model, w http.ResponseWriter, r *http.Request) {
|
||||
limit = n
|
||||
}
|
||||
v := p.Version()
|
||||
page := p.Page(q.Get("branch"), limit)
|
||||
page := p.Page(q.Get("module"), limit)
|
||||
var rows []linkedRow
|
||||
for _, row := range page.Rows {
|
||||
rows = append(rows, linkedRow{Cells: PipelineRowText(row), Link: PipelineLink(row.Pipeline, "")})
|
||||
}
|
||||
w.Header().Set("Content-Type", "text/html; charset=utf-8")
|
||||
pipelinesPage.Execute(w, map[string]any{"Branch": page.Branch, "Error": page.Error, "Head": PipelinesHead, "Rows": rows, "Limit": limit, "Changes": changesLink("", v)})
|
||||
pipelinesPage.Execute(w, map[string]any{"Module": page.Module, "Error": page.Error, "Head": PipelinesHead, "Rows": rows, "Limit": limit, "Changes": changesLink("", v)})
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -48,9 +48,9 @@ type ask struct {
|
||||
Words string `json:"words,omitempty"`
|
||||
Module string `json:"module,omitempty"`
|
||||
FP string `json:"fp,omitempty"`
|
||||
// The pipelines page's asks (design 47 H2 H-A-467): pipelines of a branch, or one pipeline, of a mover when named; follow
|
||||
// The pipelines page's asks (design 47 H2 H-A-467, H-A-533): pipelines of every branch, of a module when named, or one
|
||||
// pipeline, of a mover when named; follow
|
||||
// keeps the connection and answers again at each change the runner's events say.
|
||||
Branch string `json:"branch,omitempty"`
|
||||
Limit int `json:"limit,omitempty"` // the newest this many of the branch, the default's when left out
|
||||
Pipeline string `json:"pipeline,omitempty"`
|
||||
Mover string `json:"mover,omitempty"`
|
||||
@@ -570,7 +570,7 @@ func answerPipelines(c net.Conn, m *Model, a ask) {
|
||||
v := p.Version()
|
||||
var err error
|
||||
if a.Ask == "pipelines" {
|
||||
err = enc.Encode(p.Page(a.Branch, a.Limit))
|
||||
err = enc.Encode(p.Page(a.Module, a.Limit))
|
||||
} else if sa, serr := p.Show(a.Pipeline, a.Mover, a.Next); serr != nil {
|
||||
err = enc.Encode(pipelinesRefusal{Refused: serr.Error()})
|
||||
} else {
|
||||
@@ -598,16 +598,17 @@ type pipelinesRefusal struct {
|
||||
Refused string `json:"refused"`
|
||||
}
|
||||
|
||||
// AskPipelines asks the socket at path for one branch's newest limit pipelines (the default's below one), or with pipeline
|
||||
// AskPipelines asks the socket at path for the newest limit pipelines of every branch (the default's below one), of those
|
||||
// carrying module when named (design 47 H2 H-A-533), or with pipeline
|
||||
// set for that pipeline (of mover when named); with follow, each answers again at each change, handed to each until it
|
||||
// answers false or the view leaves.
|
||||
func AskPipelines(path, branch string, limit int, pipeline, mover, next string, follow bool, each func(PipelinesPage, *PipelineAnswer) bool) error {
|
||||
func AskPipelines(path, module string, limit int, pipeline, mover, next string, follow bool, each func(PipelinesPage, *PipelineAnswer) bool) error {
|
||||
c, err := net.DialTimeout("unix", path, 5*time.Second)
|
||||
if err != nil {
|
||||
return fmt.Errorf("cannot reach the view at %s: %w", path, err)
|
||||
}
|
||||
defer c.Close()
|
||||
a := ask{Ask: "pipelines", Branch: branch, Limit: limit, Follow: follow}
|
||||
a := ask{Ask: "pipelines", Module: module, Limit: limit, Follow: follow}
|
||||
if pipeline != "" {
|
||||
a = ask{Ask: "pipeline", Pipeline: pipeline, Mover: mover, Next: next, Follow: follow}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user