diff --git a/hack/jenkins/job-configs/kubernetes-jenkins/kubernetes-test-go.yaml b/hack/jenkins/job-configs/kubernetes-jenkins/kubernetes-test-go.yaml index a704dc577cc..434b1e38dcd 100644 --- a/hack/jenkins/job-configs/kubernetes-jenkins/kubernetes-test-go.yaml +++ b/hack/jenkins/job-configs/kubernetes-jenkins/kubernetes-test-go.yaml @@ -9,6 +9,7 @@ builders: - shell: 'bash <(curl -fsS --retry 3 "https://raw.githubusercontent.com/kubernetes/kubernetes/master/hack/jenkins/upload-started.sh")' - shell: | + export KUBE_FORCE_VERIFY_CHECKS='y' export KUBE_VERIFY_GIT_BRANCH='{branch}' timeout -k {kill-timeout}m {timeout}m ./hack/jenkins/gotest-dockerized.sh && rc=$? || rc=$? {report-rc} diff --git a/hack/lib/util.sh b/hack/lib/util.sh index b42f4fae199..86051b6afa1 100755 --- a/hack/lib/util.sh +++ b/hack/lib/util.sh @@ -312,4 +312,33 @@ kube::util::gv-to-swagger-name() { esac } +# Returns the name of the upstream remote repository name for the local git +# repo, e.g. "upstream" or "origin". +kube::util::git_upstream_remote_name() { + git remote -v | grep fetch |\ + grep -E 'github.com/kubernetes/kubernetes|k8s.io/kubernetes' |\ + head -n 1 | awk '{print $1}' +} + +# Checks whether there are any files matching pattern $2 changed between the +# current branch and upstream branch named by $1. +# Returns 1 (false) if there are no changes, 0 (true) if there are changes +# detected. +kube::util::has_changes_against_upstream_branch() { + local -r git_branch=$1 + local -r pattern=$2 + + readonly full_branch="$(kube::util::git_upstream_remote_name)/${git_branch}" + echo "Checking for '${pattern}' changes against '${full_branch}'" + # make sure the branch is valid, otherwise the check will pass erroneously. + if ! git describe "${full_branch}" >/dev/null; then + exit 1 + fi + # notice this uses ... to find the first shared ancestor + if ! git diff --name-only "${full_branch}...HEAD" | grep "${pattern}" > /dev/null; then + echo "No '${pattern}' changes detected." + return 1 + fi +} + # ex: ts=2 sw=2 et filetype=sh diff --git a/hack/verify-godep-licenses.sh b/hack/verify-godep-licenses.sh index 4f73dc2bab0..6d98210984a 100755 --- a/hack/verify-godep-licenses.sh +++ b/hack/verify-godep-licenses.sh @@ -19,16 +19,11 @@ set -o nounset set -o pipefail KUBE_ROOT="$(cd "$(dirname "${BASH_SOURCE}")/.." && pwd -P)" +source "${KUBE_ROOT}/hack/lib/init.sh" -readonly branch="origin/${1:-${KUBE_VERIFY_GIT_BRANCH:-master}}" -echo "Checking for Godeps changes against ${branch}" -# make sure the branch is valid, otherwise the next check will pass erroneously. -if ! git describe "${branch}" >/dev/null; then - exit 1 -fi -# notice this uses ... to find the first shared ancestor -if ! git diff --name-only "${branch}...HEAD" | grep 'Godeps/' > /dev/null; then - echo "No Godeps changes detected." +readonly branch=${1:-${KUBE_VERIFY_GIT_BRANCH:-master}} +if ! [[ ${KUBE_FORCE_VERIFY_CHECKS:-} =~ ^[yY]$ ]] && \ + ! kube::util::has_changes_against_upstream_branch "${branch}" 'Godeps/'; then exit 0 fi diff --git a/hack/verify-godeps.sh b/hack/verify-godeps.sh index 2f91fd9d618..a9890a6858d 100755 --- a/hack/verify-godeps.sh +++ b/hack/verify-godeps.sh @@ -39,15 +39,9 @@ preload-dep() { KUBE_ROOT=$(dirname "${BASH_SOURCE}")/.. source "${KUBE_ROOT}/hack/lib/init.sh" -readonly branch="origin/${1:-${KUBE_VERIFY_GIT_BRANCH:-master}}" -echo "Checking for Godeps changes against ${branch}" -# make sure the branch is valid, otherwise the next check will pass erroneously. -if ! git describe "${branch}" >/dev/null; then - exit 1 -fi -# notice this uses ... to find the first shared ancestor -if ! git diff --name-only "${branch}...HEAD" | grep 'Godeps/' > /dev/null; then - echo "No Godeps changes detected." +readonly branch=${1:-${KUBE_VERIFY_GIT_BRANCH:-master}} +if ! [[ ${KUBE_FORCE_VERIFY_CHECKS:-} =~ ^[yY]$ ]] && \ + ! kube::util::has_changes_against_upstream_branch "${branch}" 'Godeps/'; then exit 0 fi