Skip to content

Commit dfcf34a

Browse files
committed
Fix link name.
Add More information to build info section in the report. Center and split the top report headers
1 parent e157573 commit dfcf34a

File tree

3 files changed

+63
-30
lines changed

3 files changed

+63
-30
lines changed

ci/ci.py

Lines changed: 42 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -375,7 +375,8 @@ def _endtest(self, container:Container, tag:str, build_info:dict[str,str], packa
375375
"test_results": self.tag_report_tests[tag]["test"],
376376
"test_success": test_success,
377377
"runtime": runtime,
378-
"build_url": self.make_build_url(tag)
378+
"build_url": self.get_build_url(tag),
379+
"platform": self.get_platform(tag).upper()
379380
}
380381
self.report_containers[tag]["has_warnings"] = any(warning[1] for warning in self.report_containers[tag]["warnings"].items())
381382

@@ -511,6 +512,39 @@ def get_build_version(self,container:Container,tag:str) -> str:
511512
self.report_status = "FAIL"
512513
return build_version
513514

515+
def get_image_name(self) -> str:
516+
"""Get the image name from the IMAGE env.
517+
518+
Returns:
519+
str: The container name
520+
"""
521+
_, container_name = self.image.split("/")
522+
match self.image:
523+
case _ if "lspipepr" in self.image:
524+
return f"linuxserver/lspipepr-{container_name}"
525+
case _ if "lsiodev" in self.image:
526+
return f"linuxserver/lsiodev-{container_name}"
527+
case _:
528+
return self.image
529+
530+
def get_build_url(self, tag) -> str:
531+
"""Get the build url from the IMAGE env.
532+
533+
Args:
534+
tag (str): The tag we are testing
535+
536+
Returns:
537+
dict: Returns a dictionary with the build url and container name
538+
"""
539+
_, container_name = self.image.split("/")
540+
match self.image:
541+
case _ if "lspipepr" in self.image:
542+
return f"https://ghcr.io/linuxserver/lspipepr-{container_name}:{tag}"
543+
case _ if "lsiodev" in self.image:
544+
return f"https://ghcr.io/linuxserver/lsiodev-{container_name}:{tag}"
545+
case _:
546+
return f"https://ghcr.io/{self.image}:{tag}"
547+
514548
def get_build_info(self,container:Container,tag:str) -> dict[str,str]:
515549
"""Get the build information from the container object.
516550
@@ -527,7 +561,9 @@ def get_build_info(self,container:Container,tag:str) -> dict[str,str]:
527561
"created": "xxxx-xx-xx",
528562
"size": "100MB",
529563
"maintainer": "user"
530-
"builder": "node"
564+
"builder": "node",
565+
"tag": "latest",
566+
"image": "linuxserver/xxx"
531567
}
532568
```
533569
"""
@@ -540,7 +576,9 @@ def get_build_info(self,container:Container,tag:str) -> dict[str,str]:
540576
"created": container.attrs["Config"]["Labels"]["org.opencontainers.image.created"],
541577
"size": "%.2f" % float(int(container.image.attrs["Size"])/1000000) + "MB",
542578
"maintainer": container.attrs["Config"]["Labels"]["maintainer"],
543-
"builder": self.builder
579+
"builder": self.builder,
580+
"tag": tag,
581+
"image": self.get_image_name()
544582
}
545583
self._add_test_result(tag, test, "PASS", "-", start_time)
546584
self.logger.success("Get build info on tag '%s': PASS", tag)
@@ -600,7 +638,7 @@ def report_render(self) -> None:
600638
report_containers=self.report_containers,
601639
report_status=self.report_status,
602640
meta_tag=self.meta_tag,
603-
image=self.image,
641+
image=self.get_image_name(),
604642
bucket=self.bucket,
605643
region=self.region,
606644
screenshot=self.screenshot,
@@ -894,23 +932,6 @@ def create_docker_client(self) -> DockerClient|None:
894932
except Exception:
895933
self.logger.error("Failed to create Docker client!")
896934

897-
def make_build_url(self, tag) -> str:
898-
"""Create a build url for the image
899935

900-
Args:
901-
tag (str): The tag we are testing
902-
903-
Returns:
904-
str: Returns a build url
905-
"""
906-
_, container_name = self.image.split("/")
907-
match self.image:
908-
case _ if "lspipepr" in self.image:
909-
return f"https://ghcr.io/linuxserver/lspipepr-{container_name}:{tag}"
910-
case _ if "lsiodev" in self.image:
911-
return f"https://ghcr.io/linuxserver/lsiodev-{container_name}:{tag}"
912-
case _:
913-
return f"https://ghcr.io/{self.image}:{tag}"
914-
915936
class CIError(Exception):
916937
pass

