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.
ci/agent/agent.go +37−2
| @@ -213,6 +213,10 @@ type runnerRequest struct { | |||
| 213 | 213 | Record *runs.Record `json:"record,omitempty"` | |
| 214 | 214 | // Log is one chunk of the attempt's log, sent while the job runs. | |
| 215 | 215 | Log *runnerLogChunk `json:"log,omitempty"` | |
| 216 | // Step is one live step transition. The finish record still carries the | ||
| 217 | // authoritative step results; these events only make the running attempt | ||
| 218 | // readable before it finishes. | ||
| 219 | Step *runs.StepEvent `json:"step,omitempty"` | ||
| 216 | 220 | // Repos is the --repos filter, sent with every lease. The server intersects it | |
| 217 | 221 | // with what the account's allowlists grant, so it can only narrow. | |
| 218 | 222 | Repos []string `json:"repos,omitempty"` | |
| @@ -858,6 +862,29 @@ func (s *runnerSession) heartbeat(runID string) bool { | |||
| 858 | 862 | return rep.OK | |
| 859 | 863 | } | |
| 860 | 864 | ||
| 865 | // step sends one live step transition. It is best effort: the finish record still | ||
| 866 | // carries the authoritative result, so a server that refuses the update does not | ||
| 867 | // change what the job did. An older server answers "unknown op", which is why this | ||
| 868 | // does not abort the job. | ||
| 869 | func (s *runnerSession) step(job *runnerJob, ev runs.StepEvent) { | ||
| 870 | rep, err := s.call(runnerRequest{Op: "step", Run: job.ID, Step: &ev}) | ||
| 871 | if err != nil { | ||
| 872 | fmt.Fprintf(os.Stderr, "vole runner: step update for %s: %v\n", job.ID, err) | ||
| 873 | return | ||
| 874 | } | ||
| 875 | if rep.Error != "" { | ||
| 876 | fmt.Fprintf(os.Stderr, "vole runner: step update for %s: %s\n", job.ID, rep.Error) | ||
| 877 | } | ||
| 878 | } | ||
| 879 | |||
| 880 | func stepEventFor(job *runnerJob, number int, status string, result runs.StepResult) runs.StepEvent { | ||
| 881 | return runs.StepEvent{ | ||
| 882 | Attempt: job.Attempt, Number: number, Name: result.Name, Status: status, | ||
| 883 | Started: result.Started, Finished: result.Finished, Exit: result.Exit, | ||
| 884 | LogOffset: result.LogOffset, LogSize: result.LogSize, | ||
| 885 | } | ||
| 886 | } | ||
| 887 | |||
| 861 | 888 | func (s *runnerSession) close() { | |
| 862 | 889 | s.mu.Lock() | |
| 863 | 890 | _ = s.enc.Encode(runnerRequest{Op: "bye"}) | |
| @@ -1120,11 +1147,16 @@ func (s *runnerSession) run(remote, cache string, job *runnerJob, lease time.Dur | |||
| 1120 | 1147 | if d, err := time.ParseDuration(job.Timeout); err == nil && d > 0 { | |
| 1121 | 1148 | deadline = time.Now().Add(d) | |
| 1122 | 1149 | } | |
| 1123 | for _, step := range job.Steps { | ||
| 1150 | for i, step := range job.Steps { | ||
| 1124 | 1151 | // The step's section of the log starts at its header, so a reader can open | |
| 1125 | // one step without holding the image build that ran before it. | ||
| 1152 | // one step without holding the image build that ran before it. The live | ||
| 1153 | // event goes first so a page knows the range before the bytes reach it. | ||
| 1126 | 1154 | logStart := log.Len() | |
| 1127 | 1155 | started := time.Now().UTC() | |
| 1156 | s.step(job, runs.StepEvent{ | ||
| 1157 | Attempt: job.Attempt, Number: i + 1, Name: step.Name, Status: runs.StatusRunning, | ||
| 1158 | Started: started, LogOffset: logStart, | ||
| 1159 | }) | ||
| 1128 | 1160 | fmt.Fprintf(log, "\n--- %s\n", step.Name) | |
| 1129 | 1161 | own, _ := time.ParseDuration(step.Timeout) | |
| 1130 | 1162 | limit := ci.StepLimit(ci.BudgetLeft(deadline, time.Now()), own) | |
| @@ -1161,6 +1193,7 @@ func (s *runnerSession) run(remote, cache string, job *runnerJob, lease time.Dur | |||
| 1161 | 1193 | // The heartbeat said a maintainer asked the run to stop, and runCommand | |
| 1162 | 1194 | // already wrote the line to the log. Keep the partial attempt: the log and | |
| 1163 | 1195 | // the timings are what a reader asks for first after "what had it done". | |
| 1196 | s.step(job, stepEventFor(job, i+1, runs.StatusCanceled, result)) | ||
| 1164 | 1197 | steps = append(steps, result) | |
| 1165 | 1198 | jobBox.StopWithLogs(log) | |
| 1166 | 1199 | s.finish(remote, co, job, log, stream, attemptOutcome{Exit: code, Steps: steps}, box) | |
| @@ -1170,11 +1203,13 @@ func (s *runnerSession) run(remote, cache string, job *runnerJob, lease time.Dur | |||
| 1170 | 1203 | fmt.Fprintf(log, "\nstep %q exited %d\n", step.Name, code) | |
| 1171 | 1204 | result.LogSize = log.Len() - logStart | |
| 1172 | 1205 | result.Finished = time.Now().UTC() | |
| 1206 | s.step(job, stepEventFor(job, i+1, runs.StatusFailed, result)) | ||
| 1173 | 1207 | steps = append(steps, result) | |
| 1174 | 1208 | jobBox.StopWithLogs(log) | |
| 1175 | 1209 | s.finish(remote, co, job, log, stream, attemptOutcome{Exit: code, Steps: steps}, box) | |
| 1176 | 1210 | return | |
| 1177 | 1211 | } | |
| 1212 | s.step(job, stepEventFor(job, i+1, runs.StatusSuccess, result)) | ||
| 1178 | 1213 | steps = append(steps, result) | |
| 1179 | 1214 | } | |
| 1180 | 1215 | // The steps are done. Stop the container before reading artifacts or deploying a | |