-
Notifications
You must be signed in to change notification settings - Fork 7
63 lines (55 loc) · 2.25 KB
/
notify-coverage.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
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 }}