Publish Test Results #5618
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Publish Test Results | |
| on: | |
| workflow_run: | |
| workflows: ['CI'] | |
| types: | |
| - completed | |
| permissions: | |
| contents: read | |
| checks: write | |
| pull-requests: write | |
| jobs: | |
| publish-test-results: | |
| name: Publish Test Results | |
| runs-on: ubuntu-latest | |
| if: github.event.workflow_run.conclusion != 'skipped' && github.event.workflow_run.event == 'pull_request' | |
| steps: | |
| - name: Download and Extract Artifacts | |
| env: | |
| GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} | |
| run: | | |
| mkdir -p artifacts && cd artifacts | |
| artifacts_url=${{ github.event.workflow_run.artifacts_url }} | |
| gh api "$artifacts_url" -q '.artifacts[] | [.name, .archive_download_url] | @tsv' | while read artifact | |
| do | |
| IFS=$'\t' read name url <<< "$artifact" | |
| gh api $url > "$name.zip" | |
| unzip -d "$name" "$name.zip" | |
| done | |
| - name: Extract PR Number | |
| run: | | |
| prnumber=$(jq -r '.pull_request.number' < 'artifacts/Event File/event.json') | |
| sanitized_prnumber=$(grep -E '^[0-9]+$' <<< "$prnumber") | |
| echo "PR_NUMBER=$sanitized_prnumber" >> "$GITHUB_ENV" | |
| - name: Publish Unit Test Results | |
| # 6e8f8c55b476f977d1c58cfbd7e337cbf86d917f is tag v2, pinned to avoid supply chain attacks | |
| uses: EnricoMi/publish-unit-test-result-action@34d7c956a59aed1bfebf31df77b8de55db9bbaaf | |
| with: | |
| commit: ${{ github.event.workflow_run.head_sha }} | |
| event_file: artifacts/Event File/event.json | |
| event_name: ${{ github.event.workflow_run.event }} | |
| files: 'artifacts/Unit Test Results/*.xml' | |
| check_name: "Unit Test Results" | |
| - name: Add Coverage PR Comment | |
| # 773744901bac0e8cbb5a0dc842800d45e9b2b405 is tag v2, pinned to avoid supply chain attacks | |
| uses: marocchino/sticky-pull-request-comment@773744901bac0e8cbb5a0dc842800d45e9b2b405 | |
| with: | |
| recreate: true | |
| path: artifacts/Code Coverage Report/code-coverage-results.md | |
| number: ${{ env.PR_NUMBER }} |