Skip to content

Commit f78841a

Browse files
committed
Test out what happens to sonarqubebot if no coverage included in pysonar upload
1 parent cf14cc0 commit f78841a

File tree

1 file changed

+4
-15
lines changed

1 file changed

+4
-15
lines changed

exasol/toolbox/nox/_artifacts.py

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -207,19 +207,7 @@ def _prepare_coverage_xml(session: Session, source: Path) -> None:
207207
f"{source}/*",
208208
"--fail-under=0",
209209
]
210-
output = subprocess.run(
211-
command, capture_output=True, text=True, check=False
212-
) # nosec
213-
214-
if output.returncode != 0:
215-
if output.stdout.strip() == "No data to report.":
216-
# Assuming that previous steps passed in the CI, this indicates — as
217-
# is in the case for newly created projects — that no coverage over the
218-
# `source` files was found. To allow Sonar to report, we create
219-
# a dummy file which will toss a warning but otherwise successfully execute.
220-
Path(COVERAGE_XML).touch()
221-
else:
222-
session.error(output.returncode)
210+
session.run(*command)
223211

224212

225213
def _upload_to_sonar(
@@ -229,8 +217,6 @@ def _upload_to_sonar(
229217
"pysonar",
230218
"--sonar-token",
231219
sonar_token,
232-
"--sonar-python-coverage-report-paths",
233-
COVERAGE_XML,
234220
"--sonar-python-pylint-report-path",
235221
LINT_JSON,
236222
"--sonar-python-bandit-report-paths",
@@ -240,6 +226,9 @@ def _upload_to_sonar(
240226
"--sonar-sources",
241227
config.source,
242228
]
229+
if Path("dummy").exists():
230+
command.extend(["--sonar-python-coverage-report-paths", COVERAGE_XML])
231+
243232
session.run(*command) # type: ignore
244233

245234

0 commit comments

Comments
 (0)