Skip to content

Test Report

Test Report #397

Workflow file for this run

# This workflow makes it possible to publish test reports without running into
# permission issues when the test workflow was run from a fork or by Dependabot.
#
# The test workflow uploads a junit file per matrix target as an artifact, plus
# the worflow events file, both of which this worfklow buids upon. Note that
# the events file artifact, specifically, is expected to be named 'Event File'.
#
# See the [Publish Test Results action documentation][ptr] for more information.
#
# [ptr]: https://github.com/marketplace/actions/publish-test-results#support-fork-repositories-and-dependabot-branches
name: "Test Report"
on:
workflow_run:
workflows: ["Test Build"]
types:
- completed
permissions: {}
jobs:
test-results:
name: Test Results
runs-on: ubuntu-latest
if: github.event.workflow_run.conclusion != 'skipped'
permissions:
checks: write
# permission to comment on PRs
pull-requests: write
# permission to download artifacts
actions: read
steps:
- name: Download and extract artifacts
env:
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
run: |
# Unzip all artifacts created by the triggering workflow into
# directories under an `artifacts/` directory.
#
# This uses `gh api` to output the name and URL for each artifact as
# tab-separated lines, then uses `read` to take each name and URL
# and download those to named zip files, and finally extracting those
# zip files into directories with matching names.
mkdir -p artifacts && cd artifacts
# The artifacts URL from the *triggering* test workflow, not *this*
# workflow.
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
# Run the publisher. Note that it is given the 'Event File' artifact
# created by the test workflow so it has the *original* webhook payload
# to base its context on.
- name: Publish Test Results
uses: EnricoMi/publish-unit-test-result-action@v2
with:
commit: ${{ github.event.workflow_run.head_sha }}
event_file: artifacts/Event File/event.json
event_name: ${{ github.event.workflow_run.event }}
junit_files: "artifacts/**/*.xml"