summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMaxim Kuvyrkov <maxim.kuvyrkov@linaro.org>2022-08-15 09:56:46 +0000
committerMaxim Kuvyrkov <maxim.kuvyrkov@linaro.org>2022-08-15 11:54:01 +0000
commit9fe5761fb3df94f8cb3c8d5346a13aed7008dd44 (patch)
tree90ae605e7880479f4489140de9b9e069479388cd
parent100fd175b20d849597af04e8ef720e10b881cb12 (diff)
round-robin.sh: Always generate email reports, not just for regressions
... and gracefully handle builds with multiple updated components and multiple new commits. Change-Id: I6c0126fe6403a7f6ea34072cb3e84582634a3463
-rwxr-xr-xround-robin-bisect.sh5
-rw-r--r--round-robin.sh136
2 files changed, 96 insertions, 45 deletions
diff --git a/round-robin-bisect.sh b/round-robin-bisect.sh
index 31119420..e762f86d 100755
--- a/round-robin-bisect.sh
+++ b/round-robin-bisect.sh
@@ -792,8 +792,9 @@ $(git -C $current_project show --stat --patch $first_bad | head -n 1000)
</cut>
EOF
- cp $artifacts/build-$first_bad/mail/mail-subject.txt \
- $artifacts/jenkins/mail-subject.draft
+ cat > $artifacts/jenkins/mail-subject.draft <<EOF
+[TCWG CI] $(cat $artifacts/build-$first_bad/mail/mail-subject.txt)
+EOF
# Set mail recipients last to preserve catch-error value from .yaml file.
# Email developers.
diff --git a/round-robin.sh b/round-robin.sh
index a769abc6..705aeb23 100644
--- a/round-robin.sh
+++ b/round-robin.sh
@@ -737,9 +737,102 @@ check_regression ()
rm -rf $run_step_artifacts/top-artifacts
fi
+ # Generate default notification templates
+ if ! [ -f $run_step_artifacts/mail-subject.txt ]; then
+ if [ $res != 0 ]; then
+ cat <<EOF
+Regression after \$COMMIT_COMPONENT: \$COMMIT_SUBJECT
+EOF
+ else
+ cat <<EOF
+Successful build after \$COMMIT_COMPONENT: \$COMMIT_SUBJECT
+EOF
+ fi > $run_step_artifacts/mail-subject.txt
+ fi
+
+ if ! [ -f $run_step_artifacts/jira-body.txt ]; then
+ cat > $run_step_artifacts/jira-body.txt <<EOF
+$(cat $run_step_artifacts/mail-subject.txt):
+\$COMMIT_LOG
+EOF
+ fi
+
+ if ! [ -f $run_step_artifacts/mail-body.txt ]; then
+ cat > $run_step_artifacts/mail-body.txt <<EOF
+$(cat $run_step_artifacts/jira-body.txt)
+
+Results changed to
+$(cat ${rr[top_artifacts]}/results)
+
+from
+$(cat base-artifacts/results)
+EOF
+ fi
+
local -a changed_components
IFS=" " read -r -a changed_components <<< "$(print_changed_components)"
+ local single_commit_p=false
+ if [ ${#changed_components[@]} = 1 ]; then
+ local c base_rev cur_rev sha1
+ c=${changed_components[0]}
+ base_rev=$(get_baseline_git ${c}_rev)
+ cur_rev=$(get_current_git ${c}_rev)
+ for sha1 in $(git -C $c rev-parse $cur_rev^@); do
+ if [ x"$sha1" = x"$base_rev" ]; then
+ # We have a single-commit build
+ single_commit_p=true
+ break
+ fi
+ done
+ fi
+
+ # Generate text for COMMIT_* variables._
+ (
+ local new_commits=0 c base_rev cur_rev c_commits
+
+ if [ ${#changed_components[@]} = 0 ]; then
+ COMMIT_COMPONENT="baseline build"
+ COMMIT_SUBJECT="no new commits"
+ COMMIT_LOG=""
+ elif $single_commit_p; then
+ c=${changed_components[0]}
+ base_rev=$(get_baseline_git ${c}_rev)
+ cur_rev=$(get_current_git ${c}_rev)
+ COMMIT_COMPONENT=$c
+ COMMIT_SUBJECT=$(git -C $c log --pretty=%s -n1 $cur_rev)
+ COMMIT_LOG=$(git -C $c log --pretty=short -n1 $cur_rev)
+ else
+ COMMIT_COMPONENT=$(print_changed_components "/")
+ COMMIT_LOG=""
+ 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)
+ new_commits=$(($new_commits + $c_commits))
+
+ COMMIT_LOG="$COMMIT_LOG
+$(git -C $c log --pretty=oneline $base_rev..$cur_rev | head -n5 || true)"
+ if [ $c_commits -gt 5 ]; then
+ COMMIT_LOG="$COMMIT_LOG
+... and $(($c_commits - 5)) more $c commits"
+ fi
+ done
+
+ COMMIT_SUBJECT="$new_commits commits"
+ fi
+
+ export COMMIT_COMPONENT COMMIT_SUBJECT COMMIT_LOG
+
+ local mail_dir=${rr[top_artifacts]}/mail
+ mkdir -p $mail_dir
+
+ for i in mail-subject.txt jira-body.txt mail-body.txt; do
+ envsubst '$COMMIT_COMPONENT $COMMIT_SUBJECT $COMMIT_LOG' \
+ < $run_step_artifacts/$i > $mail_dir/$i
+ done
+ )
+
if [ $res = 0 ]; then
# All good, no regression
return
@@ -818,49 +911,6 @@ EOF
fi
fi
- if [ x"$single_component" != x"" ] && ! [ $score -lt 0 ] 2>/dev/null; then
- local mail_dir=${rr[top_artifacts]}/mail
- mkdir -p $mail_dir
-
- if ! [ -f $run_step_artifacts/mail-subject.txt ]; then
- cat > $run_step_artifacts/mail-subject.txt <<EOF
-[TCWG CI] Regression caused by \$COMMIT_COMPONENT: \$COMMIT_SUBJECT
-EOF
- fi
-
- if ! [ -f $run_step_artifacts/jira-body.txt ]; then
- cat > $run_step_artifacts/jira-body.txt <<EOF
-$(cat $run_step_artifacts/mail-subject.txt):
-\$COMMIT_LOG
-EOF
- fi
-
- if ! [ -f $run_step_artifacts/mail-body.txt ]; then
- cat > $run_step_artifacts/mail-body.txt <<EOF
-$(cat $run_step_artifacts/jira-body.txt)
-
-Results regressed to
-$(cat ${rr[top_artifacts]}/results)
-
-from
-$(cat base-artifacts/results)
-EOF
- fi
-
- (
- COMMIT_COMPONENT=$single_component
- export COMMIT_COMPONENT
- COMMIT_SUBJECT=$(git -C $single_component log --pretty=%s -n 1 HEAD)
- export COMMIT_SUBJECT
- COMMIT_LOG=$(git -C $single_component log --pretty=short -n 1 HEAD)
- export COMMIT_LOG
- for i in mail-subject.txt jira-body.txt mail-body.txt; do
- envsubst '$COMMIT_COMPONENT $COMMIT_SUBJECT $COMMIT_LOG' \
- < $run_step_artifacts/$i > $mail_dir/$i
- done
- )
- fi
-
if [ x"${rr[update_baseline]}" != x"force" ]; then
echo "Detected a regression!"
false