Commit 71d9bd6

Eric Bower  ·  2026-08-09 11:33:25 -0400 EDT
parent 1c94e4e
fix: naming ci
2 files changed,  +39, -14
+16, -14
......@@ -661,10 +661,21 @@ func (eng *JobEngine) Setup() error {
661661 return eng.Wk.Setup()
662662 }
663663
664+// getDomain maps an event type (e.g. "git.push", "git.tag", "local") to a session domain prefix ("ci", "local", etc.).
665+func getDomain(eventType string) string {
666+ if eventType == "local" {
667+ return "local"
668+ }
669+ if eventType == "test-ci" || strings.HasPrefix(eventType, "test-") {
670+ return eventType
671+ }
672+ return "ci"
673+}
674+
664675 func (eng *JobEngine) Run(manifest string) error {
665676 domain := "ci"
666- if eng.Ev != nil && eng.Ev.Type != "" {
667- domain = eng.Ev.Type
677+ if eng.Ev != nil {
678+ domain = getDomain(eng.Ev.Type)
668679 }
669680 prefix := fmt.Sprintf("%s.%s.%s.", domain, eng.Ev.Name, eng.JobID)
670681 // Child sessions use ".step." sub-prefix so zmx wait "*" inside pico.sh
......@@ -741,10 +752,7 @@ func eventHandler(cfg *Cfg, eventData *Event) error {
741752 }
742753
743754 eventBytes, _ := json.Marshal(eventData)
744- domain := "ci"
745- if eventData.Type != "" {
746- domain = eventData.Type
747- }
755+ domain := getDomain(eventData.Type)
748756 fmt.Fprintf(os.Stdout, "🚀 starting job %s.%s.%s\n", domain, eventData.Name, jobID) //nolint:errcheck
749757 fmt.Fprintf(os.Stdout, " event: type=%s name=%s workspace=%s\n", eventData.Type, eventData.Name, eventData.Workspace) //nolint:errcheck
750758 fmt.Fprintf(os.Stdout, " %s\n", string(eventBytes)) //nolint:errcheck
......@@ -852,10 +860,7 @@ See: https://github.com/picosh/pici
852860 return nil
853861 }
854862
855- domain = "ci"
856- if eventData.Type != "" {
857- domain = eventData.Type
858- }
863+ domain = getDomain(eventData.Type)
859864 session := fmt.Sprintf("%s.%s.%s.runner", domain, eventData.Name, jobID)
860865 fmt.Fprintf(os.Stdout, " zmx tail %s\n", session) //nolint:errcheck
861866 fmt.Fprintf(os.Stdout, " zmx history %s\n", session) //nolint:errcheck
......@@ -866,10 +871,7 @@ See: https://github.com/picosh/pici
866871 // waitAndReport polls the job's sessions until all complete, prints live
867872 // progress to stdout, then dumps session history and a final summary.
868873 func waitAndReport(cfg *Cfg, log *slog.Logger, name, jobID, eventType string) error {
869- domain := "ci"
870- if eventType != "" {
871- domain = eventType
872- }
874+ domain := getDomain(eventType)
873875 prefix := domain + "." + name + "." + jobID + "."
874876 interval := cfg.MonitorInterval
875877 if interval <= 0 {
+23, -0
......@@ -547,6 +547,29 @@ func TestParseZMXList(t *testing.T) {
547547 }
548548 }
549549
550+func TestGetDomain(t *testing.T) {
551+ tests := []struct {
552+ eventType string
553+ want string
554+ }{
555+ {"git.push", "ci"},
556+ {"git.tag", "ci"},
557+ {"push", "ci"},
558+ {"manual", "ci"},
559+ {"ci", "ci"},
560+ {"", "ci"},
561+ {"local", "local"},
562+ {"test-ci", "test-ci"},
563+ }
564+
565+ for _, tt := range tests {
566+ got := getDomain(tt.eventType)
567+ if got != tt.want {
568+ t.Errorf("getDomain(%q) = %q, want %q", tt.eventType, got, tt.want)
569+ }
570+ }
571+}
572+
550573 func TestExtractJobID(t *testing.T) {
551574 tests := []struct {
552575 runnerName string