Commit 234c991

Eric Bower  ·  2026-08-09 10:42:26 -0400 EDT
parent 8394af3
fix: default to local so pici-monitor doesn't get the report
2 files changed,  +20, -11
+13, -4
......@@ -692,7 +692,11 @@ func eventHandler(cfg *Cfg, eventData *Event) error {
692692 }
693693
694694 eventBytes, _ := json.Marshal(eventData)
695- fmt.Fprintf(os.Stdout, "🚀 starting job ci.%s.%s\n", eventData.Name, jobID) //nolint:errcheck
695+ domain := "ci"
696+ if eventData.Type == "local" {
697+ domain = "local"
698+ }
699+ fmt.Fprintf(os.Stdout, "🚀 starting job %s.%s.%s\n", domain, eventData.Name, jobID) //nolint:errcheck
696700 fmt.Fprintf(os.Stdout, " event: type=%s name=%s workspace=%s\n", eventData.Type, eventData.Name, eventData.Workspace) //nolint:errcheck
697701 fmt.Fprintf(os.Stdout, " %s\n", string(eventBytes)) //nolint:errcheck
698702
......@@ -799,7 +803,11 @@ See: https://github.com/picosh/pici
799803 return nil
800804 }
801805
802- session := fmt.Sprintf("ci.%s.%s.runner", eventData.Name, jobID)
806+ domain = "ci"
807+ if eventData.Type == "local" {
808+ domain = "local"
809+ }
810+ session := fmt.Sprintf("%s.%s.%s.runner", domain, eventData.Name, jobID)
803811 fmt.Fprintf(os.Stdout, " zmx tail %s\n", session) //nolint:errcheck
804812 fmt.Fprintf(os.Stdout, " zmx history %s\n", session) //nolint:errcheck
805813 fmt.Fprintf(os.Stdout, " zmx attach %s\n", session) //nolint:errcheck
......@@ -1798,7 +1806,7 @@ func findRunningJobs(name string) ([]string, []SessionInfo) {
17981806 var runners []string
17991807 for _, s := range sessions {
18001808 // Match ci.<name>.*.runner sessions that are still active (no ended)
1801- if strings.HasPrefix(s.Name, "ci."+name+".") && strings.HasSuffix(s.Name, ".runner") && s.Ended == "" {
1809+ if (strings.HasPrefix(s.Name, "ci."+name+".") || strings.HasPrefix(s.Name, "local."+name+".")) && strings.HasSuffix(s.Name, ".runner") && s.Ended == "" {
18021810 runners = append(runners, s.Name)
18031811 }
18041812 }
......@@ -1811,6 +1819,7 @@ func extractJobID(runnerName string) string {
18111819 // Remove "ci." prefix and ".runner" suffix, then take the part after the first "."
18121820 name := strings.TrimSuffix(runnerName, ".runner")
18131821 name = strings.TrimPrefix(name, "ci.")
1822+ name = strings.TrimPrefix(name, "local.")
18141823 // name is now <name>.<jobID>, take the jobID part
18151824 parts := strings.SplitN(name, ".", 2)
18161825 if len(parts) == 2 {
......@@ -2084,7 +2093,7 @@ func runLocal(cfg *Cfg, dest string) error {
20842093 }
20852094
20862095 repoName := filepath.Base(cwd)
2087- jobID := fmt.Sprintf("local-%d", time.Now().Unix())
2096+ jobID := fmt.Sprintf("%d", time.Now().Unix())
20882097
20892098 eventData := &Event{
20902099 Type: "local",
+7, -7
......@@ -51,7 +51,7 @@ zmx run step2 echo "hello from step2"
5151 _ = exec.Command("zmx", "kill", "-f", fmt.Sprintf("ci.test-repo.%s", testJobID)).Run()
5252 })
5353 event := Event{
54- Type: "build",
54+ Type: "ci",
5555 Name: "test-repo",
5656 JobID: testJobID,
5757 Workspace: workspaceDir,
......@@ -239,7 +239,7 @@ zmx run step2 echo "hello from step2"
239239
240240 // Cleanup any leftover zmx sessions for this job
241241 if finalPayload != nil {
242- _ = exec.Command("zmx", "kill", "-f", fmt.Sprintf("ci.test-repo.%s", finalPayload.JobID)).Run()
242+ _ = exec.Command("zmx", "kill", "-f", fmt.Sprintf("local.test-repo.%s", finalPayload.JobID)).Run()
243243 }
244244 }
245245
......@@ -299,7 +299,7 @@ zmx run fast-step echo "done"
299299 }
300300
301301 // 3. Start first job (slow)
302- event1 := Event{Type: "build", Name: "dup-repo", Workspace: workspaceDir}
302+ event1 := Event{Type: "local", Name: "dup-repo", Workspace: workspaceDir}
303303 event1JSON, _ := json.Marshal(event1)
304304 cfg1 := makeCfg(io.NopCloser(bytes.NewReader(append(event1JSON, '\n'))))
305305
......@@ -308,7 +308,7 @@ zmx run fast-step echo "done"
308308 }()
309309
310310 // Wait for the first job's runner session to appear
311- if !waitForSessionPrefix(t, "ci.dup-repo.", 10*time.Second) {
311+ if !waitForSessionPrefix(t, "local.dup-repo.", 10*time.Second) {
312312 t.Fatal("first job's runner session never appeared")
313313 }
314314
......@@ -320,7 +320,7 @@ zmx run fast-step echo "done"
320320 t.Logf("first job runner: %s", firstRunner)
321321
322322 // 4. Start second job (same repo name, should cancel the first)
323- event2 := Event{Type: "build", Name: "dup-repo", Workspace: workspaceDir2}
323+ event2 := Event{Type: "local", Name: "dup-repo", Workspace: workspaceDir2}
324324 event2JSON, _ := json.Marshal(event2)
325325 cfg2 := makeCfg(io.NopCloser(bytes.NewReader(append(event2JSON, '\n'))))
326326
......@@ -356,7 +356,7 @@ zmx run fast-step echo "done"
356356 }
357357
358358 // Cleanup
359- _ = exec.Command("zmx", "kill", "-f", "ci.dup-repo").Run()
359+ _ = exec.Command("zmx", "kill", "-f", "local.dup-repo").Run()
360360 }
361361
362362 // waitForSessionPrefix returns true if a session with the given prefix appears within the timeout.
......@@ -385,7 +385,7 @@ func findRunnerSession(t *testing.T, name string) string {
385385 }
386386 sessions := parseZMXList(string(listOutput))
387387 for _, s := range sessions {
388- if strings.HasPrefix(s.Name, "ci."+name+".") && strings.HasSuffix(s.Name, ".runner") {
388+ if (strings.HasPrefix(s.Name, "local."+name+".") || strings.HasPrefix(s.Name, "ci."+name+".")) && strings.HasSuffix(s.Name, ".runner") {
389389 return s.Name
390390 }
391391 }