diff options
author | Maxim Kuvyrkov <maxim.kuvyrkov@linaro.org> | 2022-08-11 18:12:06 +0000 |
---|---|---|
committer | Maxim Kuvyrkov <maxim.kuvyrkov@linaro.org> | 2022-08-13 13:20:12 +0000 |
commit | 445a9c382a5a87f33ac6b8d105548962c0348385 (patch) | |
tree | 4a0374f0462b0dee5f1a52b8ae770ba63afa5094 | |
parent | 42b5d81f3a22b5b39ac91a2defc2984725d4df8a (diff) |
round-robin.sh: Store baseline git data in separate directory
... instead of the manifest. We need to do this to correctly handle
builds that fail before all their components are checked out.
In other words, we need to store all baseline git data at the very
beginning of the build, so that it is preserved even if build
doesn't clone/checkout all components.
We also rework clone_repo() code to store git data for bisect builds,
which will then be used in upcoming report-generation code.
Change-Id: I782a0c050ac4227b21fbaf88a179e574bd7709be
-rw-r--r-- | round-robin.sh | 128 |
1 files changed, 89 insertions, 39 deletions
diff --git a/round-robin.sh b/round-robin.sh index 810714cb..a71bcf0c 100644 --- a/round-robin.sh +++ b/round-robin.sh @@ -137,6 +137,69 @@ reset_artifacts () cat <<EOF | manifest_out rr[base-artifacts_rev]=$(git -C base-artifacts rev-parse HEAD) EOF + + local baseline_dir=${rr[top_artifacts]}/baseline + if [ -d base-artifacts/baseline/ ]; then + # Copy baseline git_url/git_rev settings into the current build, + # which will then be overwritten in due course by clone_repo() + # of various components. + # Note that we need to copy the whole directory to correctly handle + # builds that fail before all their components are checked out. + rsync -a base-artifacts/baseline/ $baseline_dir/ + else + # E.g., we are in "init" mode of update_baseline. + mkdir $baseline_dir + + # Transitional workaround + # Extract baseline from manifest of baseline build + ( + local components c + components="${rr[components]}" + # Remove our current settings from ${rr[]}. + unset rr + # For a short time manifests used "debug" array, so we need + # to declare it when sourcing these manifests. + # shellcheck disable=SC2034 + declare -A rr debug + if [ -f base-artifacts/manifest.sh ]; then + source base-artifacts/manifest.sh + elif [ -f base-artifacts/jenkins/manifest.sh ]; then + source base-artifacts/jenkins/manifest.sh + else + # We are in "init" baseline build, apparently. + # Do nothing and hope get_baseline() is not called. + exit 0 + fi + + for c in $components; do + if [ x"${rr[${c}_url]}" != x"" ]; then + echo "${rr[${c}_url]}" + else + print_baseline_repo "$project" true + fi > $baseline_dir/${c}_url + + echo "${rr[${c}_rev]}" > $baseline_dir/${c}_rev + done + ) + fi + ) +} + +get_baseline_git () +{ + ( + set -euf -o pipefail + assert_with_msg "ERROR: No $1 in baseline git" \ + [ -f "base-artifacts/baseline/$1" ] + cat "base-artifacts/baseline/$1" + ) +} + +set_current_git () +{ + ( + set -euf -o pipefail + cat > "${rr[top_artifacts]}/baseline/$1" ) } @@ -151,63 +214,50 @@ clone_repo () if [ x"${rr[mode]}" = x"bisect" ]; then # Cleanup current checkout in bisect mode. git_clean "$project" - return 0 - fi - - local url branch - - if [ x"${rr[${project}_git]}" != x"baseline" ]; then - # Fetch and checkout from the specified repo. - url="${rr[${project}_git]%#*}" - branch="${rr[${project}_git]#*#}" else - # TODO: Remove transitional compatability code - local base_manifest - if [ -e base-artifacts/manifest.sh ]; then - base_manifest=base-artifacts/manifest.sh + local url branch + + if [ x"${rr[${project}_git]}" != x"baseline" ]; then + # Fetch and checkout from the specified repo. + url="${rr[${project}_git]%#*}" + branch="${rr[${project}_git]#*#}" else - base_manifest=base-artifacts/jenkins/manifest.sh + url=$(get_baseline_git ${project}_url) + branch=$(get_baseline_git ${project}_rev) fi - # For a short time manifests used "debug" array, so we need - # to declare it when sourcing these manifests. - # shellcheck disable=SC2034 - declare -A debug - url=$(source $base_manifest; echo "${rr[${project}_url]-}") - branch=$(source $base_manifest; echo "${rr[${project}_rev]-}") + # Allow manifest override for $url + url="${rr[${project}_url]-$url}" + clone_or_update_repo_no_checkout "$project" "$url" auto "" origin \ + > /dev/null - if [ x"$url" = x"" ]; then - url=$(print_baseline_repo "$project" false) - fi + # Store git url in the manifest. + cat <<EOF | manifest_out +rr[${project}_url]=$url +EOF + # Store baseline git_url data. This is then used by + # subsequent builds to fetch baseline commits. + echo "$url" | set_current_git ${project}_url - assert_with_msg "ERROR: No rr[${project}_url] in baseline manifest" \ - [ x"$url" != x"" ] - assert_with_msg "ERROR: No rr[${project}_rev] in baseline manifest" \ - [ x"$branch" != x"" ] + # Allow manifest override for $branch + branch="${rr[${project}_rev]-$branch}" + git_checkout "$project" "$branch" origin fi - # Allow manifest override for $url - url="${rr[${project}_url-$url]-$url}" - clone_or_update_repo_no_checkout "$project" "$url" auto "" origin \ - > /dev/null - - # Allow manifest override for $branch - branch="${rr[${project}_rev]-$branch}" - git_checkout "$project" "$branch" origin - local cur_rev cur_rev=$(git -C $project rev-parse HEAD) local debug_project_date debug_project_date=$(git -C $project show --no-patch --pretty="%ct # %cr" HEAD) - # Store git url and rev info in the manifest. This is then used by - # subsequent builds to fetch baseline commits. + # Store git rev info in the manifest. cat <<EOF | manifest_out -rr[${project}_url]=$url rr[${project}_rev]=$cur_rev rr[debug_${project}_date]=$debug_project_date EOF + # Store baseline git_rev data. This is then used by + # subsequent builds to fetch baseline commits. + echo "$cur_rev" | set_current_git ${project}_rev ) } |