Skip to content

Commit 4649afa

Browse files
authored
tests: Add coverage report to sonar (#324)
1 parent 30b82cc commit 4649afa

2 files changed

Lines changed: 26 additions & 2 deletions

File tree

.github/workflows/python-package.yml

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ on:
1111

1212
jobs:
1313
build:
14-
1514
runs-on: ubuntu-latest
1615
strategy:
1716
fail-fast: false
@@ -20,6 +19,7 @@ jobs:
2019

2120
steps:
2221
- uses: actions/checkout@v3
22+
- run: git fetch origin develop
2323
- name: Set up Python ${{ matrix.python-version }}
2424
uses: actions/setup-python@v3
2525
with:
@@ -61,4 +61,27 @@ jobs:
6161
- name: Test with pytest
6262
run: |
6363
source .venv/bin/activate
64-
pytest
64+
pytest --cov-report=xml --junitxml=xunit-results.xml
65+
coverage xml
66+
- name: Upload artifacts
67+
uses: actions/upload-artifact@v3
68+
with:
69+
name: test-results
70+
path: |
71+
coverage.xml
72+
xunit-results.xml
73+
- name: SonarCloud Scan
74+
uses: SonarSource/sonarcloud-github-action@master
75+
env:
76+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
77+
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
78+
with:
79+
args: >
80+
-Dsonar.organization=fgmacedo
81+
-Dsonar.projectKey=fgmacedo_python-statemachine
82+
-Dsonar.python.coverage.reportPaths=coverage.xml
83+
-Dsonar.sources=statemachine/
84+
-Dsonar.test.exclusions=tests/**
85+
-Dsonar.tests=tests/
86+
-Dsonar.python.version=3
87+
-Dsonar.verbose=false

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,7 @@ convention = "google"
135135

136136
[tool.coverage.run]
137137
branch = true
138+
relative_files = true
138139
data_file = ".coverage"
139140
source = [
140141
"statemachine",

0 commit comments

Comments
 (0)