diff options
author | Maxim Kuvyrkov <maxim.kuvyrkov@linaro.org> | 2019-01-19 14:08:21 +0000 |
---|---|---|
committer | Maxim Kuvyrkov <maxim.kuvyrkov@linaro.org> | 2019-01-21 14:27:28 +0000 |
commit | a85440a3d1f11061f9b5149606e57337563bc610 (patch) | |
tree | 7c628ed023bb0cdb0e0c5cdb9308211f6a295a4f | |
parent | a61032cab5def612c864bb10c5e35d4f44d708db (diff) |
jenkins-helpers: Enable clone_or_update_repo to fetch single branch
... to optimize clone and updates of base-artifacts.
The base-artifacts repo has a lot of contineously re-written
branches, but these branches are only a few commits deep
(they store "stack" of current regressions). We want to fetch
only the branch of base-artifacts for configuration we are testing,
not the whole repo.
This patch adds new parameter to clone_or_update_repo and
clone_or_update_repo_no_checkout.
Change-Id: I286a78e167ddc2e34a770fb6f8b60323a14fe8c6
-rw-r--r-- | jenkins-helpers.sh | 42 | ||||
-rw-r--r-- | round-robin.sh | 10 |
2 files changed, 32 insertions, 20 deletions
diff --git a/jenkins-helpers.sh b/jenkins-helpers.sh index b63fa150..5b87a29d 100644 --- a/jenkins-helpers.sh +++ b/jenkins-helpers.sh @@ -358,6 +358,7 @@ clone_or_update_repo_no_checkout () local dir="$1" local url="$2" local reference="$3" + local single_branch="$4" local refopt="" case "$reference" in @@ -378,7 +379,13 @@ clone_or_update_repo_no_checkout () if ! [ -d "$dir/.git" ]; then rm -rf "$dir" - run_with_timeout_and_retry 1h 3 git clone $refopt "$url" "$dir" + + local single_branch_opt="" + if [ x"$single_branch" != x"" ]; then + single_branch_opt="--single-branch --branch $single_branch" + fi + + run_with_timeout_and_retry 1h 3 git clone $refopt $single_branch_opt "$url" "$dir" else # Clean up the clone (this is supposed to re-share objects from # reference clone and keep the size of the clone minimal). @@ -398,8 +405,13 @@ clone_or_update_repo_no_checkout () # Update from URL. git remote add origin "$url" > /dev/null 2>&1 || true git remote set-url origin "$url" - run_with_timeout_and_retry 1h 3 git remote update -p - run_with_timeout_and_retry 1h 3 git fetch -q origin "refs/changes/*:refs/changes/*" + local refspec="+refs/changes/*:refs/changes/*" + if [ x"$single_branch" = x"" ]; then + run_with_timeout_and_retry 1h 3 git remote update -p + else + refspec="+refs/heads/$single_branch:refs/remotes/origin/$single_branch" + fi + run_with_timeout_and_retry 1h 3 git fetch -q origin $refspec --prune ) ) } @@ -418,25 +430,23 @@ clone_or_update_repo () local ref="$2" local url="$3" local reference="auto" + local single_branch="" if [ $# -ge 4 ]; then + if [ $# -ge 5 ]; then + single_branch="$5" + fi reference="$4" fi - clone_or_update_repo_no_checkout "$dir" "$url" "$reference" + clone_or_update_repo_no_checkout "$dir" "$url" "$reference" "$single_branch" - ( - cd "$dir" - - # Convert git branch/tag names into SHA1 - local sha1 - sha1=$(git_rev_parse "." "$ref") - - # Checkout - git reset --hard - git clean -dfx - git checkout --detach "$sha1" - ) + git_clean "$dir" + # Convert git branch/tag names into SHA1 + local sha1 + sha1=$(git_rev_parse "$dir" "$ref") + # Checkout + git -C "$dir" checkout --detach "$sha1" ) } diff --git a/round-robin.sh b/round-robin.sh index 3d043455..034e6726 100644 --- a/round-robin.sh +++ b/round-robin.sh @@ -54,12 +54,14 @@ reset_artifacts () echo "Starting build" > ${rr[top_artifacts]}/results echo "-10" >> ${rr[top_artifacts]}/results + local single_branch=${rr[baseline_branch]} + # Clone base-artifacts so that run_step can rsync artifacts for skipped # steps. - # TODO: base-artifacts repo is starting to get big, so we should - # fetch only the $baseline branch, instead of all branches. + # base-artifacts repo is big and changes all the time, so we + # fetch only the $baseline_branch, instead of all branches. rr[base-artifacts_rev]="${rr[base-artifacts_rev]-${rr[baseline_branch]}}" - clone_or_update_repo base-artifacts ${rr[base-artifacts_rev]} https://git-us.linaro.org/toolchain/ci/base-artifacts.git + clone_or_update_repo base-artifacts ${rr[base-artifacts_rev]} https://git-us.linaro.org/toolchain/ci/base-artifacts.git auto $single_branch cat <<EOF | manifest_out rr[base-artifacts_rev]=$(git_rev_parse_long base-artifacts HEAD) EOF @@ -108,7 +110,7 @@ clone_repo () fi # Clone origin remote - clone_or_update_repo_no_checkout $project ${rr[${project}_url]} auto > /dev/null + clone_or_update_repo_no_checkout $project ${rr[${project}_url]} auto "" > /dev/null # Add baseline remote git_init_linaro_local_remote $project baseline $read_only # Checkout, now that we have both origin and baseline remotes ready. |