Skip to content

Commit da9d8bb

Browse files
committed
add mutation testing to PR
1 parent ad564c0 commit da9d8bb

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

.github/workflows/ci.yml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,10 @@ jobs:
104104
os: ubuntu-latest
105105
python-version: 3.9
106106
tox-env: codechecks
107+
- name: mutation testing
108+
os: ubuntu-latest
109+
python-version: '3.11'
110+
mutation: 'true'
107111
steps:
108112
- uses: actions/checkout@v2
109113
if: ${{ !matrix.container }}
@@ -149,6 +153,11 @@ jobs:
149153
run: |
150154
apt-get update
151155
apt-get install -y git make python-is-python3 python3 curl wget python3-distutils python3-pip
156+
157+
- name: Dependencies for mutation testing
158+
if: ${{ matrix.mutation == 'true' }}
159+
run: |
160+
sudo apt-get install -y sqlite3
152161
- name: workaround git failures with py3.10
153162
run: |
154163
git config --global --add safe.directory /__w/python-ecdsa/python-ecdsa
@@ -256,6 +265,10 @@ jobs:
256265
else
257266
pip install -r build-requirements.txt;
258267
fi
268+
- name: Install mutation testing dependencies
269+
if: ${{ matrix.mutation == 'true' }}
270+
run: |
271+
pip install cosmic-ray
259272
- name: Display installed python package versions
260273
run: pip list
261274
- name: Test native speed
@@ -277,6 +290,26 @@ jobs:
277290
- name: Run unit tests
278291
if: ${{ matrix.tox-env }}
279292
run: tox -e ${{ matrix.tox-env }}
293+
- name: Init for mutation testing in PR
294+
if: ${{ matrix.mutation == 'true' && github.event.pull_request }}
295+
run: |
296+
cosmic-ray init cosmic-ray.toml session-vs-master.sqlite
297+
git branch master origin/master
298+
git rev-parse HEAD
299+
git rev-parse master
300+
cr-filter-git --config cosmic-ray.toml session-vs-master.sqlite
301+
- name: Exec mutation testing for PR
302+
if: ${{ matrix.mutation == 'true' && github.event.pull_request }}
303+
run: |
304+
cosmic-ray exec cosmic-ray.toml session-vs-master.sqlite
305+
- name: Check test coverage for PR
306+
if: ${{ matrix.mutation == 'true' && github.event.pull_request }}
307+
run: |
308+
# remove not-executed results
309+
sqlite3 session-vs-master.sqlite "DELETE from work_results WHERE work_results.worker_outcome = 'NO_TEST' OR work_results.worker_outcome = 'SKIPPED'"
310+
cr-report session-vs-master.sqlite | tail -n 5
311+
# check if executed have at most 5% survival rate
312+
cr-rate --fail-over 5 session-vs-master.sqlite
280313
- name: instrumental test coverage on PR
281314
if: ${{ contains(matrix.opt-deps, 'instrumental') && github.event.pull_request }}
282315
env:

0 commit comments

Comments
 (0)