diff --git a/ci/ci.py b/ci/ci.py index 312c617..62925ef 100755 --- a/ci/ci.py +++ b/ci/ci.py @@ -374,7 +374,9 @@ class CI(SetEnvs): "build_info": build_info, "test_results": self.tag_report_tests[tag]["test"], "test_success": test_success, - "runtime": runtime + "runtime": runtime, + "build_url": self.get_build_url(tag), + "platform": self.get_platform(tag).upper() } self.report_containers[tag]["has_warnings"] = any(warning[1] for warning in self.report_containers[tag]["warnings"].items()) @@ -510,6 +512,39 @@ class CI(SetEnvs): self.report_status = "FAIL" return build_version + def get_image_name(self) -> str: + """Get the image name from the IMAGE env. + + Returns: + str: The container name + """ + _, container_name = self.image.split("/") + match self.image: + case _ if "lspipepr" in self.image: + return f"linuxserver/lspipepr-{container_name}" + case _ if "lsiodev" in self.image: + return f"linuxserver/lsiodev-{container_name}" + case _: + return self.image + + def get_build_url(self, tag) -> str: + """Get the build url from the IMAGE env. + + Args: + tag (str): The tag we are testing + + Returns: + dict: Returns a dictionary with the build url and container name + """ + _, container_name = self.image.split("/") + match self.image: + case _ if "lspipepr" in self.image: + return f"https://ghcr.io/linuxserver/lspipepr-{container_name}:{tag}" + case _ if "lsiodev" in self.image: + return f"https://ghcr.io/linuxserver/lsiodev-{container_name}:{tag}" + case _: + return f"https://ghcr.io/{self.image}:{tag}" + def get_build_info(self,container:Container,tag:str) -> dict[str,str]: """Get the build information from the container object. @@ -526,7 +561,9 @@ class CI(SetEnvs): "created": "xxxx-xx-xx", "size": "100MB", "maintainer": "user" - "builder": "node" + "builder": "node", + "tag": "latest", + "image": "linuxserver/xxx" } ``` """ @@ -539,7 +576,9 @@ class CI(SetEnvs): "created": container.attrs["Config"]["Labels"]["org.opencontainers.image.created"], "size": "%.2f" % float(int(container.image.attrs["Size"])/1000000) + "MB", "maintainer": container.attrs["Config"]["Labels"]["maintainer"], - "builder": self.builder + "builder": self.builder, + "tag": tag, + "image": self.get_image_name() } self._add_test_result(tag, test, "PASS", "-", start_time) self.logger.success("Get build info on tag '%s': PASS", tag) @@ -599,7 +638,7 @@ class CI(SetEnvs): report_containers=self.report_containers, report_status=self.report_status, meta_tag=self.meta_tag, - image=self.image, + image=self.get_image_name(), bucket=self.bucket, region=self.region, screenshot=self.screenshot, @@ -892,6 +931,7 @@ class CI(SetEnvs): return docker.from_env() except Exception: self.logger.error("Failed to create Docker client!") + class CIError(Exception): pass diff --git a/ci/template.html b/ci/template.html index 991fb55..c34d08f 100644 --- a/ci/template.html +++ b/ci/template.html @@ -502,17 +502,18 @@ padding: 10px 30px; margin: 0; font-size: 12px; - word-break: break-all; - display: grid; } .build-info { padding-right: .3rem; padding-left: .3rem; + overflow: hidden; + text-overflow: ellipsis; + white-space: nowrap; } .build-summary { - display: inline-flex; + display: flex; } .tag-image { @@ -562,7 +563,9 @@

LinuxServer.io

-

Test Results {{ image }}:{{ meta_tag }}

+

Test Results

+

{{ image }}

+

{{ meta_tag }}

Cumulative: {{ report_status }}

Total Runtime: {{ total_runtime }}
@@ -570,13 +573,13 @@
{% if report_containers[tag]["test_success"] %} -

PASS

+

{{ report_containers[tag]["platform"] }} PASS

{% else %} -

FAIL

+

{{ report_containers[tag]["platform"] }} FAIL

{% endif %}

{% if report_status.lower() == "pass" %} - {{ image }}:{{ tag }} + {{ image }} {% else %} {{ image }}:{{ tag }} {% endif %} diff --git a/tests/test_ci.py b/tests/test_ci.py index e782489..f7ff5f5 100644 --- a/tests/test_ci.py +++ b/tests/test_ci.py @@ -118,7 +118,9 @@ def test_get_build_info(ci: CI, mock_container: Mock): "created": "2024-08-21T02:17:44+00:00", "size": '275.93MB', "maintainer": "Roxedus,thespad", - "builder": "test-node" + "builder": "test-node", + "tag": "amd64-nightly-5.10.1.9109-ls85", + "image": "linuxserver/test", } assert info == mock_info @@ -174,3 +176,20 @@ def test_upload_file(ci: CI) -> None: ci.s3_client.create_bucket(Bucket=ci.bucket) # Upload a file to the bucket ci.upload_file("tests/log_blob.log", "log_blob.log", {"ContentType": "text/plain", "ACL": "public-read"}) + +def test_get_build_url(ci: CI) -> None: + ci.image = "linuxserver/plex" + tag = "amd64-nightly-5.10.1.9109-ls85" + assert ci.get_build_url(tag) == f"https://ghcr.io/{ci.image}:{tag}" + ci.image = "lsiodev/plex" + assert ci.get_build_url(tag) == f"https://ghcr.io/linuxserver/lsiodev-plex:{tag}" + ci.image = "lspipepr/plex" + assert ci.get_build_url(tag) == f"https://ghcr.io/linuxserver/lspipepr-plex:{tag}" + +def test_get_image_name(ci: CI) -> None: + ci.image = "linuxserver/plex" + assert ci.get_image_name() == "linuxserver/plex" + ci.image = "lsiodev/plex" + assert ci.get_image_name() == "linuxserver/lsiodev-plex" + ci.image = "lspipepr/plex" + assert ci.get_image_name() == "linuxserver/lspipepr-plex" \ No newline at end of file