Skip to content

Commit 0885613

Browse files
authored
Merge pull request #58 from linuxserver/57-bug-incorrect-ghcr-link-for-lsiodev-and-lspipepr-images
2 parents 39c556b + d075967 commit 0885613

File tree

3 files changed

+74
-12
lines changed

3 files changed

+74
-12
lines changed

ci/ci.py

Lines changed: 44 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -374,7 +374,9 @@ 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.get_build_url(tag),
379+
"platform": self.get_platform(tag).upper()
378380
}
379381
self.report_containers[tag]["has_warnings"] = any(warning[1] for warning in self.report_containers[tag]["warnings"].items())
380382

@@ -510,6 +512,39 @@ def get_build_version(self,container:Container,tag:str) -> str:
510512
self.report_status = "FAIL"
511513
return build_version
512514

515+
def get_image_name(self) -> str:
516+
"""Get the image name from the IMAGE env.
517+
518+
Returns:
519+
str: The container name
520+
"""
521+
_, container_name = self.image.split("/")
522+
match self.image:
523+
case _ if "lspipepr" in self.image:
524+
return f"linuxserver/lspipepr-{container_name}"
525+
case _ if "lsiodev" in self.image:
526+
return f"linuxserver/lsiodev-{container_name}"
527+
case _:
528+
return self.image
529+
530+
def get_build_url(self, tag) -> str:
531+
"""Get the build url from the IMAGE env.
532+
533+
Args:
534+
tag (str): The tag we are testing
535+
536+
Returns:
537+
dict: Returns a dictionary with the build url and container name
538+
"""
539+
_, container_name = self.image.split("/")
540+
match self.image:
541+
case _ if "lspipepr" in self.image:
542+
return f"https://ghcr.io/linuxserver/lspipepr-{container_name}:{tag}"
543+
case _ if "lsiodev" in self.image:
544+
return f"https://ghcr.io/linuxserver/lsiodev-{container_name}:{tag}"
545+
case _:
546+
return f"https://ghcr.io/{self.image}:{tag}"
547+
513548
def get_build_info(self,container:Container,tag:str) -> dict[str,str]:
514549
"""Get the build information from the container object.
515550
@@ -526,7 +561,9 @@ def get_build_info(self,container:Container,tag:str) -> dict[str,str]:
526561
"created": "xxxx-xx-xx",
527562
"size": "100MB",
528563
"maintainer": "user"
529-
"builder": "node"
564+
"builder": "node",
565+
"tag": "latest",
566+
"image": "linuxserver/xxx"
530567
}
531568
```
532569
"""
@@ -539,7 +576,9 @@ def get_build_info(self,container:Container,tag:str) -> dict[str,str]:
539576
"created": container.attrs["Config"]["Labels"]["org.opencontainers.image.created"],
540577
"size": "%.2f" % float(int(container.image.attrs["Size"])/1000000) + "MB",
541578
"maintainer": container.attrs["Config"]["Labels"]["maintainer"],
542-
"builder": self.builder
579+
"builder": self.builder,
580+
"tag": tag,
581+
"image": self.get_image_name()
543582
}
544583
self._add_test_result(tag, test, "PASS", "-", start_time)
545584
self.logger.success("Get build info on tag '%s': PASS", tag)
@@ -599,7 +638,7 @@ def report_render(self) -> None:
599638
report_containers=self.report_containers,
600639
report_status=self.report_status,
601640
meta_tag=self.meta_tag,
602-
image=self.image,
641+
image=self.get_image_name(),
603642
bucket=self.bucket,
604643
region=self.region,
605644
screenshot=self.screenshot,
@@ -892,6 +931,7 @@ def create_docker_client(self) -> DockerClient|None:
892931
return docker.from_env()
893932
except Exception:
894933
self.logger.error("Failed to create Docker client!")
934+
895935

896936
class CIError(Exception):
897937
pass

ci/template.html

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -502,17 +502,18 @@
502502
padding: 10px 30px;
503503
margin: 0;
504504
font-size: 12px;
505-
word-break: break-all;
506-
display: grid;
507505
}
508506

