Skip to content

Commit 99502bb

Browse files
chore(ci): fix k8s validate comment job logic (vectordotdev#17841)
The comment validation job was incorrectly running on any workflow trigger that _wasn't_ the comment trigger. This resulted in the job running on contributor PRs and failing. On vector team member PRs, the job was being run excessively but passed because the validation passed. --------- Co-authored-by: Doug Smith <[email protected]>
1 parent 9c0d2f2 commit 99502bb

File tree

3 files changed

+25
-40
lines changed

3 files changed

+25
-40
lines changed

.github/workflows/comment-trigger.yml

+8
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
# /ci-run-unit-windows : runs Unit - Windows
1616
# /ci-run-environment : runs Environment Suite
1717
# /ci-run-regression : runs Regression Detection Suite
18+
# /ci-run-k8s : runs K8s E2E Suite
1819

1920
name: Comment Trigger
2021

@@ -55,6 +56,7 @@ jobs:
5556
|| contains(github.event.comment.body, '/ci-run-unit-windows')
5657
|| contains(github.event.comment.body, '/ci-run-environment')
5758
|| contains(github.event.comment.body, '/ci-run-regression')
59+
|| contains(github.event.comment.body, '/ci-run-k8s')
5860
)
5961
steps:
6062
- name: Get PR comment author
@@ -116,3 +118,9 @@ jobs:
116118
if: contains(github.event.comment.body, '/ci-run-all') || contains(github.event.comment.body, '/ci-run-regression')
117119
uses: ./.github/workflows/regression.yml
118120
secrets: inherit
121+
122+
k8s:
123+
needs: validate
124+
if: contains(github.event.comment.body, '/ci-run-all') || contains(github.event.comment.body, '/ci-run-k8s')
125+
uses: ./.github/workflows/k8s_e2e.yml
126+
secrets: inherit

.github/workflows/integration-comment.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -377,9 +377,9 @@ jobs:
377377
uses: xt0rted/pull-request-comment-branch@v2
378378
id: comment-branch
379379

380-
- name: (PR comment) Submit PR result as ${{ needs.test-integration.result }}
380+
- name: (PR comment) Submit PR result as ${{ needs.integration-tests.result }}
381381
uses: myrotvorets/[email protected]
382382
with:
383383
sha: ${{ steps.comment-branch.outputs.head_sha }}
384384
token: ${{ secrets.GITHUB_TOKEN }}
385-
status: ${{ needs.test-integration.result }}
385+
status: ${{ needs.integration-tests.result }}

.github/workflows/k8s_e2e.yml

+15-38
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,8 @@ name: K8S E2E Suite
1616

1717
on:
1818
workflow_dispatch:
19+
workflow_call:
1920
pull_request:
20-
issue_comment:
21-
types: [created]
2221
merge_group:
2322
types: [checks_requested]
2423
schedule:
@@ -27,7 +26,6 @@ on:
2726

2827
concurrency:
2928
group: ${{ github.workflow }}-${{ github.event.number || github.event.comment.html_url || github.event.merge_group.head_sha || github.event.schedule || github.sha }}
30-
3129
cancel-in-progress: true
3230

3331
env:
@@ -42,31 +40,9 @@ env:
4240
PROFILE: debug
4341

