Skip to content

Commit 33f968f

Browse files
committed
ci: подключить SonarCloud без sonar-project.properties
- Sonar scan настроен через args в workflow - Добавлены SONAR_ORGANIZATION и SONAR_PROJECT_KEY через GitHub Variables - Скан выполняется только при наличии SONAR_TOKEN и переменных
1 parent 41e4adb commit 33f968f

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

.github/workflows/ci.yml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ jobs:
2424
steps:
2525
- name: Checkout
2626
uses: actions/checkout@v4
27+
with:
28+
fetch-depth: 0
2729

2830
- name: Setup Python
2931
uses: actions/setup-python@v5
@@ -88,6 +90,23 @@ jobs:
8890
- name: Run tests with coverage
8991
run: uv run pytest -q --cov=app --cov-report=term-missing --cov-report=xml --junitxml=pytest.xml
9092

93+
- name: SonarCloud Scan
94+
if: ${{ secrets.SONAR_TOKEN != '' && vars.SONAR_PROJECT_KEY != '' && vars.SONAR_ORGANIZATION != '' }}
95+
uses: SonarSource/sonarqube-scan-action@v5
96+
with:
97+
args: >
98+
-Dsonar.projectKey=${{ vars.SONAR_PROJECT_KEY }}
99+
-Dsonar.organization=${{ vars.SONAR_ORGANIZATION }}
100+
-Dsonar.host.url=https://sonarcloud.io
101+
-Dsonar.sources=app
102+
-Dsonar.tests=tests
103+
-Dsonar.test.inclusions=tests/**/*.py
104+
-Dsonar.python.coverage.reportPaths=coverage.xml
105+
-Dsonar.python.xunit.reportPath=pytest.xml
106+
env:
107+
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
108+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
109+
91110
- name: Upload coverage report
92111
uses: actions/upload-artifact@v4
93112
with:

0 commit comments

Comments
 (0)