Set correct build url based on if its a dev of pr image.

Add test for build_url function.
This commit is contained in:
GilbN 2024-09-18 21:28:35 +02:00
parent bef009e43c
commit e1575730d9
3 changed files with 30 additions and 2 deletions

View File

@ -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

View File

@ -576,7 +576,7 @@
{% endif %}
<h2 class="section-header-h2">
{% if report_status.lower() == "pass" %}
<a target="_blank" href="https://ghcr.io/{{ image }}:{{ tag }}">{{ image }}:{{ tag }}</a>
<a target="_blank" href="{{ report_containers[tag]['build_url'] }}">{{ image }}:{{ tag }}</a>
{% else %}
{{ image }}:{{ tag }}
{% endif %}

View File

@ -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}"