-
Notifications
You must be signed in to change notification settings - Fork 4.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add go modules verification and update scripts #3995
Closed
Closed
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
420af54
update scripts in package.json
eloyekunle 3a9f901
remove unnecessary before_install scripts
eloyekunle a39b45d
add vendor verification
eloyekunle 57af412
add vendor update
eloyekunle 34307cf
add echo statements
eloyekunle 48c1188
re-add a travis before_install
eloyekunle f6f0763
add vendor/ directory to gitignore
eloyekunle 064082b
remove vendor dir verification
eloyekunle File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
#!/usr/bin/env bash | ||
|
||
# Copyright 2019 The Kubernetes Authors. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
TMP_DIR="${TMP_DIR:-$(mktemp -d /tmp/update-vendor.XXXX)}" | ||
|
||
echo "vendor: running 'go mod tidy'" | ||
go mod tidy -v | ||
|
||
echo "vendor: running 'go mod vendor'" | ||
go mod vendor | ||
|
||
# sort recorded packages for a given vendored dependency in modules.txt. | ||
# `go mod vendor` outputs in imported order, which means slight go changes (or different platforms) can result in a differently ordered modules.txt. | ||
# scan | prefix comment lines with the module name | sort field 1 | strip leading text on comment lines | ||
awk '{if($1=="#") print $2 " " $0; else print}' < vendor/modules.txt | sort -k1,1 -s | sed 's/.*#/#/' > "${TMP_DIR}/modules.txt.tmp" | ||
mv "${TMP_DIR}/modules.txt.tmp" vendor/modules.txt | ||
|
||
echo "Vendor Updated" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
#!/usr/bin/env bash | ||
|
||
# Copyright 2015 The Kubernetes Authors. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
set -o errexit | ||
set -o nounset | ||
set -o pipefail | ||
|
||
KUBE_ROOT=$(dirname "${BASH_SOURCE[0]}")/../.. | ||
|
||
mkdir -p "${KUBE_ROOT}/_tmp" | ||
_tmpdir="$(mktemp -d "${KUBE_ROOT}/_tmp/kube-vendor.XXXXXX")" | ||
|
||
if [[ -z ${KEEP_TMP:-} ]]; then | ||
KEEP_TMP=false | ||
fi | ||
|
||
# Copy the contents of the kube directory into the nice clean place (which is NOT shaped like a GOPATH) | ||
_kubetmp="${_tmpdir}" | ||
mkdir -p "${_kubetmp}" | ||
# should create ${_kubectmp}/kubernetes | ||
git archive --format=tar --prefix=kubernetes/ "$(git write-tree)" | (cd "${_kubetmp}" && tar xf -) | ||
_kubetmp="${_kubetmp}/kubernetes" | ||
|
||
pushd "${_kubetmp}" > /dev/null 2>&1 | ||
# Destroy deps in the copy of the kube tree | ||
rm -rf ./vendor | ||
|
||
# Recreate the vendor tree using the nice clean set we just downloaded | ||
aio/scripts/update-vendor.sh | ||
popd > /dev/null 2>&1 | ||
|
||
ret=0 | ||
|
||
pushd "${KUBE_ROOT}" > /dev/null 2>&1 | ||
# Test for diffs | ||
if ! _out="$(diff -Naupr --ignore-matching-lines='^\s*\"GoVersion\":' go.mod "${_kubetmp}/go.mod")"; then | ||
echo "Your go.mod file is different:" >&2 | ||
echo "${_out}" >&2 | ||
echo "Vendor Verify failed." >&2 | ||
echo "If you're seeing this locally, run the below command to fix your go.mod:" >&2 | ||
echo "npm run fix:backend:vendor" >&2 | ||
ret=1 | ||
fi | ||
popd > /dev/null 2>&1 | ||
|
||
chmod -R +w "${_tmpdir}" | ||
if [ "${KEEP_TMP}" == "true" ]; then | ||
echo "Leaving ${_tmpdir} for you to examine or copy. Please delete it manually when finished. (rm -rf ${_tmpdir})" | ||
else | ||
echo "Removing ${_tmpdir}" | ||
rm -rf "${_tmpdir}" | ||
fi | ||
|
||
if [[ ${ret} -gt 0 ]]; then | ||
exit ${ret} | ||
fi | ||
|
||
echo "Vendor Verified." | ||
# ex: ts=2 sw=2 et filetype=sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not needed as it would create a local vendor dir.