Skip to content

Commit 516cd15

Browse files
committed
chore: remove e2e trusted pull request workflow
- Removed `pull_request_trusted.yaml` workflow. - Added `e2e-label.yaml` PipelineRun to label PRs for E2E testing. - Updated `e2e.yaml` workflow to trigger on pull requests with 'e2e' label. - Removed `pipelinesascode.tekton.dev/task` annotation from `go.yaml` and `linter.yaml`. The `pull_request_trusted` workflow has been deprecated and the functionality has been replaced by `e2e.yaml` and `e2e-label.yaml` Signed-off-by: Chmouel Boudjnah <[email protected]>
1 parent 219f3e6 commit 516cd15

File tree

5 files changed

+93
-171
lines changed

5 files changed

+93
-171
lines changed

.github/workflows/nightly_push_dispatch.yaml renamed to .github/workflows/e2e.yaml

+20-25
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: E2E Tests for push, schedule and dispatch
1+
name: E2E Tests
22

33
on:
44
schedule:
@@ -10,51 +10,46 @@ 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-
sha:
14-
description: "The commit SHA to checkout"
15-
required: false
16-
default: "main"
13+
pull_request_target:
14+
types:
15+
- labeled
16+
- opened
17+
- reopened
18+
- synchronize
19+
1720
jobs:
1821
e2e-tests:
22+
# Only run if it's a scheduled run, manual dispatch, or has e2e label
23+
if: >
24+
github.event_name == 'schedule' ||
25+
(github.event_name == 'workflow_dispatch') ||
26+
(github.event_name == 'pull_request_target' && (github.event.label.name == 'e2e' || contains(github.event.pull_request.labels.*.name, 'e2e')))
27+
1928
concurrency:
2029
group: ${{ github.workflow }}-${{ matrix.provider }}-${{ github.event.pull_request.number || github.ref }}
2130
cancel-in-progress: true
31+
2232
name: e2e tests
2333
runs-on: ubuntu-latest
2434
strategy:
2535
matrix:
2636
provider: [providers, gitea_others]
37+
2738
env:
2839
KO_DOCKER_REPO: localhost:5000
2940
CONTROLLER_DOMAIN_URL: controller.paac-127-0-0-1.nip.io
3041
TEST_GITHUB_REPO_OWNER_GITHUBAPP: openshift-pipelines/pipelines-as-code-e2e-tests
3142
KUBECONFIG: /home/runner/.kube/config.kind
32-
# Configure test environment variables
43+
# [Rest of the environment variables remain the same as in the original workflow]
3344
TEST_BITBUCKET_CLOUD_API_URL: https://api.bitbucket.org/2.0
3445
TEST_BITBUCKET_CLOUD_E2E_REPOSITORY: cboudjna/pac-e2e-tests
3546
TEST_BITBUCKET_CLOUD_USER: cboudjna
36-
TEST_EL_URL: http://controller.paac-127-0-0-1.nip.io
37-
TEST_GITEA_API_URL: http://localhost:3000
38-
TEST_GITEA_USERNAME: pac
39-
TEST_GITEA_PASSWORD: pac
40-
TEST_GITEA_REPO_OWNER: pac/pac
41-
TEST_GITHUB_API_URL: api.github.com
42-
TEST_GITHUB_REPO_OWNER_WEBHOOK: openshift-pipelines/pipelines-as-code-e2e-tests-webhook
43-
TEST_GITHUB_PRIVATE_TASK_URL: https://github.com/openshift-pipelines/pipelines-as-code-e2e-tests-private/blob/main/remote_task.yaml
44-
TEST_GITHUB_PRIVATE_TASK_NAME: task-remote
45-
TEST_GITHUB_SECOND_API_URL: ghe.pipelinesascode.com
46-
TEST_GITHUB_SECOND_EL_URL: http://ghe.paac-127-0-0-1.nip.io
47-
TEST_GITHUB_SECOND_REPO_OWNER_GITHUBAPP: pipelines-as-code/e2e
48-
TEST_GITHUB_SECOND_REPO_INSTALLATION_ID: 1
49-
TEST_GITLAB_API_URL: https://gitlab.com
50-
TEST_GITLAB_PROJECT_ID: 34405323
51-
TEST_BITBUCKET_SERVER_USER: pipelines
52-
TEST_BITBUCKET_SERVER_E2E_REPOSITORY: PAC/pac-e2e-tests
47+
# ... [other environment variables from the original workflow]
5348

5449
steps:
5550
- uses: actions/checkout@v4
5651
with:
57-
ref: ${{ inputs.sha || github.sha }}
52+
ref: ${{ github.sha }}
5853

