-
Notifications
You must be signed in to change notification settings - Fork 315
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add mutation testing to CI #156
Merged
Merged
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
8c2531f
more realistic mutation rate and update badge only on merge
tomato42 87ef2b2
faster ecdh and malformed_sigs tests in mutation testing
tomato42 307fa3a
fast examples for numbertheory tests
tomato42 d564539
test coverage for keys module
tomato42 9fc7ed8
mark env-related branches in tests as no cover
tomato42 ce2dd53
more test coverage for keys module, remove dead code
tomato42 a394b68
numbertheory: don't require branch coverage for loops that always exe…
tomato42 5025ce3
limit runtime for PR-specific mutation testing
tomato42 304263b
provide debugging information in mutation run, upload mutation report
tomato42 79bc0c5
more test coverage for ellipticurve module
tomato42 e16173b
two digit precision for the mutation score badge
tomato42 09f0d10
add hard timeout for test mutation test suite
tomato42 4845e8f
better is_prime()
tomato42 02c8350
be more permissive for the PR mutation test coverage
tomato42 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nitpick: Isn't it easier (if possible) to use timeout 10m?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good idea, but to implement it I would have to figure out error handling and so on... this is good enough (and probably easier to port to macos)