forked from numerique-gouv/b3desk
-
Notifications
You must be signed in to change notification settings - Fork 0
58 lines (49 loc) · 1.65 KB
/
Test_coverage.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
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 }}