ClickHouse/tests/ci/cherry_pick.py

49 lines
1.3 KiB
Python
Raw Normal View History

2021-11-08 14:30:27 +00:00
#!/usr/bin/env python3
2021-11-08 14:45:19 +00:00
import sys
2021-11-08 14:30:27 +00:00
import logging
import os
import subprocess
2021-11-08 14:45:19 +00:00
2021-11-26 14:00:09 +00:00
from env_helper import GITHUB_WORKSPACE, TEMP_PATH
2021-11-09 17:56:44 +00:00
from get_robot_token import get_parameter_from_ssm
2021-11-08 14:30:27 +00:00
from ssh import SSHKey
from cherry_pick_utils.backport import Backport
from cherry_pick_utils.cherrypick import CherryPick
if __name__ == "__main__":
logging.basicConfig(level=logging.INFO)
2021-11-26 14:00:09 +00:00
repo_path = GITHUB_WORKSPACE
temp_path = TEMP_PATH
2021-11-08 14:30:27 +00:00
if not os.path.exists(temp_path):
os.makedirs(temp_path)
sys.path.append(os.path.join(repo_path, "utils/github"))
with SSHKey("ROBOT_CLICKHOUSE_SSH_KEY"):
2021-11-09 17:56:44 +00:00
token = get_parameter_from_ssm("github_robot_token_1")
2021-11-08 14:30:27 +00:00
bp = Backport(
token,
os.environ.get("REPO_OWNER"),
os.environ.get("REPO_NAME"),
os.environ.get("REPO_TEAM"),
)
2021-11-08 14:30:27 +00:00
def cherrypick_run(token, pr, branch):
return CherryPick(
token,
os.environ.get("REPO_OWNER"),
os.environ.get("REPO_NAME"),
os.environ.get("REPO_TEAM"),
pr,
branch,
).execute(repo_path, False)
2021-11-08 14:30:27 +00:00
try:
bp.execute(repo_path, "origin", None, cherrypick_run)
2021-11-08 14:30:27 +00:00
except subprocess.CalledProcessError as e:
logging.error(e.output)