Skip to content

Commit

Permalink
chore: Modify the way that test coverage is calculated and reported in
Browse files Browse the repository at this point in the history
build.yml.
  • Loading branch information
gkapfham committed Oct 26, 2023
1 parent 0faa226 commit 0a90192
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -88,17 +88,29 @@ jobs:
if: always()
run: |
poetry run task test
# Run the test coverage monitoring
- name: Run Test Coverage
if: always()
# Run and collect the test coverage
# Important: only run and collect test coverage monitoring on Linux
- name: Run and Collect Test Coverage
if: always() && matrix.os == 'ubuntu-latest'
run: |
poetry run task test-coverage-silent > coverage.txt
# Display the Coverage Report
- name: Display Coverage
# Important: only report the monitored test coverage on Linux
- name: Display Collected Test Coverage
if: always() && matrix.os == 'ubuntu-latest'
run: |
export TOTAL=$(python -c "import json;print(json.load(open('coverage.json'))['totals']['percent_covered_display'])")
echo "total=$TOTAL" >> $GITHUB_ENV
echo "### Total coverage: ${TOTAL}%" >> $GITHUB_STEP_SUMMARY
CURRENT_GITHUB_STEP_SUMMARY="\`\`\`\n$(cat coverage.txt)\n\`\`\`"
echo "$CURRENT_GITHUB_STEP_SUMMARY" >> $GITHUB_STEP_SUMMARY
# Run and display the test coverage
# If the current operating system is not Linux, then only run test
# coverage monitoring and display it inside of the GitHub Actions
# panel. This allows for test coverage to be calculated for each
# operating system. However, coverage is only reported for Linux
# through the badge and through the GitHub job summary.
- name: Run and Report Test Coverage
if: always() && matrix.os != 'ubuntu-latest'
run: |
poetry run task test-coverage

0 comments on commit 0a90192

Please sign in to comment.