Skip to content

Commit efd2f47

Browse files
committed
sonarcloud.yml fix 5
1 parent 1854379 commit efd2f47

File tree

3 files changed

+19
-9
lines changed

3 files changed

+19
-9
lines changed

.coveragerc

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
[run]
2+
branch = True
3+
source = task_manager
4+
relative_files = True
5+
6+
[paths]
7+
source =
8+
task_manager
9+
/home/runner/work/python-project-52/python-project-52/task_manager
10+
/github/workspace/task_manager

.github/workflows/sonarcloud.yml

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,13 @@ jobs:
2222
with:
2323
python-version: '3.11'
2424

25-
- name: Install uv and sync
25+
- name: Install uv and deps
2626
run: |
2727
pip install uv
2828
uv sync --frozen
29-
uv pip install pytest pytest-cov pytest-django
29+
uv pip install pytest pytest-django coverage
3030
31-
- name: Run tests with coverage
31+
- name: Run tests and build coverage.xml (relative paths)
3232
env:
3333
DJANGO_SETTINGS_MODULE: task_manager.settings
3434
SECRET_KEY: test-secret-key
@@ -40,14 +40,12 @@ jobs:
4040
CSRF_COOKIE_SECURE: "False"
4141
run: |
4242
mkdir -p reports
43-
uv run pytest --ds=task_manager.settings \
44-
--cov=task_manager \
45-
--cov-report=xml \
46-
--junitxml=reports/junit.xml
47-
sed -i 's|<source>/home/runner/work/python-project-52/python-project-52</source>|<source>.</source>|g' coverage.xml
43+
uv run coverage erase
44+
uv run coverage run -m pytest --ds=task_manager.settings --junitxml=reports/junit.xml
45+
uv run coverage xml -i -o coverage.xml # учитывает .coveragerc (relative_files + paths)
4846
4947
- name: SonarCloud Scan
5048
uses: SonarSource/sonarcloud-github-action@v2
5149
env:
5250
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
53-
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
51+
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}

sonar-project.properties

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
sonar.projectKey=olyapka84_python-project-52
22
sonar.organization=olyapka84
33
sonar.python.version=3.11
4+
45
sonar.sources=task_manager
56
sonar.tests=tests
67
sonar.exclusions=**/migrations/**,**/__pycache__/**,**/.venv/**,**/venv/**,manage.py
8+
79
sonar.python.coverage.reportPaths=coverage.xml
810
sonar.python.xunit.reportPath=reports/junit.xml

0 commit comments

Comments
 (0)