Use PRInfo and TEMP_PATH in codebrowser

This commit is contained in:
Mikhail f. Shiryaev 2022-11-15 17:57:56 +01:00
parent 40b8c8559f
commit eb738fa13e
No known key found for this signature in database
GPG Key ID: 4B02ED204C7D93F4

View File

@ -7,14 +7,21 @@ import logging
from github import Github from github import Github
from env_helper import IMAGES_PATH, REPO_COPY, S3_TEST_REPORTS_BUCKET, S3_DOWNLOAD from env_helper import (
from stopwatch import Stopwatch IMAGES_PATH,
from upload_result_helper import upload_results REPO_COPY,
from s3_helper import S3Helper S3_DOWNLOAD,
from get_robot_token import get_best_robot_token S3_TEST_REPORTS_BUCKET,
TEMP_PATH,
)
from commit_status_helper import post_commit_status from commit_status_helper import post_commit_status
from docker_pull_helper import get_image_with_version from docker_pull_helper import get_image_with_version
from get_robot_token import get_best_robot_token
from pr_info import PRInfo
from s3_helper import S3Helper
from stopwatch import Stopwatch
from tee_popen import TeePopen from tee_popen import TeePopen
from upload_result_helper import upload_results
NAME = "Woboq Build" NAME = "Woboq Build"
@ -33,17 +40,16 @@ if __name__ == "__main__":
stopwatch = Stopwatch() stopwatch = Stopwatch()
temp_path = os.getenv("TEMP_PATH", os.path.abspath("."))
gh = Github(get_best_robot_token(), per_page=100) gh = Github(get_best_robot_token(), per_page=100)
pr_info = PRInfo()
if not os.path.exists(temp_path): if not os.path.exists(TEMP_PATH):
os.makedirs(temp_path) os.makedirs(TEMP_PATH)
docker_image = get_image_with_version(IMAGES_PATH, "clickhouse/codebrowser") docker_image = get_image_with_version(IMAGES_PATH, "clickhouse/codebrowser")
s3_helper = S3Helper() s3_helper = S3Helper()
result_path = os.path.join(temp_path, "result_path") result_path = os.path.join(TEMP_PATH, "result_path")
if not os.path.exists(result_path): if not os.path.exists(result_path):
os.makedirs(result_path) os.makedirs(result_path)
@ -51,7 +57,7 @@ if __name__ == "__main__":
logging.info("Going to run codebrowser: %s", run_command) logging.info("Going to run codebrowser: %s", run_command)
run_log_path = os.path.join(temp_path, "runlog.log") run_log_path = os.path.join(TEMP_PATH, "runlog.log")
with TeePopen(run_command, run_log_path) as process: with TeePopen(run_command, run_log_path) as process:
retcode = process.wait() retcode = process.wait()
@ -60,7 +66,7 @@ if __name__ == "__main__":
else: else:
logging.info("Run failed") logging.info("Run failed")
subprocess.check_call(f"sudo chown -R ubuntu:ubuntu {temp_path}", shell=True) subprocess.check_call(f"sudo chown -R ubuntu:ubuntu {TEMP_PATH}", shell=True)
report_path = os.path.join(result_path, "html_report") report_path = os.path.join(result_path, "html_report")
logging.info("Report path %s", report_path) logging.info("Report path %s", report_path)
@ -76,12 +82,8 @@ if __name__ == "__main__":
test_results = [(index_html, "Look at the report")] test_results = [(index_html, "Look at the report")]
report_url = upload_results( report_url = upload_results(s3_helper, 0, pr_info.sha, test_results, [], NAME)
s3_helper, 0, os.getenv("GITHUB_SHA"), test_results, [], NAME
)
print(f"::notice ::Report url: {report_url}") print(f"::notice ::Report url: {report_url}")
post_commit_status( post_commit_status(gh, pr_info.sha, NAME, "Report built", "success", report_url)
gh, os.getenv("GITHUB_SHA"), NAME, "Report built", "success", report_url
)