Skip to content

Commit

Permalink
Add vitess releaser items specified in vitessio/vitess#16795 (comment)
Browse files Browse the repository at this point in the history
Signed-off-by: Rohit Nayak <[email protected]>
  • Loading branch information
rohit-nayak-ps committed Oct 17, 2024
1 parent 4c82173 commit 1004db3
Show file tree
Hide file tree
Showing 5 changed files with 81 additions and 10 deletions.
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),
)

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),
simpleMenuItem(ctx, "ReleaseArtifacts", []string{releaser.ReleaseArtifactsItem}, steps.ReleaseArtifacts, false),
)
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),
)

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"

// 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}

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"
)

0 comments on commit 1004db3

Please sign in to comment.