Skip to content

Commit 17d0d15

Browse files
authored
Merge branch 'main' into fix-update-concurrency-group-expression-in-e2e-wor
2 parents 2660059 + 4d2dd33 commit 17d0d15

File tree

20 files changed

+728
-668
lines changed

20 files changed

+728
-668
lines changed

.github/workflows/e2e.yaml

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ on:
1010
description: "Run the build with tmate debugging enabled (https://github.com/marketplace/actions/debugging-with-tmate)"
1111
required: false
1212
default: false
13+
target_ref:
14+
type: string
15+
description: "Target ref to run the tests against"
16+
required: false
1317
pull_request_target:
1418
types:
1519
- labeled
@@ -22,7 +26,7 @@ jobs:
2226
# Only run if it's a scheduled run, manual dispatch, or has e2e label
2327
if: >
2428
github.event_name == 'schedule' ||
25-
(github.event_name == 'workflow_dispatch') ||
29+
github.event_name == 'workflow_dispatch' ||
2630
(github.event_name == 'pull_request_target' && (github.event.label.name == 'e2e' || contains(github.event.pull_request.labels.*.name, 'e2e')))
2731
2832
concurrency:
@@ -57,13 +61,13 @@ jobs:
5761
TEST_GITHUB_SECOND_REPO_OWNER_GITHUBAPP: pipelines-as-code/e2e
5862
TEST_GITHUB_SECOND_REPO_INSTALLATION_ID: 1
5963
TEST_GITLAB_API_URL: https://gitlab.com
60-
TEST_GITLAB_PROJECT_ID: 34405323
64+
TEST_GITLAB_PROJECT_ID: ${{ vars.TEST_GITLAB_PROJECT_ID }}
6165
TEST_BITBUCKET_SERVER_USER: pipelines
6266
TEST_BITBUCKET_SERVER_E2E_REPOSITORY: PAC/pac-e2e-tests
6367
steps:
6468
- uses: actions/checkout@v4
6569
with:
66-
ref: ${{ github.event.pull_request.head.sha || github.sha }}
70+
ref: ${{ inputs.target_ref || github.event.pull_request.head.sha || github.sha }}
6771

6872
- uses: actions/setup-go@v5
6973
with:
@@ -96,7 +100,7 @@ jobs:
96100
- name: Create PAC github-app-secret
97101
env:
98102
PAC_GITHUB_PRIVATE_KEY: ${{ secrets.APP_PRIVATE_KEY }}
99-
PAC_GITHUB_APPLICATION_ID: ${{ secrets.APPLICATION_ID }}
103+
PAC_GITHUB_APPLICATION_ID: ${{ vars.APPLICATION_ID }}
100104
PAC_WEBHOOK_SECRET: ${{ secrets.WEBHOOK_SECRET }}
101105
run: |
102106
./hack/gh-workflow-ci.sh create_pac_github_app_secret
@@ -116,7 +120,7 @@ jobs:
116120
TEST_BITBUCKET_CLOUD_TOKEN: ${{ secrets.BITBUCKET_CLOUD_TOKEN }}
117121
TEST_EL_WEBHOOK_SECRET: ${{ secrets.WEBHOOK_SECRET }}
118122
TEST_GITEA_SMEEURL: ${{ secrets.TEST_GITEA_SMEEURL }}
119-
TEST_GITHUB_REPO_INSTALLATION_ID: ${{ secrets.INSTALLATION_ID }}
123+
TEST_GITHUB_REPO_INSTALLATION_ID: ${{ vars.INSTALLATION_ID }}
120124
TEST_GITHUB_TOKEN: ${{ secrets.GH_APPS_TOKEN }}
121125
TEST_GITHUB_SECOND_TOKEN: ${{ secrets.TEST_GITHUB_SECOND_TOKEN }}
122126
TEST_GITLAB_TOKEN: ${{ secrets.GITLAB_TOKEN }}
@@ -134,7 +138,7 @@ jobs:
134138
TEST_BITBUCKET_CLOUD_TOKEN: ${{ secrets.BITBUCKET_CLOUD_TOKEN }}
135139
TEST_EL_WEBHOOK_SECRET: ${{ secrets.WEBHOOK_SECRET }}
136140
TEST_GITEA_SMEEURL: ${{ secrets.TEST_GITEA_SMEEURL }}
137-
TEST_GITHUB_REPO_INSTALLATION_ID: ${{ secrets.INSTALLATION_ID }}
141+
TEST_GITHUB_REPO_INSTALLATION_ID: ${{ vars.INSTALLATION_ID }}
138142
TEST_GITHUB_TOKEN: ${{ secrets.GH_APPS_TOKEN }}
139143
TEST_GITHUB_SECOND_TOKEN: ${{ secrets.TEST_GITHUB_SECOND_TOKEN }}
140144
TEST_GITLAB_TOKEN: ${{ secrets.GITLAB_TOKEN }}

