Debian Codegraph @

.github/workflows/ci.yml

raw
1 name: GitHub CI
2
3 on:
4 push:
5 branches:
6 - master
7 pull_request:
8
9 jobs:
10 test:
11 runs-on: ${{ matrix.os }}
12 container: ${{ matrix.container }}
13 strategy:
14 fail-fast: false
15 matrix:
16 include:
17 - name: py2.6
18 os: ubuntu-latest
19 container: centos:6
20 python-version: 2.6
21 - name: py3.10 with ossl3.0
22 os: ubuntu-latest
23 container: ubuntu:22.04
24 python-version: "3.10"
25 tox-env: py310
26 - name: py2.7
27 os: ubuntu-22.04
28 python-version: 2.7
29 tox-env: py27
30 - name: py2.7 with old gmpy
31 os: ubuntu-22.04
32 python-version: 2.7
33 tox-env: py27_old_gmpy
34 - name: py2.7 with old gmpy2
35 os: ubuntu-22.04
36 python-version: 2.7
37 tox-env: py27_old_gmpy2
38 - name: py2.7 with old six
39 os: ubuntu-22.04
40 python-version: 2.7
41 tox-env: py27_old_six
42 - name: py2.7 with gmpy
43 os: ubuntu-22.04
44 python-version: 2.7
45 tox-env: gmpypy27
46 - name: py2.7 with gmpy2
47 os: ubuntu-22.04
48 python-version: 2.7
49 tox-env: gmpy2py27
50 - name: py3.6
51 os: ubuntu-latest
52 container: centos:8
53 python-version: 3.6
54 tox-env: py36
55 - name: py3.7
56 os: ubuntu-22.04
57 python-version: 3.7
58 tox-env: py37
59 - name: py3.8
60 os: ubuntu-latest
61 python-version: 3.8
62 tox-env: py38
63 - name: py3.9
64 os: ubuntu-latest
65 python-version: 3.9
66 tox-env: py39
67 - name: py3.10
68 os: ubuntu-latest
69 python-version: '3.10'
70 tox-env: py310
71 - name: py3.10 with gmpy
72 os: ubuntu-latest
73 python-version: '3.10'
74 tox-env: gmpypy310
75 - name: py3.10 with gmpy2
76 os: ubuntu-latest
77 python-version: '3.10'
78 tox-env: gmpy2py310
79 - name: py3.11
80 os: ubuntu-latest
81 python-version: '3.11'
82 tox-env: py311
83 - name: py3.12
84 os: ubuntu-latest
85 python-version: '3.12'
86 tox-env: py312
87 - name: py3.13
88 os: ubuntu-latest
89 python-version: '3.13'
90 tox-env: py313
91 - name: pypy
92 os: ubuntu-latest
93 python-version: pypy-2.7
94 tox-env: pypy
95 - name: pypy3
96 os: ubuntu-22.04
97 python-version: pypy-3.7
98 tox-env: pypy3
99 # special configurations
100 - name: py2.7 with instrumental
101 os: ubuntu-22.04
102 python-version: 2.7
103 opt-deps: ['instrumental']
104 - name: code checks
105 os: ubuntu-latest
106 python-version: 3.9
107 tox-env: codechecks
108 - name: mutation testing
109 os: ubuntu-latest
110 python-version: '3.11'
111 mutation: 'true'
112 steps:
113 - uses: actions/checkout@v2
114 if: ${{ !matrix.container }}
115 with:
116 fetch-depth: 50
117 - uses: actions/checkout@v1
118 # centos 6 doesn't have glibc new enough for the nodejs used by v2
119 if: ${{ matrix.container }}
120 with:
121 fetch-depth: 50
122 - name: Ensure dependencies on CentOS:6
123 if: ${{ matrix.container == 'centos:6' }}
124 run: |
125 ls /etc/yum.repos.d/
126 cat /etc/yum.repos.d/CentOS-Base.repo
127 rm /etc/yum.repos.d/CentOS-Base.repo
128 cat > /etc/yum.repos.d/CentOS-Base.repo <<EOF
129 [base]
130 name=CentOS-$releasever - Base
131 baseurl=https://vault.centos.org/6.10/os/x86_64/
132 gpgcheck=1
133 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
134
135 [updates]
136 name=CentOS-$releasever - Updates
137 baseurl=https://vault.centos.org/6.10/updates/x86_64/
138 gpgcheck=1
139 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
140
141 [extras]
142 name=CentOS-$releasever - Extras
143 baseurl=https://vault.centos.org/6.10/extras/x86_64/
144 gpgcheck=1
145 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
146
147 EOF
148 echo installing
149 yum clean all
150 yum repolist all
151 yum install -y make python curl gcc libffi-devel python-devel glibc-devel openssl-devel wget curl-config curl-devel expat-devel gettext-devel zlib-devel perl-ExtUtils-MakeMaker
152 cd /usr/src
153 wget https://www.kernel.org/pub/software/scm/git/git-2.31.0.tar.gz
154 tar xzf git-2.31.0.tar.gz
155 cd git-2.31.0
156 make prefix=/usr/local/git all
157 make prefix=/usr/local/git install
158 ln -fs /usr/local/git/bin/git /usr/bin/git
159 - name: Ensere dependenceis on CentOS:8
160 if: ${{ matrix.container == 'centos:8' }}
161 run: |
162 ls /etc/yum.repos.d/
163 cat /etc/yum.repos.d/CentOS-Linux-BaseOS.repo
164 cat /etc/yum.repos.d/CentOS-Linux-AppStream.repo
165 cat /etc/yum.repos.d/CentOS-Linux-Extras.repo
166 rm /etc/yum.repos.d/CentOS-Linux-BaseOS.repo
167 rm /etc/yum.repos.d/CentOS-Linux-AppStream.repo
168 rm /etc/yum.repos.d/CentOS-Linux-Extras.repo
169 cat > /etc/yum.repos.d/CentOS-Linux-BaseOS.repo <<EOF
170 [BaseOS]
171 name=CentOS Linux $releasever - BaseOS
172 baseurl=https://vault.centos.org/8.5.2111/BaseOS/x86_64/os/
173 gpgcheck=0
174 metadata_expire=-1
175 EOF
176 cat > /etc/yum.repos.d/CentOS-Linux-AppStream.repo <<EOF
177 [AppStream]
178 name=CentOS Linux $releasever - AppStream
179 baseurl=https://vault.centos.org/8.5.2111/AppStream/x86_64/os/
180 gpgcheck=0
181 metadata_expire=-1
182 EOF
183 cat > /etc/yum.repos.d/CentOS-Linux-Extras.repo <<EOF
184 [Extras]
185 name=CentOS Linux $releasever - Extras
186 baseurl=https://vault.centos.org/8.5.2111/extras/x86_64/os/
187 gpgcheck=0
188 metadata_expire=-1
189 EOF
190 echo installing
191 yum clean all
192 yum repolist all
193 yum install -y git make python36 curl gcc libffi-devel python36-devel glibc-devel openssl-devel wget
194 ln -fs /usr/bin/python3.6 /usr/bin/python
195 - name: Ensure dependencies on Ubuntu 22.04
196 if: ${{ matrix.container == 'ubuntu:22.04' }}
197 run: |
198 apt-get update
199 apt-get install -y git make python-is-python3 python3 curl wget python3-distutils python3-pip
200 - name: Dependencies for mutation testing
201 if: ${{ matrix.mutation == 'true' }}
202 run: |
203 sudo apt-get install -y sqlite3
204 - name: workaround git failures with py3.10
205 run: |
206 git config --global --add safe.directory /__w/python-ecdsa/python-ecdsa
207 - name: Verify git status
208 run: |
209 git status
210 git remote -v
211 - name: Ensure we have baseline branch for quality coverage
212 run: git fetch origin master:refs/remotes/origin/master
213 - name: Set up Python ${{ matrix.python-version }}
214 # we use containers to use the native python version from them
215 if: ${{ !matrix.container && matrix.python-version != '2.7' }}
216 uses: actions/setup-python@v2
217 with:
218 python-version: ${{ matrix.python-version }}
219 - name: Ensure python 2.7
220 if: matrix.python-version == '2.7'
221 run: |
222 sudo apt-get update
223 sudo apt-get install -y \
224 python2.7 python2.7-dev
225 curl https://bootstrap.pypa.io/pip/2.7/get-pip.py --output get-pip.py
226 sudo ln -sf python2.7 /usr/bin/python
227 sudo python get-pip.py
228 sudo pip install --upgrade setuptools wheel
229 sudo chown -R $USER /usr/local/lib/python2.7
230 - name: Display Python version
231 run: python -c "import sys; print(sys.version)"
232 - name: Display installed python package versions
233 run: |
234 pip list || :
235 - name: Ensure working pip on 3.3
236 if: ${{ matrix.python-version == '3.3' }}
237 run: |
238 curl -o get-pip.py https://bootstrap.pypa.io/pip/3.3/get-pip.py
239 python get-pip.py
240 - name: Ensure working pip on 2.6
241 if: ${{ matrix.python-version == '2.6' }}
242 run: |
243 # pypi deprecated SNI-less access to the CDN, so we have to download
244 # the packages manually
245 curl -o get-pip.py https://bootstrap.pypa.io/pip/2.6/get-pip.py
246 wget https://files.pythonhosted.org/packages/ac/95/a05b56bb975efa78d3557efa36acaf9cf5d2fd0ee0062060493687432e03/pip-9.0.3-py2.py3-none-any.whl
247 wget https://files.pythonhosted.org/packages/27/f6/fabfc9c71c9b1b99d2ec4768a6e1f73b2e924f51c89d436302b8c2a25459/setuptools-36.8.0-py2.py3-none-any.whl
248 wget https://files.pythonhosted.org/packages/8a/e9/8468cd68b582b06ef554be0b96b59f59779627131aad48f8a5bce4b13450/wheel-0.29.0-py2.py3-none-any.whl
249 wget https://files.pythonhosted.org/packages/f2/94/3af39d34be01a24a6e65433d19e107099374224905f1e0cc6bbe1fd22a2f/argparse-1.4.0-py2.py3-none-any.whl
250 python get-pip.py pip-9.0.3-py2.py3-none-any.whl setuptools-36.8.0-py2.py3-none-any.whl wheel-0.29.0-py2.py3-none-any.whl argparse-1.4.0-py2.py3-none-any.whl
251 pip list
252 wget https://files.pythonhosted.org/packages/3b/7e/293d19ccd106119e35db4bf3e111b1895098f618b455b758aa636496cf03/setuptools-28.8.0-py2.py3-none-any.whl
253 wget https://files.pythonhosted.org/packages/83/53/e120833aa2350db333df89a40dea3b310dd9dabf6f29eaa18934a597dc79/wheel-0.30.0a0-py2.py3-none-any.whl
254 pip install setuptools-28.8.0-py2.py3-none-any.whl wheel-0.30.0a0-py2.py3-none-any.whl
255 - name: ensure working pip on 3.6
256 if: ${{ matrix.python-version == '3.6' }}
257 run: |
258 curl -o get-pip.py https://bootstrap.pypa.io/pip/3.6/get-pip.py
259 python get-pip.py
260 - name: Install instrumental
261 if: ${{ contains(matrix.opt-deps, 'instrumental') }}
262 run: pip install instrumental
263 - name: Install gmpy
264 if: ${{ contains(matrix.tox-env, 'gmpyp') }}
265 run: pip install gmpy
266 - name: Install gmpy2 dependencies
267 if: ${{ contains(matrix.tox-env, 'gmpy2') || contains(matrix.tox-env, 'instrumental') || matrix.mutation == 'true' }}
268 run: sudo apt-get install -y libmpfr-dev libmpc-dev
269 - name: Install gmpy2
270 if: ${{ contains(matrix.tox-env, 'gmpy2') || contains(matrix.tox-env, 'instrumental') || matrix.mutation == 'true' }}
271 run: pip install gmpy2
272 - name: Install build dependencies (2.6)
273 if: ${{ matrix.python-version == '2.6' }}
274 run: |
275 wget https://files.pythonhosted.org/packages/1d/4e/20c679f8c5948f7c48591fde33d442e716af66a31a88f5791850a75041eb/tox-2.9.1-py2.py3-none-any.whl
276 wget https://files.pythonhosted.org/packages/d9/9d/077582a4c6d771e3b742631e6c1d3688f48210626de488e032776242b3f2/inflect-0.3.0-py2.py3-none-any.whl
277 wget https://files.pythonhosted.org/packages/79/db/7c0cfe4aa8341a5fab4638952520d8db6ab85ff84505e12c00ea311c3516/pyOpenSSL-17.5.0-py2.py3-none-any.whl
278 wget https://files.pythonhosted.org/packages/2d/bf/960e5a422db3ac1a5e612cb35ca436c3fc985ed4b7ed13a1b4879006f450/cffi-1.13.2.tar.gz
279 wget https://files.pythonhosted.org/packages/4b/2a/0276479a4b3caeb8a8c1af2f8e4355746a97fab05a372e4a2c6a6b876165/idna-2.7-py2.py3-none-any.whl
280 wget https://files.pythonhosted.org/packages/72/20/7f0f433060a962200b7272b8c12ba90ef5b903e218174301d0abfd523813/unittest2-1.1.0-py2.py3-none-any.whl
281 wget https://files.pythonhosted.org/packages/a8/5a/5cf074e1c6681dcbb4e640113f58bed16955e7da9a6c8090b518031775e7/hypothesis-2.0.0.tar.gz
282 wget https://files.pythonhosted.org/packages/85/d5/818d0e603685c4a613d56f065a721013e942088047ff1027a632948bdae6/coverage-4.5.4.tar.gz
283 wget https://files.pythonhosted.org/packages/e6/35/f187bdf23be87092bd0f1200d43d23076cee4d0dec109f195173fd3ebc79/mock-2.0.0-py2.py3-none-any.whl
284 wget https://files.pythonhosted.org/packages/ed/ea/e20b5cbebf45d3096e8138ab74eda139595d827677f38e9dd543e6015bdf/virtualenv-15.2.0-py2.py3-none-any.whl
285 wget https://files.pythonhosted.org/packages/53/67/9620edf7803ab867b175e4fd23c7b8bd8eba11cb761514dcd2e726ef07da/py-1.4.34-py2.py3-none-any.whl
286 wget https://files.pythonhosted.org/packages/65/26/32b8464df2a97e6dd1b656ed26b2c194606c16fe163c695a992b36c11cdf/six-1.13.0-py2.py3-none-any.whl
287 wget https://files.pythonhosted.org/packages/4d/d1/e478b8a33230f85f38e35b386376fbd115219de2a2c4c8783610851ad1c3/pluggy-0.5.2-py2.py3-none-any.whl
288 wget https://files.pythonhosted.org/packages/78/c5/7188f15a92413096c93053d5304718e1f6ba88b818357d05d19250ebff85/cryptography-2.1.4.tar.gz
289 wget https://files.pythonhosted.org/packages/8c/2d/aad7f16146f4197a11f8e91fb81df177adcc2073d36a17b1491fd09df6ed/pycparser-2.18.tar.gz
290 wget https://files.pythonhosted.org/packages/a2/55/8f8cab2afd404cf578136ef2cc5dfb50baa1761b68c9da1fb1e4eed343c9/docopt-0.6.2.tar.gz
291 wget https://files.pythonhosted.org/packages/65/47/7e02164a2a3db50ed6d8a6ab1d6d60b69c4c3fdf57a284257925dfc12bda/requests-2.19.1-py2.py3-none-any.whl
292 wget https://files.pythonhosted.org/packages/17/0a/6ac05a3723017a967193456a2efa0aa9ac4b51456891af1e2353bb9de21e/traceback2-1.4.0-py2.py3-none-any.whl
293 wget https://files.pythonhosted.org/packages/31/77/3781f65cafe55480b56914def99022a5d2965a4bb269655c89ef2f1de3cd/importlib-1.0.4.zip
294 wget https://files.pythonhosted.org/packages/7d/b0/23d19892f8d91ec9c5b8a2035659bce23587fed419d68fa3d70b6abf8bcd/Counter-1.0.0.tar.gz
295 wget https://files.pythonhosted.org/packages/69/cb/f5be453359271714c01b9bd06126eaf2e368f1fddfff30818754b5ac2328/funcsigs-1.0.2-py2.py3-none-any.whl
296 wget https://files.pythonhosted.org/packages/fb/48/69046506f6ac61c1eaa9a0d42d22d54673b69e176d30ca98e3f61513e980/pbr-5.5.1-py2.py3-none-any.whl
297 wget https://files.pythonhosted.org/packages/b5/a8/56be92dcd4a5bf1998705a9b4028249fe7c9a035b955fe93b6a3e5b829f8/asn1crypto-1.4.0-py2.py3-none-any.whl
298 wget https://files.pythonhosted.org/packages/6f/2c/a9386903ece2ea85e9807e0e062174dc26fdce8b05f216d00491be29fad5/enum34-1.1.10-py2-none-any.whl
299 wget https://files.pythonhosted.org/packages/c2/f8/49697181b1651d8347d24c095ce46c7346c37335ddc7d255833e7cde674d/ipaddress-1.0.23-py2.py3-none-any.whl
300 wget https://files.pythonhosted.org/packages/bc/a9/01ffebfb562e4274b6487b4bb1ddec7ca55ec7510b22e4c51f14098443b8/chardet-3.0.4-py2.py3-none-any.whl
301 wget https://files.pythonhosted.org/packages/bd/c9/6fdd990019071a4a32a5e7cb78a1d92c53851ef4f56f62a3486e6a7d8ffb/urllib3-1.23-py2.py3-none-any.whl
302 wget https://files.pythonhosted.org/packages/5e/a0/5f06e1e1d463903cf0c0eebeb751791119ed7a4b3737fdc9a77f1cdfb51f/certifi-2020.12.5-py2.py3-none-any.whl
303 wget https://files.pythonhosted.org/packages/c7/a3/c5da2a44c85bfbb6eebcfc1dde24933f8704441b98fdde6528f4831757a6/linecache2-1.0.0-py2.py3-none-any.whl
304 wget https://files.pythonhosted.org/packages/53/25/ef88e8e45db141faa9598fbf7ad0062df8f50f881a36ed6a0073e1572126/ordereddict-1.1.tar.gz
305 wget https://files.pythonhosted.org/packages/ef/41/d8a61f1b2ba308e96b36106e95024977e30129355fd12087f23e4b9852a1/pytest-3.2.5-py2.py3-none-any.whl
306 pip install pycparser-2.18.tar.gz importlib-1.0.4.zip Counter-1.0.0.tar.gz tox-2.9.1-py2.py3-none-any.whl inflect-0.3.0-py2.py3-none-any.whl pyOpenSSL-17.5.0-py2.py3-none-any.whl cffi-1.13.2.tar.gz idna-2.7-py2.py3-none-any.whl unittest2-1.1.0-py2.py3-none-any.whl hypothesis-2.0.0.tar.gz coverage-4.5.4.tar.gz mock-2.0.0-py2.py3-none-any.whl virtualenv-15.2.0-py2.py3-none-any.whl py-1.4.34-py2.py3-none-any.whl six-1.13.0-py2.py3-none-any.whl pluggy-0.5.2-py2.py3-none-any.whl cryptography-2.1.4.tar.gz docopt-0.6.2.tar.gz requests-2.19.1-py2.py3-none-any.whl traceback2-1.4.0-py2.py3-none-any.whl funcsigs-1.0.2-py2.py3-none-any.whl pbr-5.5.1-py2.py3-none-any.whl asn1crypto-1.4.0-py2.py3-none-any.whl enum34-1.1.10-py2-none-any.whl ipaddress-1.0.23-py2.py3-none-any.whl chardet-3.0.4-py2.py3-none-any.whl urllib3-1.23-py2.py3-none-any.whl certifi-2020.12.5-py2.py3-none-any.whl linecache2-1.0.0-py2.py3-none-any.whl ordereddict-1.1.tar.gz pytest-3.2.5-py2.py3-none-any.whl git+https://github.com/tomato42/coveralls-python.git@add-py26#egg=coveralls
307 - name: Install build dependencies
308 if: ${{ matrix.python-version != '2.6' }}
309 run: |
310 PYTHON_VERSION=${{ matrix.python-version }}
311 PYTHON_VERSION=${PYTHON_VERSION#pypy-}
312 if [[ -e build-requirements-${PYTHON_VERSION}.txt ]]; then
313 pip install -r build-requirements-${PYTHON_VERSION}.txt;
314 else
315 pip install -r build-requirements.txt;
316 fi
317 - name: Install mutation testing dependencies
318 if: ${{ matrix.mutation == 'true' }}
319 run: |
320 pip install cosmic-ray
321 pip install pytest-timeout
322 - name: Display installed python package versions
323 run: pip list
324 - name: Test native speed
325 # tox uses pip to install dependenceis, so it breaks on py2.6
326 if: ${{ !contains(matrix.tox-env, 'gmpy') && matrix.python-version != '2.6' && ! matrix.mutation && !contains(matrix.tox-env, 'codechecks') }}
327 run: tox -e speed
328 - name: Test speed with gmpy
329 if: ${{ contains(matrix.tox-env, 'gmpyp') }}
330 run: tox -e speedgmpy
331 - name: Test speed with gmpy2
332 if: ${{ contains(matrix.tox-env, 'gmpy2') }}
333 run: tox -e speedgmpy2
334 - name: Run unit tests (2.6)
335 if: ${{ matrix.python-version == '2.6' }}
336 run: |
337 # because tox uses pip, and pip is broken on py2.6, we need run the
338 # tests directly on the system
339 coverage run --branch -m pytest
340 - name: Run unit tests
341 if: ${{ matrix.tox-env }}
342 run: tox -e ${{ matrix.tox-env }}
343 - name: Init for mutation testing in PR
344 if: ${{ matrix.mutation == 'true' && github.event.pull_request }}
345 run: |
346 cosmic-ray init cosmic-ray.toml session-vs-master.sqlite
347 git branch master origin/master
348 cr-filter-git --config cosmic-ray.toml session-vs-master.sqlite
349 cr-report session-vs-master.sqlite | tail -n 3
350 - name: Exec mutation testing for PR
351 if: ${{ matrix.mutation == 'true' && github.event.pull_request }}
352 run: |
353 systemd-run --user --scope -p MemoryMax=2G -p MemoryHigh=2G cosmic-ray --verbosity INFO exec cosmic-ray.toml session-vs-master.sqlite &
354 cosmic_pid=$!
355 for i in $(seq 1 600); do
356 # wait for test execution at most 10 minutes
357 if ! kill -s 0 $cosmic_pid; then
358 break
359 fi
360 sleep 1
361 done
362 kill $cosmic_pid || true
363 wait $cosmic_pid || true
364 - name: Check test coverage for PR
365 if: ${{ matrix.mutation == 'true' && github.event.pull_request }}
366 run: |
367 # remove not-executed results
368 sqlite3 session-vs-master.sqlite "DELETE from work_results WHERE work_results.worker_outcome = 'SKIPPED'"
369 cr-report session-vs-master.sqlite | tail -n 3
370 - name: Generate html report
371 if: ${{ matrix.mutation == 'true' && github.event.pull_request }}
372 run: |
373 cr-html session-vs-master.sqlite > cosmic-ray.html
374 - name: Archive mutation testing results
375 if: ${{ matrix.mutation == 'true' && github.event.pull_request }}
376 uses: actions/upload-artifact@v4
377 with:
378 name: mutation-PR-coverage-report
379 path: cosmic-ray.html
380 - name: Check test coverage for PR
381 if: ${{ matrix.mutation == 'true' && github.event.pull_request }}
382 run: |
383 # check if executed have at most 50% survival rate
384 cr-rate --estimate --confidence 99.9 --fail-over 50 session-vs-master.sqlite
385 - name: instrumental test coverage on PR
386 if: ${{ contains(matrix.opt-deps, 'instrumental') && github.event.pull_request }}
387 env:
388 BASE_REF: ${{ github.event.pull_request.base.ref }}
389 run: |
390 git fetch origin $BASE_REF
391 MERGE_BASE=$(git merge-base origin/$BASE_REF HEAD)
392 echo "MERGE_BASE:" $MERGE_BASE
393 git checkout $MERGE_BASE
394 instrumental -t ecdsa -i '.*test_.*|.*_version|.*_compat|.*_sha3' `which pytest` src/ecdsa/test*.py
395 instrumental -f .instrumental.cov -s
396 instrumental -f .instrumental.cov -s | python diff-instrumental.py --save .diff-instrumental
397 git checkout $GITHUB_SHA
398 instrumental -t ecdsa -i '.*test_.*|.*_version|.*_compat|.*_sha3' `which pytest` src/ecdsa/test*.py
399 instrumental -f .instrumental.cov -sr
400 instrumental -f .instrumental.cov -s | python diff-instrumental.py --read .diff-instrumental --fail-under 70 --max-difference -0.1
401 - name: instrumental test coverage on push
402 if: ${{ contains(matrix.opt-deps, 'instrumental') && !github.event.pull_request }}
403 run: |
404 instrumental -t ecdsa -i '.*test_.*|.*_version|.*_compat|.*_sha3' `which pytest` src/ecdsa
405 instrumental -f .instrumental.cov -s
406 # just log the values when merging
407 instrumental -f .instrumental.cov -s | python diff-instrumental.py
408 echo "COND_COV=$(instrumental -f .instrumental.cov -s | python diff-instrumental.py --raw)" >> $GITHUB_ENV
409 - name: Create condition coverage badge
410 uses: schneegans/[email protected]
411 if: ${{ contains(matrix.opt-deps, 'instrumental') && !github.event.pull_request }}
412 with:
413 auth: ${{ secrets.GIST_SECRET }}
414 gistID: 9b6ca1f3410207fbeca785a178781651
415 filename: python-ecdsa-condition-coverage.json
416 label: condition coverage
417 message: ${{ env.COND_COV }}%
418 valColorRange: ${{ env.COND_COV }}
419 maxColorRange: 100
420 minColorRange: 0
421 - name: Publish coverage to Coveralls
422 if: ${{ !matrix.opt-deps && matrix.tox-env != 'codechecks' }}
423 env:
424 GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
425 COVERALLS_FLAG_NAME: ${{ matrix.name }}
426 COVERALLS_PARALLEL: true
427 COVERALLS_SERVICE_NAME: github
428 PY_VERSION: ${{ matrix.python-version }}
429 run: |
430 if [[ $PY_VERSION == "2.6" ]]; then
431 COVERALLS_SKIP_SSL_VERIFY=1 coveralls
432 else
433 coveralls
434 fi
435 coveralls:
436 name: Indicate completion to coveralls.io
437 needs: test
438 runs-on: ubuntu-latest
439 container: python:3-slim
440 steps:
441 - name: Install coveralls
442 run: |
443 pip3 install --upgrade coveralls
444 - name: Send "finished" signal to coveralls
445 env:
446 GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
447 COVERALLS_SERVICE_NAME: github
448 run: |
449 coveralls --finish
450
451 mutation-prepare:
452 name: Prepare job files for the mutation runners
453 # use runner minutes on mutation testing only after the PR passed basic
454 # testing
455 needs: coveralls
456 runs-on: ubuntu-latest
457 steps:
458 - uses: actions/checkout@v2
459 if: ${{ !matrix.container }}
460 with:
461 fetch-depth: 50
462 - name: save session objects
463 uses: actions/cache@v3
464 with:
465 path: |
466 sessions/
467 key: sessions-${{ github.sha }}
468 - name: Install cosmic-ray
469 run: |
470 pip3 install cosmic-ray
471 pip install pytest-timeout
472 - name: Install dependencies
473 run: |
474 sudo apt-get install -y sqlite3
475 - name: Display Python version
476 run: python -c "import sys; print(sys.version)"
477 - name: Create list of mutations
478 run: |
479 cosmic-ray init cosmic-ray.toml session.sqlite
480 - name: Log number of jobs created
481 run: |
482 cr-report session.sqlite | tail -n 3
483 - name: Split up mutations to workers
484 run: |
485 cp session.sqlite session-to_del.sqlite
486 sqlite3 session-to_del.sqlite "$(cat sql/create_to_del.sql)"
487 mkdir sessions
488 for i in $(seq 0 19); do
489 sed "s/%SHARD%/$i/" < sql/shard-db.sql > shard.sql
490 cp session-to_del.sqlite session-$i.sqlite
491 sqlite3 session-$i.sqlite "$(cat shard.sql)"
492 mv session-$i.sqlite sessions/
493 done
494 mutation-execute:
495 name: Execute mutation testing
496 needs: mutation-prepare
497 runs-on: ubuntu-latest
498 strategy:
499 fail-fast: false
500 matrix:
501 include:
502 - name: 0
503 - name: 1
504 - name: 2
505 - name: 3
506 - name: 4
507 - name: 5
508 - name: 6
509 - name: 7
510 - name: 8
511 - name: 9
512 - name: 10
513 - name: 11
514 - name: 12
515 - name: 13
516 - name: 14
517 - name: 15
518 - name: 16
519 - name: 17
520 - name: 18
521 - name: 19
522 steps:
523 - uses: actions/checkout@v2
524 if: ${{ !matrix.container }}
525 with:
526 fetch-depth: 1
527 - name: Session objects
528 uses: actions/cache@v3
529 with:
530 path: |
531 sessions/
532 key: sessions-${{ github.sha }}
533 - name: Session done objects
534 uses: actions/cache@v3
535 with:
536 path: |
537 sessions-done/session-${{ matrix.name }}-done.sqlite
538 key: sessions-${{ github.sha }}-${{ matrix.name }}-done
539 - name: Install gmpy2 dependencies
540 run: sudo apt-get install -y libmpfr-dev libmpc-dev
541 - name: Install gmpy2
542 run: pip install gmpy2
543 - name: Install build dependencies
544 run: |
545 pip install -r build-requirements.txt
546 pip install cosmic-ray
547 pip install pytest-timeout
548 - name: Run mutation testing
549 run: |
550 cp sessions/session-${{ matrix.name }}.sqlite session.sqlite
551 systemd-run --user --scope -p MemoryMax=2G -p MemoryHigh=2G cosmic-ray exec cosmic-ray.toml session.sqlite &
552 cosmic_pid=$!
553 sleep 1
554 for i in $(seq 1 10); do
555 if ! kill -s 0 $cosmic_pid; then
556 break
557 fi
558 echo $i
559 sleep 60
560 done
561 kill -s 0 $cosmic_pid && kill $cosmic_pid
562 mkdir sessions-done/
563 cp session.sqlite sessions-done/session-${{ matrix.name }}-done.sqlite
564 - name: Report executed
565 run: |
566 cr-report session.sqlite | tail -n 3
567 mutation-combine:
568 name: Combine mutation testing results
569 needs: mutation-execute
570 runs-on: ubuntu-latest
571 steps:
572 - uses: actions/checkout@v2
573 if: ${{ !matrix.container }}
574 with:
575 fetch-depth: 1
576 - name: Session done 0 objects
577 uses: actions/cache@v3
578 with:
579 path: |
580 sessions-done/session-0-done.sqlite
581 key: sessions-${{ github.sha }}-0-done
582 - name: Session done 1 objects
583 uses: actions/cache@v3
584 with:
585 path: |
586 sessions-done/session-1-done.sqlite
587 key: sessions-${{ github.sha }}-1-done
588 - name: Session done 2 objects
589 uses: actions/cache@v3
590 with:
591 path: |
592 sessions-done/session-2-done.sqlite
593 key: sessions-${{ github.sha }}-2-done
594 - name: Session done 3 objects
595 uses: actions/cache@v3
596 with:
597 path: |
598 sessions-done/session-3-done.sqlite
599 key: sessions-${{ github.sha }}-3-done
600 - name: Session done 4 objects
601 uses: actions/cache@v3
602 with:
603 path: |
604 sessions-done/session-4-done.sqlite
605 key: sessions-${{ github.sha }}-4-done
606 - name: Session done 5 objects
607 uses: actions/cache@v3
608 with:
609 path: |
610 sessions-done/session-5-done.sqlite
611 key: sessions-${{ github.sha }}-5-done
612 - name: Session done 6 objects
613 uses: actions/cache@v3
614 with:
615 path: |
616 sessions-done/session-6-done.sqlite
617 key: sessions-${{ github.sha }}-6-done
618 - name: Session done 7 objects
619 uses: actions/cache@v3
620 with:
621 path: |
622 sessions-done/session-7-done.sqlite
623 key: sessions-${{ github.sha }}-7-done
624 - name: Session done 8 objects
625 uses: actions/cache@v3
626 with:
627 path: |
628 sessions-done/session-8-done.sqlite
629 key: sessions-${{ github.sha }}-8-done
630 - name: Session done 9 objects
631 uses: actions/cache@v3
632 with:
633 path: |
634 sessions-done/session-9-done.sqlite
635 key: sessions-${{ github.sha }}-9-done
636 - name: Session done 10 objects
637 uses: actions/cache@v3
638 with:
639 path: |
640 sessions-done/session-10-done.sqlite
641 key: sessions-${{ github.sha }}-10-done
642 - name: Session done 11 objects
643 uses: actions/cache@v3
644 with:
645 path: |
646 sessions-done/session-11-done.sqlite
647 key: sessions-${{ github.sha }}-11-done
648 - name: Session done 12 objects
649 uses: actions/cache@v3
650 with:
651 path: |
652 sessions-done/session-12-done.sqlite
653 key: sessions-${{ github.sha }}-12-done
654 - name: Session done 13 objects
655 uses: actions/cache@v3
656 with:
657 path: |
658 sessions-done/session-13-done.sqlite
659 key: sessions-${{ github.sha }}-13-done
660 - name: Session done 14 objects
661 uses: actions/cache@v3
662 with:
663 path: |
664 sessions-done/session-14-done.sqlite
665 key: sessions-${{ github.sha }}-14-done
666 - name: Session done 15 objects
667 uses: actions/cache@v3
668 with:
669 path: |
670 sessions-done/session-15-done.sqlite
671 key: sessions-${{ github.sha }}-15-done
672 - name: Session done 16 objects
673 uses: actions/cache@v3
674 with:
675 path: |
676 sessions-done/session-16-done.sqlite
677 key: sessions-${{ github.sha }}-16-done
678 - name: Session done 17 objects
679 uses: actions/cache@v3
680 with:
681 path: |
682 sessions-done/session-17-done.sqlite
683 key: sessions-${{ github.sha }}-17-done
684 - name: Session done 18 objects
685 uses: actions/cache@v3
686 with:
687 path: |
688 sessions-done/session-18-done.sqlite
689 key: sessions-${{ github.sha }}-18-done
690 - name: Session done 19 objects
691 uses: actions/cache@v3
692 with:
693 path: |
694 sessions-done/session-19-done.sqlite
695 key: sessions-${{ github.sha }}-19-done
696 - name: Install cosmic-ray
697 run: |
698 pip3 install cosmic-ray
699 pip install pytest-timeout
700 - name: Install dependencies
701 run: |
702 sudo apt-get install -y sqlite3
703 - name: Combine worker results
704 run: |
705 cp sessions-done/session-0-done.sqlite session.sqlite
706 for i in $(seq 1 19); do
707 cp sessions-done/session-$i-done.sqlite session-to_merge.sqlite && sqlite3 session.sqlite "$(cat sql/combine.sql)" || true
708 done
709 - name: Report executed
710 run: |
711 cr-report session.sqlite | tail -n 3
712 - name: Generate html report
713 run: |
714 cr-html session.sqlite > cosmic-ray.html
715 - name: Archive mutation testing results
716 uses: actions/upload-artifact@v4
717 with:
718 name: mutation-coverage-report
719 path: cosmic-ray.html
720 - name: Get mutation score
721 run: |
722 echo "print('{0:.2f}'.format(100-$(cr-rate session.sqlite)))" > print-score.py
723 echo "MUT_SCORE=$(python print-score.py)" >> $GITHUB_ENV
724 - name: Create mutation score badge
725 if: ${{ !github.event.pull_request }}
726 uses: schneegans/[email protected]
727 with:
728 auth: ${{ secrets.GIST_SECRET }}
729 gistID: 9b6ca1f3410207fbeca785a178781651
730 filename: python-ecdsa-mutation-score.json
731 label: mutation score
732 message: ${{ env.MUT_SCORE }}%
733 valColorRange: ${{ env.MUT_SCORE }}
734 maxColorRange: 100
735 minColorRange: 0
736 - name: Check survival estimate
737 run: cr-rate --estimate --fail-over 32 --confidence 99.9 session.sqlite