ci/template.html

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -562,21 +562,23 @@
562562
<h1>Linux<span>Server</span>.io</h1>
563563
</header>
564564
<div id="results">
565-
<h1>Test Results <strong>{{ image }}:{{ meta_tag }}</strong></h1>
565+
<h1 style="margin-bottom: 0; text-align: center;">Test Results</h1>
566+
<h2 style="margin-bottom: 0; text-align: center;"><strong>{{ image }}</strong></span></h2>
567+
<h3 style="margin-top:0; margin-bottom: 0; text-align: center;"><strong>{{ meta_tag }}</strong></span></h2>
566568
<h2 style="margin-bottom: 0">Cumulative: <span class="report-status-{{ report_status.lower() }}">{{ report_status }}</span></h2>
567569
<span>Total Runtime: {{ total_runtime }}</span>
568570
<main>
569571
{% for tag in report_containers %}
570572
<section>
571573
<div class="section-header">
572574
{% if report_containers[tag]["test_success"] %}
573-
<h3 class="section-header-status"><span class="report-status-pass">PASS</span></h3>
575+
<h3 class="section-header-status"><span class="report-status-pass">{{ report_containers[tag]["platform"] }} PASS</span></h3>
574576
{% else %}
575-
<h3 class="section-header-status"><span class="report-status-fail">FAIL</span></h3>
577+
<h3 class="section-header-status"><span class="report-status-fail">{{ report_containers[tag]["platform"] }} FAIL</span></h3>
576578
{% endif %}
577579
<h2 class="section-header-h2">
578580
{% if report_status.lower() == "pass" %}
579-
<a target="_blank" href="{{ report_containers[tag]['build_url'] }}">{{ image }}:{{ tag }}</a>
581+
<a target="_blank" href="{{ report_containers[tag]['build_url'] }}">{{ image }}</a>
580582
{% else %}
581583
{{ image }}:{{ tag }}
582584
{% endif %}

tests/test_ci.py

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,9 @@ def test_get_build_info(ci: CI, mock_container: Mock):
118118
"created": "2024-08-21T02:17:44+00:00",
119119
"size": '275.93MB',
120120
"maintainer": "Roxedus,thespad",
121-
"builder": "test-node"
121+
"builder": "test-node",
122+
"tag": "amd64-nightly-5.10.1.9109-ls85",
123+
"image": "linuxserver/test",
122124
}
123125
assert info == mock_info
124126

@@ -175,11 +177,19 @@ def test_upload_file(ci: CI) -> None:
175177
# Upload a file to the bucket
176178
ci.upload_file("tests/log_blob.log", "log_blob.log", {"ContentType": "text/plain", "ACL": "public-read"})
177179

178-
def test_make_build_url(ci: CI) -> None:
180+
def test_get_build_url(ci: CI) -> None:
179181
ci.image = "linuxserver/plex"
180182
tag = "amd64-nightly-5.10.1.9109-ls85"
181-
assert ci.make_build_url(tag) == f"https://ghcr.io/{ci.image}:{tag}"
183+
assert ci.get_build_url(tag) == f"https://ghcr.io/{ci.image}:{tag}"
182184
ci.image = "lsiodev/plex"
183-
assert ci.make_build_url(tag) == f"https://ghcr.io/linuxserver/lsiodev-plex:{tag}"
185+
assert ci.get_build_url(tag) == f"https://ghcr.io/linuxserver/lsiodev-plex:{tag}"
184186
ci.image = "lspipepr/plex"
185-
assert ci.make_build_url(tag) == f"https://ghcr.io/linuxserver/lspipepr-plex:{tag}"
187+
assert ci.get_build_url(tag) == f"https://ghcr.io/linuxserver/lspipepr-plex:{tag}"
188+
189+
def test_get_image_name(ci: CI) -> None:
190+
ci.image = "linuxserver/plex"
191+
assert ci.get_image_name() == "linuxserver/plex"
192+
ci.image = "lsiodev/plex"
193+
assert ci.get_image_name() == "linuxserver/lsiodev-plex"
194+
ci.image = "lspipepr/plex"
195+
assert ci.get_image_name() == "linuxserver/lspipepr-plex"

0 commit comments

Comments
 (0)