4442
jobs:
45-
validate:
46-
name: Validate comment
47-
runs-on: ubuntu-latest
48-
if: |
49-
github.event_name != 'issue_comment' ||
50-
( github.event.issue.pull_request &&
51-
( contains(github.event.comment.body, '/ci-run-all') ||
52-
contains(github.event.comment.body, '/ci-run-k8s')
53-
)
54-
)
55-
steps:
56-
- name: Get PR comment author
57-
id: comment
58-
uses: tspascoal/get-user-teams-membership@v2
59-
with:
60-
username: ${{ github.actor }}
61-
team: 'Vector'
62-
GITHUB_TOKEN: ${{ secrets.GH_PAT_ORG }}
63-
64-
- name: Validate author membership
65-
if: steps.comment.outputs.isTeamMember == 'false'
66-
run: exit 1
67-
6843
changes:
69-
needs: validate
44+
# Only evaluate files changed on pull request trigger
45+
if: github.event_name == 'pull_request'
7046
uses: ./.github/workflows/changes.yml
7147
with:
7248
base_ref: ${{ github.event.pull_request.base.ref }}
@@ -76,8 +52,9 @@ jobs:
7652
build-x86_64-unknown-linux-gnu:
7753
name: Build - x86_64-unknown-linux-gnu
7854
runs-on: [linux, ubuntu-20.04-4core]
79-
needs: [changes, validate]
80-
if: github.event_name != 'pull_request' || needs.changes.outputs.k8s == 'true'
55+
needs: changes
56+
# Run this job even if `changes` job is skipped (non- pull request trigger)
57+
if: ${{ !failure() && !cancelled() && (github.event_name != 'pull_request' || needs.changes.outputs.k8s == 'true') }}
8158
# cargo-deb requires a release build, but we don't need optimizations for tests
8259
env:
8360
CARGO_PROFILE_RELEASE_OPT_LEVEL: 0
@@ -141,8 +118,9 @@ jobs:
141118
compute-k8s-test-plan:
142119
name: Compute K8s test plan
143120
runs-on: ubuntu-latest
144-
needs: [changes, validate]
145-
if: github.event_name != 'pull_request' || needs.changes.outputs.k8s == 'true'
121+
needs: changes
122+
# Run this job even if `changes` job is skipped
123+
if: ${{ !failure() && !cancelled() && (github.event_name != 'pull_request' || needs.changes.outputs.k8s == 'true') }}
146124
outputs:
147125
matrix: ${{ steps.set-matrix.outputs.matrix }}
148126
steps:
@@ -195,9 +173,10 @@ jobs:
195173
name: K8s ${{ matrix.kubernetes_version.version }} / ${{ matrix.container_runtime }} (${{ matrix.kubernetes_version.role }})
196174
runs-on: [linux, ubuntu-20.04-4core]
197175
needs:
198-
- validate
199176
- build-x86_64-unknown-linux-gnu
200177
- compute-k8s-test-plan
178+
# because `changes` job might be skipped
179+
if: always() && needs.build-x86_64-unknown-linux-gnu.result == 'success' && needs.compute-k8s-test-plan.result == 'success'
201180
strategy:
202181
matrix: ${{ fromJson(needs.compute-k8s-test-plan.outputs.matrix) }}
203182
fail-fast: false
@@ -246,20 +225,18 @@ jobs:
246225
final-result:
247226
name: K8s E2E Suite
248227
runs-on: ubuntu-latest
249-
needs: [test-e2e-kubernetes, validate]
250-
if: |
251-
always() && (github.event_name != 'issue_comment' || (github.event.issue.pull_request
252-
&& (contains(github.event.comment.body, '/ci-run-k8s') || contains(github.event.comment.body, '/ci-run-all'))))
228+
needs: test-e2e-kubernetes
229+
if: always()
253230
env:
254231
FAILED: ${{ contains(needs.*.result, 'failure') }}
255232
steps:
256233
- name: (PR comment) Get PR branch
257-
if: success() && github.event_name == 'issue_comment'
234+
if: github.event_name == 'issue_comment' && env.FAILED != 'true'
258235
uses: xt0rted/pull-request-comment-branch@v2
259236
id: comment-branch
260237

261238
- name: (PR comment) Submit PR result as success
262-
if: success() && github.event_name == 'issue_comment'
239+
if: github.event_name == 'issue_comment' && env.FAILED != 'true'
263240
uses: myrotvorets/[email protected]
264241
with:
265242
sha: ${{ steps.comment-branch.outputs.head_sha }}

0 commit comments

Comments
 (0)