Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add vitess releaser items specified in https://github.com/vitessio/vitess/issues/16795#todos #123

Merged
merged 5 commits into from
Oct 22, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion go/cmd/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ import (
"github.com/vitessio/vitess-releaser/go/releaser/utils"
)

const VERSION = "v1.0.2"
const VERSION = "v1.0.3"

var (
releaseVersion string
Expand Down
5 changes: 5 additions & 0 deletions go/interactive/main_menu.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import (
"github.com/vitessio/vitess-releaser/go/interactive/ui"
"github.com/vitessio/vitess-releaser/go/releaser"
"github.com/vitessio/vitess-releaser/go/releaser/github"
"github.com/vitessio/vitess-releaser/go/releaser/steps"
)

func blankLineMenu() *ui.MenuItem {
Expand Down Expand Up @@ -66,6 +67,7 @@ func MainScreen(ctx context.Context, state *releaser.State) {
pre_release.CreateReleasePRMenuItem(ctx),
pre_release.VtopUpdateGolangMenuItem(ctx),
createBlogPostPRMenuItem(ctx),
simpleMenuItem(ctx, "UpdateCobraDocs", []string{releaser.UpdateCobraDocsItem}, steps.UpdateCobraDocs, false),
frouioui marked this conversation as resolved.
Show resolved Hide resolved
)

releaseMenu := ui.NewMenu(
Expand All @@ -83,6 +85,8 @@ func MainScreen(ctx context.Context, state *releaser.State) {
benchmarkedItem(ctx),
dockerImagesItem(ctx),
release.CloseMilestoneItem(ctx),
simpleMenuItem(ctx, "VtTestServer", []string{releaser.VttestServerItem}, steps.VtTestServer, false),
frouioui marked this conversation as resolved.
Show resolved Hide resolved
simpleMenuItem(ctx, "ReleaseArtifacts", []string{releaser.ReleaseArtifactsItem}, steps.ReleaseArtifacts, false),
frouioui marked this conversation as resolved.
Show resolved Hide resolved
)
releaseMenu.Sequential = true

Expand All @@ -92,6 +96,7 @@ func MainScreen(ctx context.Context, state *releaser.State) {
slackAnnouncementMenuItem(ctx, slackAnnouncementPostRelease),
twitterMenuItem(ctx),
post_release.CloseIssueItem(ctx),
simpleMenuItem(ctx, "RemoveBypassProtection", []string{releaser.RemoveBypassProtection}, steps.RemoveBypassProtection, false),
frouioui marked this conversation as resolved.
Show resolved Hide resolved
)

menuTitle := fmt.Sprintf("Main Menu (%s)", github.CurrentUser())
Expand Down
43 changes: 42 additions & 1 deletion go/interactive/menu_item_constructors.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,16 @@ package interactive

import (
"context"

"fmt"
"github.com/vitessio/vitess-releaser/go/interactive/ui"
"github.com/vitessio/vitess-releaser/go/releaser"
"github.com/vitessio/vitess-releaser/go/releaser/code_freeze"
"github.com/vitessio/vitess-releaser/go/releaser/post_release"
"github.com/vitessio/vitess-releaser/go/releaser/prerequisite"
"github.com/vitessio/vitess-releaser/go/releaser/release"
"github.com/vitessio/vitess-releaser/go/releaser/steps"
"github.com/vitessio/vitess-releaser/go/releaser/utils"
"reflect"
)

func checkSummaryMenuItem(ctx context.Context) *ui.MenuItem {
Expand Down Expand Up @@ -137,3 +139,42 @@ func mergeBlogPostPRMenuItem(ctx context.Context) *ui.MenuItem {
state.Issue.MergeBlogPostPR,
!state.Issue.GA)
}

func simpleMenuItem(ctx context.Context, issueFieldName string, msgs []string, stepName string, onlyGA bool) *ui.MenuItem {
state := releaser.UnwrapState(ctx)
logMsg := fmt.Sprintf("Menu item %s", stepName)

fieldVal := getFieldVal(&state.Issue, issueFieldName, logMsg)

ignore := false
if onlyGA {
ignore = !state.Issue.GA
}

return newBooleanMenu(
ctx,
msgs,
stepName,
func() {
fieldVal.SetBool(!fieldVal.Bool())
},
fieldVal.Bool(),
ignore,
)
}

func getFieldVal(issue *releaser.Issue, issueFieldName string, logMsg string) reflect.Value {
v := reflect.ValueOf(issue).Elem()
fieldVal := v.FieldByName(issueFieldName)
if !fieldVal.IsValid() {
utils.BailOut(fmt.Errorf("no such field: %s", issueFieldName), logMsg)
}
if fieldVal.Kind() != reflect.Bool {
utils.BailOut(fmt.Errorf("field %s is not of type bool", issueFieldName), logMsg)
}

if !fieldVal.CanSet() {
utils.BailOut(fmt.Errorf("cannot set field: %s", issueFieldName), logMsg)
}
return fieldVal
}
31 changes: 26 additions & 5 deletions go/releaser/issue.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ const (
vtopUpdateGoItem = "Update vitess-operator Golang version."
vtopUpdateCompTableItem = "Update vitess-operator compatibility table."
createBlogPostPRItem = "Open a Pull Request on the website repository for the blog post."
UpdateCobraDocsItem = "Update Cobra Docs"
frouioui marked this conversation as resolved.
Show resolved Hide resolved

// Release
mergeReleasePRItem = "Merge the Release PR."
Expand All @@ -95,13 +96,18 @@ const (
dockerImagesItem = "Docker Images available on DockerHub."
closeMilestoneItem = "Close current GitHub Milestone."
mergeBlogPostItem = "Merge the blog post Pull Request on the website repository."
VttestServerItem = "Check vttestserver image is pushed"
ReleaseArtifactsItem = "Check that release artifacts were generated"

// Post-Release
postSlackAnnouncementItem = "Notify the community on Slack for the new release."
twitterItem = "Twitter announcement."
closeReleaseItem = "Close this Issue."
RemoveBypassProtection = "Remove bypass protection for release branch"
)

var simpleItems = []string{UpdateCobraDocsItem, VttestServerItem}

frouioui marked this conversation as resolved.
Show resolved Hide resolved
type (
ItemWithLink struct {
Done bool
Expand Down Expand Up @@ -151,6 +157,7 @@ type (
VtopCreateReleasePR ItemWithLinks
VtopManualUpdate bool
CreateBlogPostPR bool
UpdateCobraDocs bool

// Release
MergeReleasePR ItemWithLink
Expand All @@ -165,11 +172,13 @@ type (
Benchmarked bool
DockerImages bool
CloseMilestone ItemWithLink

VtTestServer bool
ReleaseArtifacts bool
// Post-Release
SlackPostRelease bool
Twitter bool
CloseIssue bool
SlackPostRelease bool
Twitter bool
CloseIssue bool
RemoveBypassProtection bool
}
)

Expand Down Expand Up @@ -257,6 +266,7 @@ const (
{{- if .GA }}
- [{{fmtStatus .CreateBlogPostPR}}] Open a Pull Request on the website repository for the blog post.
{{- end }}
- [{{fmtStatus .UpdateCobraDocs}}] Update Cobra Docs

### Release _({{fmtShortDate .Date }})_

Expand Down Expand Up @@ -298,12 +308,15 @@ const (
- {{ .CloseMilestone.URL }}
{{- end }}
{{- end }}

- [{{fmtStatus .VtTestServer}}] Check vttestserver image is pushed.
- [{{fmtStatus .ReleaseArtifacts}}] Check that release artifacts were generated.

### Post-Release _({{fmtShortDate .Date }})_
- [{{fmtStatus .SlackPostRelease}}] Notify the community on Slack for the new release.
- [{{fmtStatus .Twitter}}] Twitter announcement.
- [{{fmtStatus .RemoveBypassProtection}}] Remove bypass protection for release branch.
- [{{fmtStatus .CloseIssue}}] Close this Issue.

`
)

Expand Down Expand Up @@ -497,6 +510,14 @@ func (s *State) LoadIssue() {
newIssue.MergeBlogPostPR = strings.HasPrefix(line, markdownItemDone)
case strings.Contains(line, javaRelease):
newIssue.JavaRelease = strings.HasPrefix(line, markdownItemDone)
case strings.Contains(line, UpdateCobraDocsItem):
newIssue.UpdateCobraDocs = strings.HasPrefix(line, markdownItemDone)
case strings.Contains(line, VttestServerItem):
newIssue.VtTestServer = strings.HasPrefix(line, markdownItemDone)
case strings.Contains(line, ReleaseArtifactsItem):
newIssue.ReleaseArtifacts = strings.HasPrefix(line, markdownItemDone)
case strings.Contains(line, RemoveBypassProtection):
newIssue.RemoveBypassProtection = strings.HasPrefix(line, markdownItemDone)
}
case stateReadingGeneral:
newIssue.General.Items = append(newIssue.General.Items, handleNewListItem(lines, i, &st))
Expand Down
10 changes: 7 additions & 3 deletions go/releaser/steps/steps.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ const (
CreateReleasePR = "Create Release PR"
CreateMilestone = "Create Milestone"
VtopUpdateGolang = "Update Go version in vitess-operator"
UpdateCobraDocs = "Update Cobra Docs"

// Release
MergeReleasePR = "Merge Release PR"
Expand All @@ -55,9 +56,12 @@ const (
Benchmarked = "Benchmarks"
DockerImages = "Docker Images"
CloseMilestone = "Close Milestone"
VtTestServer = "VtTestServer"
ReleaseArtifacts = "Release Artifacts"

// Post-Release
SlackAnnouncementPost = "Slack Announcement Post-Release"
Twitter = "Twitter"
CloseIssue = "Close Issue"
SlackAnnouncementPost = "Slack Announcement Post-Release"
Twitter = "Twitter"
CloseIssue = "Close Issue"
RemoveBypassProtection = "Remove Bypass Protection"
)