Skip to content

Commit 38dd713

Browse files
committed
Adapting GH action for coverage
Signed-off-by: Cédric Foellmi <cedric@onekiloparsec.dev>
1 parent 40eff83 commit 38dd713

File tree

2 files changed

+30
-8
lines changed

2 files changed

+30
-8
lines changed

.github/workflows/tests.yml

Lines changed: 28 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ on:
77
branches: [ '*' ]
88

99
jobs:
10-
test:
10+
tests:
1111
runs-on: ubuntu-latest
1212
strategy:
1313
matrix:
@@ -30,21 +30,41 @@ jobs:
3030
3131
- name: Test with pytest
3232
run: |
33-
pytest -xvs tests/ --cov=arcsecond --cov-report=xml
33+
pytest -xvs tests/ --cov=arcsecond --cov-report=xml:coverage-${{ matrix.python-version }}.xml
3434
35-
- name: Upload coverage to Codecov
36-
uses: codecov/codecov-action@v3
35+
- name: Upload coverage artifact
36+
uses: actions/upload-artifact@v4
3737
with:
38-
file: ./coverage.xml
39-
fail_ci_if_error: false
38+
name: coverage-${{ matrix.python-version }}
39+
path: coverage-${{ matrix.python-version }}.xml
4040

4141
scan:
4242
runs-on: ubuntu-latest
43+
needs: tests
44+
4345
steps:
4446
- uses: actions/checkout@v4
45-
47+
48+
- name: Set up Python
49+
uses: actions/setup-python@v4
50+
with:
51+
python-version: "3.12"
52+
53+
- name: Download all coverage artifacts
54+
uses: actions/download-artifact@v4
55+
with:
56+
path: coverages
57+
58+
- name: Install coverage.py
59+
run: pip install coverage
60+
61+
- name: Merge coverage files
62+
run: |
63+
coverage combine coverages
64+
coverage xml -o coverage.xml
65+
4666
- name: SonarQube Scan
47-
uses: SonarSource/sonarqube-scan-action@v4
67+
uses: SonarSource/sonarcloud-github-action@master
4868
env:
4969
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
5070

sonar-project.properties

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ sonar.tests=./tests
1515
sonar.test.exclusions=
1616
sonar.test.inclusions=**/tests/**,**/_tests_/**
1717

18+
sonar.python.coverage.reportPaths=coverage.xml
19+
1820
# Encoding of the source code. Default is default system encoding
1921
sonar.sourceEncoding=UTF-8
2022

0 commit comments

Comments
 (0)