Skip to content

Add 100% coverage

Add 100% coverage #188

Workflow file for this run

name: test
on:
push:
branches:
- main
pull_request:
branches:
- main
defaults:
run:
shell: bash
jobs:
test:
name: ${{ matrix.os }} python-${{ matrix.python-version }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
python-version: [ '3.8', '3.9', '3.10', '3.11', '3.12' ]
defaults:
run:
shell: bash -l {0}
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Setup conda environment
uses: mamba-org/setup-micromamba@v1
with:
environment-file: environment-dev.yml
environment-name: pycrdt
create-args: python=${{ matrix.python-version }}
- name: Build and install pycrdt
run: pip install -e ".[test]"
- name: Check types
run: mypy python
- name: Run tests
run: pytest --color=yes -v tests
- name: Run code coverage
if: ${{ (matrix.python-version == '3.12') && (matrix.os == 'ubuntu-latest') }}
run: |
coverage run -m pytest
coverage report --show-missing
coverage json
export TOTAL=$(python -c "import json;print(json.load(open('coverage.json'))['totals']['percent_covered_display'])")
echo "total=$TOTAL" >> $GITHUB_ENV
echo "### Total coverage: ${TOTAL}%" >> $GITHUB_STEP_SUMMARY
- name: Make coverage badge
if: ${{ (matrix.python-version == '3.12') && (matrix.os == 'ubuntu-latest') }}
uses: schneegans/[email protected]
with:
auth: ${{ secrets.GIST_TOKEN }}
gistID: davidbrochart/b7b1bad6a6ad7c2ae651b201119f1c27
filename: covbadge.json
label: Coverage
message: ${{ env.total }}%
minColorRange: 50
maxColorRange: 90
valColorRange: ${{ env.total }}