Skip to content

Commit

Permalink
Set PR status checks.
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewsomething committed Feb 7, 2023
1 parent 21c87b8 commit 68d4138
Show file tree
Hide file tree
Showing 2 changed files with 69 additions and 33 deletions.
69 changes: 69 additions & 0 deletions .github/workflows/acceptance-test-pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
on:
repository_dispatch:
types: [testacc-command]

name: Acceptance Test PR

jobs:
acceptance:
runs-on: ubuntu-latest
if:
github.event.client_payload.slash_command.sha != '' &&
github.event.client_payload.slash_command.pkg != '' &&
github.event.client_payload.pull_request.head.sha == github.event.client_payload.slash_command.sha

concurrency: ${{ github.workflow }}-${{ github.event.client_payload.slash_command.pkg }}-${{ github.event.client_payload.pull_request.number }}

steps:
- name: Set status pending
run: |
gh api --method POST -H "Accept: application/vnd.github+json" \
/repos/${{ github.repository }}/statuses/${{ github.event.client_payload.pull_request.head.sha }} \
-f state='pending' \
-f target_url='https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}' \
-f description='Running acceptance tests...' \
-f context='acceptance/${{ github.event.client_payload.slash_command.pkg }}'
env:
GH_TOKEN: ${{ github.token }}

- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.19.x

- name: Checkout PR
uses: actions/checkout@v2
with:
ref: ${{ github.event.client_payload.slash_command.sha }}

- name: Run Acceptance Tests
id: run_tests
run: make PKG_NAME="${{ github.event.client_payload.slash_command.pkg }}" testacc
env:
ACCTEST_PARALLELISM: 10
DIGITALOCEAN_TOKEN: ${{ secrets.ACCEPTANCE_TESTS_TOKEN }}
SPACES_ACCESS_KEY_ID: ${{ secrets.SPACES_ACCESS_KEY_ID }}
SPACES_SECRET_ACCESS_KEY: ${{ secrets.SPACES_SECRET_ACCESS_KEY }}

- name: Results
if: always()
run: |
if [[ ${{ steps.run_tests.outcome }} == 'success' ]]; then
echo "test_result=success" >> $GITHUB_ENV
echo "check_description=Acceptance tests for ${{ github.event.client_payload.slash_command.pkg }} successful" >> $GITHUB_ENV
else
echo "test_result=failure" >> $GITHUB_ENV
echo "check_description=Acceptance tests for ${{ github.event.client_payload.slash_command.pkg }} failed" >> $GITHUB_ENV
fi
- name: Update status on PR
if: always()
run: |
gh api --method POST -H "Accept: application/vnd.github+json" \
/repos/${{ github.repository }}/statuses/${{ github.event.client_payload.pull_request.head.sha }} \
-f state='${{ env.test_result }}' \
-f target_url='https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}' \
-f description='${{ env.check_description }}' \
-f context='acceptance/${{ github.event.client_payload.slash_command.pkg }}'
env:
GH_TOKEN: ${{ github.token }}
33 changes: 0 additions & 33 deletions .github/workflows/acceptance-tests.yml

This file was deleted.

0 comments on commit 68d4138

Please sign in to comment.