Skip to content

Commit

Permalink
Update hack scripts to use go mod
Browse files Browse the repository at this point in the history
  • Loading branch information
liggitt committed Apr 3, 2019
1 parent 7f246d4 commit 2ea3cbd
Show file tree
Hide file tree
Showing 24 changed files with 596 additions and 629 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -130,5 +130,5 @@ zz_generated_*_test.go
/bazel-*
*.pyc

# generated by verify-godeps.sh
# generated by verify-vendor.sh
vendordiff.patch
2 changes: 1 addition & 1 deletion build/root/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ define VERIFY_HELP_INFO
# Runs all the presubmission verifications.
#
# Args:
# BRANCH: Branch to be passed to verify-godeps.sh script.
# BRANCH: Branch to be passed to verify-vendor.sh script.
# WHAT: List of checks to run
#
# Example:
Expand Down
5 changes: 2 additions & 3 deletions hack/.shellcheck_failures
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,11 @@
./hack/update-generated-kms-dockerized.sh
./hack/update-generated-protobuf-dockerized.sh
./hack/update-generated-runtime-dockerized.sh
./hack/update-godep-licenses.sh
./hack/update-gofmt.sh
./hack/update-openapi-spec.sh
./hack/update-staging-godeps-dockerized.sh
./hack/update-staging-godeps.sh
./hack/update-translations.sh
./hack/update-vendor-licenses.sh
./hack/update-vendor.sh
./hack/update-workspace-mirror.sh
./hack/verify-api-groups.sh
./hack/verify-boilerplate.sh
Expand Down
35 changes: 0 additions & 35 deletions hack/godep-restore.sh

This file was deleted.

128 changes: 0 additions & 128 deletions hack/godep-save.sh

This file was deleted.

2 changes: 1 addition & 1 deletion hack/jenkins/verify.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.

# Sets up the environment (e.g. installing godep and etcd if necessary)
# Sets up the environment (e.g. installing etcd if necessary)
# and then runs all of the verification checks.

set -o errexit
Expand Down
2 changes: 1 addition & 1 deletion hack/lib/golang.sh
Original file line number Diff line number Diff line change
Expand Up @@ -437,7 +437,7 @@ kube::golang::setup_env() {
# Unset GOBIN in case it already exists in the current session.
unset GOBIN

# This seems to matter to some tools (godep, ginkgo...)
# This seems to matter to some tools
export GO15VENDOREXPERIMENT=1
}

Expand Down
6 changes: 6 additions & 0 deletions hack/lib/init.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,12 @@ set -o pipefail
# https://github.com/kubernetes/kubernetes/issues/52255
unset CDPATH

# Until all GOPATH references are removed from all build scripts as well,
# explicitly reset to auto mode to avoid picking up user-set GO111MODULE preferences.
# As individual scripts (like hack/update-vendor.sh) make use of go modules,
# they can explicitly set GO111MODULE=on
export GO111MODULE=auto

# The root of the build/dist directory
KUBE_ROOT="$(cd "$(dirname "${BASH_SOURCE}")/../.." && pwd -P)"

Expand Down
87 changes: 0 additions & 87 deletions hack/lib/util.sh
Original file line number Diff line number Diff line change
Expand Up @@ -330,64 +330,6 @@ kube::util::git_upstream_remote_name() {
head -n 1 | awk '{print $1}'
}

# Ensures the current directory is a git tree for doing things like restoring or
# validating godeps
kube::util::create-fake-git-tree() {
local -r target_dir=${1:-$(pwd)}

pushd "${target_dir}" >/dev/null || return 1
git init >/dev/null
git config --local user.email "nobody@k8s.io"
git config --local user.name "$0"
git add . >/dev/null
git commit -q -m "Snapshot" >/dev/null
if (( ${KUBE_VERBOSE:-5} >= 6 )); then
kube::log::status "${target_dir} is now a git tree."
fi
popd >/dev/null || return 1
}

