Skip to content

Commit f51eb61

Browse files
committed
fix(workflow): update e2e test workflows
Renamed the existing GitHub Actions workflow for nightly push dispatch and created a new workflow for pull requests from trusted users. The new workflow includes steps to check user permissions, set up the environment, and run E2E tests. Signed-off-by: Chmouel Boudjnah <[email protected]>
1 parent 1c12fe0 commit f51eb61

File tree

2 files changed

+155
-3
lines changed

2 files changed

+155
-3
lines changed

.github/workflows/kind-e2e-tests.yaml renamed to .github/workflows/nightly_push_dispatch.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: E2E Tests on Kind
1+
name: E2E Tests for push, schedule and dispatch
22

33
on:
44
schedule:
@@ -55,7 +55,7 @@ jobs:
5555
steps:
5656
- uses: actions/checkout@v4
5757
with:
58-
ref: ${{ github.event.pull_request.head.sha }}
58+
ref: ${{ github.sha }}
5959

6060
- uses: actions/setup-go@v5
6161
with:
@@ -101,7 +101,7 @@ jobs:
101101
run: |
102102
./hack/gh-workflow-ci.sh create_second_github_app_controller_on_ghe
103103
104-
- name: Run E2E Tests on pull_request
104+
- name: Run E2E Tests
105105
if: ${{ github.event_name != 'schedule' }}
106106
env:
107107
TEST_PROVIDER: ${{ matrix.provider }}
Lines changed: 152 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,152 @@
1+
name: E2E Tests on Kind for trusted users
2+
3+
on:
4+
pull_request_target:
5+
types: [opened, synchronize, reopened]
6+
paths:
7+
- "**.go"
8+
9+
jobs:
10+
e2e-tests:
11+
concurrency:
12+
group: ${{ github.workflow }}-${{ matrix.provider }}-${{ github.event.pull_request.number || github.ref }}
13+
cancel-in-progress: true
14+
name: e2e tests
15+
runs-on: ubuntu-latest
16+
if: >
17+
(github.event_name == 'pull_request_target' || github.event_name == 'pull_request') &&
18+
contains(fromJson('["chmouel", "zakisk", "savitaashture", "aThorp96", "vdemeester"]'), github.event.pull_request.user.login)
19+
strategy:
20+
matrix:
21+
provider: [providers, gitea_others]
22+
env:
23+
KO_DOCKER_REPO: localhost:5000
24+
CONTROLLER_DOMAIN_URL: controller.paac-127-0-0-1.nip.io
25+
TEST_GITHUB_REPO_OWNER_GITHUBAPP: openshift-pipelines/pipelines-as-code-e2e-tests
26+
KUBECONFIG: /home/runner/.kube/config.kind
27+
# Configure test environment variables
28+
TEST_BITBUCKET_CLOUD_API_URL: https://api.bitbucket.org/2.0
29+
TEST_BITBUCKET_CLOUD_E2E_REPOSITORY: cboudjna/pac-e2e-tests
30+
TEST_BITBUCKET_CLOUD_USER: cboudjna
31+
TEST_EL_URL: http://controller.paac-127-0-0-1.nip.io
32+
TEST_GITEA_API_URL: http://localhost:3000
33+
TEST_GITEA_USERNAME: pac
34+
TEST_GITEA_PASSWORD: pac
35+
TEST_GITEA_REPO_OWNER: pac/pac
36+
TEST_GITHUB_API_URL: api.github.com
37+
TEST_GITHUB_REPO_OWNER_WEBHOOK: openshift-pipelines/pipelines-as-code-e2e-tests-webhook
38+
TEST_GITHUB_PRIVATE_TASK_URL: https://github.com/openshift-pipelines/pipelines-as-code-e2e-tests-private/blob/main/remote_task.yaml
39+
TEST_GITHUB_PRIVATE_TASK_NAME: task-remote
40+
TEST_GITHUB_SECOND_API_URL: ghe.pipelinesascode.com
41+
TEST_GITHUB_SECOND_EL_URL: http://ghe.paac-127-0-0-1.nip.io
42+
TEST_GITHUB_SECOND_REPO_OWNER_GITHUBAPP: pipelines-as-code/e2e
43+
TEST_GITHUB_SECOND_REPO_INSTALLATION_ID: 1
44+
TEST_GITLAB_API_URL: https://gitlab.com
45+
TEST_GITLAB_PROJECT_ID: 34405323
46+
TEST_BITBUCKET_SERVER_USER: pipelines
47+
TEST_BITBUCKET_SERVER_E2E_REPOSITORY: PAC/pac-e2e-tests
48+
49+
steps:
50+
- uses: actions/checkout@v4
51+
with:
52+
ref: ${{ github.event.pull_request.head.sha }}
53+
54+
- name: Check if user is an admin
55+
id: check-permissions
56+
run: |
57+
set -x
58+
USER_LOGIN="${{ github.event.pull_request.user.login }}"
59+
REPO_FULL_NAME="${{ github.repository }}"
60+
echo "Checking permissions for user: $USER_LOGIN in repo: $REPO_FULL_NAME"
61+
62+
# Fetch user permissions using GitHub API
63+
PERMISSIONS=$(curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
64+
"https://api.github.com/repos/$REPO_FULL_NAME/collaborators/$USER_LOGIN/permission")
65+
66+
# Extract the permission level
67+
PERMISSION_LEVEL=$(echo "$PERMISSIONS" | jq -r '.permission')
68+
69+
# Set output variable to indicate if the user is an admin
70+
if [[ "$PERMISSION_LEVEL" == "admin" ]]; then
71+
echo "User is an admin."
72+
echo "is-admin=true" >> $GITHUB_OUTPUT
73+
else
74+
echo "User is not an admin."
75+
echo "is-admin=false" >> $GITHUB_OUTPUT
76+
fi
77+
shell: bash
78+
79+
- uses: actions/setup-go@v5
80+
with:
81+
go-version-file: "go.mod"
82+
83+
- uses: ko-build/[email protected]
84+
85+
- name: Install gosmee
86+
uses: jaxxstorm/[email protected]
87+
with:
88+
repo: chmouel/gosmee
89+
90+
- name: Run gosmee
91+
run: |
92+
nohup gosmee client --saveDir /tmp/gosmee-replay ${{ secrets.PYSMEE_URL }} "http://${CONTROLLER_DOMAIN_URL}" &
93+
94+
- name: Setup tmate session
95+
uses: mxschmitt/action-tmate@v3
96+
if: ${{ github.event_name == 'workflow_dispatch' && inputs.debug_enabled }}
97+
with:
98+
detached: true
99+
limit-access-to-actor: true
100+
101+
- name: Start installing cluster
102+
run: |
103+
export PAC_DIR=${PWD}
104+
export TEST_GITEA_SMEEURL="${{ secrets.TEST_GITEA_SMEEURL }}"
105+
bash -x ./hack/dev/kind/install.sh
106+
107+
- name: Create PAC github-app-secret
108+
env:
109+
PAC_GITHUB_PRIVATE_KEY: ${{ secrets.APP_PRIVATE_KEY }}
110+
PAC_GITHUB_APPLICATION_ID: ${{ secrets.APPLICATION_ID }}
111+
PAC_WEBHOOK_SECRET: ${{ secrets.WEBHOOK_SECRET }}
112+
run: |
113+
./hack/gh-workflow-ci.sh create_pac_github_app_secret
114+
115+
- name: Create second Github APP Controller on GHE
116+
env:
117+
TEST_GITHUB_SECOND_SMEE_URL: ${{ secrets.TEST_GITHUB_SECOND_SMEE_URL }}
118+
TEST_GITHUB_SECOND_PRIVATE_KEY: ${{ secrets.TEST_GITHUB_SECOND_PRIVATE_KEY }}
119+
TEST_GITHUB_SECOND_WEBHOOK_SECRET: ${{ secrets.TEST_GITHUB_SECOND_WEBHOOK_SECRET }}
120+
run: |
121+
./hack/gh-workflow-ci.sh create_second_github_app_controller_on_ghe
122+
123+
- name: Run E2E Tests on pull_request
124+
env:
125+
TEST_PROVIDER: ${{ matrix.provider }}
126+
TEST_BITBUCKET_CLOUD_TOKEN: ${{ secrets.BITBUCKET_CLOUD_TOKEN }}
127+
TEST_EL_WEBHOOK_SECRET: ${{ secrets.WEBHOOK_SECRET }}
128+
TEST_GITEA_SMEEURL: ${{ secrets.TEST_GITEA_SMEEURL }}
129+
TEST_GITHUB_REPO_INSTALLATION_ID: ${{ secrets.INSTALLATION_ID }}
130+
TEST_GITHUB_TOKEN: ${{ secrets.GH_APPS_TOKEN }}
131+
TEST_GITHUB_SECOND_TOKEN: ${{ secrets.TEST_GITHUB_SECOND_TOKEN }}
132+
TEST_GITLAB_TOKEN: ${{ secrets.GITLAB_TOKEN }}
133+
TEST_BITBUCKET_SERVER_TOKEN: ${{ secrets.BITBUCKET_SERVER_TOKEN }}
134+
TEST_BITBUCKET_SERVER_API_URL: ${{ secrets.BITBUCKET_SERVER_API_URL }}
135+
TEST_BITBUCKET_SERVER_WEBHOOK_SECRET: ${{ secrets.BITBUCKET_SERVER_WEBHOOK_SECRET }}
136+
run: |
137+
./hack/gh-workflow-ci.sh run_e2e_tests
138+
139+
- name: Collect logs
140+
if: ${{ always() }}
141+
env:
142+
TEST_GITEA_SMEEURL: ${{ secrets.TEST_GITEA_SMEEURL }}
143+
TEST_GITHUB_SECOND_SMEE_URL: ${{ secrets.TEST_GITHUB_SECOND_SMEE_URL }}
144+
run: |
145+
./hack/gh-workflow-ci.sh collect_logs
146+
147+
- name: Upload artifacts
148+
if: ${{ always() }}
149+
uses: actions/upload-artifact@v4
150+
with:
151+
name: logs-e2e-tests-${{ matrix.provider }}
152+
path: /tmp/logs

0 commit comments

Comments
 (0)