-
Notifications
You must be signed in to change notification settings - Fork 316
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #156 from tomato42/cosmic-ray
Add mutation testing to CI
- Loading branch information
Showing
14 changed files
with
344 additions
and
46 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -215,10 +215,10 @@ jobs: | |
if: ${{ contains(matrix.tox-env, 'gmpyp') }} | ||
run: pip install gmpy | ||
- name: Install gmpy2 dependencies | ||
if: ${{ contains(matrix.tox-env, 'gmpy2') || contains(matrix.tox-env, 'instrumental') }} | ||
if: ${{ contains(matrix.tox-env, 'gmpy2') || contains(matrix.tox-env, 'instrumental') || matrix.mutation == 'true' }} | ||
run: sudo apt-get install -y libmpfr-dev libmpc-dev | ||
- name: Install gmpy2 | ||
if: ${{ contains(matrix.tox-env, 'gmpy2') || contains(matrix.tox-env, 'instrumental') }} | ||
if: ${{ contains(matrix.tox-env, 'gmpy2') || contains(matrix.tox-env, 'instrumental') || matrix.mutation == 'true' }} | ||
run: pip install gmpy2 | ||
- name: Install build dependencies (2.6) | ||
if: ${{ matrix.python-version == '2.6' }} | ||
|
@@ -268,7 +268,8 @@ jobs: | |
- name: Install mutation testing dependencies | ||
if: ${{ matrix.mutation == 'true' }} | ||
run: | | ||
pip install cosmic-ray | ||
pip install https://github.com/sixty-north/cosmic-ray/archive/master.zip | ||
pip install pytest-timeout | ||
- name: Display installed python package versions | ||
run: pip list | ||
- name: Test native speed | ||
|
@@ -296,19 +297,40 @@ jobs: | |
cosmic-ray init cosmic-ray.toml session-vs-master.sqlite | ||
git branch master origin/master | ||
cr-filter-git --config cosmic-ray.toml session-vs-master.sqlite | ||
cr-report session-vs-master.sqlite | tail -n 5 | ||
cr-report session-vs-master.sqlite | tail -n 3 | ||
- name: Exec mutation testing for PR | ||
if: ${{ matrix.mutation == 'true' && github.event.pull_request }} | ||
run: | | ||
cosmic-ray exec cosmic-ray.toml session-vs-master.sqlite | ||
systemd-run --user --scope -p MemoryMax=2G -p MemoryHigh=2G cosmic-ray --verbosity INFO exec cosmic-ray.toml session-vs-master.sqlite & | ||
cosmic_pid=$! | ||
for i in $(seq 1 600); do | ||
# wait for test execution at most 10 minutes | ||
kill -s 0 $cosmic_pid || break | ||
sleep 1 | ||
done | ||
kill $cosmic_pid || true | ||
wait $cosmic_pid || true | ||
- name: Check test coverage for PR | ||
if: ${{ matrix.mutation == 'true' && github.event.pull_request }} | ||
run: | | ||
# remove not-executed results | ||
sqlite3 session-vs-master.sqlite "DELETE from work_results WHERE work_results.worker_outcome = 'SKIPPED'" | ||
cr-report session-vs-master.sqlite | tail -n 5 | ||
# check if executed have at most 5% survival rate | ||
cr-rate --fail-over 5 session-vs-master.sqlite | ||
cr-report session-vs-master.sqlite | tail -n 3 | ||
- name: Generate html report | ||
if: ${{ matrix.mutation == 'true' && github.event.pull_request }} | ||
run: | | ||
cr-html session-vs-master.sqlite > cosmic-ray.html | ||
- name: Archive mutation testing results | ||
if: ${{ matrix.mutation == 'true' && github.event.pull_request }} | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: mutation-PR-coverage-report | ||
path: cosmic-ray.html | ||
- name: Check test coverage for PR | ||
if: ${{ matrix.mutation == 'true' && github.event.pull_request }} | ||
run: | | ||
# check if executed have at most 50% survival rate | ||
cr-rate --estimate --confidence 99.9 --fail-over 50 session-vs-master.sqlite | ||
- name: instrumental test coverage on PR | ||
if: ${{ contains(matrix.opt-deps, 'instrumental') && github.event.pull_request }} | ||
env: | ||
|
@@ -372,6 +394,9 @@ jobs: | |
mutation-prepare: | ||
name: Prepare job files for the mutation runners | ||
# use runner minutes on mutation testing only after the PR passed basic | ||
# testing | ||
needs: coveralls | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
|
@@ -386,7 +411,8 @@ jobs: | |
key: sessions-${{ github.sha }} | ||
- name: Install cosmic-ray | ||
run: | | ||
pip3 install cosmic-ray | ||
pip3 install https://github.com/sixty-north/cosmic-ray/archive/master.zip | ||
pip install pytest-timeout | ||
- name: Install dependencies | ||
run: | | ||
sudo apt-get install -y sqlite3 | ||
|
@@ -461,7 +487,8 @@ jobs: | |
- name: Install build dependencies | ||
run: | | ||
pip install -r build-requirements.txt | ||
pip install cosmic-ray | ||
pip install https://github.com/sixty-north/cosmic-ray/archive/master.zip | ||
pip install pytest-timeout | ||
- name: Run mutation testing | ||
run: | | ||
cp sessions/session-${{ matrix.name }}.sqlite session.sqlite | ||
|
@@ -608,7 +635,8 @@ jobs: | |
key: sessions-${{ github.sha }}-19-done | ||
- name: Install cosmic-ray | ||
run: | | ||
pip3 install cosmic-ray | ||
pip3 install https://github.com/sixty-north/cosmic-ray/archive/master.zip | ||
pip install pytest-timeout | ||
- name: Install dependencies | ||
run: | | ||
sudo apt-get install -y sqlite3 | ||
|
@@ -621,13 +649,20 @@ jobs: | |
- name: Report executed | ||
run: | | ||
cr-report session.sqlite | tail -n 3 | ||
- name: Log survival estimate | ||
run: cr-rate --estimate --fail-over 32 --confidence 99.9 session.sqlite || true | ||
- name: Generate html report | ||
run: | | ||
cr-html session.sqlite > cosmic-ray.html | ||
- name: Archive mutation testing results | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: mutation-coverage-report | ||
path: cosmic-ray.html | ||
- name: Get mutation score | ||
run: | | ||
echo "print(100-$(cr-rate session.sqlite))" > print-score.py | ||
echo "print('{0:.2f}'.format(100-$(cr-rate session.sqlite)))" > print-score.py | ||
echo "MUT_SCORE=$(python print-score.py)" >> $GITHUB_ENV | ||
- name: Create mutation score badge | ||
if: ${{ !github.event.pull_request }} | ||
uses: schneegans/[email protected] | ||
with: | ||
auth: ${{ secrets.GIST_SECRET }} | ||
|
@@ -638,3 +673,5 @@ jobs: | |
valColorRange: ${{ env.MUT_SCORE }} | ||
maxColorRange: 100 | ||
minColorRange: 0 | ||
- name: Check survival estimate | ||
run: cr-rate --estimate --fail-over 32 --confidence 99.9 session.sqlite |
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
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
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
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
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
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
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
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
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
Oops, something went wrong.