Merge pull request #58 from linuxserver/57-bug-incorrect-ghcr-link-for-lsiodev-and-lspipepr-images

This commit is contained in:
GilbN 2024-09-24 21:57:21 +02:00 committed by GitHub
commit 0885613fc1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 74 additions and 12 deletions

View File

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

View File

@ -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 @@
<h1>Linux<span>Server</span>.io</h1>
</header>
<div id="results">
<h1>Test Results <strong>{{ image }}:{{ meta_tag }}</strong></h1>
<h1 style="margin-bottom: 0; text-align: center;">Test Results</h1>
<h2 style="margin-bottom: 0; text-align: center;"><strong>{{ image }}</strong></span></h2>
<h3 style="margin-top:0; margin-bottom: 0; text-align: center;"><strong>{{ meta_tag }}</strong></span></h2>
<h2 style="margin-bottom: 0">Cumulative: <span class="report-status-{{ report_status.lower() }}">{{ report_status }}</span></h2>
<span>Total Runtime: {{ total_runtime }}</span>
<main>
@ -570,13 +573,13 @@
<section>
<div class="section-header">
{% if report_containers[tag]["test_success"] %}
<h3 class="section-header-status"><span class="report-status-pass">PASS</span></h3>
<h3 class="section-header-status"><span class="report-status-pass">{{ report_containers[tag]["platform"] }} PASS</span></h3>
{% else %}
<h3 class="section-header-status"><span class="report-status-fail">FAIL</span></h3>
<h3 class="section-header-status"><span class="report-status-fail">{{ report_containers[tag]["platform"] }} FAIL</span></h3>
{% 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 }}</a>
{% else %}
{{ image }}:{{ tag }}
{% endif %}

View File

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