Repository navigation
57 lines (48 loc) · 1.96 KB
/
Copy pathpython-tests.yml
File metadata and controls
57 lines (48 loc) · 1.96 KB
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
name: Python Tests
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
workflow_dispatch:
# Permet de déclencher manuellement le workflow depuis l'interface GitHub
jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [3.9, 3.10]
steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
cache: 'pip'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
if [ -f argumentation_analysis/requirements.txt ]; then pip install -r argumentation_analysis/requirements.txt; fi
pip install pytest pytest-cov
- name: Run tests with coverage
run: |
cd argumentation_analysis
# Exécuter d'abord les tests des modèles et services qui sont stables
python -m pytest --cov=models --cov=services tests/test_extract_definition.py tests/test_extract_result.py tests/test_cache_service.py tests/test_crypto_service.py --cov-report=xml --cov-report=term
# Tenter d'exécuter tous les tests, mais ne pas échouer si certains échouent
python -m pytest --cov=. --cov-append --cov-report=xml --cov-report=term || true
- name: Upload coverage report to Codecov
uses: codecov/codecov-action@v3
with:
file: ./argumentation_analysis/coverage.xml
fail_ci_if_error: false
verbose: true
- name: Check coverage threshold
run: |
cd argumentation_analysis
coverage_percentage=$(python -c "import xml.etree.ElementTree as ET; tree = ET.parse('coverage.xml'); root = tree.getroot(); print(float(root.attrib['line-rate']) * 100)")
echo "Code coverage: $coverage_percentage%"
if (( $(echo "$coverage_percentage < 80" | bc -l) )); then
echo "Code coverage is below 80%"
exit 1
fi