Commit 04bc5f3e authored by Arthur Lutz's avatar Arthur Lutz
Browse files

feat: add CLI argument "delay" to sleep before cloning

This is used to ease CI load.
parent 9cb9913bdb5c
......@@ -349,6 +349,7 @@ class Command:
branch_name=None,
commit_message=None,
update_mr=False,
delay=None,
other_args=None,
):
forced_branch_name = branch_name
......@@ -418,6 +419,9 @@ class Command:
logger.info(f'cloning {cube.attributes["web_url"]}')
# hg clone
if delay:
logger.debug(f"sleeping {delay} seconds before cloning to easy CI load")
sleep(delay)
with Repository(url=cube.attributes["web_url"]) as repo:
modifications = self.modify_code(
cube, repo, root_files, branches, other_args
......
......@@ -31,7 +31,7 @@ def hg_command(dir, command):
subprocess.check_call(f"cd {dir} && {command}", shell=True)
def auto_mr(merge_when_pipeline_succeeds, target):
def auto_mr(merge_when_pipeline_succeeds, target, delay):
def doesnt_already_have_a_mr_from_another_command(cube):
# if we already have a MR from at least one command, returns
if branch_names.intersection({x.name for x in cube.branches.list()}):
......@@ -75,6 +75,7 @@ def auto_mr(merge_when_pipeline_succeeds, target):
merge_when_pipeline_succeeds=merge_when_pipeline_succeeds,
additional_checks=[doesnt_already_have_a_mr_from_another_command],
target=target,
delay=delay,
)
except EmptyCubeQueryResult:
# it's actually good that we don't have any result
......@@ -134,6 +135,7 @@ def main():
parser.add_argument(
"-k", "--command", type=str, default=None, dest="script_command"
)
parser.add_argument("-d", "--delay", type=int, default=None, help="delay before 'hg clone' to ease server load")
args = parser.parse_args()
......@@ -141,6 +143,7 @@ def main():
auto_mr(
merge_when_pipeline_succeeds=args.merge_when_pipeline_succeeds,
target=args.target,
delay=args.delay,
)
else:
commands[args.command](
......@@ -154,6 +157,7 @@ def main():
branch_name=args.branch_name,
commit_message=args.commit_message,
update_mr=args.update_mr,
delay=args.delay,
other_args=args,
)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment