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
 1@@ -692,7 +692,11 @@ func eventHandler(cfg *Cfg, eventData *Event) error {
 2 	}
 3 
 4 	eventBytes, _ := json.Marshal(eventData)
 5-	fmt.Fprintf(os.Stdout, "🚀 starting job ci.%s.%s\n", eventData.Name, jobID)                                              //nolint:errcheck
 6+	domain := "ci"
 7+	if eventData.Type == "local" {
 8+		domain = "local"
 9+	}
10+	fmt.Fprintf(os.Stdout, "🚀 starting job %s.%s.%s\n", domain, eventData.Name, jobID) //nolint:errcheck
11 	fmt.Fprintf(os.Stdout, "   event: type=%s name=%s workspace=%s\n", eventData.Type, eventData.Name, eventData.Workspace) //nolint:errcheck
12 	fmt.Fprintf(os.Stdout, "   %s\n", string(eventBytes))                                                                   //nolint:errcheck
13 
14@@ -799,7 +803,11 @@ See: https://github.com/picosh/pici
15 		return nil
16 	}
17 
18-	session := fmt.Sprintf("ci.%s.%s.runner", eventData.Name, jobID)
19+	domain = "ci"
20+	if eventData.Type == "local" {
21+		domain = "local"
22+	}
23+	session := fmt.Sprintf("%s.%s.%s.runner", domain, eventData.Name, jobID)
24 	fmt.Fprintf(os.Stdout, "   zmx tail %s\n", session)    //nolint:errcheck
25 	fmt.Fprintf(os.Stdout, "   zmx history %s\n", session) //nolint:errcheck
26 	fmt.Fprintf(os.Stdout, "   zmx attach %s\n", session)  //nolint:errcheck
27@@ -1798,7 +1806,7 @@ func findRunningJobs(name string) ([]string, []SessionInfo) {
28 	var runners []string
29 	for _, s := range sessions {
30 		// Match ci.<name>.*.runner sessions that are still active (no ended)
31-		if strings.HasPrefix(s.Name, "ci."+name+".") && strings.HasSuffix(s.Name, ".runner") && s.Ended == "" {
32+		if (strings.HasPrefix(s.Name, "ci."+name+".") || strings.HasPrefix(s.Name, "local."+name+".")) && strings.HasSuffix(s.Name, ".runner") && s.Ended == "" {
33 			runners = append(runners, s.Name)
34 		}
35 	}
36@@ -1811,6 +1819,7 @@ func extractJobID(runnerName string) string {
37 	// Remove "ci." prefix and ".runner" suffix, then take the part after the first "."
38 	name := strings.TrimSuffix(runnerName, ".runner")
39 	name = strings.TrimPrefix(name, "ci.")
40+	name = strings.TrimPrefix(name, "local.")
41 	// name is now <name>.<jobID>, take the jobID part
42 	parts := strings.SplitN(name, ".", 2)
43 	if len(parts) == 2 {
44@@ -2084,7 +2093,7 @@ func runLocal(cfg *Cfg, dest string) error {
45 	}
46 
47 	repoName := filepath.Base(cwd)
48-	jobID := fmt.Sprintf("local-%d", time.Now().Unix())
49+	jobID := fmt.Sprintf("%d", time.Now().Unix())
50 
51 	eventData := &Event{
52 		Type:         "local",
+7, -7
 1@@ -51,7 +51,7 @@ zmx run step2 echo "hello from step2"
 2 		_ = exec.Command("zmx", "kill", "-f", fmt.Sprintf("ci.test-repo.%s", testJobID)).Run()
 3 	})
 4 	event := Event{
 5-		Type:      "build",
 6+		Type:      "ci",
 7 		Name:      "test-repo",
 8 		JobID:     testJobID,
 9 		Workspace: workspaceDir,
10@@ -239,7 +239,7 @@ zmx run step2 echo "hello from step2"
11 
12 	// Cleanup any leftover zmx sessions for this job
13 	if finalPayload != nil {
14-		_ = exec.Command("zmx", "kill", "-f", fmt.Sprintf("ci.test-repo.%s", finalPayload.JobID)).Run()
15+		_ = exec.Command("zmx", "kill", "-f", fmt.Sprintf("local.test-repo.%s", finalPayload.JobID)).Run()
16 	}
17 }
18 
19@@ -299,7 +299,7 @@ zmx run fast-step echo "done"
20 	}
21 
22 	// 3. Start first job (slow)
23-	event1 := Event{Type: "build", Name: "dup-repo", Workspace: workspaceDir}
24+	event1 := Event{Type: "local", Name: "dup-repo", Workspace: workspaceDir}
25 	event1JSON, _ := json.Marshal(event1)
26 	cfg1 := makeCfg(io.NopCloser(bytes.NewReader(append(event1JSON, '\n'))))
27 
28@@ -308,7 +308,7 @@ zmx run fast-step echo "done"
29 	}()
30 
31 	// Wait for the first job's runner session to appear
32-	if !waitForSessionPrefix(t, "ci.dup-repo.", 10*time.Second) {
33+	if !waitForSessionPrefix(t, "local.dup-repo.", 10*time.Second) {
34 		t.Fatal("first job's runner session never appeared")
35 	}
36 
37@@ -320,7 +320,7 @@ zmx run fast-step echo "done"
38 	t.Logf("first job runner: %s", firstRunner)
39 
40 	// 4. Start second job (same repo name, should cancel the first)
41-	event2 := Event{Type: "build", Name: "dup-repo", Workspace: workspaceDir2}
42+	event2 := Event{Type: "local", Name: "dup-repo", Workspace: workspaceDir2}
43 	event2JSON, _ := json.Marshal(event2)
44 	cfg2 := makeCfg(io.NopCloser(bytes.NewReader(append(event2JSON, '\n'))))
45 
46@@ -356,7 +356,7 @@ zmx run fast-step echo "done"
47 	}
48 
49 	// Cleanup
50-	_ = exec.Command("zmx", "kill", "-f", "ci.dup-repo").Run()
51+	_ = exec.Command("zmx", "kill", "-f", "local.dup-repo").Run()
52 }
53 
54 // waitForSessionPrefix returns true if a session with the given prefix appears within the timeout.
55@@ -385,7 +385,7 @@ func findRunnerSession(t *testing.T, name string) string {
56 	}
57 	sessions := parseZMXList(string(listOutput))
58 	for _, s := range sessions {
59-		if strings.HasPrefix(s.Name, "ci."+name+".") && strings.HasSuffix(s.Name, ".runner") {
60+		if (strings.HasPrefix(s.Name, "local."+name+".") || strings.HasPrefix(s.Name, "ci."+name+".")) && strings.HasSuffix(s.Name, ".runner") {
61 			return s.Name
62 		}
63 	}