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

feat: add reproducible and non reproducible states #134

Merged
merged 2 commits into from
Jun 26, 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
2 changes: 2 additions & 0 deletions pixi.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,14 @@ platforms = ["osx-arm64", "linux-64", "osx-64", "win-64"]
[tasks]
# Rewrite the html with the updated data
generate-html = { cmd = "repror generate-html", inputs = [
"src/repror/**",
"src/repror/cli/templates/index.html.jinja",
"repro.local.db",
], outputs = [
"docs.local/index.html",
] }
generate-html-prod = { cmd = "repror generate-html", env = { REPRO_DB_NAME = "repro.db" }, inputs = [
"src/repror/**",
"repro.db",
"src/repror/cli/templates/index.html.jinja",
], outputs = [
Expand Down
34 changes: 26 additions & 8 deletions src/repror/cli/generate_html.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,19 +44,32 @@ def get_platform_fa(platform):
return "fa-solid fa-question" # Default emoji if platform is unknown


def get_build_state_fa(build_state: BuildState):
if build_state == BuildState.SUCCESS:
return "fa-solid fa-check text-green-600"
reproducible = "fa-solid fa-thumbs-up text-green-600"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's use UPPER_CASE for them

failure = "fa-solid fa-times text-red-600"
non_reproducible = "fa-solid fa-thumbs-down text-red-300"


def get_build_state_fa(
build_state: BuildState, rebuild_state: Optional[BuildState] = None
):
if build_state == BuildState.SUCCESS and (
rebuild_state is None or rebuild_state == BuildState.SUCCESS
):
return reproducible
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

small qq:
if we dont have rebuild state, maybe we could have unknown state?
like the one at the end:
return "fa-solid fa-question"

elif build_state == BuildState.FAIL:
return "fa-solid fa-times text-red-600"
return failure
elif build_state == BuildState.SUCCESS and rebuild_state == BuildState.FAIL:
return non_reproducible
else:
return "fa-solid fa-question"


def platform_fa(platform):
return get_platform_fa(platform)


def build_state_fa(platform):
return get_build_state_fa(platform)
def build_state_fa(build, rebuild):
return get_build_state_fa(build, rebuild)


def get_docs_dir(root_folder: Path):
Expand All @@ -78,7 +91,6 @@ def rerender_html(root_folder: Path, update_remote: bool = False):
loader=FileSystemLoader(searchpath=Path(__file__).parent / "templates")
)
env.filters["platform_fa"] = platform_fa
env.filters["build_state_fa"] = build_state_fa

builds = get_rebuild_data()

Expand Down Expand Up @@ -115,7 +127,13 @@ def rerender_html(root_folder: Path, update_remote: bool = False):

template = env.get_template("index.html.jinja")

html_content = template.render(by_platform=by_platform)
html_content = template.render(
by_platform=by_platform,
build_state_fa=build_state_fa,
reproducible=reproducible,
failure=failure,
non_reproducible=non_reproducible,
)
# Save the table to README.md
index_html_path = docs_folder / Path("index.html")
index_html_path.parent.mkdir(exist_ok=True)
Expand Down
10 changes: 8 additions & 2 deletions src/repror/cli/templates/index.html.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,13 @@
<div>
<canvas id="myChart"></canvas>
</div>

<div class="inline-flex gap-4 border py-3 px-4 bg-gray-50 rounded-xl">
<div>Reproducible: <i class="{{ reproducible }}"></i></div>
<span>|</span>
<div>Non-reproducible: <i class="{{ non_reproducible }}"></i></div>
<span>|</span>
<div>Failure: <i class="{{ failure }}"></i></div>
</div>
{% for platform, builds in by_platform.items() %}
<div class="max-w-xl min-w-full py-2 mt-2 mb-6 overflow-x-auto" x-show="activeTab === {{loop.index}}">
<table class="min-w-full bg-white border border-gray-300">
Expand All @@ -140,7 +146,7 @@
{% for build in builds | sort(attribute='build_state') %}
<tr class="border-b border-dashed">
<td class="py-2 px-4">
<span class="{{build.build_state | build_state_fa}}"></span>
<span class="{{ build_state_fa(build.build_state, build.rebuild_state) }}"></span>
<b>{{ build.recipe_name }}</b>
</td>
<td class="py-2 px-4">
Expand Down
Loading