Documentation
¶
Index ¶
- Constants
- Variables
- func CommentReopenedWorkflow(ctx workflow.Context, event bitbucket.PullRequestEvent) error
- func CommentResolvedWorkflow(ctx workflow.Context, event bitbucket.PullRequestEvent) error
- func CommitCommentCreatedWorkflow(ctx workflow.Context, _ bitbucket.RepositoryEvent) error
- func CreateSchedule(ctx context.Context, c client.Client, taskQueue string)
- func DrainPullRequestSignals(ctx workflow.Context) bool
- func DrainRepositorySignals(ctx workflow.Context) bool
- func PullRequestReviewedWorkflow(ctx workflow.Context, event bitbucket.PullRequestEvent) error
- func RegisterPullRequestSignals(ctx workflow.Context, sel workflow.Selector)
- func RegisterPullRequestWorkflows(cmd *cli.Command, opts client.Options, taskQueue string, w worker.Worker)
- func RegisterRepositorySignals(ctx workflow.Context, sel workflow.Selector)
- func RegisterRepositoryWorkflows(cmd *cli.Command, opts client.Options, taskQueue string, w worker.Worker)
- type Config
- func (c Config) CommentCreatedWorkflow(ctx workflow.Context, event bitbucket.PullRequestEvent) error
- func (c Config) CommentDeletedWorkflow(ctx workflow.Context, event bitbucket.PullRequestEvent) error
- func (c Config) CommentUpdatedWorkflow(ctx workflow.Context, event bitbucket.PullRequestEvent) error
- func (c Config) CommitStatusWorkflow(ctx workflow.Context, event bitbucket.RepositoryEvent) error
- func (c Config) PollCommentWorkflow(ctx workflow.Context, req PollCommentRequest) error
- func (c Config) PollingCleanupWorkflow(ctx workflow.Context) error
- func (c Config) PullRequestClosedWorkflow(ctx workflow.Context, event bitbucket.PullRequestEvent) error
- func (c Config) PullRequestCreatedWorkflow(ctx workflow.Context, event bitbucket.PullRequestEvent) error
- func (c Config) PullRequestUpdatedWorkflow(ctx workflow.Context, event bitbucket.PullRequestEvent) error
- type PollCommentRequest
Constants ¶
Variables ¶
var PullRequestSignals = []string{
"bitbucket.events.pullrequest.created",
"bitbucket.events.pullrequest.updated",
"bitbucket.events.pullrequest.approved",
"bitbucket.events.pullrequest.unapproved",
"bitbucket.events.pullrequest.changes_request_created",
"bitbucket.events.pullrequest.changes_request_removed",
"bitbucket.events.pullrequest.fulfilled",
"bitbucket.events.pullrequest.rejected",
"bitbucket.events.pullrequest.comment_created",
"bitbucket.events.pullrequest.comment_updated",
"bitbucket.events.pullrequest.comment_deleted",
"bitbucket.events.pullrequest.comment_resolved",
"bitbucket.events.pullrequest.comment_reopened",
}
PullRequestSignals is a list of signal names that RevChat receives from Timpani, to trigger event handling workflows.
This is based on:
- https://support.atlassian.com/bitbucket-cloud/docs/event-payloads/#Pull-request-events
- https://github.com/tzrikka/revchat/blob/main/docs/setup/bitbucket.md#webhook-triggers
- https://github.com/tzrikka/timpani/blob/main/pkg/listeners/bitbucket/webhook.go
var RepositorySignals = []string{
"bitbucket.events.repo.commit_comment_created",
"bitbucket.events.repo.commit_status_created",
"bitbucket.events.repo.commit_status_updated",
}
RepositorySignals is a list of signal names that RevChat receives from Timpani, to trigger event handling workflows.
This is based on:
- https://support.atlassian.com/bitbucket-cloud/docs/event-payloads/#Repository-events
- https://github.com/tzrikka/revchat/blob/main/docs/setup/bitbucket.md#webhook-triggers
- https://github.com/tzrikka/timpani/blob/main/pkg/listeners/bitbucket/webhook.go
var Schedules = []string{
"bitbucket.schedules.poll_comment",
"bitbucket.schedules.polling_cleanup",
}
Schedules is a list of workflow names that RevChat runs periodically via Temporal schedules (https://docs.temporal.io/develop/go/schedules).
Functions ¶
func CommentReopenedWorkflow ¶
func CommentReopenedWorkflow(ctx workflow.Context, event bitbucket.PullRequestEvent) error
CommentReopenedWorkflow mirrors the reopening of a resolved PR comment in the PR's Slack channel: https://support.atlassian.com/bitbucket-cloud/docs/event-payloads/#Comment-reopened
func CommentResolvedWorkflow ¶
func CommentResolvedWorkflow(ctx workflow.Context, event bitbucket.PullRequestEvent) error
CommentResolvedWorkflow mirrors the resolution of a PR comment in the PR's Slack channel: https://support.atlassian.com/bitbucket-cloud/docs/event-payloads/#Comment-resolved
func CommitCommentCreatedWorkflow ¶
func CommitCommentCreatedWorkflow(ctx workflow.Context, _ bitbucket.RepositoryEvent) error
CommitCommentCreatedWorkflow (will) handle (in the future) this event: https://support.atlassian.com/bitbucket-cloud/docs/event-payloads/#Commit-comment-created
func CreateSchedule ¶ added in v1.2.0
CreateSchedule starts a scheduled workflow that runs once an hour, to delete obsolete (i.e. completed) PR comment polling schedules (which were started by [Config.pollCommentForUpdates]) instead of waiting a week for the Temporal server to do it.
func DrainPullRequestSignals ¶
DrainPullRequestSignals drains all pending PullRequestSignals channels, and waits for their corresponding workflow executions to complete in order. This is called in preparation for resetting the dispatcher workflow's history.
func DrainRepositorySignals ¶
DrainRepositorySignals drains all pending RepositorySignals channels, and waits for their corresponding workflow executions to complete in order. This is called in preparation for resetting the dispatcher workflow's history.
func PullRequestReviewedWorkflow ¶
func PullRequestReviewedWorkflow(ctx workflow.Context, event bitbucket.PullRequestEvent) error
PullRequestReviewedWorkflow mirrors PR review results in the PR's Slack channel:
- https://support.atlassian.com/bitbucket-cloud/docs/event-payloads/#Approved
- https://support.atlassian.com/bitbucket-cloud/docs/event-payloads/#Approval-removed
- https://support.atlassian.com/bitbucket-cloud/docs/event-payloads/#Changes-Request-created
- https://support.atlassian.com/bitbucket-cloud/docs/event-payloads/#Changes-Request-removed
func RegisterPullRequestSignals ¶
RegisterPullRequestSignals routes PullRequestSignals to their registered workflows.
func RegisterPullRequestWorkflows ¶
func RegisterPullRequestWorkflows(cmd *cli.Command, opts client.Options, taskQueue string, w worker.Worker)
RegisterPullRequestWorkflows maps event-handling workflow functions to PullRequestSignals.
func RegisterRepositorySignals ¶
RegisterRepositorySignals routes RepositorySignals to their registered workflows.
func RegisterRepositoryWorkflows ¶
func RegisterRepositoryWorkflows(cmd *cli.Command, opts client.Options, taskQueue string, w worker.Worker)
RegisterRepositoryWorkflows maps event-handling workflow functions to RepositorySignals.
Types ¶
type Config ¶
type Config struct {
SlackAlertsChannel string
SlackChannelNamePrefix string
SlackChannelNameMaxLength int
SlackChannelsArePrivate bool
LinkifyMap map[string]string
Opts client.Options
TaskQueue string
}
func (Config) CommentCreatedWorkflow ¶
func (c Config) CommentCreatedWorkflow(ctx workflow.Context, event bitbucket.PullRequestEvent) error
CommentCreatedWorkflow mirrors the creation of a new PR comment in the PR's Slack channel: https://support.atlassian.com/bitbucket-cloud/docs/event-payloads/#Comment-created.1
func (Config) CommentDeletedWorkflow ¶
func (c Config) CommentDeletedWorkflow(ctx workflow.Context, event bitbucket.PullRequestEvent) error
CommentDeletedWorkflow mirrors the deletion of a PR comment in the PR's Slack channel: https://support.atlassian.com/bitbucket-cloud/docs/event-payloads/#Comment-deleted
func (Config) CommentUpdatedWorkflow ¶
func (c Config) CommentUpdatedWorkflow(ctx workflow.Context, event bitbucket.PullRequestEvent) error
CommentUpdatedWorkflow mirrors an edit of an existing PR comment in the PR's Slack channel: https://support.atlassian.com/bitbucket-cloud/docs/event-payloads/#Comment-updated
Note: these events are not reported by Bitbucket if they occur within a 10-minute window after the creation or last update of the same PR comment. As a workaround, we actively poll Bitbucket to detect text changes within these windows: see Config.PollCommentWorkflow.
func (Config) CommitStatusWorkflow ¶ added in v1.3.2
CommitStatusWorkflow mirrors build/commit status updates in the corresponding PR's Slack channel:
func (Config) PollCommentWorkflow ¶
func (c Config) PollCommentWorkflow(ctx workflow.Context, req PollCommentRequest) error
PollCommentWorkflow checks a specific PR comment to detect and mirror edits made within Bitbucket's [10-minute silent window] after its creation or last update, instead of [CommentUpdatedWorkflow]. This workflow runs in a Temporal schedule, roughly every CommentPollingInterval during CommentPollingWindow, or until the comment is deleted.
This workflow uses a checksum of the comment's text for privacy and efficiency reasons.
func (Config) PollingCleanupWorkflow ¶ added in v1.2.0
PollingCleanupWorkflow deletes obsolete (i.e. completed) PR comment polling schedules. This workflow runs once an hour in a Temporal schedule, and is a trivial wrapper for [deleteSchedulesActivity].
func (Config) PullRequestClosedWorkflow ¶ added in v1.3.2
func (c Config) PullRequestClosedWorkflow(ctx workflow.Context, event bitbucket.PullRequestEvent) error
PullRequestClosedWorkflow archives a PR's Slack channel when the PR is merged or declined/rejected:
func (Config) PullRequestCreatedWorkflow ¶
func (c Config) PullRequestCreatedWorkflow(ctx workflow.Context, event bitbucket.PullRequestEvent) error
PullRequestCreatedWorkflow initializes a new Slack channel for a newly-created PR: https://support.atlassian.com/bitbucket-cloud/docs/event-payloads/#Created.1
func (Config) PullRequestUpdatedWorkflow ¶
func (c Config) PullRequestUpdatedWorkflow(ctx workflow.Context, event bitbucket.PullRequestEvent) error
PullRequestUpdatedWorkflow mirrors various PR updates in the PR's Slack channel (such as title/description edits, reviewer changes, commit pushes, and branch retargeting): https://support.atlassian.com/bitbucket-cloud/docs/event-payloads/#Updated.2
type PollCommentRequest ¶ added in v1.2.0
type PollCommentRequest struct {
ThrippyID string `json:"thrippy_id"`
CommentURL string `json:"comment_url"`
Checksum string `json:"checksum"`
}
PollCommentRequest is the input to Config.PollCommentWorkflow.