From 551d35bf6fcd8899fb367c11fabc74bc95902160 Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Mon, 10 Oct 2022 12:00:33 +0200 Subject: [PATCH] cls_containerize.CreateWorkspace(): make blobless clone to speedup --- ci-scripts/cls_containerize.py | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/ci-scripts/cls_containerize.py b/ci-scripts/cls_containerize.py index 6197cc7e4f..15c1d30be8 100644 --- a/ci-scripts/cls_containerize.py +++ b/ci-scripts/cls_containerize.py @@ -53,33 +53,34 @@ import constants as CONST # (e.g., cls_cluster.py) #----------------------------------------------------------- def CreateWorkspace(sshSession, sourcePath, ranRepository, ranCommitID, ranTargetBranch, ranAllowMerge): - # on RedHat/CentOS .git extension is mandatory - result = re.search('([a-zA-Z0-9\:\-\.\/])+\.git', ranRepository) - if result is not None: - full_ran_repo_name = ranRepository.replace('git/', 'git') - else: - full_ran_repo_name = ranRepository + '.git' + if ranCommitID == '': + logging.error('need ranCommitID in CreateWorkspace()') + sys.exit('Insufficient Parameter in CreateWorkspace()') + + sshSession.command(f'rm -rf {sourcePath}', '\$', 10) sshSession.command('mkdir -p ' + sourcePath, '\$', 5) sshSession.command('cd ' + sourcePath, '\$', 5) - sshSession.command('if [ ! -e .git ]; then stdbuf -o0 git clone ' + full_ran_repo_name + ' .; else stdbuf -o0 git fetch --prune; fi', '\$', 600) + sshSession.command(f'git clone --filter=blob:none -n -b develop {full_ran_repo_name} .', '\$', 60) if sshSession.getBefore().count('done.') == 0: logging.warning('did not find \'done.\' in git output while cloning/fetching, was not successful?') sshSession.command('git config user.email "jenkins@openairinterface.org"', '\$', 5) sshSession.command('git config user.name "OAI Jenkins"', '\$', 5) - sshSession.command('git clean -x -d -ff', '\$', 30) sshSession.command('mkdir -p cmake_targets/log', '\$', 5) # if the commit ID is provided use it to point to it - if ranCommitID != '': - sshSession.command('git checkout -f ' + ranCommitID, '\$', 30) + sshSession.command(f'git checkout -f {ranCommitID}', '\$', 30) + if sshSession.getBefore().count(f'HEAD is now at {ranCommitID[:6]}') != 1: + sshSession.command('git log --oneline | head -n5', '\$', 5) + logging.warning(f'problems during checkout, is at: {sshSession.getBefore()}') + else: + logging.debug('successful checkout') # if the branch is not develop, then it is a merge request and we need to do # the potential merge. Note that merge conflicts should already been checked earlier if ranAllowMerge: if ranTargetBranch == '': - sshSession.command('git merge --ff origin/develop -m "Temporary merge for CI"', '\$', 5) - else: - logging.debug('Merging with the target branch: ' + ranTargetBranch) - sshSession.command('git merge --ff origin/' + ranTargetBranch + ' -m "Temporary merge for CI"', '\$', 5) + ranTargetBranch = 'develop' + logging.debug(f'Merging with the target branch: {ranTargetBranch}') + sshSession.command(f'git merge --ff origin/{ranTargetBranch} -m "Temporary merge for CI"', '\$', 5) def CopyLogsToExecutor(sshSession, sourcePath, log_name, scpIp, scpUser, scpPw): sshSession.command(f'cd {sourcePath}/cmake_targets', '\$', 5)