Notify coverage changes #10
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Notify coverage changes | |
# Daily notification for coverage changes in `main`. | |
# | |
# PR coverage diffs are computed directly in the `Continuous Integration` workflow. | |
on: | |
schedule: | |
# 04:00 daily | |
- cron: '0 4 * * *' | |
workflow_dispatch: {} | |
jobs: | |
check-coverage: | |
runs-on: ubuntu-latest | |
outputs: | |
msg: ${{ steps.make_msg.outputs.msg }} | |
steps: | |
- name: Get today's and yesterday's coverage trends from codecov | |
# API reference: https://docs.codecov.com/reference/repos_totals_retrieve | |
run: | | |
YESTERDAY=$( date -u +%Y-%m-%dT%H:%M:%SZ -d 'yesterday' ) | |
curl --request GET \ | |
--url "https://api.codecov.io/api/v2/github/${{ github.repository_owner }}/repos/${{ github.event.repository.name }}/coverage/?interval=1d&start_date=$YESTERDAY" \ | |
--header 'accept: application/json' \ | |
--header "authorization: Bearer ${{ secrets.CODECOV_GET_TOKEN }}" \ | |
> coverage.json | |
echo "Coverage JSON:" | |
cat coverage.json | |
echo | |
cat coverage.json | jq ".results[0].max" > coverage-prev.txt | |
cat coverage.json | jq ".results[-1].max" > coverage.txt | |
echo "Previous coverage: `cat coverage-prev.txt`%" | |
echo "Current coverage: `cat coverage.txt`%" | |
- name: Compare with previous summary and make message | |
id: make_msg | |
run: | | |
change="`cat coverage-prev.txt`% --> `cat coverage.txt`%" | |
codecov="https://codecov.io/gh/${{ github.repository }}?search=&trend=7%20days" | |
if (( $(echo "`cat coverage-prev.txt` < `cat coverage.txt` + 0.04" | bc -l) )) | |
then | |
MSG="msg=Coverage check for hugr shows no regression (${change}). ✅ ${codecov}" | |
else | |
MSG="msg=Coverage check for hugr shows regression (${change}). ❌ ${codecov}" | |
fi | |
echo $MSG | |
echo $MSG >> "$GITHUB_OUTPUT" | |
#notify-slack: | |
# needs: check-coverage | |
# runs-on: ubuntu-latest | |
# steps: | |
# - name: Send notification | |
# uses: slackapi/[email protected] | |
# with: | |
# channel-id: 'C04SHCL4FKP' | |
# slack-message: ${{ needs.check-coverage.outputs.msg }} | |
# env: | |
# SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }} | |