diff --git a/.github/workflows/e2e.yaml b/.github/workflows/e2e.yaml index 331b296..f1d4dfb 100644 --- a/.github/workflows/e2e.yaml +++ b/.github/workflows/e2e.yaml @@ -3,13 +3,30 @@ name: E2E Tests on: workflow_dispatch: + pull_request_target: permissions: contents: read + statuses: write jobs: + set-pending: + if: github.event_name == 'pull_request_target' + runs-on: ubuntu-latest + name: Set pending e2e status + steps: + - name: Set pending e2e status + run: | + gh api "repos/${{ github.repository }}/statuses/${{ github.event.pull_request.head.sha }}" \ + -f state="pending" \ + -f context="e2e" \ + -f description="E2E tests must be triggered manually via workflow_dispatch" + env: + GH_TOKEN: ${{ github.token }} + e2e: + if: github.event_name == 'workflow_dispatch' runs-on: ubuntu-latest timeout-minutes: 5 @@ -55,3 +72,36 @@ jobs: E2E_RELEASE: ${{ matrix.release }} CONTAINER_RUNTIME: docker run: go test -tags e2e -v -race -timeout 5m -run ${{ matrix.test }} ./test/e2e/ + + report-status: + if: always() && github.event_name == 'workflow_dispatch' + needs: [e2e] + runs-on: ubuntu-latest + name: Report e2e status + steps: + - name: Report e2e status + run: | + case "${{ needs.e2e.result }}" in + success) + state="success" + description="All E2E tests passed" + ;; + cancelled) + state="error" + description="E2E tests were cancelled" + ;; + skipped) + state="error" + description="E2E tests were skipped" + ;; + *) + state="failure" + description="E2E tests failed" + ;; + esac + gh api "repos/${{ github.repository }}/statuses/${{ github.sha }}" \ + -f state="$state" \ + -f context="e2e" \ + -f description="$description" + env: + GH_TOKEN: ${{ github.token }}