Skip to content

Preflight Summary

Preflight Summary #26

name: Preflight Summary
on:
workflow_run:
workflows: [Preflight]
types: [completed]
defaults:
run:
shell: bash
jobs:
submit-summary:
runs-on: ubuntu-latest
permissions:
pull-requests: write
steps:
- name: Download Preflight artifacts
# https://github.com/marketplace/actions/download-workflow-artifact
uses: dawidd6/action-download-artifact@v3
with:
name: preflight-reports
run_id: ${{ github.event.workflow_run.id }}
- name: Load Environment
run: cat environment.txt | tee -a $GITHUB_ENV
- name: Generate Test Summary
if: ${{ hashFiles('pytest-report.xml') != '' }}
# https://github.com/marketplace/actions/junit-test-dashboard
uses: test-summary/action@v2
with:
paths: pytest-report.xml
output: test-summary.md
- name: Generate Coverage Summary
if: ${{ hashFiles('pytest-coverage.xml') != '' }}
# https://github.com/marketplace/actions/code-coverage-summary
# Generates code-coverage-results.md
uses: irongut/[email protected]
with:
filename: pytest-coverage.xml
badge: false
hide_branch_rate: true
hide_complexity: true
indicators: false
format: markdown
output: file
- name: Generate Preflight Summary
run: |
{
if [[ -s test-summary.md ]]; then
cat test-summary.md
fi
if [[ -s code-coverage-results.md ]]; then
printf "\n\n### Code Coverage Summary\n"
cat code-coverage-results.md
fi
cat {pylint,black,isort,bandit}-report.md > linter-reports.md 2>/dev/null || true
if [[ -s linter-reports.md ]]; then
printf "\n### Linter reports\n"
# Max size of comments on GitHub is 64KB. Don't post reports if they don't fit.
if awk '{sum += $1} END {exit sum > (62*1024)}' \
<<< $(stat --format=%s test-summary.md code-coverage-results.md linter-reports.md 2>/dev/null)
then
cat linter-reports.md
else
printf "The reports are too big to be posted here.\n"
fi
fi
JOB_URL="$GITHUB_SERVER_URL/$GITHUB_REPOSITORY/actions/runs/${{ github.event.workflow_run.id }}"
printf "\nView full reports on the [Job Summary]($JOB_URL \"Go to Job Summary\") page.\n"
} > preflight-report.md
- name: Comment PR
# https://github.com/marketplace/actions/comment-pull-request
uses: thollander/actions-comment-pull-request@v2
with:
filePath: preflight-report.md
comment_tag: preflight_summary
pr_number: ${{ env.PR_NUMBER }}