Skip to content

Report

Report #4

Workflow file for this run

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@v16
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 }}