Skip to content

Commit e3604e6

Browse files
dmitshurgopherbot
authored andcommitted
internal/relui, internal/task: merge KindCurrentMinor and KindPrevMinor
Unfortunately, KindPrevMinor doesn't work for the one-off Go 1.19.x release, because GetNextVersion(KindPrevMinor) gets the next Go 1.20.x minor version, not the next Go 1.19.x minor version. So GetNextVersion needs some change, or its callers do. Almost all tasks already have access to the major version number, and other than GetNextVersion itself, pretty much everything else treats KindCurrentMinor and KindPrevMinor interchangeably. In fact, when relui was just being started, we kept forgetting to handle both of them. Instead of trying to add KindPrevPrevMinor or some 1.19-specific hack, it seems simpler to give GetNextVersion the major explicitly and leave only KindMinor behind. For golang/go#62076. Change-Id: I18c2cb76c2008949d6ac055a2ed0fa4cd3c4a32a Reviewed-on: https://go-review.googlesource.com/c/build/+/520238 Run-TryBot: Dmitri Shuralyov <[email protected]> TryBot-Result: Gopher Robot <[email protected]> Reviewed-by: Heschi Kreinick <[email protected]> Reviewed-by: Dmitri Shuralyov <[email protected]> Auto-Submit: Dmitri Shuralyov <[email protected]>
1 parent a24ba0f commit e3604e6

11 files changed

+114
-78
lines changed