docs/content/docs/dev/_index.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,16 @@ When it finishes, you will have the following installed in your kind cluster:
2626
- Pipelines as code deployed from your repo with ko.
2727
- Gitea service running locally so you can run the E2E tests against it (Gitea has the most comprehensive set of tests).
2828

29+
### Configuring the Kind Registry Port
30+
31+
By default, the Kind registry runs on port 5000. To use a different port, set the `REG_PORT` environment variable:
32+
33+
```shell
34+
# Set a custom registry port
35+
export REG_PORT=5001
36+
make dev
37+
```
38+
2939
By default, it will try to install from
3040
$GOPATH/src/github.com/openshift-pipelines/pipelines-as-code. To override it,
3141
set the `PAC_DIRS` environment variable.

docs/content/docs/install/gitlab.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ There are two ways to create the `Repository` and configure the webhook:
3030
* Use the [`tkn pac create repo`](/docs/guide/cli) command to
3131
configure a webhook and create the `Repository` CR.
3232

33-
You need to have a personal access token created with `admin:repo_hook` scope. `tkn pac` will use this token to configure the webhook, and add it in a secret
33+
You need to have a personal access token created with `api` scope. `tkn pac` will use this token to configure the webhook, and add it in a secret
3434
in the cluster which will be used by Pipelines-As-Code controller for accessing the `Repository`.
3535

