| 1 |
name: Analyze Test Results |
| 2 |
|
| 3 |
on: |
| 4 |
workflow_run: |
| 5 |
workflows: ["Run Tests"] |
| 6 |
types: |
| 7 |
- completed |
| 8 |
permissions: {} |
| 9 |
|
| 10 |
jobs: |
| 11 |
test-results: |
| 12 |
name: Test Results |
| 13 |
runs-on: ubuntu-latest |
| 14 |
if: github.event.workflow_run.conclusion != 'skipped' |
| 15 |
|
| 16 |
permissions: |
| 17 |
checks: write |
| 18 |
|
| 19 |
# needed unless run with comment_mode: off |
| 20 |
pull-requests: write |
| 21 |
|
| 22 |
# only needed for private repository |
| 23 |
contents: read |
| 24 |
|
| 25 |
# only needed for private repository |
| 26 |
issues: read |
| 27 |
|
| 28 |
# required by download step to access artifacts API |
| 29 |
actions: read |
| 30 |
|
| 31 |
steps: |
| 32 |
- name: Download and Extract Artifacts |
| 33 |
env: |
| 34 |
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} |
| 35 |
run: | |
| 36 |
ls -alR |
| 37 |
mkdir -p artifacts && cd artifacts |
| 38 |
|
| 39 |
artifacts_url=${{ github.event.workflow_run.artifacts_url }} |
| 40 |
|
| 41 |
gh api --paginate "$artifacts_url" -q '.artifacts[] | [.name, .archive_download_url] | @tsv' | while read artifact |
| 42 |
do |
| 43 |
IFS=$'\t' read name url <<< "$artifact" |
| 44 |
if [ "$name" != "test-results" ] && [ "$name" != "event-file" ]; then |
| 45 |
continue |
| 46 |
fi |
| 47 |
gh api $url > "$name.zip" |
| 48 |
unzip -d "$name" "$name.zip" |
| 49 |
done |
| 50 |
ls -alR |
| 51 |
|
| 52 |
- name: Publish Test Results |
| 53 |
uses: EnricoMi/publish-unit-test-result-action@v2 |
| 54 |
with: |
| 55 |
commit: ${{ github.event.workflow_run.head_sha }} |
| 56 |
event_file: artifacts/event-file/event.json |
| 57 |
event_name: ${{ github.event.workflow_run.event }} |
| 58 |
files: "artifacts/**/*.xml" |