Skip to content

Commit e157573

Browse files
committed
Set correct build url based on if its a dev of pr image.
Add test for build_url function.
1 parent bef009e commit e157573

File tree

3 files changed

+30
-2
lines changed

3 files changed

+30
-2
lines changed

ci/ci.py

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -374,7 +374,8 @@ def _endtest(self, container:Container, tag:str, build_info:dict[str,str], packa
374374
"build_info": build_info,
375375
"test_results": self.tag_report_tests[tag]["test"],
376376
"test_success": test_success,
377-
"runtime": runtime
377+
"runtime": runtime,
378+
"build_url": self.make_build_url(tag)
378379
}
379380
self.report_containers[tag]["has_warnings"] = any(warning[1] for warning in self.report_containers[tag]["warnings"].items())
380381

@@ -892,6 +893,24 @@ def create_docker_client(self) -> DockerClient|None:
892893
return docker.from_env()
893894
except Exception:
894895
self.logger.error("Failed to create Docker client!")
896+
897+
def make_build_url(self, tag) -> str:
898+
"""Create a build url for the image
895899
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+
896915
class CIError(Exception):
897916
pass

ci/template.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -576,7 +576,7 @@ <h3 class="section-header-status"><span class="report-status-fail">FAIL</span></
576576
{% endif %}
577577
<h2 class="section-header-h2">
578578
{% if report_status.lower() == "pass" %}
579-
<a target="_blank" href="https://ghcr.io/{{ image }}:{{ tag }}">{{ image }}:{{ tag }}</a>
579+
<a target="_blank" href="{{ report_containers[tag]['build_url'] }}">{{ image }}:{{ tag }}</a>
580580
{% else %}
581581
{{ image }}:{{ tag }}
582582
{% endif %}

tests/test_ci.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,3 +174,12 @@ def test_upload_file(ci: CI) -> None:
174174
ci.s3_client.create_bucket(Bucket=ci.bucket)
175175
# Upload a file to the bucket
176176
ci.upload_file("tests/log_blob.log", "log_blob.log", {"ContentType": "text/plain", "ACL": "public-read"})
177+
178+
def test_make_build_url(ci: CI) -> None:
179+
ci.image = "linuxserver/plex"
180+
tag = "amd64-nightly-5.10.1.9109-ls85"
181+
assert ci.make_build_url(tag) == f"https://ghcr.io/{ci.image}:{tag}"
182+
ci.image = "lsiodev/plex"
183+
assert ci.make_build_url(tag) == f"https://ghcr.io/linuxserver/lsiodev-plex:{tag}"
184+
ci.image = "lspipepr/plex"
185+
assert ci.make_build_url(tag) == f"https://ghcr.io/linuxserver/lspipepr-plex:{tag}"

0 commit comments

Comments
 (0)