Files
datastore/ci/praktika/html_prepare.py
Max KainovandClaude Opus 4.6 565b43665d Rename HTML_S3_PATH to S3_REPORT_BUCKET, add upstream catalog merge support
Replace hardcoded bucket names with Settings.S3_REPORT_BUCKET across CI
scripts. Add S3_UPSTREAM_REPORT_BUCKET setting so forks can optionally
merge the upstream issue catalog when checking for flaky tests.

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
2026-04-08 10:48:06 +02:00

37 lines
1011 B
Python

from pathlib import Path
from praktika.utils import Shell
from .s3 import S3
from .settings import Settings
from .utils import Utils
class Html:
@classmethod
def prepare(cls, is_test):
if is_test:
page_file = Settings.HTML_PAGE_FILE.removesuffix(".html") + "_test.html"
Shell.check(f"cp {Settings.HTML_PAGE_FILE} {page_file}")
else:
page_file = Settings.HTML_PAGE_FILE
with open(page_file, "r", encoding="utf-8") as f:
html = f.read()
with open(page_file, "w", encoding="utf-8") as f:
f.write(html)
compressed_file = Utils.compress_gz(page_file)
S3.copy_file_to_s3(
s3_path=str(Path(Settings.S3_REPORT_BUCKET) / Path(page_file).name),
local_path=compressed_file,
content_type="text/html",
content_encoding="gzip",
with_rename=True,
)
with open(page_file, "w", encoding="utf-8") as f:
f.write(html)