Skip to content

Commit

Permalink
chore: Use GH Checks API for manual e2e tests (#3071)
Browse files Browse the repository at this point in the history
  • Loading branch information
Jorge Turrado Ferrero authored Jun 1, 2022
1 parent 97fb357 commit f7a06b6
Show file tree
Hide file tree
Showing 5 changed files with 123 additions and 46 deletions.
35 changes: 35 additions & 0 deletions .github/workflows/pr-e2e-checker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: e2e-tests
on:
pull_request_target:
types:
- labeled
- unlabeled

env:
SKIP_E2E_TAG: skip-e2e
E2E_CHECK_NAME: e2e tests

jobs:
e2e-checker:
name: label checker
runs-on: ubuntu-latest
steps:
- uses: LouisBrunner/checks-action@v1.1.1
name: Enqueue e2e
id: create
with:
token: ${{ secrets.GITHUB_TOKEN }}
sha: ${{ github.event.pull_request.head.sha }}
name: ${{ env.E2E_CHECK_NAME }}
status: queued

- uses: LouisBrunner/checks-action@v1.1.1
name: Skip e2e
if: ${{ contains(github.event.pull_request.labels.*.name, env.SKIP_E2E_TAG )}}
with:
token: ${{ secrets.GITHUB_TOKEN }}
sha: ${{ github.event.pull_request.head.sha }}
check_id: ${{ steps.create.outputs.check_id }}
conclusion: success
output: |
{"summary": "skipped by maintainer"}
35 changes: 35 additions & 0 deletions .github/workflows/pr-e2e-creator.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: e2e-tests
on:
pull_request_target:
types:
- opened
- synchronize

env:
SKIP_E2E_TAG: skip-e2e
E2E_CHECK_NAME: e2e tests

jobs:
check-creator:
name: check-creator
runs-on: ubuntu-latest
steps:
- uses: LouisBrunner/checks-action@v1.1.1
name: Enqueue e2e
id: create
with:
token: ${{ secrets.GITHUB_TOKEN }}
sha: ${{ github.event.pull_request.head.sha }}
name: ${{ env.E2E_CHECK_NAME }}
status: queued

- uses: LouisBrunner/checks-action@v1.1.1
name: Skip e2e
if: ${{ contains(github.event.pull_request.labels.*.name, env.SKIP_E2E_TAG )}}
with:
token: ${{ secrets.GITHUB_TOKEN }}
sha: ${{ github.event.pull_request.head.sha }}
check_id: ${{ steps.create.outputs.check_id }}
conclusion: success
output: |
{"summary": "skipped by maintainer"}
19 changes: 0 additions & 19 deletions .github/workflows/pr-e2e-pr-validation.yml

This file was deleted.

77 changes: 51 additions & 26 deletions .github/workflows/pr-e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ on:
types: [created]

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

jobs:
triage:
Expand All @@ -13,8 +13,11 @@ jobs:
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 }}-${{ github.event.comment.id }}"
image_tag: "pr-${{ steps.parser.outputs.pr_num }}-${{ steps.parser.outputs.commit_sha }}"
commit_sha: ${{ steps.parser.outputs.commit_sha }}
steps:
- uses: actions/checkout@v3

- uses: tspascoal/get-user-teams-membership@v1
id: checkUserMember
with:
Expand All @@ -31,13 +34,22 @@ jobs:
**Update:** You can check the progres [here](https://github.com/${{github.repository}}/actions/runs/${{github.run_id}})
reactions: rocket

- name: Get Pull Request number
- 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 "::set-output name=pr_num::$PR_NUM"
# 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 "::set-output name=commit_sha::$SHA"
build-test-images:
needs: triage
Expand All @@ -46,15 +58,16 @@ jobs:
container: ghcr.io/kedacore/build-tools:main
if: needs.triage.outputs.run-e2e == 'true'
steps:
- uses: actions/checkout@v3
- name: Set status in-progress
uses: LouisBrunner/checks-action@v1.1.1
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}}

- name: Remove '${{ env.E2E_LABEL}}' 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}}'
- uses: actions/checkout@v3

- name: Checkout Pull Request
env:
Expand Down Expand Up @@ -87,15 +100,16 @@ jobs:
concurrency: pr-e2e-tests
if: needs.triage.outputs.run-e2e == 'true'
steps:
- uses: actions/checkout@v3
- name: Set status in-progress
uses: LouisBrunner/checks-action@v1.1.1
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}}

- name: Remove '${{ env.E2E_LABEL}}' 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}}'
- uses: actions/checkout@v3

- name: Checkout Pull Request
env:
Expand Down Expand Up @@ -176,14 +190,15 @@ jobs:
commentId: ${{ github.event.comment.id }}
reaction: "+1"

- name: Add '${{ env.E2E_LABEL}}' label
id: add-label
- name: Set status success
uses: LouisBrunner/checks-action@v1.1.1
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}}'
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@v1
Expand All @@ -192,3 +207,13 @@ jobs:
token: ${{ secrets.GITHUB_TOKEN }}
commentId: ${{ github.event.comment.id }}
reaction: "-1"

- name: Set status failure
uses: LouisBrunner/checks-action@v1.1.1
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}}
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,9 @@ To learn more about our roadmap, we recommend reading [this document](ROADMAP.md

### Other

- **General:** Improve e2e on PR process. ([3004](https://github.com/kedacore/keda/issues/3004))
- **General:** Fix devcontainer on ARM64 Arch. ([3084](https://github.com/kedacore/keda/issues/3084))
- **General:** Improve e2e on PR process. ([3004](https://github.com/kedacore/keda/issues/3004))
- **General:** Use Github's Checks API for e2e tests on PR. ([2567](https://github.com/kedacore/keda/issues/2567))

## v2.7.1

Expand Down

0 comments on commit f7a06b6

Please sign in to comment.