Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/report.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,6 @@ jobs:
poetry run -- nox -s project:report -- --format markdown >> $GITHUB_STEP_SUMMARY
poetry run -- nox -s dependency:licenses >> $GITHUB_STEP_SUMMARY
echo -e "\n\n# Coverage\n" >> $GITHUB_STEP_SUMMARY
poetry run coverage report -- --format markdown >> $GITHUB_STEP_SUMMARY
poetry run -- coverage report --format markdown >> $GITHUB_STEP_SUMMARY || true
poetry run -- tbx lint pretty-print >> $GITHUB_STEP_SUMMARY
poetry run -- tbx security pretty-print .security.json >> $GITHUB_STEP_SUMMARY
4 changes: 4 additions & 0 deletions doc/changes/unreleased.md
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
# Unreleased

## Bugfixes

* #397: Fix handling empty coverage
19 changes: 16 additions & 3 deletions exasol/toolbox/metrics.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import datetime
import json
import re
import subprocess
import sys
from collections import defaultdict
from dataclasses import (
asdict,
Expand All @@ -13,7 +15,6 @@
from functools import singledispatch
from inspect import cleandoc
from pathlib import Path
from subprocess import run
from tempfile import TemporaryDirectory
from typing import (
Any,
Expand Down Expand Up @@ -104,11 +105,23 @@ def total_coverage(file: Union[str, Path]) -> float:
with TemporaryDirectory() as tmpdir:
tmp_dir = Path(tmpdir)
report = tmp_dir / "coverage.json"
run(
p = subprocess.run(
["coverage", "json", f"--data-file={file}", "-o", f"{report}"],
capture_output=True,
check=True,
check=False,
encoding="utf-8",
)
stdout = p.stdout.strip()
if (p.returncode == 1) and (stdout == "No data to report."):
print(
f"The following command"
f" returned non-zero exit status {p.returncode}:\n"
f' {" ".join(p.args)}\n'
f"{stdout}\n"
"Returning total coverage 100 %.",
file=sys.stderr,
)
return 100.0
with open(report, encoding="utf-8") as r:
data = json.load(r)
total: float = data["totals"]["percent_covered"]
Expand Down
4 changes: 2 additions & 2 deletions exasol/toolbox/templates/github/workflows/report.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ jobs:
# Errors during copying are ignored because they are checked in the next step
cp .coverage ../ || true
cp lint-python3.9/.lint.txt ../ || true
cp lint-python3.9/.lint.txt ../ || true
cp lint-python3.9/.lint.json ../ || true
cp security-python3.9/.security.json ../ || true

- name: Validate Artifacts
Expand All @@ -52,6 +52,6 @@ jobs:
poetry run -- nox -s project:report -- --format markdown >> $GITHUB_STEP_SUMMARY
poetry run -- nox -s dependency:licenses >> $GITHUB_STEP_SUMMARY
echo -e "\n\n# Coverage\n" >> $GITHUB_STEP_SUMMARY
poetry run coverage report -- --format markdown >> $GITHUB_STEP_SUMMARY
poetry run -- coverage report --format markdown >> $GITHUB_STEP_SUMMARY || true
poetry run -- tbx lint pretty-print >> $GITHUB_STEP_SUMMARY
poetry run -- tbx security pretty-print .security.json >> $GITHUB_STEP_SUMMARY
8 changes: 7 additions & 1 deletion project-template/{{cookiecutter.repo_name}}/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -142,4 +142,10 @@ doc/api
itde/

# Emacs
TAGS
/TAGS

# PTB
/.lint.json
/.lint.txt
/.security.json