Skip to content

Commit

Permalink
cmd/relui: add mail-dl-cl workflow
Browse files Browse the repository at this point in the history
Previously, this task was exposed only via the cmd/releasebot CLI.
Now that relui workflows support slice of string parameters,
it's easy to expose this task via a relui workflow too.

This is another step in having relui do more release work.

For golang/go#40279.

Change-Id: Icf94e49ac8124ffb77a78b80c65c477d6b43bf05
Reviewed-on: https://go-review.googlesource.com/c/build/+/404535
Reviewed-by: Dmitri Shuralyov <[email protected]>
Auto-Submit: Dmitri Shuralyov <[email protected]>
TryBot-Result: Gopher Robot <[email protected]>
Run-TryBot: Dmitri Shuralyov <[email protected]>
Reviewed-by: Heschi Kreinick <[email protected]>
  • Loading branch information
dmitshur authored and gopherbot committed May 11, 2022
1 parent fb638e1 commit adda295
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 0 deletions.
1 change: 1 addition & 0 deletions cmd/relui/deployment-prod.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ spec:
# Define the site header and external service configuration.
- "--site-title=Go Releases"
- "--site-header-css=Site-header--production"
- "--gerrit-api-secret=secret:symbolic-datum-552/gobot-password"
- "--twitter-api-secret=secret:symbolic-datum-552/twitter-api-secret"
ports:
- containerPort: 444
Expand Down
7 changes: 7 additions & 0 deletions cmd/relui/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
"net/url"

"github.com/jackc/pgx/v4/pgxpool"
"golang.org/x/build/gerrit"
"golang.org/x/build/internal/https"
"golang.org/x/build/internal/relui"
"golang.org/x/build/internal/secret"
Expand All @@ -32,6 +33,7 @@ func main() {
if err := secret.InitFlagSupport(context.Background()); err != nil {
log.Fatalln(err)
}
gerritAPIFlag := secret.Flag("gerrit-api-secret", "Gerrit API secret to use for workflows that interact with Gerrit.")
var twitterAPI secret.TwitterCredentials
secret.JSONVarFlag(&twitterAPI, "twitter-api-secret", "Twitter API secret to use for workflows involving tweeting.")
https.RegisterFlags(flag.CommandLine)
Expand Down Expand Up @@ -61,12 +63,17 @@ func main() {
CSSClass: *siteHeaderCSS,
}
extCfg = task.ExternalConfig{
GerritAPI: struct {
URL string
Auth gerrit.Auth
}{"https://go-review.googlesource.com", gerrit.BasicAuth("git-gobot.golang.org", *gerritAPIFlag)},
// TODO(go.dev/issue/51150): When twitter client creation is factored out from task package, update code here.
TwitterAPI: twitterAPI,
}
)

dh := relui.NewDefinitionHolder()
relui.RegisterMailDLCLDefinition(dh, extCfg)
relui.RegisterTweetDefinitions(dh, extCfg)
db, err := pgxpool.Connect(ctx, *pgConnect)
if err != nil {
Expand Down
24 changes: 24 additions & 0 deletions internal/relui/workflows.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,30 @@ func (h *DefinitionHolder) Definitions() map[string]*workflow.Definition {
return defs
}

// RegisterMailDLCLDefinition registers a workflow definition for mailing a golang.org/dl CL
// onto h, using e for the external service configuration.
func RegisterMailDLCLDefinition(h *DefinitionHolder, e task.ExternalConfig) {
versions := workflow.Parameter{
Name: "Versions",
ParameterType: workflow.SliceShort,
Doc: `Versions are the Go versions that have been released.
The versions must use the same format as Go tags,
and the list must contain one or two versions.
For example:
• "go1.18.2" and "go1.17.10" for a minor Go release
• "go1.19" for a major Go release
• "go1.19beta1" or "go1.19rc1" for a pre-release`,
}

wd := workflow.New()
wd.Output("ChangeURL", wd.Task("mail-dl-cl", func(ctx *workflow.TaskContext, versions []string) (string, error) {
return task.MailDLCL(ctx, versions, e)
}, wd.Parameter(versions)))
h.RegisterDefinition("mail-dl-cl", wd)
}

// RegisterTweetDefinitions registers workflow definitions involving tweeting
// onto h, using e for the external service configuration.
func RegisterTweetDefinitions(h *DefinitionHolder, e task.ExternalConfig) {
Expand Down

0 comments on commit adda295

Please sign in to comment.