Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure coverage entries are sorted #114424

Merged
merged 7 commits into from
Apr 1, 2024
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Adjust
  • Loading branch information
epenet committed Mar 29, 2024
commit 04720d7a08c8e52935e932c17ab0d53782e81693
17 changes: 16 additions & 1 deletion script/hassfest/coverage.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ def validate(integrations: dict[str, Integration], config: Config) -> None:
not_found: list[str] = []
checking = False

previous_line = ""
with coverage_path.open("rt") as fp:
for line in fp:
line = line.strip()
Expand Down Expand Up @@ -87,13 +88,27 @@ 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:
if not line.startswith("homeassistant/components/"):
continue

integration_path = path.parent
while len(integration_path.parts) > 3:
integration_path = integration_path.parent

integration = integrations[integration_path.name]

# Ensure sorted
if line < previous_line:
integration.add_error(
"coverage",
f"{line} is unsorted in .coveragerc file",
)
previous_line = line

# Ignore sub-directories for further checks
if len(path.parts) > 4:
continue

if (
path.parts[-1] == "*"
and Path(f"tests/components/{integration.domain}/__init__.py").exists()
Expand Down