# Checks whether godep restore was run in the current GOPATH, i.e. that all referenced repos exist
# and are checked out to the referenced rev.
kube::util::godep_restored() {
local -r godeps_json=${1:-Godeps/Godeps.json}
local -r gopath=${2:-${GOPATH%:*}}

kube::util::require-jq

local root
local old_rev=""
while read -r path rev; do
rev="${rev//[\'\"]}" # remove quotes which are around revs sometimes

if [[ "${rev}" == "${old_rev}" ]] && [[ "${path}" == "${root}"* ]]; then
# avoid checking the same git/hg root again
continue
fi

root="${path}"
while [ "${root}" != "." ] && [ ! -d "${gopath}/src/${root}/.git" ] && [ ! -d "${gopath}/src/${root}/.hg" ]; do
root=$(dirname "${root}")
done
if [ "${root}" == "." ]; then
echo "No checkout of ${path} found in GOPATH \"${gopath}\"." 1>&2
return 1
fi
local head
if [ -d "${gopath}/src/${root}/.git" ]; then
head="$(cd "${gopath}/src/${root}" && git rev-parse HEAD)"
else
head="$(cd "${gopath}/src/${root}" && hg parent --template '{node}')"
fi
if [ "${head}" != "${rev}" ]; then
echo "Unexpected HEAD '${head}' at ${gopath}/src/${root}, expected '${rev}'." 1>&2
return 1
fi
old_rev="${rev}"
done < <(jq '.Deps|.[]|.ImportPath + " " + .Rev' -r < "${godeps_json}")
return 0
}

# Exits script if working directory is dirty. If it's run interactively in the terminal
# the user can commit changes in a second terminal. This script will wait.
kube::util::ensure_clean_working_dir() {
Expand All @@ -404,35 +346,6 @@ kube::util::ensure_clean_working_dir() {
done 1>&2
}

# Ensure that none of the staging repos is checked out in the GOPATH because this
# easily confused godep.
kube::util::ensure_no_staging_repos_in_gopath() {
kube::util::ensure_single_dir_gopath
local error=0
for repo_file in "${KUBE_ROOT}"/staging/src/k8s.io/*; do
if [[ ! -d "${repo_file}" ]]; then
# not a directory or there were no files
continue;
fi
repo="$(basename "${repo_file}")"
if [ -e "${GOPATH}/src/k8s.io/${repo}" ]; then
echo "k8s.io/${repo} exists in GOPATH. Remove before running godep-save.sh." 1>&2
error=1
fi
done
if [ "${error}" = "1" ]; then
exit 1
fi
}

# Checks that the GOPATH is simple, i.e. consists only of one directory, not multiple.
kube::util::ensure_single_dir_gopath() {
if [[ "${GOPATH}" == *:* ]]; then
echo "GOPATH must consist of a single directory." 1>&2
exit 1
fi
}

# Find the base commit using:
# $PULL_BASE_SHA if set (from Prow)
# current ref from the remote upstream branch
Expand Down
3 changes: 0 additions & 3 deletions hack/make-rules/update.sh
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,6 @@ if ! ${ALL} ; then
echo "Running in short-circuit mode; run with FORCE_ALL=true to force all scripts to run."
fi

"${KUBE_ROOT}/hack/godep-restore.sh" ${V}

BASH_TARGETS="
update-generated-protobuf
update-codegen
Expand All @@ -57,7 +55,6 @@ BASH_TARGETS="
update-generated-docs
update-generated-swagger-docs
update-openapi-spec
update-staging-godeps
update-bazel"

for t in ${BASH_TARGETS}; do
Expand Down
11 changes: 6 additions & 5 deletions hack/make-rules/verify.sh
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,13 @@ if [[ ${EXCLUDE_TYPECHECK:-} =~ ^[yY]$ ]]; then
fi


# Exclude godep checks in certain cases, if they're running in a separate job.
# Exclude vendor checks in certain cases, if they're running in a separate job.
if [[ ${EXCLUDE_GODEP:-} =~ ^[yY]$ ]]; then
EXCLUDED_PATTERNS+=(
"verify-godeps.sh" # runs in separate godeps job
"verify-staging-godeps.sh" # runs in separate godeps job
"verify-godep-licenses.sh" # runs in separate godeps job
"verify-godeps-licenses.sh" # runs in separate godeps job
"verify-vendor.sh" # runs in separate godeps job
"verify-vendor-licenses.sh" # runs in separate godeps job
)
fi

Expand All @@ -63,12 +64,12 @@ fi

# Only run whitelisted fast checks in quick mode.
# These run in <10s each on enisoc's workstation, assuming that
# `make` and `hack/godep-restore.sh` had already been run.
# `make` had already been run.
QUICK_PATTERNS+=(
"verify-api-groups.sh"
"verify-bazel.sh"
"verify-boilerplate.sh"
"verify-godep-licenses.sh"
"verify-vendor-licenses.sh"
"verify-gofmt.sh"
"verify-imports.sh"
"verify-pkg-names.sh"
Expand Down
Loading

0 comments on commit 2ea3cbd

Please sign in to comment.