#!/bin/bash set -ef -o pipefail scripts=$(dirname $0) . $scripts/jenkins-helpers.sh artifacts=$(pwd)/artifacts rm -rf $artifacts mkdir $artifacts # Process bisect-only args convert_args_to_variables "$@" shift "$SHIFT_CONVERTED_ARGS" bad_rev="${bad_rev:-default}" baseline_rev="${baseline_rev:-baseline}" BUILD_URL="${BUILD_URL:-$(pwd)}" confirm_failure="${confirm_failure:-false}" # Process build args and record them in build-manifest.sh convert_args_to_variables %% artifacts/build-manifest.sh "$@" obligatory_variables current_project toolchain linux_config="${linux_config:-defconfig}" target="${target:-native}" verbose="${verbose:-true}" set -u if $verbose; then set -x; fi trap "eval \"echo ERROR at \${FUNCNAME[0]}:\${BASH_LINENO[0]}\" > $artifacts/failures" EXIT if $confirm_failure; then # Make sure we are not about to bisect a sporadic failure. $scripts/tcwg_kernel-build.sh \ @@ artifacts/build-manifest.sh \ --mode "baseline" \ --current_rev "$bad_rev" \ --top_artifacts "$artifacts/build-bad" \ --verbose "$verbose" & res=0 && wait $! || res=$? bad_rev=$(git -C $current_project rev-parse HEAD) if [ x"$res" = x"0" ]; then # Build job had a spurious failure. Re-try. cat > $artifacts/trigger-2-build-master < ../bisect-run.sh <&1 | tee $artifacts/bisect.log # "git bisect run" can fail (exit with non-zero) in a number of cases: # - on trivial bisects (e.g., between HEAD^ and HEAD), # - when merge-base between baseline and bad is worse than baseline, # - something else? # In all these cases we want to reset baseline to HEAD, so that we catch # most of the commits that introduced change in the result metric. git bisect run ../bisect-run.sh 2>&1 | tee -a $artifacts/bisect.log & res=0 && wait $! || res=$? if [ x"$res" = x"0" ]; then first_bad=$(cat .git/BISECT_RUN | head -n 1 | grep "is the first bad commit" | cut -d" " -f 1) assert [ x"$first_bad" != x"" ] echo $first_bad > $artifacts/first-bad else first_bad=$(git rev-parse HEAD) if ! [ -f .git/BISECT_LOG ]; then # It seems this was a trivial bisect with $bad_rev^ == $good_rev. first_bad=$bad_rev echo $first_bad > $artifacts/first-bad fi fi cd .. # Save BISECT_* logs mkdir $artifacts/git-logs find "$current_project" -path "$current_project/.git/BISECT_*" -print0 | xargs -0 -I@ mv @ $artifacts/git-logs/ # Reset baseline to the regressed commit so that we will catch subsequent # regressions (worse than $bad_rev). cat > $artifacts/trigger-1-reset-baseline < artifacts/ci_mail_parameters.sh < Results regressed from (for $last_good) $(cat artifacts/build-$last_good-last_good/results) to (for $first_bad) $(cat artifacts/build-$first_bad-first_bad/results) Artifacts of first_bad build: ${BUILD_URL}artifact/artifacts/build-$first_bad-first_bad/ Artifacts of last_good build: ${BUILD_URL}artifact/artifacts/build-$last_good-last_good/ Reproduce builds: mkdir investigate-$current_project-$first_bad cd investigate-$current_project-$first_bad git clone https://git.linaro.org/toolchain/jenkins-scripts wget ${BUILD_URL}artifact/artifacts/build-manifest.sh mkdir reproduce-good cd reproduce-good ../jenkins-scripts/tcwg_kernel-build.sh @@ ../build-manifest.sh ==rr[${current_project}_rev] $last_good cd .. mkdir reproduce-bad cd reproduce-bad ../jenkins-scripts/tcwg_kernel-build.sh @@ ../build-manifest.sh ==rr[${current_project}_rev] $first_bad cd .. History of pending regressions and results: https://git.linaro.org/toolchain/ci/base-artifacts.git/log/?h=linaro-local/ci/tcwg_kernel/$toolchain-${rr[${toolchain}_version]}-$target-${rr[linux_version]}-$linux_config Bisect log: ${BUILD_URL}artifact/artifacts/bisect.log/*view*/ Artifacts: ${BUILD_URL}artifact/artifacts/ Build URL: $BUILD_URL Build log: ${BUILD_URL}consoleText Full commit: $(git -C $current_project show $first_bad | tr '"' "'") " EOF chmod +x artifacts/ci_mail_parameters.sh fi # Trigger master build now instead of waiting for next timed SCM trigger. cat > $artifacts/trigger-2-build-master <