509507
.build-info {
510508
padding-right: .3rem;
511509
padding-left: .3rem;
510+
overflow: hidden;
511+
text-overflow: ellipsis;
512+
white-space: nowrap;
512513
}
513514

514515
.build-summary {
515-
display: inline-flex;
516+
display: flex;
516517
}
517518

518519
.tag-image {
@@ -562,21 +563,23 @@
562563
<h1>Linux<span>Server</span>.io</h1>
563564
</header>
564565
<div id="results">
565-
<h1>Test Results <strong>{{ image }}:{{ meta_tag }}</strong></h1>
566+
<h1 style="margin-bottom: 0; text-align: center;">Test Results</h1>
567+
<h2 style="margin-bottom: 0; text-align: center;"><strong>{{ image }}</strong></span></h2>
568+
<h3 style="margin-top:0; margin-bottom: 0; text-align: center;"><strong>{{ meta_tag }}</strong></span></h2>
566569
<h2 style="margin-bottom: 0">Cumulative: <span class="report-status-{{ report_status.lower() }}">{{ report_status }}</span></h2>
567570
<span>Total Runtime: {{ total_runtime }}</span>
568571
<main>
569572
{% for tag in report_containers %}
570573
<section>
571574
<div class="section-header">
572575
{% if report_containers[tag]["test_success"] %}
573-
<h3 class="section-header-status"><span class="report-status-pass">PASS</span></h3>
576+
<h3 class="section-header-status"><span class="report-status-pass">{{ report_containers[tag]["platform"] }} PASS</span></h3>
574577
{% else %}
575-
<h3 class="section-header-status"><span class="report-status-fail">FAIL</span></h3>
578+
<h3 class="section-header-status"><span class="report-status-fail">{{ report_containers[tag]["platform"] }} FAIL</span></h3>
576579
{% endif %}
577580
<h2 class="section-header-h2">
578581
{% if report_status.lower() == "pass" %}
579-
<a target="_blank" href="https://ghcr.io/{{ image }}:{{ tag }}">{{ image }}:{{ tag }}</a>
582+
<a target="_blank" href="{{ report_containers[tag]['build_url'] }}">{{ image }}</a>
580583
{% else %}
581584
{{ image }}:{{ tag }}
582585
{% endif %}

tests/test_ci.py

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,9 @@ def test_get_build_info(ci: CI, mock_container: Mock):
118118
"created": "2024-08-21T02:17:44+00:00",
119119
"size": '275.93MB',
120120
"maintainer": "Roxedus,thespad",
121-
"builder": "test-node"
121+
"builder": "test-node",
122+
"tag": "amd64-nightly-5.10.1.9109-ls85",
123+
"image": "linuxserver/test",
122124
}
123125
assert info == mock_info
124126

@@ -174,3 +176,20 @@ def test_upload_file(ci: CI) -> None:
174176
ci.s3_client.create_bucket(Bucket=ci.bucket)
175177
# Upload a file to the bucket
176178
ci.upload_file("tests/log_blob.log", "log_blob.log", {"ContentType": "text/plain", "ACL": "public-read"})
179+
180+
def test_get_build_url(ci: CI) -> None:
181+
ci.image = "linuxserver/plex"
182+
tag = "amd64-nightly-5.10.1.9109-ls85"
183+
assert ci.get_build_url(tag) == f"https://ghcr.io/{ci.image}:{tag}"
184+
ci.image = "lsiodev/plex"
185+
assert ci.get_build_url(tag) == f"https://ghcr.io/linuxserver/lsiodev-plex:{tag}"
186+
ci.image = "lspipepr/plex"
187+
assert ci.get_build_url(tag) == f"https://ghcr.io/linuxserver/lspipepr-plex:{tag}"
188+
189+
def test_get_image_name(ci: CI) -> None:
190+
ci.image = "linuxserver/plex"
191+
assert ci.get_image_name() == "linuxserver/plex"
192+
ci.image = "lsiodev/plex"
193+
assert ci.get_image_name() == "linuxserver/lsiodev-plex"
194+
ci.image = "lspipepr/plex"
195+
assert ci.get_image_name() == "linuxserver/lspipepr-plex"

0 commit comments

Comments
 (0)