3636
Below is the sample format for `tkn pac create repo`

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ require (
127127
go.uber.org/automaxprocs v1.6.0 // indirect
128128
go.uber.org/multierr v1.11.0 // indirect
129129
golang.org/x/crypto v0.36.0 // indirect
130-
golang.org/x/net v0.37.0 // indirect
130+
golang.org/x/net v0.38.0 // indirect
131131
golang.org/x/sys v0.31.0 // indirect
132132
golang.org/x/term v0.30.0 // indirect
133133
golang.org/x/time v0.11.0 // indirect

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -625,8 +625,8 @@ golang.org/x/net v0.21.0/go.mod h1:bIjVDfnllIU7BJ2DNgfnXvpSvtn8VRwhlsaeUTyUS44=
625625
golang.org/x/net v0.23.0/go.mod h1:JKghWKKOSdJwpW2GEx0Ja7fmaKnMsbu+MWVZTokSYmg=
626626
golang.org/x/net v0.25.0/go.mod h1:JkAGAh7GEvH74S6FOH42FLoXpXbE/aqXSrIQjXgsiwM=
627627
golang.org/x/net v0.33.0/go.mod h1:HXLR5J+9DxmrqMwG9qjGCxZ+zKXxBru04zlTvWlWuN4=
628-
golang.org/x/net v0.37.0 h1:1zLorHbz+LYj7MQlSf1+2tPIIgibq2eL5xkrGk6f+2c=
629-
golang.org/x/net v0.37.0/go.mod h1:ivrbrMbzFq5J41QOQh0siUuly180yBYtLp+CKbEaFx8=
628+
golang.org/x/net v0.38.0 h1:vRMAPTMaeGqVhG5QyLJHqNDwecKTomGeqbnfZyKlBI8=
629+
golang.org/x/net v0.38.0/go.mod h1:ivrbrMbzFq5J41QOQh0siUuly180yBYtLp+CKbEaFx8=
630630
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
631631
golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
632632
golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=

hack/dev/kind/install.sh

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ if ! builtin type -p gosmee &>/dev/null; then
4646
fi
4747

4848
TMPD=$(mktemp -d /tmp/.GITXXXX)
49-
REG_PORT='5000'
49+
REG_PORT=${REG_PORT:-'5000'}
5050
REG_NAME='kind-registry'
5151
INSTALL_FROM_RELEASE=
5252
PAC_PASS_SECRET_FOLDER=${PAC_PASS_SECRET_FOLDER:-""}
@@ -173,7 +173,7 @@ function install_pac() {
173173
if [[ -n ${PAC_DEPLOY_SCRIPT:-""} ]]; then
174174
${PAC_DEPLOY_SCRIPT}
175175
else
176-
env KO_DOCKER_REPO=localhost:5000 $ko apply -f config --sbom=none -B >/dev/null
176+
env KO_DOCKER_REPO=localhost:${REG_PORT} $ko apply -f config --sbom=none -B >/dev/null
177177
fi
178178
cd ${oldPwd}
179179
fi
@@ -243,6 +243,7 @@ main() {
243243
install_pac
244244
[[ -z ${DISABLE_GITEA} ]] && install_gitea
245245
echo "And we are done :): "
246+
echo "Using registry on localhost:${REG_PORT}"
246247
}
247248

248249
function usage() {

pkg/pipelineascode/cancel_pipelineruns.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ func (p *PacRun) cancelAllInProgressBelongingToClosedPullRequest(ctx context.Con
4646
if len(prs.Items) == 0 {
4747
msg := fmt.Sprintf("no pipelinerun found for repository: %v and pullRequest %v",
4848
p.event.Repository, p.event.PullRequestNumber)
49-
p.eventEmitter.EmitMessage(repo, zap.InfoLevel, "RepositoryPipelineRun", msg)
49+
p.eventEmitter.EmitMessage(repo, zap.InfoLevel, "CancelInProgress", msg)
5050
return nil
5151
}
5252

@@ -144,7 +144,7 @@ func (p *PacRun) cancelPipelineRunsOpsComment(ctx context.Context, repo *v1alpha
144144
if len(prs.Items) == 0 {
145145
msg := fmt.Sprintf("no pipelinerun found for repository: %v , sha: %v and pulRequest %v",
146146
p.event.Repository, p.event.SHA, p.event.PullRequestNumber)
147-
p.eventEmitter.EmitMessage(repo, zap.InfoLevel, "RepositoryPipelineRun", msg)
147+
p.eventEmitter.EmitMessage(repo, zap.InfoLevel, "CancelInProgress", msg)
148148
return nil
149149
}
150150

@@ -183,7 +183,7 @@ func (p *PacRun) cancelPipelineRuns(ctx context.Context, prs *tektonv1.PipelineR
183183
defer wg.Done()
184184
if _, err := action.PatchPipelineRun(ctx, p.logger, "cancel patch", p.run.Clients.Tekton, &pr, cancelMergePatch); err != nil {
185185
errMsg := fmt.Sprintf("failed to cancel pipelineRun %s/%s: %s", pr.GetNamespace(), pr.GetName(), err.Error())
186-
p.eventEmitter.EmitMessage(repo, zap.ErrorLevel, "RepositoryPipelineRun", errMsg)
186+
p.eventEmitter.EmitMessage(repo, zap.ErrorLevel, "CancelInProgress", errMsg)
187187
}
188188
}(ctx, pr)
189189
}

test/pkg/gitea/test.go

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import (
2727
v1 "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1"
2828
"github.com/tektoncd/pipeline/pkg/names"
2929
"gotest.tools/v3/assert"
30+
corev1 "k8s.io/api/core/v1"
3031
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
3132
)
3233

@@ -72,6 +73,26 @@ func PostCommentOnPullRequest(t *testing.T, topt *TestOpts, body string) {
7273
assert.NilError(t, err)
7374
}
7475

76+
func checkEvents(t *testing.T, events *corev1.EventList, topts *TestOpts) {
77+
t.Helper()
78+
newEvents := make([]corev1.Event, 0)
79+
// filter out events that are not related to the test like checking for cancelled pipelineruns
80+
for i := len(events.Items) - 1; i >= 0; i-- {
81+
topts.ParamsRun.Clients.Log.Infof("Reason is %s", events.Items[i].Reason)
82+
if events.Items[i].Reason == "CancelInProgress" {
83+
continue
84+
}
85+
newEvents = append(newEvents, events.Items[i])
86+
}
87+
if len(newEvents) > 0 {
88+
topts.ParamsRun.Clients.Log.Infof("0 events expected in case of failure but got %d", len(newEvents))
89+
for _, em := range newEvents {
90+
topts.ParamsRun.Clients.Log.Infof("Event: Reason: %s Type: %s ReportingInstance: %s Message: %s", em.Reason, em.Type, em.ReportingInstance, em.Message)
91+
}
92+
t.FailNow()
93+
}
94+
}
95+
7596
func AddLabelToIssue(t *testing.T, topt *TestOpts, label string) {
7697
var targetID int64
7798
allLabels, _, err := topt.GiteaCNX.Client.ListRepoLabels(topt.Opts.Organization, topt.Opts.Repo, gitea.ListLabelsOptions{})
@@ -249,7 +270,7 @@ func TestPR(t *testing.T, topts *TestOpts) (context.Context, func()) {
249270
}
250271
assert.Assert(t, len(events.Items) != 0, "events expected in case of failure but got 0")
251272
} else if !topts.SkipEventsCheck {
252-
assert.Assert(t, len(events.Items) == 0, fmt.Sprintf("no events expected but got %v in %v ns, items: %+v", len(events.Items), topts.TargetNS, events.Items))
273+
checkEvents(t, events, topts)
253274
}
254275
return ctx, cleanup
255276
}
@@ -369,7 +390,7 @@ func NewPR(t *testing.T, topts *TestOpts) func() {
369390
}
370391
assert.Assert(t, len(events.Items) != 0, "events expected in case of failure but got 0")
371392
} else if !topts.SkipEventsCheck {
372-
assert.Assert(t, len(events.Items) == 0, fmt.Sprintf("no events expected but got %v in %v ns, items: %+v", len(events.Items), topts.TargetNS, events.Items))
393+
checkEvents(t, events, topts)
373394
}
374395
return cleanup
375396
}

0 commit comments

Comments
 (0)