summaryrefslogtreecommitdiff
path: root/round-robin.sh
diff options
context:
space:
mode:
Diffstat (limited to 'round-robin.sh')
-rw-r--r--round-robin.sh70
1 files changed, 69 insertions, 1 deletions
diff --git a/round-robin.sh b/round-robin.sh
index f25af57b..c12ec8e3 100644
--- a/round-robin.sh
+++ b/round-robin.sh
@@ -923,6 +923,19 @@ get_baseline_manifest ()
)
}
+# Fetch and print value from manifest of the current build
+# $1: Variable to fetch.
+get_current_manifest ()
+{
+ (
+ set -euf -o pipefail
+ unset rr
+ declare -A rr
+ source ${rr[top_artifacts]}/manifest.sh
+ eval echo "\$$1"
+ )
+}
+
print_jira_card ()
{
(
@@ -1100,6 +1113,53 @@ EOF
)
}
+# Print a reasonable date to associate with the current results / artifacts.
+print_results_date ()
+{
+ local c base_d cur_d results_date=0
+
+ # Firstly, set results_date to the max of commit dates of all components.
+ for c in "${components[@]}"; do
+ base_d=$(get_baseline_manifest "{rr[debug_${c}_date]}" \
+ | cut -d" " -f 1 || true)
+ cur_d=$(get_current_manifest "{rr[debug_${c}_date]}" \
+ | cut -d" " -f 1 || true)
+ if [ x"$base_d" != x"" ]; then
+ if [ x"$cur_d" = x"" ] || [ $cur_d -lt $base_d ]; then
+ cur_d="$base_d"
+ fi
+ fi
+ if [ x"$cur_d" = x"" ]; then
+ continue
+ fi
+
+ if [ $cur_d -gt $results_date ]; then
+ results_date="$cur_d"
+ fi
+ done
+
+ assert_with_msg "Failed to produce results_date" [ $results_date -gt 0 ]
+
+ # Secondly, if we have a baseline date, return average between our
+ # current results_date and baseline date. The reason behind average
+ # is to spread out dates between bursts of builds, which can occur
+ # when reducing a regression.
+ base_d=$(get_baseline_manifest "{rr[results_date]}" || true)
+ if [ x"$base_d" != x"" ]; then
+ assert [ $results_date -ge $base_d ]
+ if [ $results_date -gt $base_d ]; then
+ results_date=$((($results_date + $base_d) / 2))
+ else
+ # If the dates are equal, then no point in taking average.
+ # Instead just add duration of this build to move the date some
+ # arbitrary, but reasonable, amount.
+ results_date=$(($results_date + $(date +%s) - ${rr[start_date]}))
+ fi
+ fi
+
+ echo $results_date
+}
+
# create the dashboard directory, generate the dashboard-generate.sh file, and execute it.
# (invoked from CHECK_REGRESSION stage)
create_dashboard_dir ()
@@ -1110,6 +1170,14 @@ create_dashboard_dir ()
rm -rf ${rr[top_artifacts]}/dashboard
mkdir -p ${rr[top_artifacts]}/dashboard
+ local results_date
+ results_date=$(print_results_date)
+ # Store results_date in the manifest.
+ cat <<EOF | manifest_out
+rr[results_date]=$results_date
+EOF
+ results_date=$(date -utc --iso-8601=seconds --date="@$results_date")
+
# Create dashboard-generate.sh cmd file
cat > ${rr[top_artifacts]}/dashboard/dashboard-generate.sh << EOF
#!/bin/bash
@@ -1125,7 +1193,7 @@ fi
--top_artifacts "\$top_artifacts" \\
--baseline_branch "${rr[baseline_branch]}" \\
--components "${rr[components]}" \\
- --run_date "${rr[run_date]}"
+ --run_date "$results_date"
EOF
chmod a+x ${rr[top_artifacts]}/dashboard/dashboard-generate.sh