diff options
author | Maxim Kuvyrkov <maxim.kuvyrkov@linaro.org> | 2024-01-05 14:20:44 +0000 |
---|---|---|
committer | Maxim Kuvyrkov <maxim.kuvyrkov@linaro.org> | 2024-01-09 15:59:37 +0000 |
commit | 29a68e3348995a9e1491eb3f27026ac372249ca4 (patch) | |
tree | b251d7d7820f910c8e503cd538884ac20d51ce2d | |
parent | 121cb0b2e181548480d6d4d3cbbf2efe9353edf0 (diff) |
precommit-test.sh: New script to test each patch in a series
Change-Id: I417346de70535c6d1243a1050e3608e2741ffc7d
-rwxr-xr-x | precommit-ssh-apply.sh | 23 | ||||
-rwxr-xr-x | precommit-test.sh | 58 |
2 files changed, 75 insertions, 6 deletions
diff --git a/precommit-ssh-apply.sh b/precommit-ssh-apply.sh index c5f4bf66..ffa32d87 100755 --- a/precommit-ssh-apply.sh +++ b/precommit-ssh-apply.sh @@ -10,9 +10,11 @@ scripts=$(dirname $0) convert_args_to_variables "$@" -obligatory_variables project pw_url pw_dir build_url patch_submitter -declare project pw_url pw_dir build_url patch_submitter +obligatory_variables pw_url +declare pw_url +fetch_only="${fetch_only-false}" +series_dir="${series_dir-}" verbose="${verbose-true}" if $verbose; then @@ -40,6 +42,18 @@ if [ "$num_patch" = "" ]; then num_patch="0" fi +if [ "$series_dir" = "" ]; then + series_dir=$(mktemp -d) +fi +rsync -a "$series_url" "$series_dir/new/" + +if $fetch_only; then + exit 0 +fi + +obligatory_variables project pw_dir build_url patch_submitter +declare project pw_dir build_url patch_submitter + url=$(get_baseline_git "${project}_url") rev=$(get_baseline_git "${project}_rev") echo "Fetching baseline $url#$rev" @@ -51,7 +65,7 @@ mkdir -p "$pw_dir" cat > "$pw_dir/$project" <<EOF pw[project]='$project' pw[${project}]='$project' -pw[${project}_patch_id]='$pw_url' +pw[${project}_patch_id]='$num_patch' pw[${project}_check_cmd]='echo REPORT' pw[${project}_build_url]='$build_url' pw[${project}_patch_url]='$pw_url' @@ -62,9 +76,6 @@ EOF prev_head=$(git -C "$project" rev-parse HEAD) res=0 -series_dir=$(mktemp -d) -rsync -a "$series_url" "$series_dir/new/" - # Apply the whole series and then roll-back to the desired patch. if ! git -C "$project" am "$series_dir/"; then echo "WARNING: Series $series_url did not apply cleanly" diff --git a/precommit-test.sh b/precommit-test.sh new file mode 100755 index 00000000..67de5fb9 --- /dev/null +++ b/precommit-test.sh @@ -0,0 +1,58 @@ +#!/bin/bash + +set -euf -o pipefail + +scripts=$(dirname $0) +# shellcheck source=jenkins-helpers.sh +. $scripts/jenkins-helpers.sh + +convert_args_to_variables "$@" + +obligatory_variables project pw_url +declare project pw_url + +dryrun="${dryrun-true}" +job_filter="${job_filter-.*}" +notify="${notify-$USER@linaro.org}" +num_patches="${num_patches-0}" +verbose="${verbose-false}" + +if $verbose; then + set -x +fi + +series_dir=$(mktemp -d) +$scripts/precommit-ssh-apply.sh --pw_url "$pw_url" --fetch_only true \ + --series_dir "$series_dir" +if ! [ "$num_patches" -gt "0" ]; then + num_patches=$(find "$series_dir" -type f | wc -l) +fi +rm -rf "$series_dir" + +jenkins_query=(ssh -p2222 -l "$USER@linaro.org" ci.linaro.org) + +jenkins_run=() +if $dryrun; then + jenkins_run+=(echo DRYRUN) +fi +jenkins_run+=("${jenkins_query[@]}") + +readarray -t job_list < <("${jenkins_query[@]}" list-jobs \ + | grep "tcwg_.*-precommit" | grep "$job_filter") + +for ci_job in "${job_list[@]}"; do + if ! "${jenkins_query[@]}" get-job "$ci_job" \ + | grep "^ *<name>${project}_git</name>\$" >/dev/null; then + continue + fi + + echo "START: $ci_job: $num_patches builds" + + num="$num_patches" + while [ "$num" -gt "0" ]; do + num=$(($num - 1)) + "${jenkins_run[@]}" build "$ci_job" \ + -p "${project}_git=$pw_url#$num" \ + -p "notify=$notify" + done +done |