diff options
author | Laurent Alfonsi <laurent.alfonsi@linaro.org> | 2024-03-27 22:09:03 +0100 |
---|---|---|
committer | Antoine Moynault <antoine.moynault@linaro.org> | 2024-04-08 15:24:26 +0000 |
commit | a098660932da9c1a8a73400b5100859fadb1b612 (patch) | |
tree | 99ae63fd0f23bdf0b10b4f4dba0bfb902c22e816 | |
parent | 505cfb47a5e673c96b87f19055ad64b445fdf288 (diff) |
round-robin-bisect.sh,round-robin-notify.sh: current project directory can be different than $current_project
Change-Id: Ifd4093b61eeb291474278e5354a6cf39e565f6b8
-rwxr-xr-x | round-robin-bisect.sh | 94 | ||||
-rwxr-xr-x | round-robin-notify.sh | 9 |
2 files changed, 50 insertions, 53 deletions
diff --git a/round-robin-bisect.sh b/round-robin-bisect.sh index 1abba2f9..402286c1 100755 --- a/round-robin-bisect.sh +++ b/round-robin-bisect.sh @@ -69,6 +69,8 @@ exit_0 () { exit 0 } +current_project_dir=$(get_current_git_dir $current_project) + bad_url="${bad_git%#*}" bad_branch="${bad_git#*#}" @@ -106,7 +108,7 @@ $scripts/round-robin-baseline.sh \ @@rr[top_artifacts] "$rel_artifacts/build-baseline" \ __base_artifacts base-artifacts -baseline_rev="${baseline_rev-$(git -C ${current_project} rev-parse HEAD)}" +baseline_rev="${baseline_rev-$(git -C $current_project_dir rev-parse HEAD)}" cat <<EOF | manifest_out declare -g baseline_rev=$baseline_rev EOF @@ -118,28 +120,28 @@ mkdir -p ./bisect # Save baseline build state, which we restore before individual bisect tests. # This ensures that "bad" bisect tests won't affect "good" ones and vice versa. baseline_exclude=( - --exclude /bisect/ --exclude "/$rel_artifacts/" --exclude "/$current_project/" + --exclude /bisect/ --exclude "/$rel_artifacts/" --exclude "/$current_project_dir/" ) rsync -a --del --delete-excluded "${baseline_exclude[@]}" ./ ./bisect/baseline/ mkdir $artifacts/git-logs # Make sure the sources are clean before bisecting -git -C $current_project reset -q --hard +git -C $current_project_dir reset -q --hard if [ -f "$replay_log" ]; then cp "$replay_log" $artifacts/git-logs/bisect_replay.sh - git -C $current_project bisect replay $artifacts/git-logs/bisect_replay.sh + git -C $current_project_dir bisect replay $artifacts/git-logs/bisect_replay.sh else - git -C $current_project bisect start + git -C $current_project_dir bisect start fi # Hard-link BISECT_LOG inside $artifacts to guarantee its upload to jenkins. -ln -f "$(pwd)"/$current_project/.git/BISECT_LOG $artifacts/git-logs/bisect_log +ln -f "$(pwd)"/$current_project_dir/.git/BISECT_LOG $artifacts/git-logs/bisect_log -if ! git -C $current_project bisect log \ +if ! git -C $current_project_dir bisect log \ | grep "^git bisect .* $baseline_rev\$" >/dev/null; then - git -C $current_project bisect good $baseline_rev + git -C $current_project_dir bisect good $baseline_rev fi # Bisect script. @@ -169,18 +171,18 @@ cat > $artifacts/test.sh <<EOF set -euf -o pipefail -rev=\$(git rev-parse HEAD) +current_project_dir=\$1 + +rev=\$(git -C $current_project_dir rev-parse HEAD) -if git bisect log | grep "^git bisect bad \$rev\\\$" >/dev/null; then +if git -C $current_project_dir bisect log | grep "^git bisect bad \$rev\\\$" >/dev/null; then exit 1 -elif git bisect log | grep "^git bisect skip \$rev\\\$" >/dev/null; then +elif git -C $current_project_dir bisect log | grep "^git bisect skip \$rev\\\$" >/dev/null; then exit 125 -elif git bisect log | grep "^git bisect good \$rev\\\$" >/dev/null; then +elif git -C $current_project_dir bisect log | grep "^git bisect good \$rev\\\$" >/dev/null; then exit 0 fi -cd .. - # Restore known-good baseline state. rsync -a --del ${baseline_exclude[@]} ./bisect/baseline/ ./ @@ -194,7 +196,7 @@ $build_script \ --verbose "$verbose" & res=0 && wait \$! || res=\$? -git -C $current_project reset -q --hard +git -C $current_project_dir reset -q --hard if [ x"\$res" != x"0" ]; then if [ -f $rel_artifacts/build-\$rev/trigger-build-$current_project ]; then @@ -207,13 +209,13 @@ if [ x"\$res" != x"0" ]; then # then we mark such "skipped" revision as "bad". # Number of "git bisect skip" in a row - n_skips=\$(git -C $current_project bisect log | awk ' + n_skips=\$(git -C $current_project_dir bisect log | awk ' BEGIN { n_skips=0 } /git bisect skip/ { n_skips++; next } /git bisect/ { n_skips=0 } END { print n_skips } ') - revs_left=\$(git -C $current_project bisect view --pretty=%H | wc -l) + revs_left=\$(git -C $current_project_dir bisect view --pretty=%H | wc -l) # Half the number of steps to finish the bisect n_steps_2=\$(echo "n_steps=l(\$revs_left)/l(2); scale=0; n_steps/2" | bc -l) if [ \$n_steps_2 -lt 2 ]; then @@ -235,7 +237,7 @@ EOF chmod +x $artifacts/test.sh # Fetch $bad_branch/$bad_rev from $bad_url -prev_rev=$(git -C $current_project rev-parse HEAD) +prev_rev=$(git -C $current_project_dir rev-parse HEAD) # Note: avoid using clone_or_update_repo(), which, potentially, can delete # and re-clone the repo. Deleting the repo would be bad, since we would # lose bisect state initialized by the above "git bisect" commands. @@ -243,9 +245,9 @@ prev_rev=$(git -C $current_project rev-parse HEAD) # does a more thorough job in cleaning up the repo directory than # "git reset -q --hard" in ./test.sh. The logic here is that we want # the "bad" build to run in the same environment as the "test" builds. -git -C "$current_project" fetch "$bad_url" "$bad_branch" -git -C "$current_project" checkout --detach FETCH_HEAD -bad_rev="${bad_rev-$(git -C "$current_project" rev-parse HEAD)}" +git -C "$current_project_dir" fetch "$bad_url" "$bad_branch" +git -C "$current_project_dir" checkout --detach FETCH_HEAD +bad_rev="${bad_rev-$(git -C "$current_project_dir" rev-parse HEAD)}" cat <<EOF | manifest_out declare -g bad_rev=$bad_rev EOF @@ -257,16 +259,14 @@ if [ x"$baseline_rev" = x"$bad_rev" ]; then else # Confirm regression in $bad_rev vs $baseline_rev. echo "Testing bad revision (expecting failure)" - git -C $current_project checkout --detach $bad_rev - cd $current_project - $artifacts/test.sh & + git -C $current_project_dir checkout --detach $bad_rev + $artifacts/test.sh $current_project_dir & res=0 && wait $! || res=$? - cd .. fi # Restore revision previously checked out. Otherwise "git bisect run" # below will not use replay info. -git -C $current_project checkout --detach $prev_rev +git -C $current_project_dir checkout --detach $prev_rev if [ x"$res" = x"0" ]; then if $rebase_workaround; then @@ -303,9 +303,9 @@ elif [ x"$res" = x"125" ]; then exit_0 fi -if ! git -C $current_project bisect log \ +if ! git -C $current_project_dir bisect log \ | grep "^git bisect .* $bad_rev\$" >/dev/null; then - git -C $current_project bisect bad $bad_rev + git -C $current_project_dir bisect bad $bad_rev ln -f -s "build-$bad_rev" "$artifacts/build-bad" fi @@ -318,7 +318,7 @@ get_first_bad () # excplicitly set "+o pipefail". set -euf +o pipefail - git -C $current_project bisect log | tail -n1 \ + git -C $current_project_dir bisect log | tail -n1 \ | grep "^# first bad commit:" \ | sed -e "s/^# first bad commit: \[\([0-9a-f]*\)\].*/\1/" ) @@ -336,7 +336,7 @@ print_tested_revs () set -euf +o pipefail local kind="${1-[a-z]*}" - git -C $current_project bisect log | grep "^git bisect $kind " \ + git -C $current_project_dir bisect log | grep "^git bisect $kind " \ | sed -e "s/^git bisect $kind //" ) } @@ -359,7 +359,7 @@ print_sha1_split () # Skip revisions that were already tested. Good revisions are filtered # out in the above $commits_to_test check, and here we filter out # "bad" and "skip" revisions. - if git -C $current_project bisect log \ + if git -C $current_project_dir bisect log \ | grep "^git bisect .* $sha1\$" >/dev/null; then echo "-1" return @@ -380,7 +380,7 @@ print_interesting_commit () set -euf -o pipefail # Generate list of commits inside the bisection range. - git -C $current_project bisect view --pretty=%H > $commits_to_test + git -C $current_project_dir bisect view --pretty=%H > $commits_to_test # Bisecting linux-next.git regressions is difficult enough due to how # the tree is constructed, so we prefer to not use interesting-commits @@ -430,7 +430,7 @@ print_interesting_commit () # loop (rather than switching to "git bisect run") in the hopes that # some other job will add a new entry to interesting-commits while # we are testing the stock revisions. - best_sha1=$(git -C $current_project bisect next | tail -n1 \ + best_sha1=$(git -C $current_project_dir bisect next | tail -n1 \ | sed -e "s/^\[\([0-9a-f]\+\)\].*\$/\1/") # Ensure that best_sha1 is indeed a sha1. I could not figure out # how to tell "git bisect next" to print only sha1 without extra @@ -462,22 +462,20 @@ while [ x"$sha1" != x"" ] \ "at ${split}%" fi - git -C $current_project checkout --detach $sha1 - cd $current_project - $artifacts/test.sh & + git -C $current_project_dir checkout --detach $sha1 + $artifacts/test.sh $current_project_dir & res=0 && wait $! || res=$? - cd .. if [ x"$res" = x"0" ]; then - git -C $current_project bisect good || break + git -C $current_project_dir bisect good || break elif [ x"$res" = x"125" ]; then # It may happen that we get to the point where only skipped commits # are left to test, and any new "git bisect skip" will return an error. # In this case break from this loop, and let "git bisect run" below # handle this case. [We also add "|| break" for good and bad cases # for symmetry.] - git -C $current_project bisect skip || break + git -C $current_project_dir bisect skip || break else - git -C $current_project bisect bad || break + git -C $current_project_dir bisect bad || break fi IFS=" " read -r split sha1 <<< "$(print_interesting_commit)" @@ -486,10 +484,8 @@ done if [ x"$(get_first_bad)" = x"" ]; then # Run stock "git bisect run" for corner cases like $rebase_workaround. # Most of the time we have bisected the failure down to first_bad above. - cd $current_project - git bisect run $artifacts/test.sh & + git bisect run $artifacts/test.sh $current_project_dir & res=0 && wait $! || res=$? - cd .. if [ x"$res" = x"0" ]; then assert_with_msg "Didn't find first bad commit!" [ x"$(get_first_bad)" != x"" ] @@ -510,7 +506,7 @@ if [ x"$first_bad" != x"" ]; then # or bisection artifact. last_good="" bad_last_good="" - for sha1 in $(git -C $current_project rev-parse $first_bad^@); do + for sha1 in $(git -C $current_project_dir rev-parse $first_bad^@); do # It seems that git-bisect assumes parent commit as "good" on # the basis of one of its children being "good". Therefore we # can have a situation when we have parent P with children C1 and C2, @@ -526,7 +522,7 @@ if [ x"$first_bad" != x"" ]; then if ! grep -q "^$sha1\$" $commits_in_range; then child_tested_good=false for tested_good in $(print_tested_revs good); do - if git -C $current_project merge-base --is-ancestor $sha1 $tested_good; then + if git -C $current_project_dir merge-base --is-ancestor $sha1 $tested_good; then child_tested_good=true break fi @@ -537,11 +533,9 @@ if [ x"$first_bad" != x"" ]; then fi echo "Testing first_bad's parent $sha1 (hoping for success)" - git -C $current_project checkout --detach "$sha1" - cd $current_project - $artifacts/test.sh & + git -C $current_project_dir checkout --detach "$sha1" + $artifacts/test.sh $current_project_dir & res=0 && wait $! || res=$? - cd .. if [ x"$res" = x"0" ]; then last_good=$sha1 break @@ -673,7 +667,7 @@ sed -i -e "s%^\(${current_project}_git\)=.*\$%\1=$bad_git%" \ $artifacts/trigger-build-3-default # Save BISECT_* logs -find "$current_project" -path "$current_project/.git/BISECT_*" -print0 \ +find "$current_project_dir" -path "$current_project_dir/.git/BISECT_*" -print0 \ | xargs -0 -I@ mv @ $artifacts/git-logs/ if [ x"$first_bad" != x"" ]; then diff --git a/round-robin-notify.sh b/round-robin-notify.sh index e4fbfe5d..3f92594a 100755 --- a/round-robin-notify.sh +++ b/round-robin-notify.sh @@ -194,7 +194,8 @@ check_source_changes () for c in "${changed_components[@]}"; do base_rev=$(get_baseline_git ${c}_rev) cur_rev=$(get_current_git ${c}_rev) - c_commits=$(git -C $c rev-list --count $base_rev..$cur_rev || echo "??") + cur_dir=$(get_current_git_dir ${c}) + c_commits=$(git -C "$cur_dir" rev-list --count $base_rev..$cur_rev || echo "??") echo "# rev for $c : $base_rev..$cur_rev ($c_commits commits)" done echo "" @@ -501,7 +502,8 @@ print_commits() for c in "${changed_components[@]}"; do base_rev=$(get_baseline_git ${c}_rev) cur_rev=$(get_current_git ${c}_rev) - c_commits=$(git -C $c rev-list --count $base_rev..$cur_rev \ + cur_dir=$(get_current_git_dir ${c}) + c_commits=$(git -C "$cur_dir" rev-list --count $base_rev..$cur_rev \ || echo 0) new_commits=$(($new_commits + $c_commits)) done @@ -516,7 +518,8 @@ print_commits() for c in "${changed_components[@]}"; do base_rev=$(get_baseline_git ${c}_rev) cur_rev=$(get_current_git ${c}_rev) - c_commits=$(git -C $c rev-list --count $base_rev..$cur_rev \ + cur_dir=$(get_current_git_dir ${c}) + c_commits=$(git -C "$cur_dir" rev-list --count $base_rev..$cur_rev \ || echo 0) if [ "${pw[$c]-}" != "" ]; then |