Skip to content

Commit 042e3f5

Browse files
committed
Try to simplify SonarQube upload
1 parent 71f7514 commit 042e3f5

File tree

2 files changed

+80
-49
lines changed

2 files changed

+80
-49
lines changed

.github/workflows/tests.yml

Lines changed: 78 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,52 @@ jobs:
2929
runs-on: ubuntu-latest
3030
needs: debug
3131
steps:
32-
- uses: actions/checkout@v4
33-
- name: Install uv
34-
uses: astral-sh/setup-uv@v5
35-
with:
36-
version: ${{ env.UV_VERSION }}
37-
- name: Check lockfile
38-
run: uv lock --check
32+
- uses: actions/checkout@v4
33+
- name: Install uv
34+
uses: astral-sh/setup-uv@v5
35+
with:
36+
version: ${{ env.UV_VERSION }}
37+
- name: Check lockfile
38+
run: uv lock --check
39+
40+
41+
linter:
42+
runs-on: ubuntu-latest
43+
needs: debug
44+
steps:
45+
- uses: actions/checkout@v4
46+
- name: Install uv
47+
uses: astral-sh/setup-uv@v5
48+
with:
49+
version: ${{ env.UV_VERSION }}
50+
- name: Ruff
51+
run: uv run ruff check .
52+
53+
formatter:
54+
runs-on: ubuntu-latest
55+
continue-on-error: true
56+
needs: debug
57+
steps:
58+
- uses: actions/checkout@v4
59+
- name: Install uv
60+
uses: astral-sh/setup-uv@v5
61+
with:
62+
version: ${{ env.UV_VERSION }}
63+
- name: Ruff Format
64+
run: uv run ruff format . --check
65+
66+
mypy:
67+
runs-on: ubuntu-latest
68+
needs: debug
69+
steps:
70+
- uses: actions/checkout@v4
71+
- name: Install uv
72+
uses: astral-sh/setup-uv@v5
73+
with:
74+
version: ${{ env.UV_VERSION }}
75+
- name: Mypy
76+
run: |
77+
uv run --group=type-checking mypy .
3978
4079
generate-jobs:
4180
runs-on: ubuntu-latest
@@ -61,8 +100,6 @@ jobs:
61100
session: ${{ fromJson(needs.generate-jobs.outputs.session) }}
62101
steps:
63102
- uses: actions/checkout@v4
64-
with:
65-
fetch-depth: 0 # SonraQube analysis requires disabling shallow clones
66103

67104
- name: Install nox
68105
uses: wntrblm/nox@2254a1ee500bbf66c2a5e4ff5dad030b9f579dcd # https://github.com/wntrblm/nox/tags
@@ -75,6 +112,16 @@ jobs:
75112
- name: Test session
76113
run: nox -s "${{ matrix.session }}" -- --cov --cov-report=xml:coverage.xml
77114

115+
- name: Build a random name for coverage result upload
116+
id: gen-uuid
117+
run: echo uuid=$(uuidgen) >> $GITHUB_OUTPUT
118+
119+
- name: Archive coverage report
120+
uses: actions/upload-artifact@v4
121+
with:
122+
name: "coverage-report-${{ steps.gen-uuid.outputs.uuid }}"
123+
path: coverage.xml
124+
78125
- name: Submit coverage report - Coveralls
79126
continue-on-error: true
80127
uses: coverallsapp/github-action@v2
@@ -85,45 +132,29 @@ jobs:
85132
CODACY_PROJECT_TOKEN: ${{ secrets.CODACY_PROJECT_TOKEN }}
86133
run: uvx --from codacy-coverage python-codacy-coverage -r coverage.xml
87134

88-
- name: SonarQube Scan + Coverage upload
89-
uses: SonarSource/sonarqube-scan-action@v5
90-
env:
91-
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
92-
93-
linter:
135+
sonar:
94136
runs-on: ubuntu-latest
95-
needs: debug
137+
needs: tests
96138
steps:
97-
- uses: actions/checkout@v4
98-
- name: Install uv
99-
uses: astral-sh/setup-uv@v5
100-
with:
101-
version: ${{ env.UV_VERSION }}
102-
- name: Ruff
103-
run: uv run ruff check .
139+
- uses: actions/checkout@v4
140+
with:
141+
fetch-depth: 0 # SonraQube analysis requires disabling shallow clones
104142

105-
formatter:
106-
runs-on: ubuntu-latest
107-
continue-on-error: true
108-
needs: debug
109-
steps:
110-
- uses: actions/checkout@v4
111-
- name: Install uv
112-
uses: astral-sh/setup-uv@v5
113-
with:
114-
version: ${{ env.UV_VERSION }}
115-
- name: Ruff Format
116-
run: uv run ruff format . --check
143+
- name: Collect coverage report files
144+
uses: actions/download-artifact@v4
145+
with:
146+
pattern: coverage-report*
147+
path: ./artifacts
117148

118-
mypy:
119-
runs-on: ubuntu-latest
120-
needs: debug
121-
steps:
122-
- uses: actions/checkout@v4
123-
- name: Install uv
124-
uses: astral-sh/setup-uv@v5
125-
with:
126-
version: ${{ env.UV_VERSION }}
127-
- name: Mypy
128-
run: |
129-
uv run --group=type-checking mypy .
149+
- name: Join artifacts paths
150+
id: joined-cov-paths
151+
run: echo paths=$(find ./artifacts -name 'coverage.xml' | sed 'N;s/\n/,/g') >> $GITHUB_OUTPUT
152+
153+
- name: SonarQube Scan + Coverage upload
154+
continue-on-error: true
155+
uses: SonarSource/sonarqube-scan-action@v5
156+
env:
157+
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
158+
with:
159+
args: >
160+
--define sonar.python.coverage.reportPaths="${{ steps.joined-cov-paths.outputs.paths }}"

sonar-project.properties

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,5 @@ sonar.sourceEncoding=UTF-8
2020
sonar.py.version=3.8, 3.9, 3.10, 3.11, 3.12, 3.13
2121
sonar.python.version=3.8, 3.9, 3.10, 3.11, 3.12, 3.13
2222

23-
# Upload coverage using the following file
24-
sonar.python.coverage.reportPaths=coverage.xml
23+
# Upload coverage using the following file (overridden in GH Actions workflow)
24+
# sonar.python.coverage.reportPaths=coverage.xml

0 commit comments

Comments
 (0)