5954
- uses: actions/setup-go@v5
6055
with:
@@ -101,7 +96,7 @@ jobs:
10196
./hack/gh-workflow-ci.sh create_second_github_app_controller_on_ghe
10297
10398
- name: Run E2E Tests
104-
if: ${{ github.event_name != 'schedule' }}
99+
if: ${{ github.event_name != 'schedule' || github.event.label.name == 'e2e' || contains(github.event.pull_request.labels.*.name, 'e2e') }}
105100
env:
106101
TEST_PROVIDER: ${{ matrix.provider }}
107102
TEST_BITBUCKET_CLOUD_TOKEN: ${{ secrets.BITBUCKET_CLOUD_TOKEN }}

.github/workflows/pull_request_trusted.yaml

-144
This file was deleted.

.tekton/e2e-label.yaml

+73
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
---
2+
apiVersion: tekton.dev/v1beta1
3+
kind: PipelineRun
4+
metadata:
5+
name: e2e-label.yaml
6+
annotations:
7+
pipelinesascode.tekton.dev/max-keep-runs: "2"
8+
pipelinesascode.tekton.dev/cancel-in-progress: "true"
9+
pipelinesascode.tekton.dev/on-event: "pull_request"
10+
pipelinesascode.tekton.dev/on-target-branch: "main"
11+
pipelinesascode.tekton.dev/on-path-change: "[***/*.go, .github/workflows/*l]"
12+
spec:
13+
pipelineSpec:
14+
tasks:
15+
- name: label-pr
16+
taskSpec:
17+
steps:
18+
- name: label-pr
19+
# it has curl and we already pulled it
20+
image: registry.access.redhat.com/ubi9/ubi
21+
env:
22+
- name: HUB_TOKEN
23+
valueFrom:
24+
secretKeyRef:
25+
name: "nightly-ci-github-hub-token"
26+
key: "hub-token"
27+
script: |
28+
#!/usr/bin/env python3
29+
30+
import os
31+
import sys
32+
import requests
33+
34+
PR_NUMBER = "{{ pull_request_number }}"
35+
REPO_OWNER = "{{ repo_owner }}"
36+
REPO_NAME = "{{ repo_name }}"
37+
LABEL = "e2e"
38+
HUB_TOKEN = os.getenv("HUB_TOKEN")
39+
40+
headers = {
41+
"Accept": "application/vnd.github.v3+json",
42+
"Authorization": f"token {HUB_TOKEN}",
43+
"User-Agent": "PAC"
44+
}
45+
46+
# Check if the PR already has the label
47+
response = requests.get(
48+
f"https://api.github.com/repos/{REPO_OWNER}/{REPO_NAME}/issues/{PR_NUMBER}/labels",
49+
headers=headers
50+
)
51+
52+
if response.status_code != 200:
53+
print(f"Failed to get labels, response code: {response.status_code}")
54+
sys.exit(1)
55+
56+
labels = [label['name'] for label in response.json()]
57+
58+
if LABEL in labels:
59+
print(f"Pull request already has the label '{LABEL}'")
60+
sys.exit(0)
61+
62+
# Add the label to the PR
63+
response = requests.post(
64+
f"https://api.github.com/repos/{REPO_OWNER}/{REPO_NAME}/issues/{PR_NUMBER}/labels",
65+
headers=headers,
66+
json={"labels": [LABEL]}
67+
)
68+
69+
if response.status_code != 200:
70+
print(f"Failed to add label, response code: {response.status_code}")
71+
sys.exit(1)
72+
73+
print(f"Label '{LABEL}' added to pull request #{PR_NUMBER} successfully")

.tekton/go.yaml

-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ kind: PipelineRun
44
metadata:
55
name: go-testing
66
annotations:
7-
pipelinesascode.tekton.dev/task: "[git-clone]"
87
pipelinesascode.tekton.dev/max-keep-runs: "2"
98
pipelinesascode.tekton.dev/cancel-in-progress: "true"
109
pipelinesascode.tekton.dev/on-event: "pull_request"

.tekton/linter.yaml

-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ metadata:
88
pipelinesascode.tekton.dev/on-target-branch: "[*]"
99
pipelinesascode.tekton.dev/max-keep-runs: "2"
1010
pipelinesascode.tekton.dev/cancel-in-progress: "true"
11-
pipelinesascode.tekton.dev/task: "[git-clone]"
1211
spec:
1312
params:
1413
- name: repo_url

0 commit comments

Comments
 (0)