Skip to content

Commit

Permalink
Fix hassfest coverage check (home-assistant#86443)
Browse files Browse the repository at this point in the history
* Fix hassfest coverage check

* A-Z
  • Loading branch information
epenet authored Jan 23, 2023
1 parent a1a324a commit ea43eff
Showing 1 changed file with 16 additions and 14 deletions.
30 changes: 16 additions & 14 deletions script/hassfest/coverage.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,28 @@
("doorbird", "logbook.py"),
("elkm1", "scene.py"),
("fibaro", "scene.py"),
("hunterdouglas_powerview", "scene.py"),
("jellyfin", "media_source.py"),
("lcn", "scene.py"),
("lifx_cloud", "scene.py"),
("lutron", "scene.py"),
("lutron_caseta", "scene.py"),
("nanoleaf", "device_trigger.py"),
("overkiz", "scene.py"),
("radio_browser", "media_source.py"),
("system_bridge", "media_source.py"),
("tuya", "scene.py"),
("upb", "scene.py"),
("velux", "scene.py"),
("xbox", "media_source.py"),
}


def validate(integrations: dict[str, Integration], config: Config) -> None:
"""Validate coverage."""
coverage_path = config.root / ".coveragerc"

not_found = []
not_found: list[str] = []
checking = False

with coverage_path.open("rt") as fp:
Expand Down Expand Up @@ -64,18 +74,17 @@ def validate(integrations: dict[str, Integration], config: Config) -> None:
not_found.append(line)
continue

if (
not line.startswith("homeassistant/components/")
or len(path.parts) != 4
or path.parts[-1] != "*"
):
if not line.startswith("homeassistant/components/") or len(path.parts) != 4:
continue

integration_path = path.parent

integration = integrations[integration_path.name]

for check in DONT_IGNORE:
if path.parts[-1] not in {"*", check}:
continue

if (integration_path.name, check) in ALLOWED_IGNORE_VIOLATIONS:
continue

Expand All @@ -85,14 +94,7 @@ def validate(integrations: dict[str, Integration], config: Config) -> None:
f"{check} must not be ignored by the .coveragerc file",
)

if not not_found:
return

errors = []

if not_found:
errors.append(
raise RuntimeError(
f".coveragerc references files that don't exist: {', '.join(not_found)}."
)

raise RuntimeError(" ".join(errors))

0 comments on commit ea43eff

Please sign in to comment.