Commit b036a5e

Eric Bower  ·  2026-05-07 12:43:12 -0400 EDT
parent 85f918b
chore: cleanup
2 files changed,  +19, -16
+18, -15
......@@ -18,8 +18,6 @@ import (
1818 "strings"
1919 "syscall"
2020 "time"
21-
22-
2321 )
2422
2523 type WorkspaceFactory func(cfg *Cfg, logger *slog.Logger, source string) Workspace
......@@ -44,7 +42,7 @@ type Cfg struct {
4442 MonitorInterval time.Duration
4543 NewWorkspace WorkspaceFactory
4644 StatusOutput io.Writer // where status JSONL is written (default: os.Stdout)
47- StatusFilter string // "terminal" (default) or "all"
45+ IncludeRunning bool // emit running status updates in addition to terminal
4846 HumanOutput bool // human-readable output instead of JSONL / slog
4947 Wait bool // block until job completes, print history and summary
5048 }
......@@ -67,10 +65,10 @@ func NewCfg() (*Cfg, string, bool) {
6765 flag.StringVar(&event, "event", "", "event JSON to run (alternative to reading from stdin)")
6866 flag.DurationVar(&monitorInterval, "monitor-interval", 5*time.Second, "interval for monitoring zmx sessions")
6967 flag.StringVar(&logLevel, "log-level", "info", "log level: debug, info, warn, error")
70- var statusFilter string
68+ var includeRunning bool
7169 var human bool
7270 var wait bool
73- flag.StringVar(&statusFilter, "status-filter", "terminal", "status output filter: terminal (default) or all")
71+ flag.BoolVar(&includeRunning, "include-running", false, "emit running status updates in addition to terminal (default: terminal only)")
7472 flag.BoolVar(&human, "human", false, "human-readable output (default: JSONL / slog)")
7573 flag.BoolVar(&wait, "wait", false, "block until job completes, printing session history and summary")
7674
......@@ -91,7 +89,7 @@ func NewCfg() (*Cfg, string, bool) {
9189 ArtifactDir: artifactDir,
9290 Event: event,
9391 MonitorInterval: monitorInterval,
94- StatusFilter: statusFilter,
92+ IncludeRunning: includeRunning,
9593 HumanOutput: human,
9694 Wait: wait,
9795 }, cmd, wantHelp
......@@ -190,16 +188,18 @@ func printMonitorHelp() {
190188 fmt.Println(`pici monitor — poll ci.* zmx sessions, stage artifacts, publish status.
191189
192190 USAGE
193- pici monitor [flags]
194- pici monitor --human | ssh pipe.pico.sh "pub build.status -b=false"
191+ pici monitor [flags] # JSONL to stdout (pipe to webhooks)
192+ pici monitor --human # human-readable terminal output
195193
196194 OUTPUT MODES
197- Default (JSONL): One JSON object per line to stdout, suitable for piping.
195+ Default (JSONL): One JSON object per line, suitable for piping to notifications.
198196 pici monitor > status.jsonl
197+ pici monitor | ssh pipe.pico.sh "pub build.status -b=false"
199198 pici monitor | while read -r line; do curl -sd"$line" $WEBHOOK; done
200199
201- --human: Selfci-style progress output for terminal viewing.
202- pici monitor --human --status-filter all
200+ --human: Selfci-style progress output for terminal viewing (do not pipe).
201+ pici monitor --human
202+ pici monitor --human --include-running
203203 [2/3] 🚀 running: myrepo (1m23s)
204204 [3/3] ✅ success: myrepo (2m34s)
205205
......@@ -208,8 +208,8 @@ FLAGS
208208 -ck <path> SSH certificate public key
209209 -artifact-dir <path> Local directory to stage artifacts (default: /tmp/pici-artifacts)
210210 -monitor-interval <dur> Poll interval (default: 5s)
211- -status-filter <filter> "terminal" (default) or "all"
212- -human Human-readable output instead of JSONL
211+ -include-running Emit running status updates in addition to terminal (default: terminal only)
212+ -human Human-readable output instead of JSONL (for terminal, not piping)
213213 -log-level <level> Log level: debug, info, warn, error (default: info)`)
214214 }
215215
......@@ -345,6 +345,7 @@ type SessionInfo struct {
345345 }
346346
347347 type StatusPayload struct {
348+ Timestamp string `json:"timestamp"`
348349 Name string `json:"name"`
349350 JobID string `json:"job_id"`
350351 Status string `json:"status"`
......@@ -924,6 +925,7 @@ func monitorTick(cfg *Cfg, log *slog.Logger, output io.Writer, jobStates map[str
924925 renderJobFinal(output, name, jobID, group, duration, status, exitCode == 0, eventData.Workspace, cfg.ArtifactDir, artifactURL)
925926 } else {
926927 payload := StatusPayload{
928+ Timestamp: time.Now().UTC().Format(time.RFC3339),
927929 Name: name,
928930 JobID: jobID,
929931 Status: status,
......@@ -945,12 +947,13 @@ func monitorTick(cfg *Cfg, log *slog.Logger, output io.Writer, jobStates map[str
945947 }
946948 } else {
947949 log.Debug("job still running", "sessions", len(group))
948- // Publish running status only when filter is "all"
949- if cfg.StatusFilter != "terminal" {
950+ // Publish running status only when --include-running is set
951+ if cfg.IncludeRunning {
950952 if cfg.HumanOutput {
951953 renderJobRunning(output, name, jobID, group, duration, jobStates)
952954 } else {
953955 payload := StatusPayload{
956+ Timestamp: time.Now().UTC().Format(time.RFC3339),
954957 Name: name,
955958 JobID: jobID,
956959 Status: "running",
+1, -1
......@@ -59,7 +59,7 @@ zmx run step2 echo "hello from step2"
5959 MonitorInterval: 200 * time.Millisecond,
6060 NewWorkspace: defaultWorkspaceFactory,
6161 StatusOutput: statusBuf,
62- StatusFilter: "all",
62+ IncludeRunning: true,
6363 }
6464
6565 // 3. Run the runner (fire-and-forget, exits quickly)