-
Notifications
You must be signed in to change notification settings - Fork 0
87 lines (77 loc) · 1.96 KB
/
backend-tests.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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
name: Backend tests
on:
push:
branches: [ "*" ]
pull_request:
branches: [ "*" ]
permissions:
contents: read
jobs:
run_tests:
runs-on: ubuntu-latest
strategy:
matrix:
python-version:
- "3.9"
- "3.10"
- "3.11"
- "3.12"
steps:
-
uses: actions/checkout@v3
-
name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
-
name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r backend/requirements.txt
pip install coverage
-
name: Test with unittest/coverage
run: |
cd backend
coverage run --source='.' manage.py test
python -m coverage json --omit "*/tests.py,*/migrations/*.py,tools/testtools.py,manage.py"
-
name: Upload coverage results
uses: actions/upload-artifact@v3
if: strategy.job-index == 0
with:
name: coverage
path: backend/coverage.json
update_coverage_badge_data:
runs-on: ubuntu-latest
needs: ['run_tests']
if: github.ref == 'refs/heads/master'
steps:
-
name: Download coverage results
uses: actions/download-artifact@v3
with:
name: coverage
-
name: Install jq
run: |
sudo apt install jq
-
name: Fetch coverage
id: coverage
shell: bash
run: |
echo "value=$(jq -r '[.totals.percent_covered_display][0]' coverage.json)" >> $GITHUB_OUTPUT
-
name: Create badge
uses: schneegans/dynamic-badges-action@v1.6.0
with:
auth: ${{ secrets.GIST_SECRET }}
gistID: dad747c31377ea39fcd54bcd7d1702e2
filename: respublica.json
label: Coverage
message: ${{ steps.coverage.outputs.value }}%
minColorRange: 50
maxColorRange: 90
valColorRange: ${{ steps.coverage.outputs.value }}