Skip to content

Commit

Permalink
leverage test-infra go_update_deps (knative#9762)
Browse files Browse the repository at this point in the history
  • Loading branch information
Scott Nichols authored Oct 9, 2020
1 parent b1e6d3b commit 8d38294
Show file tree
Hide file tree
Showing 11 changed files with 76 additions and 239 deletions.
6 changes: 3 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ require (
k8s.io/code-generator v0.18.8
k8s.io/kube-openapi v0.0.0-20200410145947-bcb3869e6f29
knative.dev/caching v0.0.0-20201009023721-0a00448bbad0
knative.dev/networking v0.0.0-20201009061021-adc3058ce053
knative.dev/pkg v0.0.0-20201009153721-3eb7d13daebe
knative.dev/test-infra v0.0.0-20201009170521-9cecbccfd17c
knative.dev/networking v0.0.0-20201009180721-8cc9a61966f9
knative.dev/pkg v0.0.0-20201009175121-3c4df8c27293
knative.dev/test-infra v0.0.0-20201009204121-322fb08edae7
)

replace (
Expand Down
10 changes: 6 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1840,8 +1840,8 @@ knative.dev/caching v0.0.0-20201009023721-0a00448bbad0 h1:AjfJ2hjf67TMWXcli61I3z
knative.dev/caching v0.0.0-20201009023721-0a00448bbad0/go.mod h1:RMIcqGFgbjzTCxreMUmHisnOFrDjRcvQw6yoPvSmoa8=
knative.dev/eventing-contrib v0.6.1-0.20190723221543-5ce18048c08b/go.mod h1:SnXZgSGgMSMLNFTwTnpaOH7hXDzTFtw0J8OmHflNx3g=
knative.dev/eventing-contrib v0.11.2/go.mod h1:SnXZgSGgMSMLNFTwTnpaOH7hXDzTFtw0J8OmHflNx3g=
knative.dev/networking v0.0.0-20201009061021-adc3058ce053 h1:ap6oseSle/JVD8ZohZvX6aE4C8aB/q+rfGeARcyD43A=
knative.dev/networking v0.0.0-20201009061021-adc3058ce053/go.mod h1:P9moCaoXPUG0EjEtCF0QRh67AK9LBxycIugcSXtPlEA=
knative.dev/networking v0.0.0-20201009180721-8cc9a61966f9 h1:y4OWMjuhs9+RfTNShXUAmXtVtjvQOUFBoU32vqRSOdQ=
knative.dev/networking v0.0.0-20201009180721-8cc9a61966f9/go.mod h1:wG6FprXxEdLqKTRRqFqAoN9fFrXPcOCtst5fZN8D/DM=
knative.dev/pkg v0.0.0-20191101194912-56c2594e4f11/go.mod h1:pgODObA1dTyhNoFxPZTTjNWfx6F0aKsKzn+vaT9XO/Q=
knative.dev/pkg v0.0.0-20191111150521-6d806b998379/go.mod h1:pgODObA1dTyhNoFxPZTTjNWfx6F0aKsKzn+vaT9XO/Q=
knative.dev/pkg v0.0.0-20200207155214-fef852970f43/go.mod h1:pgODObA1dTyhNoFxPZTTjNWfx6F0aKsKzn+vaT9XO/Q=
Expand All @@ -1854,6 +1854,8 @@ knative.dev/pkg v0.0.0-20201008052621-c0496d5e1b2b h1:ZofOKxviVc7FMOFTSOmI94kJQj
knative.dev/pkg v0.0.0-20201008052621-c0496d5e1b2b/go.mod h1:h4jEOUhdPbt4nTdoEmyGk3bKcEr1tu5US+ou36dEeJc=
knative.dev/pkg v0.0.0-20201009153721-3eb7d13daebe h1:SgdbizTXqDd9ROM5rdNsa+JALupbmd7fS8Yu1mPxeZo=
knative.dev/pkg v0.0.0-20201009153721-3eb7d13daebe/go.mod h1:AqiTNwkpHWuywH8MtgvqzYrph/qbzACviH5iyEfDAZ8=
knative.dev/pkg v0.0.0-20201009175121-3c4df8c27293 h1:vggs9Q9whE2Ocne+JAGLhg6yz0AazOvTgOeGFWMFy2k=
knative.dev/pkg v0.0.0-20201009175121-3c4df8c27293/go.mod h1:AqiTNwkpHWuywH8MtgvqzYrph/qbzACviH5iyEfDAZ8=
knative.dev/test-infra v0.0.0-20200407185800-1b88cb3b45a5/go.mod h1:xcdUkMJrLlBswIZqL5zCuBFOC22WIPMQoVX1L35i0vQ=
knative.dev/test-infra v0.0.0-20200505052144-5ea2f705bb55/go.mod h1:WqF1Azka+FxPZ20keR2zCNtiQA1MP9ZB4BH4HuI+SIU=
knative.dev/test-infra v0.0.0-20200513011557-d03429a76034/go.mod h1:aMif0KXL4g19YCYwsy4Ocjjz5xgPlseYV+B95Oo4JGE=
Expand All @@ -1862,8 +1864,8 @@ knative.dev/test-infra v0.0.0-20200707183444-aed09e56ddc7/go.mod h1:RjYAhXnZqeHw
knative.dev/test-infra v0.0.0-20201005021934-df2084cec789/go.mod h1:Pmg2c7Z7q7BGFUV/GOpU5BlrD3ePJft4MPqx8AYBplc=
knative.dev/test-infra v0.0.0-20201008221921-aeca2ff2371a h1:Z+IRS8COiXGmnxgoeqUEvQii8QFc0mbSRjUh4c1jQdM=
knative.dev/test-infra v0.0.0-20201008221921-aeca2ff2371a/go.mod h1:W4EfffNKnIkYuBHdOjw0UP3YtFbK4ImwDiEoIAbG1zk=
knative.dev/test-infra v0.0.0-20201009170521-9cecbccfd17c h1:mM2sD7+0WmQIoyGKi1lym9gSOL3Jpuq8jkKuaMgruH8=
knative.dev/test-infra v0.0.0-20201009170521-9cecbccfd17c/go.mod h1:W4EfffNKnIkYuBHdOjw0UP3YtFbK4ImwDiEoIAbG1zk=
knative.dev/test-infra v0.0.0-20201009204121-322fb08edae7 h1:2peeccxecZH3kBH8g9U+We3kjstgX8LLloO//ndrxnQ=
knative.dev/test-infra v0.0.0-20201009204121-322fb08edae7/go.mod h1:W4EfffNKnIkYuBHdOjw0UP3YtFbK4ImwDiEoIAbG1zk=
mvdan.cc/interfacer v0.0.0-20180901003855-c20040233aed/go.mod h1:Xkxe497xwlCKkIaQYRfC7CSLworTXY9RMqwhhCm+8Nc=
mvdan.cc/lint v0.0.0-20170908181259-adc824a0674b/go.mod h1:2odslEg/xrtNQqCYg2/jCoyKnw3vv5biOc3JnIcYfL4=
mvdan.cc/unparam v0.0.0-20190720180237-d51796306d8f/go.mod h1:4G1h5nDURzA3bwVMZIVpwbkw+04kSxk3rAtzlimaUJw=
Expand Down
54 changes: 2 additions & 52 deletions hack/update-deps.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,60 +14,10 @@
# See the License for the specific language governing permissions and
# limitations under the License.

readonly ROOT_DIR=$(dirname $0)/..
source ${ROOT_DIR}/vendor/knative.dev/test-infra/scripts/library.sh

set -o errexit
set -o nounset
set -o pipefail

cd ${ROOT_DIR}

# We need these flags for things to work properly.
export GO111MODULE=on

# This controls the release branch we track.
VERSION="master"

# The list of dependencies that we track at HEAD and periodically
# float forward in this repository.
FLOATING_DEPS=(
"knative.dev/test-infra@${VERSION}"
"knative.dev/pkg@${VERSION}"
"knative.dev/networking@${VERSION}"
"knative.dev/caching@${VERSION}"
)

# Parse flags to determine any we should pass to dep.
GO_GET=0
while [[ $# -ne 0 ]]; do
parameter=$1
case ${parameter} in
--upgrade) GO_GET=1 ;;
*) abort "unknown option ${parameter}" ;;
esac
shift
done
readonly GO_GET

if (( GO_GET )); then
go get -d ${FLOATING_DEPS[@]}
fi


# Prune modules.
go mod tidy
go mod vendor

echo "Removing unwanted vendor files"

# Remove unwanted vendor files
find vendor/ \( -name "OWNERS" -o -name "*_test.go" \) -print0 | xargs -0 rm -f

export GOFLAGS=-mod=vendor

echo "Updating licenses"
update_licenses third_party/VENDOR-LICENSE "./..."
source $(dirname "$0")/../vendor/knative.dev/test-infra/scripts/library.sh

echo "Removing broken symlinks"
remove_broken_symlinks ./vendor
go_update_deps "$@"
24 changes: 0 additions & 24 deletions vendor/github.com/google/mako/go/quickstore/BUILD

This file was deleted.

14 changes: 0 additions & 14 deletions vendor/github.com/google/mako/internal/go/common/BUILD

This file was deleted.

23 changes: 0 additions & 23 deletions vendor/github.com/grpc-ecosystem/grpc-gateway/internal/BUILD.bazel

This file was deleted.

85 changes: 0 additions & 85 deletions vendor/github.com/grpc-ecosystem/grpc-gateway/runtime/BUILD.bazel

This file was deleted.

This file was deleted.

13 changes: 3 additions & 10 deletions vendor/knative.dev/pkg/hash/bucketer.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ func (b *Bucket) Has(nn types.NamespacedName) bool {
// ordered by bucket name.
func (bs *BucketSet) Buckets() []reconciler.Bucket {
bkts := make([]reconciler.Bucket, len(bs.buckets))
for i, n := range bs.sortedBucketNames() {
for i, n := range bs.BucketList() {
bkts[i] = &Bucket{
name: n,
buckets: bs,
Expand All @@ -90,13 +90,6 @@ func (bs *BucketSet) Buckets() []reconciler.Bucket {
return bkts
}

func (bs *BucketSet) sortedBucketNames() []string {
bs.mu.RLock()
defer bs.mu.RUnlock()

return bs.buckets.List()
}

// Owner returns the owner of the key.
// Owner will cache the results for faster lookup.
func (bs *BucketSet) Owner(key string) string {
Expand All @@ -116,12 +109,12 @@ func (bs *BucketSet) HasBucket(bkt string) bool {
return bs.buckets.Has(bkt)
}

// BucketList returns the bucket names of this BucketSet in random order.
// BucketList returns the bucket names of this BucketSet in sorted order.
func (bs *BucketSet) BucketList() []string {
bs.mu.RLock()
defer bs.mu.RUnlock()

return bs.buckets.UnsortedList()
return bs.buckets.List()
}

// Update updates the universe of buckets.
Expand Down
59 changes: 59 additions & 0 deletions vendor/knative.dev/test-infra/scripts/library.sh
Original file line number Diff line number Diff line change
Expand Up @@ -513,6 +513,65 @@ function add_trap {
done
}

# Update go deps.
# Parameters (parsed as flags):
# "--upgrade", bool, do upgrade.
# "--release <version>" used with upgrade. The release version to upgrade
# Knative components. ex: --release v0.18. Defaults to
# "master".
# Additional dependencies can be included in the upgrade by providing them in a
# global env var: FLOATING_DEPS
function go_update_deps() {
cd "${REPO_ROOT_DIR}" || return 1

export GO111MODULE=on
export GOFLAGS=""

echo "=== Update Deps for Golang"

local UPGRADE=0
local VERSION="master"
while [[ $# -ne 0 ]]; do
parameter=$1
case ${parameter} in
--upgrade) UPGRADE=1 ;;
--release) shift; VERSION="$1" ;;
*) abort "unknown option ${parameter}" ;;
esac
shift
done

if (( UPGRADE )); then
echo "--- Upgrading to ${VERSION}"
FLOATING_DEPS+=( $(run_go_tool knative.dev/test-infra/buoy buoy float ${REPO_ROOT_DIR}/go.mod --release ${VERSION} --domain knative.dev) )
if (( ${#FLOATING_DEPS[@]} )); then
echo "Floating deps to ${FLOATING_DEPS[@]}"
go get -d ${FLOATING_DEPS[@]}
else
echo "Nothing to upgrade."
fi
fi

echo "--- Go mod tidy and vendor"

# Prune modules.
go mod tidy
go mod vendor

echo "--- Removing unwanted vendor files"

# Remove unwanted vendor files
find vendor/ \( -name "OWNERS" -o -name "OWNERS_ALIASES" -o -name "BUILD" -o -name "BUILD.bazel" -o -name "*_test.go" \) -print0 | xargs -0 rm -f

export GOFLAGS=-mod=vendor

echo "--- Updating licenses"
update_licenses third_party/VENDOR-LICENSE "./..."

echo "--- Removing broken symlinks"
remove_broken_symlinks ./vendor
}

# Run kntest tool, error out and ask users to install it if it's not currently installed.
# Parameters: $1..$n - parameters passed to the tool.
function run_kntest() {
Expand Down
Loading

0 comments on commit 8d38294

Please sign in to comment.