generated from frehburg/TemplateForPythonProjects
-
Notifications
You must be signed in to change notification settings - Fork 0
49 lines (45 loc) · 1.62 KB
/
python_ci.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
name: CI
on:
push:
branches: [ develop ]
pull_request:
branches: [ main, develop ]
jobs:
run-ci:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ['3.10', '3.11', '3.12']
steps:
- uses: actions/checkout@v4
- name: Initialize Python
uses: actions/setup-python@v4.3.1
with:
python-version: ${{ matrix.python-version }}
- name: Install package
run: |
python3 -m pip install --editable .[test,docs]
- name: Run pytest tests with coverage
run: |
pytest --cov=phenopacket_mapper --cov-report=term --cov-report=xml:coverage.xml
- name: Extract coverage percentage
id: coverage
run: |
# Extract the percentage from the XML report
coverage=$(grep -oP '(?<=line-rate=")[0-9.]+(?=")' coverage.xml)
# Multiply by 100 to get the percentage
COVERAGE=$(awk -v cov="$coverage" 'BEGIN {printf "%.2f\n", cov * 100}')
echo "COVERAGE=${COVERAGE}" >> $GITHUB_ENV
echo "Coverage percentage: $COVERAGE"
- name: Display coverage
run: |
echo "Coverage: ${{ env.COVERAGE }}%"
- name: Create Badge
uses: schneegans/dynamic-badges-action@v1.7.0
with:
auth: ${{ secrets.GIST_SECRET }}
gistID: 67304fe3700ce3d41079e75f4fe9609f
filename: phenopacket_mapper_test_cov.JSON # Use test.svg if you want to use the SVG mode.
label: Test Coverage
message: ${{ env.COVERAGE }}%
color: green