Skip to content

Commit 54332b3

Browse files
authored
Update sonarqube.yml
Signed-off-by: David Osipov <[email protected]>
1 parent f374776 commit 54332b3

File tree

1 file changed

+14
-27
lines changed

1 file changed

+14
-27
lines changed

.github/workflows/sonarqube.yml

Lines changed: 14 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,4 @@
1-
# This workflow uses actions that are not certified by GitHub.
2-
# They are provided by a third-party and are governed by
3-
# separate terms of service, privacy policy, and support
4-
# documentation.
5-
6-
# This workflow triggers a SonarQube analysis of your code and populates
7-
# GitHub Code Scanning alerts with vulnerabilities found.
8-
# (Available starting from SonarQube 9.7, Developer Edition and above)
9-
10-
# Prerequisites:
11-
# 1. Add a valid GitHub configuration in SonarQube (Administration > DevOps platforms > GitHub).
12-
# 2. Import your project into SonarQube by creating a new project from your repository.
13-
# 3. Set up secrets in your GitHub repository:
14-
# - SONAR_TOKEN: Generate a token in SonarQube (My Account > Security) and add it to GitHub secrets.
15-
# - SONAR_HOST_URL: Add your SonarQube host URL (e.g., https://sonarcloud.io) to GitHub secrets.
16-
17-
name: SonarQube analysis
1+
name: Analyze and SonarQube Scan
182

193
on:
204
push:
@@ -39,7 +23,7 @@ jobs:
3923
- name: Set up Python
4024
uses: actions/setup-python@8d9ed9ac5c53483de85588cdf95a591a75ab9f55
4125
with:
42-
python-version: '3.12'
26+
python-version: '3.12' # Matches your log
4327

4428
- name: Cache pip dependencies
4529
uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684
@@ -51,29 +35,32 @@ jobs:
5135
5236
- name: Install project dependencies
5337
run: |
54-
pip install -e .[dev] # Assumes dev dependencies (e.g., Bandit, Ruff, Mypy) are in [dev] extras
38+
pip install .
39+
pip install .[dev]
5540
5641
- name: Install analysis tools
5742
run: |
5843
pip install bandit ruff mypy
44+
ruff --version # For debugging
45+
mypy --version # For debugging
5946
6047
- name: Run Bandit
6148
if: matrix.tool == 'bandit'
6249
run: bandit -r . -o bandit_report.json --format json --exclude tests,.git
6350

6451
- name: Run Ruff
6552
if: matrix.tool == 'ruff'
66-
run: ruff check . --output-format json --output-file ruff_report.json --exclude tests,.git
53+
run: ruff check . --output-format json --output-file ruff_report.json --exclude tests,.git || true
6754

6855
- name: Run Mypy
6956
if: matrix.tool == 'mypy'
70-
run: mypy . > mypy_report.txt
57+
run: mypy . 2>&1 | tee mypy_report.txt || true # Capture output to file and console, continue on error
7158

7259
- name: Upload report artifact
7360
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02
7461
with:
7562
name: ${{ matrix.tool }}-report
76-
path: ${{ matrix.tool }}_report.json
63+
path: ${{ matrix.tool }}_report.*
7764

7865
SonarQube:
7966
needs: Analyze
@@ -103,17 +90,17 @@ jobs:
10390
done
10491
10592
- name: Analyze with SonarQube
106-
uses: SonarSource/sonarqube-scan-action@aa494459d7c39c106cc77b166de8b4250a32bb97 # Pinned by Renovate
93+
uses: SonarSource/sonarqube-scan-action@aa494459d7c39c106cc77b166de8b4250a32bb97
10794
env:
108-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information
109-
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} # Your SonarQube token from secrets
110-
SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }} # Your SonarQube host URL from secrets
95+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
96+
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
97+
SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }}
11198
with:
11299
args: >
113100
-Dsonar.projectKey=DavidOsipov_PostQuantum-Feldman-VSS
114101
-Dsonar.organization=davidosipov
115102
-Dsonar.python.bandit.reportPaths=bandit_report.json
116103
-Dsonar.python.ruff.reportPaths=ruff_report.json
117104
-Dsonar.python.mypy.reportPaths=mypy_report.txt
118-
-Dsonar.python.version=3.10, 3.11, 3.12, 3.13
105+
-Dsonar.python.version=3.10-3.13
119106
-Dsonar.languages=python

0 commit comments

Comments
 (0)