fix(ci): publish PR test results from workflow_run
- stop publishing unit test results directly from the pull_request test jobs\n- upload the GitHub event payload from CI so a follow-up workflow can reuse the original PR context\n- add a workflow_run publisher that downloads backend/frontend test artifacts and posts the check runs and PR comments with the permissions Dependabot PRs require\n- keep the reusable test suite focused on executing tests and producing artifacts without failing on comment permissions
This commit is contained in:
@@ -0,0 +1,73 @@
|
||||
name: Test Results - Publish
|
||||
|
||||
on:
|
||||
workflow_run:
|
||||
workflows:
|
||||
- CI - Validate
|
||||
types:
|
||||
- completed
|
||||
|
||||
jobs:
|
||||
publish-test-results:
|
||||
name: Publish Test Results
|
||||
if: ${{ github.event.workflow_run.conclusion == 'success' || github.event.workflow_run.conclusion == 'failure' }}
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
permissions:
|
||||
actions: read
|
||||
contents: read
|
||||
checks: write
|
||||
pull-requests: write
|
||||
|
||||
steps:
|
||||
- name: Download Workflow Artifacts
|
||||
uses: actions/download-artifact@f1b1db2786a679e8eff8e5f0383478a629e823fc # v5.0.0
|
||||
with:
|
||||
github-token: ${{ github.token }}
|
||||
repository: ${{ github.repository }}
|
||||
run-id: ${{ github.event.workflow_run.id }}
|
||||
path: artifacts
|
||||
|
||||
- name: Detect Published Test Artifacts
|
||||
id: detect
|
||||
run: |
|
||||
set -eu
|
||||
|
||||
if [ -f "artifacts/ci-event-file/event.json" ]; then
|
||||
echo "event_file=artifacts/ci-event-file/event.json" >> "$GITHUB_OUTPUT"
|
||||
else
|
||||
echo "Missing ci-event-file artifact; cannot publish test results." >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if find artifacts/backend-test-reports -name '*.xml' -print -quit | grep -q .; then
|
||||
echo "backend_present=true" >> "$GITHUB_OUTPUT"
|
||||
else
|
||||
echo "backend_present=false" >> "$GITHUB_OUTPUT"
|
||||
fi
|
||||
|
||||
if find artifacts/frontend-test-reports -name '*.xml' -print -quit | grep -q .; then
|
||||
echo "frontend_present=true" >> "$GITHUB_OUTPUT"
|
||||
else
|
||||
echo "frontend_present=false" >> "$GITHUB_OUTPUT"
|
||||
fi
|
||||
|
||||
- name: Publish Backend Test Results
|
||||
if: ${{ steps.detect.outputs.backend_present == 'true' }}
|
||||
uses: EnricoMi/publish-unit-test-result-action@c950f6fb443cb5af20a377fd0dfaa78838901040 # v2
|
||||
with:
|
||||
commit: ${{ github.event.workflow_run.head_sha }}
|
||||
event_file: ${{ steps.detect.outputs.event_file }}
|
||||
event_name: ${{ github.event.workflow_run.event }}
|
||||
files: artifacts/backend-test-reports/**/*.xml
|
||||
check_name: Backend Test Results
|
||||
|
||||
- name: Publish Frontend Test Results
|
||||
if: ${{ steps.detect.outputs.frontend_present == 'true' }}
|
||||
uses: EnricoMi/publish-unit-test-result-action@c950f6fb443cb5af20a377fd0dfaa78838901040 # v2
|
||||
with:
|
||||
commit: ${{ github.event.workflow_run.head_sha }}
|
||||
event_file: ${{ steps.detect.outputs.event_file }}
|
||||
event_name: ${{ github.event.workflow_run.event }}
|
||||
files: artifacts/frontend-test-reports/**/*.xml
|
||||
check_name: Frontend Test Results
|
||||
Reference in New Issue
Block a user