Skip to content

Instantly share code, notes, and snippets.

@shu-yusa
Last active July 6, 2022 02:16
Show Gist options
  • Save shu-yusa/262afa2859a964e0d8bf5fac4df7a087 to your computer and use it in GitHub Desktop.
Save shu-yusa/262afa2859a964e0d8bf5fac4df7a087 to your computer and use it in GitHub Desktop.
Convert Python coverage output to GitHub Actions job summary
#!/bin/sh
## https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions#adding-a-job-summary
repo_url=https://github.com/your-user-id/your-repository/blob
branch=master
coverage report | sed "1,3 s/-\+/--|--|--|--/g" | \
sed "/-\{3\}/d"| \
sed "0,/TOTAL*/ s/ \+/|/g" | \
sed "0,/TOTAL*/ s/^/|/g" | \
sed "0,/TOTAL*/ s/$/|/g" | \
sed "1i # Test Coverage" | \
sed "s#|\(.\+\.py\)|#|[\1]($repo_url/$branch/\1)|#g" >> $GITHUB_STEP_SUMMARY
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment