Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Automatically add labels for all e2e-tests stages to PRs #3048

Closed
wants to merge 8 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions .github/workflows/new-pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: new-pr-opened
on:
pull_request:
types:
- opened
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we do this also in reopen?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd keep the current label state as the test might have already ran successfully, no?


env:
DEFAULT_LABEL: e2e-tests/not-run

jobs:
prepare_pr:
name: Prepare new PR
runs-on: ubuntu-latest
steps:
- name: Add '${{ env.DEFAULT_LABEL}}' label
id: add-label
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh pr edit ${{ github.event.number }} --add-label '${{ env.DEFAULT_LABEL}}' --repo $GITHUB_REPOSITORY
5 changes: 4 additions & 1 deletion .github/workflows/pr-e2e-pr-validation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,15 @@ on:
- labeled
- unlabeled

env:
E2E_LABEL: e2e-tests/ok-to-merge

jobs:
validate-e2e-labels:
name: Check e2e labels
runs-on: ubuntu-latest
steps:
- uses: docker://agilepathway/pull-request-label-checker:latest
with:
any_of: ok-to-merge
any_of: ${{ env.E2E_LABEL}}
repo_token: ${{ secrets.GITHUB_TOKEN }}
62 changes: 53 additions & 9 deletions .github/workflows/pr-e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@ on:
types: [created]

env:
E2E_LABEL: ok-to-merge
E2E_LABELS_NOTRUN: e2e-tests/not-run
E2E_LABELS_PASSED: e2e-tests/ok-to-merge
E2E_LABELS_FAILED: e2e-tests/failed
E2E_LABELS_RUNNING: e2e-tests/running

jobs:
triage:
Expand Down Expand Up @@ -48,13 +51,13 @@ jobs:
steps:
- uses: actions/checkout@v3

- name: Remove '${{ env.E2E_LABEL}}' label
- name: Remove '${{ env.E2E_LABELS_PASSED }}' label
id: remove-label
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
git config --global --add safe.directory "$GITHUB_WORKSPACE"
gh pr edit ${{ needs.triage.outputs.pr_num }} --remove-label '${{ env.E2E_LABEL}}'
gh pr edit ${{ needs.triage.outputs.pr_num }} --remove-label '${{ env.E2E_LABELS_PASSED}}'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we add here other labels like not-run?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea, but will see if we want this based on the main conversation


- name: Checkout Pull Request
env:
Expand Down Expand Up @@ -89,13 +92,37 @@ jobs:
steps:
- uses: actions/checkout@v3

- name: Remove '${{ env.E2E_LABEL}}' label
id: remove-label
- name: Remove '${{ env.E2E_LABELS_NOTRUN}}' label
id: remove-not-run-label
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
git config --global --add safe.directory "$GITHUB_WORKSPACE"
gh pr edit ${{ needs.triage.outputs.pr_num }} --remove-label '${{ env.E2E_LABELS_NOTRUN}}'

- name: Remove '${{ env.E2E_LABELS_PASSED}}' label
id: remove-pass-label
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
git config --global --add safe.directory "$GITHUB_WORKSPACE"
gh pr edit ${{ needs.triage.outputs.pr_num }} --remove-label '${{ env.E2E_LABELS_PASSED}}'

- name: Remove '${{ env.E2E_LABELS_FAILED }}' label
id: remove-failed-label
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
git config --global --add safe.directory "$GITHUB_WORKSPACE"
gh pr edit ${{ needs.triage.outputs.pr_num }} --remove-label '${{ env.E2E_LABEL}}'
gh pr edit ${{ needs.triage.outputs.pr_num }} --remove-label '${{ env.E2E_LABELS_FAILED }}'

- name: Add '${{ env.E2E_LABELS_RUNNING }}' label
id: add-running-label
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
git config --global --add safe.directory "$GITHUB_WORKSPACE"
gh pr edit ${{ needs.triage.outputs.pr_num }} --add-label '${{ env.E2E_LABELS_RUNNING }}'
Comment on lines +95 to +125
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we merge these 3 steps into a single one? We can reduce a lot of lines just appending the gh lines to one of them

Copy link
Member Author

@tomkerkhove tomkerkhove May 16, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea, but will see if we want this based on the main conversation


- name: Checkout Pull Request
env:
Expand Down Expand Up @@ -168,6 +195,14 @@ jobs:
AZURE_SUBSCRIPTION: ${{ secrets.AZURE_SUBSCRIPTION }}
TEST_CLUSTER_NAME: keda-pr-run

- name: Remove '${{ env.E2E_LABELS_RUNNING }}' label
id: remove-running-label
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
git config --global --add safe.directory "$GITHUB_WORKSPACE"
gh pr edit ${{ needs.triage.outputs.pr_num }} --remove-label '${{ env.E2E_LABELS_RUNNING }}'

- name: React to comment with success
uses: dkershner6/reaction-action@v1
if: steps.test.outcome == 'success'
Expand All @@ -176,14 +211,14 @@ jobs:
commentId: ${{ github.event.comment.id }}
reaction: "+1"

- name: Add '${{ env.E2E_LABEL}}' label
id: add-label
- name: Add '${{ env.E2E_LABELS_PASSED }}' label
id: add-pass-label
if: steps.test.outcome == 'success'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
git config --global --add safe.directory "$GITHUB_WORKSPACE"
gh pr edit ${{ needs.triage.outputs.pr_num }} --add-label '${{ env.E2E_LABEL}}'
gh pr edit ${{ needs.triage.outputs.pr_num }} --add-label '${{ env.E2E_LABELS_PASSED }}'

- name: React to comment with failure
uses: dkershner6/reaction-action@v1
Expand All @@ -192,3 +227,12 @@ jobs:
token: ${{ secrets.GITHUB_TOKEN }}
commentId: ${{ github.event.comment.id }}
reaction: "-1"

- name: Add '${{ env.E2E_LABELS_FAILED }}' label
id: add-failure-label
if: steps.test.outcome != 'success'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
git config --global --add safe.directory "$GITHUB_WORKSPACE"
gh pr edit ${{ needs.triage.outputs.pr_num }} --add-label '${{ env.E2E_LABELS_FAILED }}'