Skip to content

Commit

Permalink
chore(ci): correctly validate comment author in k8s e2e job (#17818)
Browse files Browse the repository at this point in the history
  • Loading branch information
dsmith3197 authored Jun 30, 2023
1 parent 812929b commit b8e3dbe
Showing 1 changed file with 28 additions and 29 deletions.
57 changes: 28 additions & 29 deletions .github/workflows/k8s_e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,31 @@ env:
PROFILE: debug

jobs:
validate:
name: Validate comment
runs-on: ubuntu-latest
if: |
github.event_name != 'issue_comment' ||
( github.event.issue.pull_request &&
( contains(github.event.comment.body, '/ci-run-all') ||
contains(github.event.comment.body, '/ci-run-k8s')
)
)
steps:
- name: Get PR comment author
id: comment
uses: tspascoal/get-user-teams-membership@v2
with:
username: ${{ github.actor }}
team: 'Vector'
GITHUB_TOKEN: ${{ secrets.GH_PAT_ORG }}

- name: Validate author membership
if: steps.comment.outputs.isTeamMember == 'false'
run: exit 1

changes:
if: github.event_name != 'issue_comment' || (github.event.issue.pull_request &&
(contains(github.event.comment.body, '/ci-run-k8s') || contains(github.event.comment.body, '/ci-run-all')))
needs: validate
uses: ./.github/workflows/changes.yml
with:
base_ref: ${{ github.event.pull_request.base.ref }}
Expand All @@ -54,22 +76,14 @@ jobs:
build-x86_64-unknown-linux-gnu:
name: Build - x86_64-unknown-linux-gnu
runs-on: [linux, ubuntu-20.04-4core]
needs: changes
needs: [changes, validate]
if: github.event_name != 'pull_request' || needs.changes.outputs.k8s == 'true'
# cargo-deb requires a release build, but we don't need optimizations for tests
env:
CARGO_PROFILE_RELEASE_OPT_LEVEL: 0
CARGO_PROFILE_RELEASE_CODEGEN_UNITS: 256
CARGO_INCREMENTAL: 0
steps:
- name: Validate issue comment
if: github.event_name == 'issue_comment'
uses: tspascoal/get-user-teams-membership@v2
with:
username: ${{ github.actor }}
team: 'Vector'
GITHUB_TOKEN: ${{ secrets.GH_PAT_ORG }}

- name: (PR comment) Get PR branch
if: ${{ github.event_name == 'issue_comment' }}
uses: xt0rted/pull-request-comment-branch@v2
Expand Down Expand Up @@ -127,19 +141,11 @@ jobs:
compute-k8s-test-plan:
name: Compute K8s test plan
runs-on: ubuntu-latest
needs: changes
needs: [changes, validate]
if: github.event_name != 'pull_request' || needs.changes.outputs.k8s == 'true'
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
- name: Validate issue comment
if: github.event_name == 'issue_comment'
uses: tspascoal/get-user-teams-membership@v2
with:
username: ${{ github.actor }}
team: 'Vector'
GITHUB_TOKEN: ${{ secrets.GH_PAT_ORG }}

- uses: actions/github-script@v6.4.1
id: set-matrix
with:
Expand Down Expand Up @@ -189,6 +195,7 @@ jobs:
name: K8s ${{ matrix.kubernetes_version.version }} / ${{ matrix.container_runtime }} (${{ matrix.kubernetes_version.role }})
runs-on: [linux, ubuntu-20.04-4core]
needs:
- validate
- build-x86_64-unknown-linux-gnu
- compute-k8s-test-plan
strategy:
Expand Down Expand Up @@ -239,21 +246,13 @@ jobs:
final-result:
name: K8s E2E Suite
runs-on: ubuntu-latest
needs: test-e2e-kubernetes
needs: [test-e2e-kubernetes, validate]
if: |
always() && (github.event_name != 'issue_comment' || (github.event.issue.pull_request
&& (contains(github.event.comment.body, '/ci-run-k8s') || contains(github.event.comment.body, '/ci-run-all'))))
env:
FAILED: ${{ contains(needs.*.result, 'failure') }}
steps:
- name: Validate issue comment
if: github.event_name == 'issue_comment'
uses: tspascoal/get-user-teams-membership@v2
with:
username: ${{ github.actor }}
team: 'Vector'
GITHUB_TOKEN: ${{ secrets.GH_PAT_ORG }}

- name: (PR comment) Get PR branch
if: success() && github.event_name == 'issue_comment'
uses: xt0rted/pull-request-comment-branch@v2
Expand Down

0 comments on commit b8e3dbe

Please sign in to comment.