Skip to content

Commit 9c17948

Browse files
authored
Merge pull request #679 from sm43/test-in-gitlab
2 parents af8da15 + 7b8e1fb commit 9c17948

File tree

3 files changed

+27
-4
lines changed

3 files changed

+27
-4
lines changed

pkg/provider/bitbucketcloud/events.go

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,12 +131,17 @@ func (v *Provider) ParsePayload(ctx context.Context, run *params.Run, request *h
131131
processedEvent.TriggerTarget = "pull_request"
132132
processedEvent.EventType = "pull_request"
133133
} else if provider.Valid(event, []string{"pullrequest:comment_created"}) {
134-
if provider.IsRetestComment(e.Comment.Content.Raw) {
134+
switch {
135+
case provider.IsRetestComment(e.Comment.Content.Raw):
135136
processedEvent.TriggerTarget = "pull_request"
136137
processedEvent.EventType = "retest-comment"
137-
} else if provider.IsOkToTestComment(e.Comment.Content.Raw) {
138+
case provider.IsOkToTestComment(e.Comment.Content.Raw):
138139
processedEvent.TriggerTarget = "pull_request"
139140
processedEvent.EventType = "ok-to-test-comment"
141+
case provider.IsTestComment(e.Comment.Content.Raw):
142+
processedEvent.TriggerTarget = "pull_request"
143+
processedEvent.EventType = "test-comment"
144+
processedEvent.TargetTestPipelineRun = provider.GetPipelineRunFromComment(e.Comment.Content.Raw)
140145
}
141146
}
142147
processedEvent.Organization = e.Repository.Workspace.Slug
@@ -203,6 +208,9 @@ func (v *Provider) Detect(reqHeader *http.Header, payload string, logger *zap.Su
203208
if provider.IsOkToTestComment(e.Comment.Content.Raw) {
204209
return setLoggerAndProceed(true, "", nil)
205210
}
211+
if provider.IsTestComment(e.Comment.Content.Raw) {
212+
return setLoggerAndProceed(true, "", nil)
213+
}
206214
}
207215
return setLoggerAndProceed(false, fmt.Sprintf("not a valid gitops comment: \"%s\"", event), nil)
208216

pkg/provider/bitbucketserver/events.go

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,12 +52,17 @@ func (v *Provider) ParsePayload(_ context.Context, _ *params.Run, request *http.
5252
processedEvent.TriggerTarget = "pull_request"
5353
processedEvent.EventType = "pull_request"
5454
} else if provider.Valid(eventType, []string{"pr:comment:added", "pr:comment:edited"}) {
55-
if provider.IsRetestComment(e.Comment.Text) {
55+
switch {
56+
case provider.IsRetestComment(e.Comment.Text):
5657
processedEvent.TriggerTarget = "pull_request"
5758
processedEvent.EventType = "retest-comment"
58-
} else if provider.IsOkToTestComment(e.Comment.Text) {
59+
case provider.IsOkToTestComment(e.Comment.Text):
5960
processedEvent.TriggerTarget = "pull_request"
6061
processedEvent.EventType = "ok-to-test-comment"
62+
case provider.IsTestComment(e.Comment.Text):
63+
processedEvent.TriggerTarget = "pull_request"
64+
processedEvent.EventType = "test-comment"
65+
processedEvent.TargetTestPipelineRun = provider.GetPipelineRunFromComment(e.Comment.Text)
6166
}
6267
}
6368
// TODO: It's Really not an OWNER but a PROJECT
@@ -181,6 +186,9 @@ func (v *Provider) Detect(reqHeader *http.Header, payload string, logger *zap.Su
181186
if provider.IsOkToTestComment(e.Comment.Text) {
182187
return setLoggerAndProceed(true, "", nil)
183188
}
189+
if provider.IsTestComment(e.Comment.Text) {
190+
return setLoggerAndProceed(true, "", nil)
191+
}
184192
}
185193
return setLoggerAndProceed(false, fmt.Sprintf("not a recognized bitbucket event: \"%s\"", event), nil)
186194

pkg/provider/gitlab/gitlab.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,9 @@ func (v *Provider) Detect(reqHeader *http.Header, payload string, logger *zap.Su
105105
if provider.IsOkToTestComment(gitEvent.ObjectAttributes.Note) {
106106
return setLoggerAndProceed(true, "", nil)
107107
}
108+
if provider.IsTestComment(gitEvent.ObjectAttributes.Note) {
109+
return setLoggerAndProceed(true, "", nil)
110+
}
108111
}
109112
return setLoggerAndProceed(false, "not a gitops style merge comment event", nil)
110113
default:
@@ -195,6 +198,10 @@ func (v *Provider) ParsePayload(_ context.Context, _ *params.Run, request *http.
195198
processedEvent.SHATitle = gitEvent.MergeRequest.LastCommit.Message
196199
processedEvent.BaseBranch = gitEvent.MergeRequest.TargetBranch
197200
processedEvent.HeadBranch = gitEvent.MergeRequest.SourceBranch
201+
// if it is a /test comment figure out the pipelineRun name
202+
if provider.IsTestComment(gitEvent.ObjectAttributes.Note) {
203+
processedEvent.TargetTestPipelineRun = provider.GetPipelineRunFromComment(gitEvent.ObjectAttributes.Note)
204+
}
198205

199206
v.pathWithNamespace = gitEvent.Project.PathWithNamespace
200207
processedEvent.Organization, processedEvent.Repository = getOrgRepo(v.pathWithNamespace)

0 commit comments

Comments
 (0)