name: GitHub CI on: push: branches: - master pull_request: jobs: test: runs-on: ${{ matrix.os }} container: ${{ matrix.container }} strategy: fail-fast: false matrix: include: - name: py2.6 os: ubuntu-latest container: centos:6 python-version: 2.6 - name: py3.10 with ossl3.0 os: ubuntu-latest container: ubuntu:22.04 python-version: "3.10" tox-env: py310 - name: py2.7 os: ubuntu-22.04 python-version: 2.7 tox-env: py27 - name: py2.7 with old gmpy os: ubuntu-22.04 python-version: 2.7 tox-env: py27_old_gmpy - name: py2.7 with old gmpy2 os: ubuntu-22.04 python-version: 2.7 tox-env: py27_old_gmpy2 - name: py2.7 with old six os: ubuntu-22.04 python-version: 2.7 tox-env: py27_old_six - name: py2.7 with gmpy os: ubuntu-22.04 python-version: 2.7 tox-env: gmpypy27 - name: py2.7 with gmpy2 os: ubuntu-22.04 python-version: 2.7 tox-env: gmpy2py27 - name: py3.6 os: ubuntu-latest container: centos:8 python-version: 3.6 tox-env: py36 - name: py3.7 os: ubuntu-22.04 python-version: 3.7 tox-env: py37 - name: py3.8 os: ubuntu-latest python-version: 3.8 tox-env: py38 - name: py3.9 os: ubuntu-latest python-version: 3.9 tox-env: py39 - name: py3.10 os: ubuntu-latest python-version: '3.10' tox-env: py310 - name: py3.10 with gmpy os: ubuntu-latest python-version: '3.10' tox-env: gmpypy310 - name: py3.10 with gmpy2 os: ubuntu-latest python-version: '3.10' tox-env: gmpy2py310 - name: py3.11 os: ubuntu-latest python-version: '3.11' tox-env: py311 - name: py3.12 os: ubuntu-latest python-version: '3.12' tox-env: py312 - name: py3.13 os: ubuntu-latest python-version: '3.13' tox-env: py313 - name: pypy os: ubuntu-latest python-version: pypy-2.7 tox-env: pypy - name: pypy3 os: ubuntu-22.04 python-version: pypy-3.7 tox-env: pypy3 # special configurations - name: py2.7 with instrumental os: ubuntu-22.04 python-version: 2.7 opt-deps: ['instrumental'] - name: code checks os: ubuntu-latest python-version: 3.9 tox-env: codechecks - name: mutation testing os: ubuntu-latest python-version: '3.11' mutation: 'true' steps: - uses: actions/checkout@v2 if: ${{ !matrix.container }} with: fetch-depth: 50 - uses: actions/checkout@v1 # centos 6 doesn't have glibc new enough for the nodejs used by v2 if: ${{ matrix.container }} with: fetch-depth: 50 - name: Ensure dependencies on CentOS:6 if: ${{ matrix.container == 'centos:6' }} run: | ls /etc/yum.repos.d/ cat /etc/yum.repos.d/CentOS-Base.repo rm /etc/yum.repos.d/CentOS-Base.repo cat > /etc/yum.repos.d/CentOS-Base.repo < /etc/yum.repos.d/CentOS-Linux-BaseOS.repo < /etc/yum.repos.d/CentOS-Linux-AppStream.repo < /etc/yum.repos.d/CentOS-Linux-Extras.repo < cosmic-ray.html - name: Archive mutation testing results if: ${{ matrix.mutation == 'true' && github.event.pull_request }} uses: actions/upload-artifact@v4 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: BASE_REF: ${{ github.event.pull_request.base.ref }} run: | git fetch origin $BASE_REF MERGE_BASE=$(git merge-base origin/$BASE_REF HEAD) echo "MERGE_BASE:" $MERGE_BASE git checkout $MERGE_BASE instrumental -t ecdsa -i '.*test_.*|.*_version|.*_compat|.*_sha3' `which pytest` src/ecdsa/test*.py instrumental -f .instrumental.cov -s instrumental -f .instrumental.cov -s | python diff-instrumental.py --save .diff-instrumental git checkout $GITHUB_SHA instrumental -t ecdsa -i '.*test_.*|.*_version|.*_compat|.*_sha3' `which pytest` src/ecdsa/test*.py instrumental -f .instrumental.cov -sr instrumental -f .instrumental.cov -s | python diff-instrumental.py --read .diff-instrumental --fail-under 70 --max-difference -0.1 - name: instrumental test coverage on push if: ${{ contains(matrix.opt-deps, 'instrumental') && !github.event.pull_request }} run: | instrumental -t ecdsa -i '.*test_.*|.*_version|.*_compat|.*_sha3' `which pytest` src/ecdsa instrumental -f .instrumental.cov -s # just log the values when merging instrumental -f .instrumental.cov -s | python diff-instrumental.py echo "COND_COV=$(instrumental -f .instrumental.cov -s | python diff-instrumental.py --raw)" >> $GITHUB_ENV - name: Create condition coverage badge uses: schneegans/dynamic-badges-action@v1.4.0 if: ${{ contains(matrix.opt-deps, 'instrumental') && !github.event.pull_request }} with: auth: ${{ secrets.GIST_SECRET }} gistID: 9b6ca1f3410207fbeca785a178781651 filename: python-ecdsa-condition-coverage.json label: condition coverage message: ${{ env.COND_COV }}% valColorRange: ${{ env.COND_COV }} maxColorRange: 100 minColorRange: 0 - name: Publish coverage to Coveralls if: ${{ !matrix.opt-deps && matrix.tox-env != 'codechecks' }} env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} COVERALLS_FLAG_NAME: ${{ matrix.name }} COVERALLS_PARALLEL: true COVERALLS_SERVICE_NAME: github PY_VERSION: ${{ matrix.python-version }} run: | if [[ $PY_VERSION == "2.6" ]]; then COVERALLS_SKIP_SSL_VERIFY=1 coveralls else coveralls fi coveralls: name: Indicate completion to coveralls.io needs: test runs-on: ubuntu-latest container: python:3-slim steps: - name: Install coveralls run: | pip3 install --upgrade coveralls - name: Send "finished" signal to coveralls env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} COVERALLS_SERVICE_NAME: github run: | coveralls --finish 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 if: ${{ !matrix.container }} with: fetch-depth: 50 - name: save session objects uses: actions/cache@v3 with: path: | sessions/ key: sessions-${{ github.sha }} - name: Install cosmic-ray run: | pip3 install cosmic-ray pip install pytest-timeout - name: Install dependencies run: | sudo apt-get install -y sqlite3 - name: Display Python version run: python -c "import sys; print(sys.version)" - name: Create list of mutations run: | cosmic-ray init cosmic-ray.toml session.sqlite - name: Log number of jobs created run: | cr-report session.sqlite | tail -n 3 - name: Split up mutations to workers run: | cp session.sqlite session-to_del.sqlite sqlite3 session-to_del.sqlite "$(cat sql/create_to_del.sql)" mkdir sessions for i in $(seq 0 19); do sed "s/%SHARD%/$i/" < sql/shard-db.sql > shard.sql cp session-to_del.sqlite session-$i.sqlite sqlite3 session-$i.sqlite "$(cat shard.sql)" mv session-$i.sqlite sessions/ done mutation-execute: name: Execute mutation testing needs: mutation-prepare runs-on: ubuntu-latest strategy: fail-fast: false matrix: include: - name: 0 - name: 1 - name: 2 - name: 3 - name: 4 - name: 5 - name: 6 - name: 7 - name: 8 - name: 9 - name: 10 - name: 11 - name: 12 - name: 13 - name: 14 - name: 15 - name: 16 - name: 17 - name: 18 - name: 19 steps: - uses: actions/checkout@v2 if: ${{ !matrix.container }} with: fetch-depth: 1 - name: Session objects uses: actions/cache@v3 with: path: | sessions/ key: sessions-${{ github.sha }} - name: Session done objects uses: actions/cache@v3 with: path: | sessions-done/session-${{ matrix.name }}-done.sqlite key: sessions-${{ github.sha }}-${{ matrix.name }}-done - name: Install gmpy2 dependencies run: sudo apt-get install -y libmpfr-dev libmpc-dev - name: Install gmpy2 run: pip install gmpy2 - name: Install build dependencies run: | pip install -r build-requirements.txt pip install cosmic-ray pip install pytest-timeout - name: Run mutation testing run: | cp sessions/session-${{ matrix.name }}.sqlite session.sqlite systemd-run --user --scope -p MemoryMax=2G -p MemoryHigh=2G cosmic-ray exec cosmic-ray.toml session.sqlite & cosmic_pid=$! sleep 1 for i in $(seq 1 10); do if ! kill -s 0 $cosmic_pid; then break fi echo $i sleep 60 done kill -s 0 $cosmic_pid && kill $cosmic_pid mkdir sessions-done/ cp session.sqlite sessions-done/session-${{ matrix.name }}-done.sqlite - name: Report executed run: | cr-report session.sqlite | tail -n 3 mutation-combine: name: Combine mutation testing results needs: mutation-execute runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 if: ${{ !matrix.container }} with: fetch-depth: 1 - name: Session done 0 objects uses: actions/cache@v3 with: path: | sessions-done/session-0-done.sqlite key: sessions-${{ github.sha }}-0-done - name: Session done 1 objects uses: actions/cache@v3 with: path: | sessions-done/session-1-done.sqlite key: sessions-${{ github.sha }}-1-done - name: Session done 2 objects uses: actions/cache@v3 with: path: | sessions-done/session-2-done.sqlite key: sessions-${{ github.sha }}-2-done - name: Session done 3 objects uses: actions/cache@v3 with: path: | sessions-done/session-3-done.sqlite key: sessions-${{ github.sha }}-3-done - name: Session done 4 objects uses: actions/cache@v3 with: path: | sessions-done/session-4-done.sqlite key: sessions-${{ github.sha }}-4-done - name: Session done 5 objects uses: actions/cache@v3 with: path: | sessions-done/session-5-done.sqlite key: sessions-${{ github.sha }}-5-done - name: Session done 6 objects uses: actions/cache@v3 with: path: | sessions-done/session-6-done.sqlite key: sessions-${{ github.sha }}-6-done - name: Session done 7 objects uses: actions/cache@v3 with: path: | sessions-done/session-7-done.sqlite key: sessions-${{ github.sha }}-7-done - name: Session done 8 objects uses: actions/cache@v3 with: path: | sessions-done/session-8-done.sqlite key: sessions-${{ github.sha }}-8-done - name: Session done 9 objects uses: actions/cache@v3 with: path: | sessions-done/session-9-done.sqlite key: sessions-${{ github.sha }}-9-done - name: Session done 10 objects uses: actions/cache@v3 with: path: | sessions-done/session-10-done.sqlite key: sessions-${{ github.sha }}-10-done - name: Session done 11 objects uses: actions/cache@v3 with: path: | sessions-done/session-11-done.sqlite key: sessions-${{ github.sha }}-11-done - name: Session done 12 objects uses: actions/cache@v3 with: path: | sessions-done/session-12-done.sqlite key: sessions-${{ github.sha }}-12-done - name: Session done 13 objects uses: actions/cache@v3 with: path: | sessions-done/session-13-done.sqlite key: sessions-${{ github.sha }}-13-done - name: Session done 14 objects uses: actions/cache@v3 with: path: | sessions-done/session-14-done.sqlite key: sessions-${{ github.sha }}-14-done - name: Session done 15 objects uses: actions/cache@v3 with: path: | sessions-done/session-15-done.sqlite key: sessions-${{ github.sha }}-15-done - name: Session done 16 objects uses: actions/cache@v3 with: path: | sessions-done/session-16-done.sqlite key: sessions-${{ github.sha }}-16-done - name: Session done 17 objects uses: actions/cache@v3 with: path: | sessions-done/session-17-done.sqlite key: sessions-${{ github.sha }}-17-done - name: Session done 18 objects uses: actions/cache@v3 with: path: | sessions-done/session-18-done.sqlite key: sessions-${{ github.sha }}-18-done - name: Session done 19 objects uses: actions/cache@v3 with: path: | sessions-done/session-19-done.sqlite key: sessions-${{ github.sha }}-19-done - name: Install cosmic-ray run: | pip3 install cosmic-ray pip install pytest-timeout - name: Install dependencies run: | sudo apt-get install -y sqlite3 - name: Combine worker results run: | cp sessions-done/session-0-done.sqlite session.sqlite for i in $(seq 1 19); do cp sessions-done/session-$i-done.sqlite session-to_merge.sqlite && sqlite3 session.sqlite "$(cat sql/combine.sql)" || true done - name: Report executed run: | cr-report session.sqlite | tail -n 3 - name: Generate html report run: | cr-html session.sqlite > cosmic-ray.html - name: Archive mutation testing results uses: actions/upload-artifact@v4 with: name: mutation-coverage-report path: cosmic-ray.html - name: Get mutation score run: | 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/dynamic-badges-action@v1.4.0 with: auth: ${{ secrets.GIST_SECRET }} gistID: 9b6ca1f3410207fbeca785a178781651 filename: python-ecdsa-mutation-score.json label: mutation score message: ${{ env.MUT_SCORE }}% valColorRange: ${{ env.MUT_SCORE }} maxColorRange: 100 minColorRange: 0 - name: Check survival estimate run: cr-rate --estimate --fail-over 32 --confidence 99.9 session.sqlite