Sign in

Search issue titles and bodies, change requests and comments. Private repositories you cannot read are not included.

vole
Site
Clone

Read only, no credentials:

https://rodent.software/vole.git

Write over SSH with a registered key:

git clone ssh://git@rodent.software/vole.git

Self-hosted forge that lives in your Git repo.

Make run pages step-aware and easier to scan

e653853a52ede660a589caeddd1bf46d5101f853 · Keenan Nemetz · 17d ago · parent fdd0b3e8

Make run pages step-aware and easier to scan

Stream structured step events from the runner so a running attempt can show per-step tabs and tail the selected step's log. Keep one log pane for finished runs, label run timings, let queued and running durations tick client-side, and fix long branch names. Polish the runs list with filter totals, a real subtitle, and clearer stop/cancel labels.

server/ssh/runner.go +51

@@ -22,6 +22,8 @@ import (
22 22 //
23 23 // {"op":"lease"} -> {"run":{...}} or {}
24 24 // {"op":"heartbeat","run":"<id>"} -> {"ok":true|false}
25 // {"op":"log","run":"<id>","log":{...}} -> {"ok":true|false,"log_size":N}
26 // {"op":"step","run":"<id>","step":{...}} -> {"ok":true|false}
25 27 // {"op":"finish","run":"<id>","record":{...}} -> {"ok":true|false}
26 28 //
27 29 // A finish carries the attempt's record: the runner uploads its log and artifacts,
@@ -113,6 +115,9 @@ type runnerRequest struct {
113 115 Record *runs.Record `json:"record,omitempty"`
114 116 // Log is one chunk of the attempt's log, sent while the job runs.
115 117 Log *runnerLogChunk `json:"log,omitempty"`
118 // Step is one live step transition, sent while the job runs. The finish
119 // record remains the authoritative step list.
120 Step *runs.StepEvent `json:"step,omitempty"`
116 121 }
117 122
118 123 // runnerLogChunk is one piece of an attempt's log. Offset is where it starts in
@@ -452,6 +457,44 @@ func (s *Server) serveRunner(ch xssh.Channel, user string) {
452 457 }
453 458 _ = enc.Encode(runnerReply{Op: "log", OK: true, LogSize: size})
454 459
460 case "step":
461 if req.Step == nil {
462 _ = enc.Encode(runnerReply{Op: "step", Error: "a step request carries no event"})
463 continue
464 }
465 run, err := cfg.Runs.Get(req.Run)
466 if err != nil {
467 _ = enc.Encode(runnerReply{Op: "step", Error: err.Error()})
468 continue
469 }
470 if run == nil {
471 _ = enc.Encode(runnerReply{Op: "step", Error: fmt.Sprintf("no run %s", req.Run)})
472 continue
473 }
474 if req.Step.Attempt != run.Attempts {
475 _ = enc.Encode(runnerReply{Op: "step", Error: fmt.Sprintf(
476 "%s: the step is attempt %d but this runner holds attempt %d",
477 req.Run, req.Step.Attempt, run.Attempts)})
478 continue
479 }
480 if req.Step.Number < 1 || req.Step.Number > len(run.Steps) ||
481 run.Steps[req.Step.Number-1].Name != req.Step.Name {
482 _ = enc.Encode(runnerReply{Op: "step", Error: fmt.Sprintf(
483 "%s: step %d does not match the pinned workflow", req.Run, req.Step.Number)})
484 continue
485 }
486 if !validStepStatus(req.Step.Status) {
487 _ = enc.Encode(runnerReply{Op: "step", Error: fmt.Sprintf(
488 "%s: step %d has status %q", req.Run, req.Step.Number, req.Step.Status)})
489 continue
490 }
491 ok, err := cfg.Runs.RecordStepEvent(run.ID, owner, *req.Step, time.Now().UTC())
492 if err != nil {
493 _ = enc.Encode(runnerReply{Op: "step", Error: err.Error()})
494 continue
495 }
496 _ = enc.Encode(runnerReply{Op: "step", OK: ok})
497
455 498 case "heartbeat":
456 499 // Liveness only: the lease is what a heartbeat buys. Presence is refreshed
457 500 // here too, so a long build does not make its runner look gone. A stop request
@@ -562,6 +605,14 @@ func (s *Server) serveRunner(ch xssh.Channel, user string) {
562 605 }
563 606 }
564 607
608 func validStepStatus(status string) bool {
609 switch status {
610 case runs.StatusRunning, runs.StatusSuccess, runs.StatusFailed, runs.StatusCanceled:
611 return true
612 }
613 return false
614 }
615
565 616 // checkRecordPointers refuses a record whose log or artifacts are not actually in
566 617 // the object store. A push used to be checked for pointer hygiene at the boundary;
567 618 // the finish channel is the boundary now.