Skip to content

Commit 040ca77

Browse files
authored
Merge branch 'main' into fix-update-concurrency-group-expression-in-e2e-wor
2 parents 17d0d15 + 8c9c443 commit 040ca77

File tree

23 files changed

+563
-294
lines changed

23 files changed

+563
-294
lines changed

.github/workflows/e2e.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@ on:
2020
- opened
2121
- reopened
2222
- synchronize
23+
paths:
24+
- "**.go"
25+
- ".github/**"
26+
- "test/testdata/**"
2327

2428
jobs:
2529
e2e-tests:

docs/content/docs/guide/authoringprs.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,10 @@ check out the code that is being tested.
5858
| repo_owner | The repository owner. | `{{repo_owner}}` | openshift-pipelines |
5959
| repo_url | The repository full URL. | `{{repo_url}}` | https:/github.com/repo/owner |
6060
| revision | The commit full sha revision. | `{{revision}}` | 1234567890abcdef |
61-
| sender | The sender username (or account ID on some providers) of the commit. | `{{sender}}` | johndoe |
62-
| source_branch | The branch name where the event comes from. | `{{source_branch}}` | main |
63-
| source_url | The source repository URL from which the event comes from (same as `repo_url` for push events). | `{{source_url}}` | https:/github.com/repo/owner |
61+
| sender | The sender username (or account ID on some providers) of the commit. | `{{sender}}` | johndoe |
62+
| source_branch | The branch name where the event comes from. | `{{source_branch}}` | main |
63+
| git_tag | The Git tag pushed (only available for tag push events; otherwise empty `""`). | `{{git_tag}}` | v1.0 |
64+
| source_url | The source repository URL from where the event comes (same as the value `repo_url` for push events). | `{{source_url}}` | https:/github.com/repo/owner |
6465
| target_branch | The branch name on which the event targets (same as `source_branch` for push events). | `{{target_branch}}` | main |
6566
| target_namespace | The target namespace where the Repository has matched and the PipelineRun will be created. | `{{target_namespace}}` | my-namespace |
6667
| trigger_comment | The comment triggering the PipelineRun when using a [GitOps command]({{< relref "/docs/guide/running.md#gitops-command-on-pull-or-merge-request" >}}) (like `/test`, `/retest`) | `{{trigger_comment}}` | /merge-pr branch |

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ require (
1919
github.com/google/go-github/v69 v69.2.0
2020
github.com/google/go-github/v70 v70.0.0
2121
github.com/hako/durafmt v0.0.0-20210608085754-5c1018a4e16b
22-
github.com/jenkins-x/go-scm v1.14.56
22+
github.com/jenkins-x/go-scm v1.14.58
2323
github.com/jonboulle/clockwork v0.5.0
2424
github.com/juju/ansiterm v1.0.0
2525
github.com/ktrysmt/go-bitbucket v0.9.81

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -294,8 +294,8 @@ github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpO
294294
github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc=
295295
github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8=
296296
github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw=
297-
github.com/jenkins-x/go-scm v1.14.56 h1:+kKwbTv+6ymaxx4bBCEMLvkrjLmFkWX39qxYe4DDHPI=
298-
github.com/jenkins-x/go-scm v1.14.56/go.mod h1:1RPxLZndnvu31XhFZ+RTvXiHmMX70HkQ17bRupTQxGs=
297+
github.com/jenkins-x/go-scm v1.14.58 h1:R7ZxZySGkvz7UxPdvAeQxUy9esUwrrseSPoTbxmXNt8=
298+
github.com/jenkins-x/go-scm v1.14.58/go.mod h1:1RPxLZndnvu31XhFZ+RTvXiHmMX70HkQ17bRupTQxGs=
299299
github.com/jonboulle/clockwork v0.5.0 h1:Hyh9A8u51kptdkR+cqRpT1EebBwTn1oK9YfGYbdFz6I=
300300
github.com/jonboulle/clockwork v0.5.0/go.mod h1:3mZlmanh0g2NDKO5TWZVJAfofYk64M7XN3SzBPjZF60=
301301
github.com/josharian/intern v1.0.0 h1:vlS4z54oSdjm0bgjRigI+G1HpF+tI+9rE5LLzOg8HmY=

pkg/customparams/customparams_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,7 @@ func TestProcessTemplates(t *testing.T) {
153153
"sender": "",
154154
"source_branch": "",
155155
"source_url": "",
156+
"git_tag": "",
156157
"target_branch": "",
157158
"target_namespace": "",
158159
"trigger_comment": "",

pkg/customparams/standard.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,19 @@ func (p *CustomParams) makeStandardParamsFromEvent(ctx context.Context) (map[str
3636
triggerCommentAsSingleLine := strings.ReplaceAll(strings.ReplaceAll(p.event.TriggerComment, "\r\n", "\\n"), "\n", "\\n")
3737
pullRequestLabels := strings.Join(p.event.PullRequestLabel, "\\n")
3838

39+
gitTag := ""
40+
if strings.HasPrefix(p.event.BaseBranch, "refs/tags/") {
41+
gitTag = strings.TrimPrefix(p.event.BaseBranch, "refs/tags/")
42+
}
43+
3944
return map[string]string{
4045
"revision": p.event.SHA,
4146
"repo_url": repoURL,
4247
"repo_owner": strings.ToLower(p.event.Organization),
4348
"repo_name": strings.ToLower(p.event.Repository),
4449
"target_branch": formatting.SanitizeBranch(p.event.BaseBranch),
4550
"source_branch": formatting.SanitizeBranch(p.event.HeadBranch),
51+
"git_tag": gitTag,
4652
"source_url": p.event.HeadURL,
4753
"sender": strings.ToLower(p.event.Sender),
4854
"target_namespace": p.repo.GetNamespace(),

pkg/customparams/standard_test.go

Lines changed: 22 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ func TestMakeStandardParamsFromEvent(t *testing.T) {
4949
"revision": "1234567890",
5050
"sender": "sender",
5151
"source_branch": "foo",
52+
"git_tag": "",
5253
"target_branch": "main",
5354
"target_namespace": "myns",
5455
"trigger_comment": `\n/test me\nHelp me obiwan kenobi\n\n\nTo test or not to test, is the question?\n\n\n`,
@@ -63,7 +64,7 @@ func TestMakeStandardParamsFromEvent(t *testing.T) {
6364
},
6465
},
6566
{
66-
name: "basic event test",
67+
name: "event with different clone URL",
6768
event: &info.Event{
6869
SHA: "1234567890",
6970
Organization: "Org",
@@ -76,6 +77,7 @@ func TestMakeStandardParamsFromEvent(t *testing.T) {
7677
HeadURL: "https://india.com",
7778
TriggerComment: "/test me\nHelp me obiwan kenobi",
7879
PullRequestLabel: []string{"bugs", "enhancements"},
80+
CloneURL: "https://blahblah",
7981
},
8082
repo: &v1alpha1.Repository{
8183
ObjectMeta: metav1.ObjectMeta{
@@ -87,11 +89,12 @@ func TestMakeStandardParamsFromEvent(t *testing.T) {
8789
"event_type": "pull_request",
8890
"repo_name": "repo",
8991
"repo_owner": "org",
90-
"repo_url": "https://paris.com",
92+
"repo_url": "https://blahblah",
9193
"source_url": "https://india.com",
9294
"revision": "1234567890",
9395
"sender": "sender",
9496
"source_branch": "foo",
97+
"git_tag": "",
9598
"target_branch": "main",
9699
"target_namespace": "myns",
97100
"trigger_comment": "/test me\\nHelp me obiwan kenobi",
@@ -106,20 +109,19 @@ func TestMakeStandardParamsFromEvent(t *testing.T) {
106109
},
107110
},
108111
{
109-
name: "event with different clone URL",
112+
name: "git tag push test event",
110113
event: &info.Event{
111-
SHA: "1234567890",
112-
Organization: "Org",
113-
Repository: "Repo",
114-
BaseBranch: "main",
115-
HeadBranch: "foo",
116-
EventType: "pull_request",
117-
Sender: "SENDER",
118-
URL: "https://paris.com",
119-
HeadURL: "https://india.com",
120-
TriggerComment: "/test me\nHelp me obiwan kenobi",
121-
PullRequestLabel: []string{"bugs", "enhancements"},
122-
CloneURL: "https://blahblah",
114+
SHA: "1234567890",
115+
Organization: "Org",
116+
Repository: "Repo",
117+
BaseBranch: "refs/tags/v1.0",
118+
HeadBranch: "refs/tags/v1.0",
119+
EventType: "push",
120+
Sender: "SENDER",
121+
URL: "https://paris.com",
122+
HeadURL: "https://india.com",
123+
TriggerComment: "/test me\nHelp me obiwan kenobi",
124+
CloneURL: "https://blahblah",
123125
},
124126
repo: &v1alpha1.Repository{
125127
ObjectMeta: metav1.ObjectMeta{
@@ -128,18 +130,19 @@ func TestMakeStandardParamsFromEvent(t *testing.T) {
128130
},
129131
},
130132
want: map[string]string{
131-
"event_type": "pull_request",
133+
"event_type": "push",
132134
"repo_name": "repo",
133135
"repo_owner": "org",
134136
"repo_url": "https://blahblah",
135137
"source_url": "https://india.com",
136138
"revision": "1234567890",
137139
"sender": "sender",
138-
"source_branch": "foo",
139-
"target_branch": "main",
140+
"source_branch": "refs/tags/v1.0",
141+
"git_tag": "v1.0",
142+
"target_branch": "refs/tags/v1.0",
140143
"target_namespace": "myns",
141144
"trigger_comment": "/test me\\nHelp me obiwan kenobi",
142-
"pull_request_labels": "bugs\\nenhancements",
145+
"pull_request_labels": "",
143146
},
144147
wantVCX: &testprovider.TestProviderImp{
145148
WantAllChangedFiles: []string{"added.go", "deleted.go", "modified.go", "renamed.go"},

pkg/pipelineascode/template_test.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,14 @@ func TestProcessTemplates(t *testing.T) {
8686
template: `{{ repo_url }}`,
8787
expected: "https://cloneurl",
8888
},
89+
{
90+
name: "test git_tag variable",
91+
event: &info.Event{
92+
BaseBranch: "refs/tags/v1.0",
93+
},
94+
template: `{{ git_tag }}`,
95+
expected: "v1.0",
96+
},
8997
{
9098
name: "replace target_namespace",
9199
template: `ns {{ target_namespace }}`,

pkg/provider/bitbucketdatacenter/acl_test.go

Lines changed: 29 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,10 @@ import (
1919
"fmt"
2020
"testing"
2121

22-
bbv1 "github.com/gfleury/go-bitbucket-v1"
2322
"github.com/openshift-pipelines/pipelines-as-code/pkg/params/info"
2423
bbv1test "github.com/openshift-pipelines/pipelines-as-code/pkg/provider/bitbucketdatacenter/test"
24+
"github.com/openshift-pipelines/pipelines-as-code/pkg/provider/bitbucketdatacenter/types"
25+
2526
"gotest.tools/v3/assert"
2627
rtesting "knative.dev/pkg/reconciler/testing"
2728
)
@@ -31,10 +32,10 @@ func TestIsAllowed(t *testing.T) {
3132
otherAccountID := 6666
3233

3334
type fields struct {
34-
projectMembers []*bbv1.UserPermission
35-
repoMembers []*bbv1.UserPermission
35+
projectMembers []*bbv1test.UserPermission
36+
repoMembers []*bbv1test.UserPermission
3637
projGroups []*bbv1test.ProjGroup
37-
activities []*bbv1.Activity
38+
activities []*bbv1test.Activity
3839
filescontents map[string]string
3940
defaultBranchLatestCommit string
4041
pullRequestNumber int
@@ -50,9 +51,9 @@ func TestIsAllowed(t *testing.T) {
5051
name: "allowed/user is owner",
5152
event: bbv1test.MakeEvent(&info.Event{Sender: "member", AccountID: fmt.Sprintf("%d", ownerAccountID)}),
5253
fields: fields{
53-
projectMembers: []*bbv1.UserPermission{
54+
projectMembers: []*bbv1test.UserPermission{
5455
{
55-
User: bbv1.User{
56+
User: types.User{
5657
Slug: "member",
5758
},
5859
},
@@ -68,18 +69,18 @@ func TestIsAllowed(t *testing.T) {
6869
Sender: "NotAllowedAtFirst",
6970
}),
7071
fields: fields{
71-
projectMembers: []*bbv1.UserPermission{
72+
projectMembers: []*bbv1test.UserPermission{
7273
{
73-
User: bbv1.User{
74+
User: types.User{
7475
Slug: "member",
7576
},
7677
},
7778
},
78-
activities: []*bbv1.Activity{
79+
activities: []*bbv1test.Activity{
7980
{
80-
Comment: bbv1.ActivityComment{
81+
Comment: types.ActivityComment{
8182
Text: "/ok-to-test",
82-
Author: bbv1.User{
83+
Author: types.User{
8384
Slug: "member",
8485
},
8586
},
@@ -97,11 +98,11 @@ func TestIsAllowed(t *testing.T) {
9798
}),
9899
fields: fields{
99100
defaultBranchLatestCommit: "defaultlatestcommit",
100-
activities: []*bbv1.Activity{
101+
activities: []*bbv1test.Activity{
101102
{
102-
Comment: bbv1.ActivityComment{
103+
Comment: types.ActivityComment{
103104
Text: "/ok-to-test",
104-
Author: bbv1.User{
105+
Author: types.User{
105106
ID: 15551,
106107
},
107108
},
@@ -121,9 +122,9 @@ func TestIsAllowed(t *testing.T) {
121122
Sender: "NotAllowed",
122123
}),
123124
fields: fields{
124-
projectMembers: []*bbv1.UserPermission{
125+
projectMembers: []*bbv1test.UserPermission{
125126
{
126-
User: bbv1.User{
127+
User: types.User{
127128
ID: 1234,
128129
},
129130
},
@@ -138,9 +139,9 @@ func TestIsAllowed(t *testing.T) {
138139
name: "disallowed/same nickname different account id",
139140
event: bbv1test.MakeEvent(&info.Event{Sender: "Bouffon", AccountID: "6666"}),
140141
fields: fields{
141-
projectMembers: []*bbv1.UserPermission{
142+
projectMembers: []*bbv1test.UserPermission{
142143
{
143-
User: bbv1.User{
144+
User: types.User{
144145
DisplayName: "Bouffon",
145146
ID: 7777,
146147
},
@@ -153,18 +154,18 @@ func TestIsAllowed(t *testing.T) {
153154
name: "disallowed/not a valid ok-to-test comment",
154155
event: bbv1test.MakeEvent(&info.Event{Sender: "Bouffon", AccountID: "6666"}),
155156
fields: fields{
156-
projectMembers: []*bbv1.UserPermission{
157+
projectMembers: []*bbv1test.UserPermission{
157158
{
158-
User: bbv1.User{
159+
User: types.User{
159160
ID: ownerAccountID,
160161
},
161162
},
162163
},
163-
activities: []*bbv1.Activity{
164+
activities: []*bbv1test.Activity{
164165
{
165-
Comment: bbv1.ActivityComment{
166+
Comment: types.ActivityComment{
166167
Text: "not a valid\n /ok-to-test",
167-
Author: bbv1.User{
168+
Author: types.User{
168169
ID: ownerAccountID,
169170
},
170171
},
@@ -180,18 +181,18 @@ func TestIsAllowed(t *testing.T) {
180181
Sender: "NotAllowedAtFirst",
181182
}),
182183
fields: fields{
183-
projectMembers: []*bbv1.UserPermission{
184+
projectMembers: []*bbv1test.UserPermission{
184185
{
185-
User: bbv1.User{
186+
User: types.User{
186187
ID: ownerAccountID,
187188
},
188189
},
189190
},
190-
activities: []*bbv1.Activity{
191+
activities: []*bbv1test.Activity{
191192
{
192-
Comment: bbv1.ActivityComment{
193+
Comment: types.ActivityComment{
193194
Text: "this is a valid\n/ok-to-test",
194-
Author: bbv1.User{
195+
Author: types.User{
195196
ID: ownerAccountID,
196197
},
197198
},

pkg/provider/bitbucketdatacenter/bitbucketdatacenter_test.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -67,15 +67,15 @@ func TestGetTektonDir(t *testing.T) {
6767
path: ".tekton",
6868
testDirPath: "../../pipelineascode/testdata/pull_request/.tekton",
6969
wantDirAPIErr: true,
70-
wantErr: "cannot list content of .tekton directory: not Authorized",
70+
wantErr: "cannot list content of .tekton directory: No message available",
7171
},
7272
{
7373
name: "bad/get files api error",
7474
event: bbtest.MakeEvent(nil),
7575
path: ".tekton",
7676
testDirPath: "../../pipelineascode/testdata/pull_request/.tekton",
7777
wantFilesAPIErr: true,
78-
wantErr: "cannot find .tekton/pipeline.yaml inside the repo repository: not Authorized",
78+
wantErr: "cannot find .tekton/pipeline.yaml inside the repo repository: No message available",
7979
},
8080
}
8181
for _, tt := range tests {
@@ -260,7 +260,7 @@ func TestGetFileInsideRepo(t *testing.T) {
260260
"foo/file.txt": "hello moto",
261261
},
262262
targetbranch: "yolo",
263-
wantErr: "cannot find foo/file.txt inside the repo repository: not Authorized",
263+
wantErr: "cannot find foo/file.txt inside the repo repository: No message available",
264264
},
265265
}
266266
for _, tt := range tests {
@@ -658,7 +658,7 @@ func TestGetFiles(t *testing.T) {
658658
wantModifiedFilesCount: 0,
659659
wantRenamedFilesCount: 0,
660660
wantError: true,
661-
errMsg: "failed to list changes for commit IAMSHA123: not Authorized",
661+
errMsg: "failed to list changes for commit IAMSHA123: No message available",
662662
},
663663
{
664664
name: "good/pull_request event",
@@ -677,7 +677,7 @@ func TestGetFiles(t *testing.T) {
677677
wantModifiedFilesCount: 0,
678678
wantRenamedFilesCount: 0,
679679
wantError: true,
680-
errMsg: "failed to list changes for pull request: not Authorized",
680+
errMsg: "failed to list changes for pull request: No message available",
681681
},
682682
}
683683
for _, tt := range tests {

0 commit comments

Comments
 (0)