Skip to content

Commit f9f59b7

Browse files
Merge pull request ClickHouse#79742 from ClickHouse/ci_compress_praktika_result_files
CI: Compress praktika result for faster report response
2 parents c3af3e7 + 0916bda commit f9f59b7

File tree

2 files changed

+30
-6
lines changed

2 files changed

+30
-6
lines changed

ci/praktika/result.py

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -541,10 +541,33 @@ class _ResultS3:
541541
def copy_result_to_s3(cls, result, clean=False):
542542
result.dump()
543543
env = _Environment.get()
544-
s3_path = f"{Settings.HTML_S3_PATH}/{env.get_s3_prefix()}"
544+
result_file_path = result.file_name()
545+
s3_path = f"{Settings.HTML_S3_PATH}/{env.get_s3_prefix()}/{Path(result_file_path).name}"
545546
if clean:
546547
S3.delete(s3_path)
547-
url = S3.copy_file_to_s3(s3_path=s3_path, local_path=result.file_name())
548+
archive_file = Utils.compress_file(result_file_path, no_strict=True)
549+
archive_type = archive_file.split(".")[-1]
550+
content_encoding = ""
551+
if archive_type == "gz":
552+
content_encoding = "gzip"
553+
elif archive_type == "zst":
554+
content_encoding = "zstd"
555+
elif archive_type == "br":
556+
content_encoding = "br"
557+
else:
558+
if archive_type:
559+
print(
560+
f"WARNING: Not supported compress codec: [{archive_type}] - skip compress"
561+
)
562+
archive_file = result_file_path
563+
564+
url = S3.copy_file_to_s3(
565+
s3_path=s3_path,
566+
local_path=archive_file,
567+
text=True,
568+
content_encoding=content_encoding,
569+
with_rename=True,
570+
)
548571
return url
549572

550573
@classmethod

ci/praktika/utils.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -627,7 +627,7 @@ def compress_file_zst(cls, path):
627627
return path_out
628628

629629
@classmethod
630-
def compress_file(cls, path):
630+
def compress_file(cls, path, no_strict=False):
631631
if Shell.check("which zstd"):
632632
return cls.compress_file_zst(path)
633633
elif Shell.check("which pigz"):
@@ -646,9 +646,10 @@ def compress_file(cls, path):
646646
)
647647
else:
648648
path_out = path
649-
Utils.raise_with_error(
650-
f"Failed to compress file [{path}] no zstd or gz installed"
651-
)
649+
if not no_strict:
650+
raise RuntimeError(
651+
f"Failed to compress file [{path}] no zstd or gz installed"
652+
)
652653
return path_out
653654

654655
@classmethod

0 commit comments

Comments
 (0)