internal/relui/buildrelease_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ import (
4141

4242
func TestNonDistpack(t *testing.T) {
4343
t.Run("minor", func(t *testing.T) {
44-
testRelease(t, "go1.20", 20, "go1.20.1", task.KindCurrentMinor)
44+
testRelease(t, "go1.20", 20, "go1.20.1", task.KindMinor)
4545
})
4646
}
4747

internal/relui/workflows.go

+24-21
Original file line numberDiff line numberDiff line change
@@ -244,17 +244,16 @@ func RegisterReleaseWorkflows(ctx context.Context, h *DefinitionHolder, build *B
244244
return err
245245
}
246246
releases := []struct {
247-
kinds []task.ReleaseKind
248-
name string
247+
majors []int
249248
}{
250-
{[]task.ReleaseKind{task.KindCurrentMinor, task.KindPrevMinor}, fmt.Sprintf("next minor release for Go 1.%d and 1.%d", currentMajor, currentMajor-1)},
251-
{[]task.ReleaseKind{task.KindCurrentMinor}, fmt.Sprintf("next minor release for Go 1.%d", currentMajor)},
252-
{[]task.ReleaseKind{task.KindPrevMinor}, fmt.Sprintf("next minor release for Go 1.%d", currentMajor-1)},
249+
{[]int{currentMajor, currentMajor - 1}}, // Both minors.
250+
{[]int{currentMajor}}, // Current minor only.
251+
{[]int{currentMajor - 1}}, // Previous minor only.
253252
}
254253
for _, r := range releases {
255254
wd := wf.New()
256255

257-
versions := wf.Task1(wd, "Get next versions", version.GetNextVersions, wf.Const(r.kinds))
256+
versions := wf.Task1(wd, "Get next versions", version.GetNextMinorVersions, wf.Const(r.majors))
258257
targetDate := wf.Param(wd, targetDateParam)
259258
securityContent := wf.Param(wd, securityPreAnnParam)
260259
cves := wf.Param(wd, securityPreAnnCVEsParam)
@@ -263,7 +262,11 @@ func RegisterReleaseWorkflows(ctx context.Context, h *DefinitionHolder, build *B
263262
sentMail := wf.Task5(wd, "mail-pre-announcement", comm.PreAnnounceRelease, versions, targetDate, securityContent, cves, coordinators)
264263
wf.Output(wd, "Pre-announcement URL", wf.Task1(wd, "await-pre-announcement", comm.AwaitAnnounceMail, sentMail))
265264

266-
h.RegisterDefinition("pre-announce "+r.name, wd)
265+
var names []string
266+
for _, m := range r.majors {
267+
names = append(names, fmt.Sprintf("1.%d", m))
268+
}
269+
h.RegisterDefinition("pre-announce next minor release for Go "+strings.Join(names, " and "), wd)
267270
}
268271

269272
// Register workflows for miscellaneous tasks that happen as part of the Go release cycle.
@@ -306,20 +309,20 @@ func registerProdReleaseWorkflows(ctx context.Context, h *DefinitionHolder, buil
306309
return err
307310
}
308311
type release struct {
309-
kind task.ReleaseKind
310312
major int
313+
kind task.ReleaseKind
311314
suffix string
312315
}
313316
releases := []release{
314-
{task.KindMajor, currentMajor + 1, "final"},
315-
{task.KindRC, currentMajor + 1, "next RC"},
316-
{task.KindBeta, currentMajor + 1, "next beta"},
317-
{task.KindCurrentMinor, currentMajor, "next minor"},
318-
{task.KindPrevMinor, currentMajor - 1, "next minor"},
319-
{task.KindPrevMinor, currentMajor - 2, "next minor"}, // TODO(go.dev/issue/62076): Remove after Go 1.19.13 is out.
317+
{currentMajor + 1, task.KindMajor, "final"},
318+
{currentMajor + 1, task.KindRC, "next RC"},
319+
{currentMajor + 1, task.KindBeta, "next beta"},
320+
{currentMajor, task.KindMinor, "next minor"}, // Current minor only.
321+
{currentMajor - 1, task.KindMinor, "next minor"}, // Previous minor only.
322+
{currentMajor - 2, task.KindMinor, "next minor"}, // TODO(go.dev/issue/62076): Remove after Go 1.19.13 is out.
320323
}
321324
if time.Since(majorReleaseTime) < 7*24*time.Hour {
322-
releases = append(releases, release{task.KindMajor, currentMajor, "final"})
325+
releases = append(releases, release{currentMajor, task.KindMajor, "final"})
323326
}
324327
for _, r := range releases {
325328
wd := wf.New()
@@ -330,7 +333,7 @@ func registerProdReleaseWorkflows(ctx context.Context, h *DefinitionHolder, buil
330333

331334
securitySummary := wf.Const("")
332335
securityFixes := wf.Slice[string]()
333-
if r.kind == task.KindCurrentMinor || r.kind == task.KindPrevMinor {
336+
if r.kind == task.KindMinor {
334337
securitySummary = wf.Param(wd, securitySummaryParameter)
335338
securityFixes = wf.Param(wd, securityFixesParameter)
336339
}
@@ -351,7 +354,7 @@ func registerProdReleaseWorkflows(ctx context.Context, h *DefinitionHolder, buil
351354
func registerBuildTestSignOnlyWorkflow(h *DefinitionHolder, version *task.VersionTasks, build *BuildReleaseTasks, major int, kind task.ReleaseKind) {
352355
wd := wf.New()
353356

354-
nextVersion := wf.Task1(wd, "Get next version", version.GetNextVersion, wf.Const(kind))
357+
nextVersion := wf.Task2(wd, "Get next version", version.GetNextVersion, wf.Const(major), wf.Const(kind))
355358
branch := fmt.Sprintf("release-branch.go1.%d", major)
356359
if kind == task.KindBeta {
357360
branch = "master"
@@ -373,12 +376,12 @@ func createMinorReleaseWorkflow(build *BuildReleaseTasks, milestone *task.Milest
373376
wd := wf.New()
374377

375378
coordinators := wf.Param(wd, releaseCoordinators)
376-
currPublished := addSingleReleaseWorkflow(build, milestone, version, wd.Sub(fmt.Sprintf("Go 1.%d", currentMajor)), currentMajor, task.KindCurrentMinor, coordinators)
377-
prevPublished := addSingleReleaseWorkflow(build, milestone, version, wd.Sub(fmt.Sprintf("Go 1.%d", prevMajor)), prevMajor, task.KindPrevMinor, coordinators)
379+
currPublished := addSingleReleaseWorkflow(build, milestone, version, wd.Sub(fmt.Sprintf("Go 1.%d", currentMajor)), currentMajor, task.KindMinor, coordinators)
380+
prevPublished := addSingleReleaseWorkflow(build, milestone, version, wd.Sub(fmt.Sprintf("Go 1.%d", prevMajor)), prevMajor, task.KindMinor, coordinators)
378381

379382
securitySummary := wf.Param(wd, securitySummaryParameter)
380383
securityFixes := wf.Param(wd, securityFixesParameter)
381-
addCommTasks(wd, build, comm, task.KindCurrentMinor, wf.Slice(currPublished, prevPublished), securitySummary, securityFixes, coordinators)
384+
addCommTasks(wd, build, comm, task.KindMinor, wf.Slice(currPublished, prevPublished), securitySummary, securityFixes, coordinators)
382385

383386
return wd, nil
384387
}
@@ -420,7 +423,7 @@ func addSingleReleaseWorkflow(
420423
startingHead := wf.Task1(wd, "Read starting branch head", version.ReadBranchHead, branchVal)
421424

422425
// Select version, check milestones.
423-
nextVersion := wf.Task1(wd, "Get next version", version.GetNextVersion, kindVal)
426+
nextVersion := wf.Task2(wd, "Get next version", version.GetNextVersion, wf.Const(major), kindVal)
424427
timestamp := wf.Task0(wd, "Timestamp release", now)
425428
versionFile := wf.Task3(wd, "Generate VERSION file", version.GenerateVersionFile, distpackVal, nextVersion, timestamp)
426429
wf.Output(wd, "VERSION file", versionFile)

internal/task/announce.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -344,7 +344,7 @@ func announcementMail(data any) (MailContent, error) {
344344
name = "announce-rc.md"
345345
case KindMajor:
346346
name = "announce-major.md"
347-
case KindCurrentMinor, KindPrevMinor:
347+
case KindMinor:
348348
name = "announce-minor.md"
349349
default:
350350
return MailContent{}, fmt.Errorf("unknown release kind: %v", r.Kind)

internal/task/announce_test.go

+5-5
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import (
2424
func TestAnnounceReleaseShortContext(t *testing.T) {
2525
ctx, cancel := context.WithTimeout(context.Background(), time.Second)
2626
defer cancel()
27-
_, err := (AnnounceMailTasks{}).AnnounceRelease(&workflow.TaskContext{Context: ctx}, KindCurrentMinor, []Published{{Version: "go1.18.1"}, {Version: "go1.17.8"}}, nil, nil)
27+
_, err := (AnnounceMailTasks{}).AnnounceRelease(&workflow.TaskContext{Context: ctx}, KindMinor, []Published{{Version: "go1.18.1"}, {Version: "go1.17.8"}}, nil, nil)
2828
if err == nil {
2929
t.Errorf("want non-nil error")
3030
} else if !strings.HasPrefix(err.Error(), "insufficient time") {
@@ -41,7 +41,7 @@ func TestAnnouncementMail(t *testing.T) {
4141
{
4242
name: "announce-minor",
4343
in: releaseAnnouncement{
44-
Kind: KindCurrentMinor,
44+
Kind: KindMinor,
4545
Version: "go1.18.1",
4646
SecondaryVersion: "go1.17.9",
4747
Names: []string{"Alice", "Bob", "Charlie"},
@@ -51,7 +51,7 @@ func TestAnnouncementMail(t *testing.T) {
5151
{
5252
name: "announce-minor-with-security",
5353
in: releaseAnnouncement{
54-
Kind: KindCurrentMinor,
54+
Kind: KindMinor,
5555
Version: "go1.18.1",
5656
SecondaryVersion: "go1.17.9",
5757
Security: []string{
@@ -85,7 +85,7 @@ This is CVE-2022-27536 and https://go.dev/issue/51759.`,
8585
{
8686
name: "announce-minor-solo",
8787
in: releaseAnnouncement{
88-
Kind: KindCurrentMinor,
88+
Kind: KindMinor,
8989
Version: "go1.11.1",
9090
Security: []string{"abc: security fix 1", "xyz: security fix 2"},
9191
Names: []string{"Alice"},
@@ -203,7 +203,7 @@ func TestAnnounceRelease(t *testing.T) {
203203
}{
204204
{
205205
name: "minor",
206-
kind: KindCurrentMinor,
206+
kind: KindMinor,
207207
published: []Published{{Version: "go1.18.1"}, {Version: "go1.17.8"}}, // Intentionally not 1.17.9 so the real email doesn't get in the way.
208208
coordinators: []string{"heschi", "dmitshur"},
209209
want: SentMail{Subject: "Go 1.18.1 and Go 1.17.8 are released"},

internal/task/dlcl.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ func (t *VersionTasks) MailDLCL(ctx *workflow.TaskContext, major int, kind Relea
6262
}
6363

6464
func docLink(major int, kind ReleaseKind, ver string) string {
65-
if kind == KindCurrentMinor || kind == KindPrevMinor {
65+
if kind == KindMinor {
6666
return fmt.Sprintf("https://go.dev/doc/devel/release#%v", ver)
6767
}
6868

internal/task/dlcl_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ func TestMailDLCL(t *testing.T) {
2626
}{
2727
{
2828
name: "minor",
29-
kind: KindCurrentMinor,
29+
kind: KindMinor,
3030
major: 17,
3131
version: "go1.17.1",
3232
wantLog: `file "go1.17.1/main.go" (command "golang.org/dl/go1.17.1"):

internal/task/milestones.go

+20-4
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,26 @@ const (
3232
KindBeta
3333
KindRC
3434
KindMajor
35-
KindCurrentMinor
36-
KindPrevMinor
35+
KindMinor
3736
)
3837

38+
func (k ReleaseKind) GoString() string {
39+
switch k {
40+
case KindUnknown:
41+
return "KindUnknown"
42+
case KindBeta:
43+
return "KindBeta"
44+
case KindRC:
45+
return "KindRC"
46+
case KindMajor:
47+
return "KindMajor"
48+
case KindMinor:
49+
return "KindMinor"
50+
default:
51+
return fmt.Sprintf("ReleaseKind(%d)", k)
52+
}
53+
}
54+
3955
type ReleaseMilestones struct {
4056
// Current is the GitHub milestone number for the current Go release.
4157
// For example, 279 for the "Go1.21" milestone (https://github.com/golang/go/milestone/279).
@@ -148,7 +164,7 @@ func (m *MilestoneTasks) PushIssues(ctx *wf.TaskContext, milestones ReleaseMiles
148164
removeLabel("okay-after-beta1")
149165
} else if kind == KindRC && strings.HasSuffix(version, "rc1") {
150166
removeLabel("okay-after-rc1")
151-
} else if kind == KindMajor || kind == KindCurrentMinor || kind == KindPrevMinor {
167+
} else if kind == KindMajor || kind == KindMinor {
152168
newMilestone = &milestones.Next
153169
actions = append(actions, fmt.Sprintf("pushed to milestone %d", milestones.Next))
154170
}
@@ -165,7 +181,7 @@ func (m *MilestoneTasks) PushIssues(ctx *wf.TaskContext, milestones ReleaseMiles
165181
}
166182
ctx.Printf("Updated issue %d: %s.", issueNumber, strings.Join(actions, ", "))
167183
}
168-
if kind == KindMajor || kind == KindCurrentMinor || kind == KindPrevMinor {
184+
if kind == KindMajor || kind == KindMinor {
169185
_, _, err := m.Client.EditMilestone(ctx, m.RepoOwner, m.RepoName, milestones.Current, &github.Milestone{
170186
State: github.String("closed"),
171187
})

internal/task/tweet.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ func tweetText(r releaseTweet, rnd *rand.Rand) (string, error) {
183183
name = "rc"
184184
case KindMajor:
185185
name = "major"
186-
case KindCurrentMinor, KindPrevMinor:
186+
case KindMinor:
187187
name = "minor"
188188
default:
189189
return "", fmt.Errorf("unknown release kind: %v", r.Kind)

internal/task/tweet_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ func TestTweetRelease(t *testing.T) {
3636
}{
3737
{
3838
name: "minor",
39-
kind: KindCurrentMinor,
39+
kind: KindMinor,
4040
published: []Published{
4141
{Version: "go1.17.1", Files: []WebsiteFile{{
4242
OS: "linux", Arch: "arm64",
@@ -70,7 +70,7 @@ go version go1.17.1 linux/arm64` + "\n",
7070
},
7171
{
7272
name: "minor-solo",
73-
kind: KindCurrentMinor,
73+
kind: KindMinor,
7474
published: []Published{{Version: "go1.11.1", Files: []WebsiteFile{{
7575
OS: "darwin", Arch: "amd64",
7676
Filename: "go1.11.1.darwin-amd64.tar.gz", Size: 124181190, Kind: "archive"}},

internal/task/version.go

+14-15
Original file line numberDiff line numberDiff line change
@@ -66,12 +66,12 @@ func (t *VersionTasks) tagInfo(ctx context.Context) (tags map[string]bool, curre
6666
return nil, 0, "", fmt.Errorf("couldn't find the most recently released major version out of %d tags", len(tagList))
6767
}
6868

69-
// GetNextVersions returns the next for each of the given types of release.
69+
// GetNextMinorVersions returns the next minor for each of the given major series.
7070
// It uses the same format as Go tags (for example, "go1.23.4").
71-
func (t *VersionTasks) GetNextVersions(ctx context.Context, kinds []ReleaseKind) ([]string, error) {
71+
func (t *VersionTasks) GetNextMinorVersions(ctx context.Context, majors []int) ([]string, error) {
7272
var next []string
73-
for _, k := range kinds {
74-
n, err := t.GetNextVersion(ctx, k)
73+
for _, major := range majors {
74+
n, err := t.GetNextVersion(ctx, major, KindMinor)
7575
if err != nil {
7676
return nil, err
7777
}
@@ -80,10 +80,10 @@ func (t *VersionTasks) GetNextVersions(ctx context.Context, kinds []ReleaseKind)
8080
return next, nil
8181
}
8282

83-
// GetNextVersion returns the next for the given type of release.
83+
// GetNextVersion returns the next for the given major series and kind of release.
8484
// It uses the same format as Go tags (for example, "go1.23.4").
85-
func (t *VersionTasks) GetNextVersion(ctx context.Context, kind ReleaseKind) (string, error) {
86-
tags, currentMajor, _, err := t.tagInfo(ctx)
85+
func (t *VersionTasks) GetNextVersion(ctx context.Context, major int, kind ReleaseKind) (string, error) {
86+
tags, _, _, err := t.tagInfo(ctx)
8787
if err != nil {
8888
return "", err
8989
}
@@ -99,18 +99,17 @@ func (t *VersionTasks) GetNextVersion(ctx context.Context, kind ReleaseKind) (st
9999
}
100100
}
101101
switch kind {
102-
case KindCurrentMinor:
103-
return findUnused(fmt.Sprintf("go1.%d.1", currentMajor))
104-
case KindPrevMinor:
105-
return findUnused(fmt.Sprintf("go1.%d.1", currentMajor-1))
102+
case KindMinor:
103+
return findUnused(fmt.Sprintf("go1.%d.1", major))
106104
case KindBeta:
107-
return findUnused(fmt.Sprintf("go1.%dbeta1", currentMajor+1))
105+
return findUnused(fmt.Sprintf("go1.%dbeta1", major))
108106
case KindRC:
109-
return findUnused(fmt.Sprintf("go1.%drc1", currentMajor+1))
107+
return findUnused(fmt.Sprintf("go1.%drc1", major))
110108
case KindMajor:
111-
return fmt.Sprintf("go1.%d.0", currentMajor+1), nil
109+
return fmt.Sprintf("go1.%d.0", major), nil
110+
default:
111+
return "", fmt.Errorf("unknown release kind %v", kind)
112112
}
113-
return "", fmt.Errorf("unknown release kind %v", kind)
114113
}
115114

116115
// GetDevelVersion returns the current major Go 1.x version in development.

0 commit comments

Comments
 (0)