#!/bin/bash set -euf -o pipefail +x scripts=$(dirname $0) # shellcheck source=jenkins-helpers.sh . $scripts/jenkins-helpers.sh # shellcheck source=pw-helpers.sh . $scripts/pw-helpers.sh convert_args_to_variables "$@" obligatory_variables check result pw_dir declare check result pw_dir verbose="${verbose-true}" if $verbose; then set -x fi if ! [ -d "$pw_dir" ]; then exit 0 fi while IFS= read -r -d '' pw_file; do ( declare -A pw # shellcheck disable=SC1090 source "$pw_file" project="${pw[project]}" build_url="${pw[${project}_build_url]}" # shellcheck disable=SC2064 trap "pw_deinit $project" EXIT pw_init "$project" case "$check-$result" in triggered-*) desc="Test started" url="${build_url}console" state="pending" ;; apply-fail) desc="Patch failed to apply" url="${build_url}artifact/artifacts/jenkins/pw-apply.log" state="fail" ;; apply-merged) desc="Patch is already merged" url="${build_url}artifact/artifacts/jenkins/pw-apply.log" # We can test patches hours after they have been # submitted, and the patches can be merged into master # branch already. Mark such cases as WARNING. state="warning" ;; apply-pass) desc="Patch applied" url="${build_url}console" state="pending" ;; test-fail) desc="Testing failed" url="${build_url}artifact/artifacts/artifacts.precommit/notify/mail-body.txt" state="fail" ;; test-pass) desc="Testing passed" url="${build_url}artifact/artifacts/artifacts.precommit/notify/mail-body.txt" state="success" ;; test-ignore) # Testing failed due to sporadic failure. Allow retrigger # testing of this patch in the next round. desc="Build did not complete; will be retriggered" url="${build_url}artifact/artifacts/artifacts.precommit/" state="pending" ;; esac ${pw[${project}_check_cmd]} --state "$state" \ --description "$desc" --url "$url" ) done < <(find "$pw_dir" -type f -print0)