-
Notifications
You must be signed in to change notification settings - Fork 195
69 lines (56 loc) · 1.89 KB
/
test-analysis.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
name: Analyze Test Results
on:
workflow_run:
workflows: [Validate]
types:
- completed
permissions: {}
jobs:
test-results:
name: Test Results
runs-on: ubuntu-latest
if: github.event.workflow_run.conclusion != 'skipped'
permissions:
checks: write
# needed unless run with comment_mode: off
pull-requests: write
# only needed for private repository
contents: read
# only needed for private repository
issues: read
# required by download step to access artifacts API
actions: read
steps:
- name: Download and Extract Artifacts
env:
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
run: |
ls -alR
mkdir -p artifacts && cd artifacts
artifacts_url=${{ github.event.workflow_run.artifacts_url }}
gh api --paginate "$artifacts_url" -q '.artifacts[] | [.name, .archive_download_url] | @tsv' | while read artifact
do
IFS=$'\t' read name url <<< "$artifact"
if [ "${name:0:12}" != "test-results" ] && [ "$name" != "event-file" ]; then
continue
fi
gh api $url > "$name.zip"
unzip -d "$name" "$name.zip"
done
ls -alR
- name: Check for event-file
id: file_check
run: |
if [ -e artifacts/event-file/event.json ]; then
echo "check_result=true" >> $GITHUB_OUTPUT
else
echo "check_result=false" >> $GITHUB_OUTPUT
fi
- name: Publish Test Results
if: steps.file_check.outputs.check_result == 'true'
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 }}
files: "artifacts/**/*.xml"