Skip to content

Commit 9deac10

Browse files
committed
Backport fixes for 0.33.x
Fixes from some of the incompatibilities when doing the backport from main to 0.33.x release Signed-off-by: Chmouel Boudjnah <[email protected]>
1 parent 7637021 commit 9deac10

File tree

3 files changed

+11
-80
lines changed

3 files changed

+11
-80
lines changed

.tekton/boussole.yaml

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -23,29 +23,5 @@ spec:
2323
value: "{{ git_auth_secret }}"
2424
- name: comment_sender
2525
value: "{{ sender }}"
26-
#
27-
# Optional parameters (value is the default):
28-
#
29-
# The key in git_auth_secret that contains the token (default: git-provider-token)
30-
# - name: git_auth_secret_key
31-
# value: git-provider-token
32-
#
33-
# The /lgtm threshold needed of approvers for a PR to be approved (default: 1)
34-
# - name: lgtm_threshold
35-
# value: "1"
36-
#
37-
# The permissionms the user need to trigger a lgtm
38-
# - name: lgtm_permissions
39-
# value: "admin,write"
40-
#
41-
# The review event when lgtm is triggered, can be APPROVE,
42-
# REQUEST_CHANGES, or COMMENT if setting to empty string it will be set as
43-
# PENDING
44-
# - name: lgtm_review_event
45-
# value: "APPROVE"
46-
#
47-
# The merge method to use. Can be one of: merge, squash, rebase
48-
# - name: merge_method
49-
# value: "rebase"
5026
pipelineRef:
5127
name: boussole

test/github_pullrequest_retest_test.go

Lines changed: 8 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -86,54 +86,14 @@ func TestGithubPullRequestGitOpsComments(t *testing.T) {
8686
prNum: 4,
8787
},
8888
}
89-
assert.NilError(t, err)
90-
err = twait.UntilPipelineRunCreated(ctx, g.Cnx.Clients, waitOpts)
91-
assert.NilError(t, err)
92-
93-
g.Cnx.Clients.Log.Infof("/cancel pr-gitops-comment on Pull Request")
94-
_, _, err = g.Provider.Client.Issues.CreateComment(ctx,
95-
g.Options.Organization,
96-
g.Options.Repo, g.PRNumber,
97-
&github.IssueComment{Body: github.Ptr("/cancel pr-gitops-comment")})
98-
assert.NilError(t, err)
99-
100-
waitOpts = twait.Opts{
101-
RepoName: g.TargetNamespace,
102-
Namespace: g.TargetNamespace,
103-
MinNumberStatus: 3,
104-
PollTimeout: twait.DefaultTimeout,
105-
TargetSHA: g.SHA,
106-
}
107-
g.Cnx.Clients.Log.Info("Waiting for Repository to be updated")
108-
_, err = twait.UntilRepositoryUpdated(ctx, g.Cnx.Clients, waitOpts)
109-
assert.NilError(t, err)
110-
111-
g.Cnx.Clients.Log.Infof("Check if we have the repository set as succeeded")
112-
repo, err := g.Cnx.Clients.PipelineAsCode.PipelinesascodeV1alpha1().Repositories(g.TargetNamespace).Get(ctx, g.TargetNamespace, metav1.GetOptions{})
113-
assert.NilError(t, err)
114-
assert.Equal(t, repo.Status[len(repo.Status)-1].Conditions[0].Status, corev1.ConditionFalse)
115-
116-
pruns, err = g.Cnx.Clients.Tekton.TektonV1().PipelineRuns(g.TargetNamespace).List(ctx, metav1.ListOptions{
117-
LabelSelector: fmt.Sprintf("%s=%s", keys.SHA, g.SHA),
118-
})
119-
assert.NilError(t, err)
120-
assert.Equal(t, len(pruns.Items), 3)
121-
122-
// go over all pruns check that at least one is canceled and the other two are succeeded
123-
canceledCount := 0
124-
succeededCount := 0
125-
unknownCount := 0
126-
for _, prun := range pruns.Items {
127-
for _, condition := range prun.Status.Conditions {
128-
if condition.Type == "Succeeded" {
129-
switch condition.Status {
130-
case corev1.ConditionFalse:
131-
canceledCount++
132-
case corev1.ConditionTrue:
133-
succeededCount++
134-
case corev1.ConditionUnknown:
135-
unknownCount++
136-
}
89+
for _, tt := range tests {
90+
t.Run(tt.name, func(t *testing.T) {
91+
waitOpts := twait.Opts{
92+
RepoName: g.TargetNamespace,
93+
Namespace: g.TargetNamespace,
94+
MinNumberStatus: tt.prNum,
95+
PollTimeout: twait.DefaultTimeout,
96+
TargetSHA: g.SHA,
13797
}
13898
if tt.comment == "/cancel pr-gitops-comment" {
13999
g.Cnx.Clients.Log.Info("/test pr-gitops-comment on Pull Request before canceling")
@@ -172,7 +132,4 @@ func TestGithubPullRequestGitOpsComments(t *testing.T) {
172132
assert.Equal(t, len(pruns.Items), tt.prNum)
173133
})
174134
}
175-
assert.Equal(t, canceledCount, 1, "should have one canceled PipelineRun")
176-
assert.Equal(t, succeededCount, 2, "should have two succeeded PipelineRuns")
177-
assert.Equal(t, unknownCount, 0, "should have zero unknown PipelineRuns: %+v", pruns.Items)
178135
}

test/gitlab_merge_request_test.go

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -335,17 +335,15 @@ func TestGitlabCancelInProgressOnPRClose(t *testing.T) {
335335
})
336336
assert.NilError(t, err)
337337

338-
err = twait.UntilPipelineRunHasReason(ctx, runcnx.Clients, v1.PipelineRunReasonCancelled, waitOpts)
339-
assert.NilError(t, err)
338+
runcnx.Clients.Log.Infof("Sleeping for 10 seconds to let the pipelinerun to be canceled")
339+
time.Sleep(10 * time.Second)
340340

341341
prs, err := runcnx.Clients.Tekton.TektonV1().PipelineRuns(targetNS).List(context.Background(), metav1.ListOptions{})
342342
assert.NilError(t, err)
343343
assert.Equal(t, len(prs.Items), 1, "should have only one pipelinerun, but we have: %d", len(prs.Items))
344344
assert.Equal(t, prs.Items[0].GetStatusCondition().GetCondition(apis.ConditionSucceeded).GetReason(), "Cancelled", "should have been canceled")
345345

346-
// failing on `true` condition because for cancelled PipelineRun we want `false` condition.
347-
waitOpts.FailOnRepoCondition = corev1.ConditionTrue
348-
repo, err := twait.UntilRepositoryUpdated(ctx, runcnx.Clients, waitOpts)
346+
repo, err := runcnx.Clients.PipelineAsCode.PipelinesascodeV1alpha1().Repositories(targetNS).Get(ctx, targetNS, metav1.GetOptions{})
349347
assert.NilError(t, err)
350348

351349
laststatus := repo.Status[len(repo.Status)-1]

0 commit comments

Comments
 (0)