summaryrefslogtreecommitdiff
path: root/precommit-test.sh
diff options
context:
space:
mode:
Diffstat (limited to 'precommit-test.sh')
-rwxr-xr-xprecommit-test.sh59
1 files changed, 59 insertions, 0 deletions
diff --git a/precommit-test.sh b/precommit-test.sh
new file mode 100755
index 00000000..249eae94
--- /dev/null
+++ b/precommit-test.sh
@@ -0,0 +1,59 @@
+#!/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" --verbose "$verbose"
+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 -e "tcwg_.*-precommit" \
+ | grep -e "$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