From a4829712f4b470695ef44fe59791f6188d8d3150 Mon Sep 17 00:00:00 2001 From: Dmitry Rodionov Date: Fri, 11 Feb 2022 19:31:44 +0300 Subject: [PATCH] merge directories in git-upload instead of removing existing files for perf test result uploads --- scripts/generate_and_push_perf_report.sh | 1 + scripts/git-upload | 12 ++++++++++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/scripts/generate_and_push_perf_report.sh b/scripts/generate_and_push_perf_report.sh index 69b71488c8..df84fa0dd8 100755 --- a/scripts/generate_and_push_perf_report.sh +++ b/scripts/generate_and_push_perf_report.sh @@ -20,4 +20,5 @@ scripts/git-upload \ --message="add performance test result for $GITHUB_SHA zenith revision" \ --branch=master \ copy "$REPORT_FROM" "data/$REPORT_TO" `# COPY FROM TO_RELATIVE`\ + --merge \ --run-cmd "python $SCRIPT_DIR/generate_perf_report_page.py --input-dir data/$REPORT_TO --out reports/$REPORT_TO.html" diff --git a/scripts/git-upload b/scripts/git-upload index 5449575df7..4649f6998d 100755 --- a/scripts/git-upload +++ b/scripts/git-upload @@ -3,6 +3,7 @@ from contextlib import contextmanager import shlex from tempfile import TemporaryDirectory +from distutils.dir_util import copy_tree from pathlib import Path import argparse @@ -111,8 +112,11 @@ def do_copy(args): raise FileExistsError(f"File exists: '{dst}'") if src.is_dir(): - shutil.rmtree(dst, ignore_errors=True) - shutil.copytree(src, dst) + if not args.merge: + shutil.rmtree(dst, ignore_errors=True) + # distutils is deprecated, but this is a temporary workaround before python version bump + # here we need dir_exists_ok=True from shutil.copytree which is available in python 3.8+ + copy_tree(str(src), str(dst)) else: shutil.copy(src, dst) @@ -136,6 +140,10 @@ def main(): p_copy.add_argument('src', type=absolute_path, help='source path') p_copy.add_argument('dst', type=relative_path, help='relative dest path') p_copy.add_argument('--forbid-overwrite', action='store_true', help='do not allow overwrites') + p_copy.add_argument( + '--merge', + action='store_true', + help='when copying a directory do not delete existing data, but add new files') p_copy.add_argument('--run-cmd', help=textwrap.dedent('''\ run arbitrary cmd on top of copied files,