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

Add checkout strategy to report. #403

Merged
merged 3 commits into from
Jun 11, 2024
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
12 changes: 11 additions & 1 deletion nixpkgs_review/report.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import subprocess
from collections.abc import Callable
from pathlib import Path
from typing import Literal

from .nix import Attr
from .utils import info, link, warn
Expand Down Expand Up @@ -90,10 +91,16 @@ def write_error_logs(attrs: list[Attr], directory: Path) -> None:

class Report:
def __init__(
self, system: str, attrs: list[Attr], extra_nixpkgs_config: str
self,
system: str,
attrs: list[Attr],
extra_nixpkgs_config: str,
*,
checkout: Literal["merge", "commit"] = "merge",
) -> None:
self.system = system
self.attrs = attrs
self.checkout = checkout
self.broken: list[Attr] = []
self.failed: list[Attr] = []
self.non_existent: list[Attr] = []
Expand Down Expand Up @@ -144,6 +151,7 @@ def serialize_attrs(attrs: list[Attr]) -> list[str]:
{
"system": self.system,
"pr": pr,
"checkout": self.checkout,
"extra-nixpkgs-config": self.extra_nixpkgs_config,
"broken": serialize_attrs(self.broken),
"non-existent": serialize_attrs(self.non_existent),
Expand All @@ -162,6 +170,8 @@ def markdown(self, pr: int | None) -> str:
cmd += f" pr {pr}"
if self.extra_nixpkgs_config:
cmd += f" --extra-nixpkgs-config '{self.extra_nixpkgs_config}'"
if self.checkout != "merge":
cmd += f" --checkout {self.checkout}"

msg = f"Result of `{cmd}` run on {self.system} [1](https://github.com/Mic92/nixpkgs-review)\n"

Expand Down
7 changes: 6 additions & 1 deletion nixpkgs_review/review.py
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,12 @@ def start_review(
os.environ["NIXPKGS_REVIEW_ROOT"] = str(path)
if pr:
os.environ["PR"] = str(pr)
report = Report(self.system, attr, self.extra_nixpkgs_config)
report = Report(
self.system,
attr,
self.extra_nixpkgs_config,
checkout=self.checkout.name.lower(), # type: ignore
)
report.print_console(pr)
report.write(path, pr)

Expand Down