From e1575730d9916983033f8849fdf05487cf4eb05e Mon Sep 17 00:00:00 2001 From: GilbN <24592972+GilbN@users.noreply.github.com> Date: Wed, 18 Sep 2024 21:28:35 +0200 Subject: [PATCH 1/3] Set correct build url based on if its a dev of pr image. Add test for build_url function. --- ci/ci.py | 21 ++++++++++++++++++++- ci/template.html | 2 +- tests/test_ci.py | 9 +++++++++ 3 files changed, 30 insertions(+), 2 deletions(-) diff --git a/ci/ci.py b/ci/ci.py index 312c617..e5a815a 100755 --- a/ci/ci.py +++ b/ci/ci.py @@ -374,7 +374,8 @@ 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.make_build_url(tag) } self.report_containers[tag]["has_warnings"] = any(warning[1] for warning in self.report_containers[tag]["warnings"].items()) @@ -892,6 +893,24 @@ class CI(SetEnvs): return docker.from_env() except Exception: self.logger.error("Failed to create Docker client!") + + def make_build_url(self, tag) -> str: + """Create a build url for the image + Args: + tag (str): The tag we are testing + + Returns: + str: Returns a build url + """ + _, 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}" + class CIError(Exception): pass diff --git a/ci/template.html b/ci/template.html index 991fb55..1262ac5 100644 --- a/ci/template.html +++ b/ci/template.html @@ -576,7 +576,7 @@ {% endif %}

{% if report_status.lower() == "pass" %} - {{ image }}:{{ tag }} + {{ image }}:{{ tag }} {% else %} {{ image }}:{{ tag }} {% endif %} diff --git a/tests/test_ci.py b/tests/test_ci.py index e782489..a758d36 100644 --- a/tests/test_ci.py +++ b/tests/test_ci.py @@ -174,3 +174,12 @@ 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_make_build_url(ci: CI) -> None: + ci.image = "linuxserver/plex" + tag = "amd64-nightly-5.10.1.9109-ls85" + assert ci.make_build_url(tag) == f"https://ghcr.io/{ci.image}:{tag}" + ci.image = "lsiodev/plex" + assert ci.make_build_url(tag) == f"https://ghcr.io/linuxserver/lsiodev-plex:{tag}" + ci.image = "lspipepr/plex" + assert ci.make_build_url(tag) == f"https://ghcr.io/linuxserver/lspipepr-plex:{tag}" \ No newline at end of file From dfcf34a15067ea43f9a310f8bef5d331786d3788 Mon Sep 17 00:00:00 2001 From: GilbN <24592972+GilbN@users.noreply.github.com> Date: Sun, 22 Sep 2024 12:50:27 +0200 Subject: [PATCH 2/3] Fix link name. Add More information to build info section in the report. Center and split the top report headers --- ci/ci.py | 63 ++++++++++++++++++++++++++++++++---------------- ci/template.html | 10 +++++--- tests/test_ci.py | 20 +++++++++++---- 3 files changed, 63 insertions(+), 30 deletions(-) diff --git a/ci/ci.py b/ci/ci.py index e5a815a..62925ef 100755 --- a/ci/ci.py +++ b/ci/ci.py @@ -375,7 +375,8 @@ class CI(SetEnvs): "test_results": self.tag_report_tests[tag]["test"], "test_success": test_success, "runtime": runtime, - "build_url": self.make_build_url(tag) + "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()) @@ -511,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. @@ -527,7 +561,9 @@ class CI(SetEnvs): "created": "xxxx-xx-xx", "size": "100MB", "maintainer": "user" - "builder": "node" + "builder": "node", + "tag": "latest", + "image": "linuxserver/xxx" } ``` """ @@ -540,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) @@ -600,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, @@ -894,23 +932,6 @@ class CI(SetEnvs): except Exception: self.logger.error("Failed to create Docker client!") - def make_build_url(self, tag) -> str: - """Create a build url for the image - Args: - tag (str): The tag we are testing - - Returns: - str: Returns a build url - """ - _, 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}" - class CIError(Exception): pass diff --git a/ci/template.html b/ci/template.html index 1262ac5..d3a6745 100644 --- a/ci/template.html +++ b/ci/template.html @@ -562,7 +562,9 @@

LinuxServer.io

-

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

+

Test Results

+

{{ image }}

+

{{ meta_tag }}

Cumulative: {{ report_status }}

Total Runtime: {{ total_runtime }}
@@ -570,13 +572,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 a758d36..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 @@ -175,11 +177,19 @@ def test_upload_file(ci: CI) -> None: # Upload a file to the bucket ci.upload_file("tests/log_blob.log", "log_blob.log", {"ContentType": "text/plain", "ACL": "public-read"}) -def test_make_build_url(ci: CI) -> None: +def test_get_build_url(ci: CI) -> None: ci.image = "linuxserver/plex" tag = "amd64-nightly-5.10.1.9109-ls85" - assert ci.make_build_url(tag) == f"https://ghcr.io/{ci.image}:{tag}" + assert ci.get_build_url(tag) == f"https://ghcr.io/{ci.image}:{tag}" ci.image = "lsiodev/plex" - assert ci.make_build_url(tag) == f"https://ghcr.io/linuxserver/lsiodev-plex:{tag}" + assert ci.get_build_url(tag) == f"https://ghcr.io/linuxserver/lsiodev-plex:{tag}" ci.image = "lspipepr/plex" - assert ci.make_build_url(tag) == f"https://ghcr.io/linuxserver/lspipepr-plex:{tag}" \ No newline at end of file + 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 From d07596774e34091744ef8c8516acbcf946f0fec2 Mon Sep 17 00:00:00 2001 From: GilbN <24592972+GilbN@users.noreply.github.com> Date: Mon, 23 Sep 2024 19:32:25 +0200 Subject: [PATCH 3/3] Truncate long text in the build info section --- ci/template.html | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/ci/template.html b/ci/template.html index d3a6745..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 {