blob: 8d3e1a90d2664d1dc2bcb6cec8f371e442a21893 (
plain)
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
|
# Licensed under the Apache License: http://www.apache.org/licenses/LICENSE-2.0
# For details: https://github.com/nedbat/coveragepy/blob/master/NOTICE.txt
name: "Coverage"
on:
# As currently structured, this adds too many jobs (checks?), so don't run it
# on pull requests yet.
push:
branches:
- master
- "**/*metacov*"
workflow_dispatch:
defaults:
run:
shell: bash
env:
PIP_DISABLE_PIP_VERSION_CHECK: 1
jobs:
coverage:
name: "Python ${{ matrix.python-version }} on ${{ matrix.os }}"
runs-on: "${{ matrix.os }}"
strategy:
matrix:
os:
- ubuntu-latest
- macos-latest
- windows-latest
python-version:
# When changing this list, be sure to check the [gh-actions] list in
# tox.ini so that tox will run properly. PYVERSIONS
# Available versions:
# https://github.com/actions/python-versions/blob/main/versions-manifest.json
- "3.7"
- "3.8"
- "3.9"
- "3.10"
- "3.11.0-alpha.2"
- "pypy-3.7"
exclude:
# Windows PyPy doesn't seem to work?
- os: windows-latest
python-version: "pypy-3.7"
# Mac PyPy always takes the longest, and doesn't add anything.
- os: macos-latest
python-version: "pypy-3.7"
# If one job fails, stop the whole thing.
fail-fast: true
steps:
- name: "Check out the repo"
uses: "actions/checkout@v2"
- name: "Set up Python"
uses: "actions/setup-python@v2"
with:
python-version: "${{ matrix.python-version }}"
cache: pip
cache-dependency-path: 'requirements/*.pip'
- name: "Install dependencies"
run: |
set -xe
python -VV
python -m site
python -m pip install -r requirements/tox.pip
- name: "Run tox coverage for ${{ matrix.python-version }}"
env:
COVERAGE_COVERAGE: "yes"
COVERAGE_CONTEXT: "${{ matrix.python-version }}.${{ matrix.os }}"
run: |
set -xe
python -m tox
- name: "Upload coverage data"
uses: actions/upload-artifact@v2
with:
name: metacov
path: .metacov.*
combine:
name: "Combine coverage data"
needs: coverage
runs-on: ubuntu-latest
steps:
- name: "Check out the repo"
uses: "actions/checkout@v2"
- name: "Set up Python"
uses: "actions/setup-python@v2"
with:
python-version: "3.8"
cache: pip
cache-dependency-path: 'requirements/*.pip'
- name: "Install dependencies"
run: |
set -xe
python -VV
python -m site
python -m pip install -e .
python igor.py zip_mods
- name: "Download coverage data"
uses: actions/download-artifact@v2
with:
name: metacov
- name: "Combine and report"
id: combine
env:
COVERAGE_RCFILE: "metacov.ini"
COVERAGE_METAFILE: ".metacov"
COVERAGE_CONTEXT: "yes"
run: |
set -xe
python -m igor combine_html
python -m coverage json
- name: "Upload HTML report"
uses: actions/upload-artifact@v2
with:
name: html_report
path: htmlcov
- name: "Upload JSON report"
uses: actions/upload-artifact@v2
with:
name: json_report
path: coverage.json
publish:
name: "Publish coverage report"
needs: combine
runs-on: ubuntu-latest
steps:
- name: "Checkout reports repo"
run: |
set -xe
git clone --depth=1 --no-checkout https://${{ secrets.COVERAGE_REPORTS_TOKEN }}@github.com/nedbat/coverage-reports reports_repo
cd reports_repo
git sparse-checkout init --cone
git sparse-checkout set '/*' '!/reports'
git config user.name nedbat
git config user.email ned@nedbatchelder.com
git checkout main
- name: "Download coverage JSON report"
uses: actions/download-artifact@v2
with:
name: json_report
- name: "Compute info for later steps"
id: info
run: |
set -xe
export TOTAL=$(python -c "import json;print(json.load(open('coverage.json'))['totals']['percent_covered_display'])")
export PCTINT=$(echo $TOTAL | cut -f1 -d.)
export SHA10=$(echo ${{ github.sha }} | cut -c 1-10)
export SLUG=$(date +'%Y%m%d')_$SHA10
export REPORT_DIR=reports/$SLUG/htmlcov
export REF="${{ github.ref }}"
echo "total=$TOTAL" >> $GITHUB_ENV
echo "sha10=$SHA10" >> $GITHUB_ENV
echo "slug=$SLUG" >> $GITHUB_ENV
echo "report_dir=$REPORT_DIR" >> $GITHUB_ENV
echo "url=https://nedbat.github.io/coverage-reports/$REPORT_DIR" >> $GITHUB_ENV
echo "branch=${REF#refs/heads/}" >> $GITHUB_ENV
if (($PCTINT >= 85)); then echo "badge_color=green"; fi >> $GITHUB_ENV
if (($PCTINT < 85)); then echo "badge_color=yellow"; fi >> $GITHUB_ENV
if (($PCTINT < 70)); then echo "badge_color=orange"; fi >> $GITHUB_ENV
if (($PCTINT < 60)); then echo "badge_color=red"; fi >> $GITHUB_ENV
- name: "Download coverage HTML report"
uses: actions/download-artifact@v2
with:
name: html_report
path: reports_repo/${{ env.report_dir }}
- name: "Push to report repo"
run: |
set -xe
# Make the redirect to the latest report.
echo "<html><head>" > reports_repo/latest.html
echo "<meta http-equiv='refresh' content='0;url=${{ env.url }}' />" >> reports_repo/latest.html
echo "<body>Coverage report redirect..." >> reports_repo/latest.html
# Make the commit message.
echo "${{ env.total }}% - ${{ github.event.head_commit.message }}" > commit.txt
echo "" >> commit.txt
echo "${{ env.url }}" >> commit.txt
echo "${{ env.sha10 }}: ${{ env.branch }}" >> commit.txt
# Commit.
cd ./reports_repo
git sparse-checkout set '/*' '${{ env.report_dir }}'
rm ${{ env.report_dir }}/.gitignore
git add ${{ env.report_dir }} latest.html
git commit --file=../commit.txt
git push
- name: "Create badge"
# https://gist.githubusercontent.com/nedbat/8c6980f77988a327348f9b02bbaf67f5
uses: schneegans/dynamic-badges-action@v1.1.0
with:
auth: ${{ secrets.METACOV_GIST_SECRET }}
gistID: 8c6980f77988a327348f9b02bbaf67f5
filename: metacov.json
label: Coverage
message: ${{ env.total }}%
color: ${{ env.badge_color }}
|