diff options
Diffstat (limited to 'tcwg_gnu-build.sh')
-rwxr-xr-x | tcwg_gnu-build.sh | 104 |
1 files changed, 104 insertions, 0 deletions
diff --git a/tcwg_gnu-build.sh b/tcwg_gnu-build.sh new file mode 100755 index 00000000..1a546169 --- /dev/null +++ b/tcwg_gnu-build.sh @@ -0,0 +1,104 @@ +#!/bin/bash + +set -euf -o pipefail + +scripts=$(dirname $0) +. $scripts/jenkins-helpers.sh +. $scripts/round-robin.sh + +convert_args_to_variables "$@" + +obligatory_variables rr[ci_config] + +# Execution mode: baseline, bisect, jenkins-full +rr[mode]="${rr[mode]-baseline}" + +# Set custom revision for one of the projects, and use baseline revisions +# for all other projects. +rr[ci_project]="${rr[ci_project]-tcwg_gnu}" +rr[baseline_branch]="${rr[baseline_branch]-linaro-local/ci/${rr[ci_project]}/${rr[ci_config]}}" +rr[reset_baseline]="${rr[reset_baseline]-false}" +rr[top_artifacts]="${rr[top_artifacts]-$(pwd)/artifacts}" + +# {toolchain_name}-{toolchain_ver}-{target}-{bootstrap_config} +IFS=- read -a ci_config <<EOF +${rr[ci_config]} +EOF +rr[target]="native" +bootstrap_config=${bootstrap_config-${ci_config[3]}} +rr[components]="gcc" + +# Use baseline branches by default. +for c in ${rr[components]}; do + rr[${c}_branch]=${rr[${c}_branch]-baseline} + obligatory_variables rr[${c}_url] +done + +start_at="${start_at-default}" +finish_at="${finish_at-default}" +verbose="${verbose-true}" +verbose2="${verbose2-false}" + +if $verbose2; then set -x; fi + +trap "eval \"echo ERROR at \${FUNCNAME[0]}:\${BASH_LINENO[0]}\"" EXIT + +# Set start and finish steps for different modes. +default_start_at="" +default_finish_at="" +case "${rr[mode]}" in + "baseline") + default_finish_at="update_baseline" + ;; + "bisect") + case "$(print_single_updated_component)" in + gcc) default_start_at="build_abe-$bootstrap_config" ;; + *) assert false ;; + esac + default_finish_at="check_regression" + ;; + "jenkins-full") ;; +esac +if [ x"$start_at" = x"default" ]; then + start_at="$default_start_at" +fi +if [ x"$finish_at" = x"default" ]; then + finish_at="$default_finish_at" +fi + +run_step_init "$start_at" "$finish_at" "${rr[top_artifacts]}" "$verbose" + +# Exit with code 0 if no regression compared to base-artifacts/results. +no_regression_p () +{ + ( + set -euf -o pipefail + + # The following check tests for an empty branch, and we return 0 if results + # are not present, since that's an inherently better state. If base-artifacts + # were not existing, then it would fail in reset_artifacts() stage. + + if ! [ -f base-artifacts/results ]; then + return 0 + fi + + local build_result_ref build_result_new + build_result_ref=$(tail -n1 base-artifacts/results) + build_result_new=$(tail -n1 ${rr[top_artifacts]}/results) + + if [ $build_result_new -lt $build_result_ref ]; then + return 1 + fi + + return 0 + ) +} + +run_step stop_on_fail -10 reset_artifacts +run_step stop_on_fail x prepare_abe +run_step skip_on_fail -5 build_abe ${bootstrap_config} +run_step reset_on_fail x check_regression +run_step stop_on_fail x update_baseline +run_step stop_on_fail x push_baseline + +trap "" EXIT |