Commit 71d9bd6
Eric Bower
·
2026-08-09 11:33:25 -0400 EDT
parent 1c94e4e
fix: naming ci
2 files changed,
+39,
-14
M
main.go
M
main.go
+16,
-14
1@@ -661,10 +661,21 @@ func (eng *JobEngine) Setup() error {
2 return eng.Wk.Setup()
3 }
4
5+// getDomain maps an event type (e.g. "git.push", "git.tag", "local") to a session domain prefix ("ci", "local", etc.).
6+func getDomain(eventType string) string {
7+ if eventType == "local" {
8+ return "local"
9+ }
10+ if eventType == "test-ci" || strings.HasPrefix(eventType, "test-") {
11+ return eventType
12+ }
13+ return "ci"
14+}
15+
16 func (eng *JobEngine) Run(manifest string) error {
17 domain := "ci"
18- if eng.Ev != nil && eng.Ev.Type != "" {
19- domain = eng.Ev.Type
20+ if eng.Ev != nil {
21+ domain = getDomain(eng.Ev.Type)
22 }
23 prefix := fmt.Sprintf("%s.%s.%s.", domain, eng.Ev.Name, eng.JobID)
24 // Child sessions use ".step." sub-prefix so zmx wait "*" inside pico.sh
25@@ -741,10 +752,7 @@ func eventHandler(cfg *Cfg, eventData *Event) error {
26 }
27
28 eventBytes, _ := json.Marshal(eventData)
29- domain := "ci"
30- if eventData.Type != "" {
31- domain = eventData.Type
32- }
33+ domain := getDomain(eventData.Type)
34 fmt.Fprintf(os.Stdout, "🚀 starting job %s.%s.%s\n", domain, eventData.Name, jobID) //nolint:errcheck
35 fmt.Fprintf(os.Stdout, " event: type=%s name=%s workspace=%s\n", eventData.Type, eventData.Name, eventData.Workspace) //nolint:errcheck
36 fmt.Fprintf(os.Stdout, " %s\n", string(eventBytes)) //nolint:errcheck
37@@ -852,10 +860,7 @@ See: https://github.com/picosh/pici
38 return nil
39 }
40
41- domain = "ci"
42- if eventData.Type != "" {
43- domain = eventData.Type
44- }
45+ domain = getDomain(eventData.Type)
46 session := fmt.Sprintf("%s.%s.%s.runner", domain, eventData.Name, jobID)
47 fmt.Fprintf(os.Stdout, " zmx tail %s\n", session) //nolint:errcheck
48 fmt.Fprintf(os.Stdout, " zmx history %s\n", session) //nolint:errcheck
49@@ -866,10 +871,7 @@ See: https://github.com/picosh/pici
50 // waitAndReport polls the job's sessions until all complete, prints live
51 // progress to stdout, then dumps session history and a final summary.
52 func waitAndReport(cfg *Cfg, log *slog.Logger, name, jobID, eventType string) error {
53- domain := "ci"
54- if eventType != "" {
55- domain = eventType
56- }
57+ domain := getDomain(eventType)
58 prefix := domain + "." + name + "." + jobID + "."
59 interval := cfg.MonitorInterval
60 if interval <= 0 {
+23,
-0
1@@ -547,6 +547,29 @@ func TestParseZMXList(t *testing.T) {
2 }
3 }
4
5+func TestGetDomain(t *testing.T) {
6+ tests := []struct {
7+ eventType string
8+ want string
9+ }{
10+ {"git.push", "ci"},
11+ {"git.tag", "ci"},
12+ {"push", "ci"},
13+ {"manual", "ci"},
14+ {"ci", "ci"},
15+ {"", "ci"},
16+ {"local", "local"},
17+ {"test-ci", "test-ci"},
18+ }
19+
20+ for _, tt := range tests {
21+ got := getDomain(tt.eventType)
22+ if got != tt.want {
23+ t.Errorf("getDomain(%q) = %q, want %q", tt.eventType, got, tt.want)
24+ }
25+ }
26+}
27+
28 func TestExtractJobID(t *testing.T) {
29 tests := []struct {
30 runnerName string