Skip to content

Commit

Permalink
Set correct build url based on if its a dev of pr image.
Browse files Browse the repository at this point in the history
Add test for build_url function.
  • Loading branch information
GilbN committed Sep 18, 2024
1 parent bef009e commit e157573
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 2 deletions.
21 changes: 20 additions & 1 deletion ci/ci.py
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,8 @@ def _endtest(self, container:Container, tag:str, build_info:dict[str,str], packa
"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())

Expand Down Expand Up @@ -892,6 +893,24 @@ def create_docker_client(self) -> DockerClient|None:
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
2 changes: 1 addition & 1 deletion ci/template.html
Original file line number Diff line number Diff line change
Expand Up @@ -576,7 +576,7 @@ <h3 class="section-header-status"><span class="report-status-fail">FAIL</span></
{% 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 %}
Expand Down
9 changes: 9 additions & 0 deletions tests/test_ci.py
Original file line number Diff line number Diff line change
Expand Up @@ -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}"

0 comments on commit e157573

Please sign in to comment.