Skip to content

Commit 9c7b5e5

Browse files
dmitshurgopherbot
authored andcommitted
internal/workflow: order sub-workflow names from highest level to lowest
Deeply nested workflows are rare, but do come up: combined minor Go release workflows (e.g., for 1.24 and 1.23) have a sub-workflow per Go release, with further nested sub-workflows per release target. It's seemingly more logical to have the top-level sub-workflow name at at the first position, the second-level sub-workflow name at the second position, and so on. We ended up with the inverse order, which leads to task names like "linux-arm64: Go 1.24: Check distpacks match" instead of task names like "Go 1.24: linux-arm64: Check distpacks match". Flip 'em. Change-Id: I833e34e66c3eaee4b40c5d9450875a15ddf3d2f7 Reviewed-on: https://go-review.googlesource.com/c/build/+/670477 Reviewed-by: Carlos Amedee <[email protected]> Auto-Submit: Dmitri Shuralyov <[email protected]> LUCI-TryBot-Result: Go LUCI <[email protected]> Reviewed-by: Dmitri Shuralyov <[email protected]>
1 parent a9e4f66 commit 9c7b5e5

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

internal/workflow/workflow.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ type Definition struct {
7979

8080
func (d *Definition) Sub(name string) *Definition {
8181
return &Definition{
82-
namePrefix: name + ": " + d.namePrefix,
82+
namePrefix: d.namePrefix + name + ": ",
8383
definitionState: d.definitionState,
8484
}
8585
}

internal/workflow/workflow_test.go

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@ import (
88
"context"
99
"errors"
1010
"fmt"
11+
"maps"
1112
"reflect"
13+
"slices"
1214
"strings"
1315
"sync/atomic"
1416
"testing"
@@ -95,17 +97,23 @@ func TestSub(t *testing.T) {
9597
}
9698

9799
wd := wf.New(wf.ACL{})
98-
sub1 := wd.Sub("sub1")
100+
topSub := wd.Sub("top-sub")
101+
sub1 := topSub.Sub("sub1")
99102
g1 := wf.Task0(sub1, "Greeting", hi)
100-
sub2 := wd.Sub("sub2")
103+
sub2 := topSub.Sub("sub2")
101104
g2 := wf.Task0(sub2, "Greeting", hi)
102105
wf.Output(wd, "result", wf.Task2(wd, "Concatenate", concat, g1, g2))
103106

107+
storage := &mapListener{Listener: &verboseListener{t}}
104108
w := startWorkflow(t, wd, nil)
105-
outputs := runWorkflow(t, w, nil)
109+
outputs := runWorkflow(t, w, storage)
106110
if got, want := outputs["result"], "hi hi"; got != want {
107111
t.Errorf("result = %q, want %q", got, want)
108112
}
113+
const wantTaskID = "top-sub: sub1: Greeting"
114+
if _, ok := storage.states[w.ID][wantTaskID]; !ok {
115+
t.Errorf("task ID %q doesn't exist, have: %q", wantTaskID, slices.Sorted(maps.Keys(storage.states[w.ID])))
116+
}
109117
}
110118

111119
func TestSplitJoin(t *testing.T) {

0 commit comments

Comments
 (0)