-
Notifications
You must be signed in to change notification settings - Fork 1.1k
262 lines (232 loc) · 9.55 KB
/
pr-e2e.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
name: pr-e2e-tests
on:
issue_comment:
types: [created]
env:
E2E_CHECK_NAME: e2e tests
jobs:
triage:
runs-on: ubuntu-latest
name: Comment evaluate
container: ghcr.io/kedacore/keda-tools:1.22.5
outputs:
run-e2e: ${{ startsWith(github.event.comment.body,'/run-e2e') && steps.checkUserMember.outputs.isTeamMember == 'true' }}
pr_num: ${{ steps.parser.outputs.pr_num }}
image_tag: "pr-${{ steps.parser.outputs.pr_num }}-${{ steps.parser.outputs.commit_sha }}"
commit_sha: ${{ steps.parser.outputs.commit_sha }}
steps:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4
- uses: tspascoal/get-user-teams-membership@v2
id: checkUserMember
with:
username: ${{ github.actor }}
team: "keda-e2e-test-executors"
GITHUB_TOKEN: ${{ secrets.GH_CHECKING_USER_AUTH }}
- name: Update comment with the execution url
if: ${{ startsWith(github.event.comment.body,'/run-e2e') && steps.checkUserMember.outputs.isTeamMember == 'true' }}
uses: peter-evans/create-or-update-comment@71345be0265236311c031f5c7866368bd1eff043 # v4
with:
comment-id: ${{ github.event.comment.id }}
body: |
**Update:** You can check the progress [here](https://github.com/${{github.repository}}/actions/runs/${{github.run_id}})
reactions: rocket
- name: Add label to skip e2e test
if: ${{ startsWith(github.event.comment.body,'/skip-e2e') && steps.checkUserMember.outputs.isTeamMember == 'true' }}
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7
with:
github-token: ${{ secrets.GH_AUTOMATION_PAT }}
script: |
github.rest.issues.addLabels({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
labels: ["skip-e2e"]
})
- name: Parse git info
if: ${{ startsWith(github.event.comment.body,'/run-e2e') && steps.checkUserMember.outputs.isTeamMember == 'true' }}
id: parser
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
# Get PR number
PR_URL="${{ github.event.issue.pull_request.url }}"
PR_NUM=${PR_URL##*/}
echo "Checking out from PR #$PR_NUM based on URL: $PR_URL"
echo "pr_num=$PR_NUM" >> $GITHUB_OUTPUT
# Get commit SHA
git config --global --add safe.directory "$GITHUB_WORKSPACE"
gh pr checkout $PR_NUM
SHA=$(git log -n 1 --pretty=format:"%H")
echo "commit_sha=$SHA" >> $GITHUB_OUTPUT
build-test-images:
needs: triage
runs-on: ubuntu-latest
name: Build images
container: ghcr.io/kedacore/keda-tools:1.22.5
if: needs.triage.outputs.run-e2e == 'true'
steps:
- name: Set status in-progress
uses: LouisBrunner/checks-action@6b626ffbad7cc56fd58627f774b9067e6118af23 # v2
with:
token: ${{ secrets.GITHUB_TOKEN }}
sha: ${{ needs.triage.outputs.commit_sha }}
name: ${{ env.E2E_CHECK_NAME }}
status: in_progress
details_url: https://github.com/${{github.repository}}/actions/runs/${{github.run_id}}
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4
- name: Register workspace path
run: git config --global --add safe.directory "$GITHUB_WORKSPACE"
- name: Checkout Pull Request
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
id: checkout
run: |
gh pr checkout ${{ needs.triage.outputs.pr_num }}
git checkout ${{ needs.triage.outputs.commit_sha }}
- name: Run regex checks
id: regex-validation
continue-on-error: true
env:
COMMENT_BODY: ${{ github.event.comment.body }}
run: |
MESSAGE="$COMMENT_BODY"
REGEX='/run-e2e (.+)'
if [[ "$MESSAGE" =~ $REGEX ]]
then
export E2E_TEST_REGEX="$(echo ${BASH_REMATCH[1]} | head -1)"
fi
make e2e-regex-check
- name: React to comment with failure
uses: dkershner6/reaction-action@v2
if: steps.regex-validation.outcome != 'success'
with:
token: ${{ secrets.GITHUB_TOKEN }}
commentId: ${{ github.event.comment.id }}
reaction: "-1"
- name: Set status failure
uses: LouisBrunner/checks-action@6b626ffbad7cc56fd58627f774b9067e6118af23 # v2
if: steps.regex-validation.outcome != 'success'
with:
token: ${{ secrets.GITHUB_TOKEN }}
sha: ${{ needs.triage.outputs.commit_sha }}
name: ${{ env.E2E_CHECK_NAME }}
conclusion: failure
details_url: https://github.com/${{github.repository}}/actions/runs/${{github.run_id}}
- name: Exit on failure
if: steps.regex-validation.outcome != 'success'
run: exit 1
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
# Username used to log in to a Docker registry. If not set then no login will occur
username: ${{ github.repository_owner }}
# Password or personal access token used to log in to a Docker registry. If not set then no login will occur
password: ${{ secrets.GH_AUTOMATION_PAT }}
# Server address of Docker registry. If not set then will default to Docker Hub
registry: ghcr.io
- name: Publish on GitHub Container Registry
run: make publish
env:
E2E_IMAGE_TAG: ${{ needs.triage.outputs.image_tag }}
run-test:
needs: [triage, build-test-images]
runs-on: e2e
name: Execute e2e tests
container: ghcr.io/kedacore/keda-tools:1.22.5
if: needs.triage.outputs.run-e2e == 'true'
steps:
- name: Set status in-progress
uses: LouisBrunner/checks-action@6b626ffbad7cc56fd58627f774b9067e6118af23 # v2
with:
token: ${{ secrets.GITHUB_TOKEN }}
sha: ${{ needs.triage.outputs.commit_sha }}
name: ${{ env.E2E_CHECK_NAME }}
status: in_progress
details_url: https://github.com/${{github.repository}}/actions/runs/${{github.run_id}}
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4
- name: Register workspace path
run: git config --global --add safe.directory "$GITHUB_WORKSPACE"
- name: Checkout Pull Request
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
id: checkout
run: |
gh pr checkout ${{ needs.triage.outputs.pr_num }}
git checkout ${{ needs.triage.outputs.commit_sha }}
- uses: oNaiPs/secrets-to-env-action@v1
with:
secrets: ${{ toJSON(secrets) }}
- name: Scale cluster
run: make scale-node-pool
env:
NODE_POOL_SIZE: 3
TEST_CLUSTER_NAME: keda-e2e-cluster-pr
- name: Run end to end tests
continue-on-error: true
id: test
env:
AWS_RUN_IDENTITY_TESTS: true
AZURE_RUN_WORKLOAD_IDENTITY_TESTS: true
GCP_RUN_IDENTITY_TESTS: true
ENABLE_OPENTELEMETRY: true
E2E_IMAGE_TAG: ${{ needs.triage.outputs.image_tag }}
TEST_CLUSTER_NAME: keda-e2e-cluster-pr
COMMENT_BODY: ${{ github.event.comment.body }}
run: |
MESSAGE="$COMMENT_BODY"
REGEX='/run-e2e (.+)'
if [[ "$MESSAGE" =~ $REGEX ]]
then
export E2E_TEST_REGEX="$(echo ${BASH_REMATCH[1]} | head -1)"
fi
echo "${{ needs.triage.outputs.pr_num }}"
make e2e-test
- name: Delete all e2e related namespaces
if: ${{ always() }}
run: make e2e-test-clean
env:
TEST_CLUSTER_NAME: keda-e2e-cluster-pr
- name: Scale cluster
if: ${{ always() }}
run: make scale-node-pool
env:
NODE_POOL_SIZE: 1
TEST_CLUSTER_NAME: keda-e2e-cluster-pr
- name: React to comment with success
uses: dkershner6/reaction-action@v2
if: steps.test.outcome == 'success'
with:
token: ${{ secrets.GITHUB_TOKEN }}
commentId: ${{ github.event.comment.id }}
reaction: "+1"
- name: Set status success
uses: LouisBrunner/checks-action@6b626ffbad7cc56fd58627f774b9067e6118af23 # v2
if: steps.test.outcome == 'success'
with:
token: ${{ secrets.GITHUB_TOKEN }}
sha: ${{ needs.triage.outputs.commit_sha }}
name: ${{ env.E2E_CHECK_NAME }}
conclusion: success
details_url: https://github.com/${{github.repository}}/actions/runs/${{github.run_id}}
- name: React to comment with failure
uses: dkershner6/reaction-action@v2
if: steps.test.outcome != 'success'
with:
token: ${{ secrets.GITHUB_TOKEN }}
commentId: ${{ github.event.comment.id }}
reaction: "-1"
- name: Set status failure
uses: LouisBrunner/checks-action@6b626ffbad7cc56fd58627f774b9067e6118af23 # v2
if: steps.test.outcome != 'success'
with:
token: ${{ secrets.GITHUB_TOKEN }}
sha: ${{ needs.triage.outputs.commit_sha }}
name: ${{ env.E2E_CHECK_NAME }}
conclusion: failure
details_url: https://github.com/${{github.repository}}/actions/runs/${{github.run_id}}
- name: Upload test logs
uses: actions/upload-artifact@50769540e7f4bd5e21e526ee35c689e35e0d6874 # v4
with:
name: e2e-test-logs
path: "${{ github.workspace }}/**/*.log"
if-no-files-found: ignore