-
Notifications
You must be signed in to change notification settings - Fork 38
65 lines (58 loc) · 2.1 KB
/
report.yml
File metadata and controls
65 lines (58 loc) · 2.1 KB
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
name: Report
on:
workflow_run:
workflows:
- Target Tests
types:
- completed
permissions:
actions: read
checks: write
pull-requests: write
jobs:
report:
runs-on: ubuntu-latest
steps:
- name: Download test results
uses: dawidd6/action-download-artifact@v18
with:
workflow: ${{ github.event.workflow_run.workflow_id }}
run_id: ${{ github.event.workflow_run.id }}
name_is_regexp: true
name: "test-results-.*"
path: test-results
if_no_artifact_found: ignore
- name: Read PR number
id: pr-number
run: |
PR_FILE=$(find test-results -name pr_number.txt | head -n 1)
if [ -n "$PR_FILE" ] && [ -f "$PR_FILE" ]; then
echo "PR_NUMBER=$(cat $PR_FILE)" >> $GITHUB_ENV
else
echo "No pr_number.txt found, skipping comment."
exit 0
fi
- name: Prepare multiple files string
if: env.PR_NUMBER != ''
id: generate-files
run: |
MULTIPLE_FILES=""
for xml_file in $(find test-results -name "pytest-*.xml"); do
dir_name=$(dirname "$xml_file")
# title from directory name test-results-qemu -> qemu
title=$(basename "$dir_name" | sed 's/^test-results-//')
# Capitalize first letter and replace hyphens with spaces
title=$(echo "$title" | awk '{print toupper(substr($0,1,1)) substr($0,2)}' | tr '-' ' ')
cov_file=$(find "$dir_name" -name "coverage-*.xml" | head -n 1)
# Add to multiple files string
MULTIPLE_FILES="${MULTIPLE_FILES}${title}, ${cov_file}, ${xml_file}"$'\n'
done
echo "FILES<<EOF" >> $GITHUB_OUTPUT
echo -e "$MULTIPLE_FILES" >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
- name: Comment on PR
uses: MishaKav/pytest-coverage-comment@v1
if: env.PR_NUMBER != '' && steps.generate-files.outputs.FILES != ''
with:
issue-number: ${{ env.PR_NUMBER }}
multiple-files: ${{ steps.generate-files.outputs.FILES }}