Skip to content

Vérifications automatiques additionnelles avec pre-commit #25

Vérifications automatiques additionnelles avec pre-commit

Vérifications automatiques additionnelles avec pre-commit #25

Workflow file for this run

name: Check coverage
on:
pull_request:
branches:
- master
- main
push:
branches:
- master
- main
jobs:
compare-coverage:
name: Compare with previous coverage
runs-on: ubuntu-latest
steps:
- name: Setup git
uses: actions/checkout@v3
- name: Setup python
uses: actions/setup-python@v4
with:
python-version: 3.9
- name: Switch to main branch
uses: actions/checkout@v3
with:
ref: ${{ github.event.repository.default_branch }}
- name: Install previous python dependencies
run: |
python -m pip install --upgrade pip
pip install -r web/requirements.app.txt
pip install -r web/requirements.dev.txt
- name: Get previous coverage
id: get_coverage
run: |
coverage run -m pytest --envfile web.env.example
coverage json
export PERCENT_COVERED=$(python -c "import json;print(json.load(open('coverage.json'))['totals']['percent_covered'])")
echo "percent_covered=$PERCENT_COVERED" >> $GITHUB_OUTPUT
- name: Switch to branch to merge
uses: actions/checkout@v3
with:
fetch-depth: 0
ref: ${{ github.event.pull_request.head.sha }}
- name: Install new python dependencies
run: |
python -m pip install --upgrade pip
pip install -r web/requirements.app.txt
pip install -r web/requirements.dev.txt
- name: Check that coverage at least equals to main coverage
run: pytest --envfile web.env.example --cov --cov-fail-under=${{ steps.get_coverage.outputs.percent_covered }}