Skip to content

Commit d2dd0d4

Browse files
upgrade to latest dependencies (#329)
bumping knative.dev/hack 8d1e4cc...664eac5: > 664eac5 Fixing go.mod foreach (# 217) > 97fd663 🎁 Support multiple Golang modules in a single project (# 205) > f472a96 fix go run invocation of github hub cli (# 212) > 7d3bed1 go run... (# 210) > e81d63a Update community files (# 209) bumping knative.dev/client 6d86bf7...794cdef: > 794cdef upgrade to latest dependencies (# 1728) Signed-off-by: Knative Automation <[email protected]> Signed-off-by: Knative Automation <[email protected]>
1 parent 60bf492 commit d2dd0d4

File tree

6 files changed

+84
-30
lines changed

6 files changed

+84
-30
lines changed

go.mod

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ go 1.17
55
require (
66
github.com/spf13/cobra v1.3.0
77
gotest.tools/v3 v3.1.0
8-
knative.dev/client v0.34.0
9-
knative.dev/hack v0.0.0-20220823140917-8d1e4ccf9dc3
8+
knative.dev/client v0.34.1-0.20220825103419-794cdef8e4e0
9+
knative.dev/hack v0.0.0-20220902220419-664eac5c391e
1010

1111
)
1212

go.sum

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2167,19 +2167,20 @@ k8s.io/utils v0.0.0-20211116205334-6203023598ed/go.mod h1:jPW/WVKK9YHAvNhRxK0md/
21672167
k8s.io/utils v0.0.0-20220210201930-3a6ce19ff2f9 h1:HNSDgDCrr/6Ly3WEGKZftiE7IY19Vz2GdbOCyI4qqhc=
21682168
k8s.io/utils v0.0.0-20220210201930-3a6ce19ff2f9/go.mod h1:jPW/WVKK9YHAvNhRxK0md/EJ228hCsBRufyofKtW8HA=
21692169
knative.dev/caching v0.0.0-20220818010648-9df7bb739739/go.mod h1:q5//FJ59aFRK42YiLSaxgBzH18DBhrtSc7UWapwXT9Q=
2170-
knative.dev/client v0.34.0 h1:CY62Bd/sodq8aeL6dYGYnDCvpe39qiPGXJHtR4Rktbk=
2171-
knative.dev/client v0.34.0/go.mod h1:mquhJiwkZytOKzLjRu3K+5HWRM6YAplWfvGUbCFZI4M=
2170+
knative.dev/client v0.34.1-0.20220825103419-794cdef8e4e0 h1:nJ10CWWkLanUT6YsgbzNgQdcfBSeGn1ykbGeH/a5pmw=
2171+
knative.dev/client v0.34.1-0.20220825103419-794cdef8e4e0/go.mod h1:bb65E1Cy1rrEamPpGHK2dp18j+ZZ2B2vTqsCSZOAzas=
21722172
knative.dev/control-protocol v0.0.0-20220818153549-f18dbde7d9bd/go.mod h1:vO3Xc0k0h6fFVsVG9kNMUMcVKG7MAx7jMbZDvgSuzwI=
21732173
knative.dev/eventing v0.34.1/go.mod h1:6UnNnPrEUNAM9PfCpf7L8N7G/1vq+HQlpOjzndY6ryw=
21742174
knative.dev/hack v0.0.0-20220815132133-e9a8475f4329/go.mod h1:t/azP8I/Cygaw+87O7rkAPrNRjCelmtfSzWzu/9TM7I=
2175-
knative.dev/hack v0.0.0-20220823140917-8d1e4ccf9dc3 h1:umaeMRecA0g5g48L9tnEAkTBIitr9eKWMyJYo9YttAA=
21762175
knative.dev/hack v0.0.0-20220823140917-8d1e4ccf9dc3/go.mod h1:t/azP8I/Cygaw+87O7rkAPrNRjCelmtfSzWzu/9TM7I=
2176+
knative.dev/hack v0.0.0-20220902220419-664eac5c391e h1:9l6GKXiwXuiU8z7/AQIF6oBFISu8geBVQltjKshh+fk=
2177+
knative.dev/hack v0.0.0-20220902220419-664eac5c391e/go.mod h1:yk2OjGDsbEnQjfxdm0/HJKS2WqTLEFg/N6nUs6Rqx3Q=
21772178
knative.dev/hack/schema v0.0.0-20220823140917-8d1e4ccf9dc3/go.mod h1:ffjwmdcrH5vN3mPhO8RrF2KfNnbHeCE2C60A+2cv3U0=
21782179
knative.dev/networking v0.0.0-20220818010248-e51df7cdf571/go.mod h1:m3ataWRwmbHjOY9sCFvcDWRNLVITxVl0fH0RxdCa4jE=
21792180
knative.dev/pkg v0.0.0-20220818004048-4a03844c0b15 h1:GNmzHVaUo3zoi/wtIN71LPQaWy6DdoYzmb+GIq2s4fw=
21802181
knative.dev/pkg v0.0.0-20220818004048-4a03844c0b15/go.mod h1:YLjXbkQLlGHok+u0FLfMbBHFzY9WGu3GHhnrptoAy8I=
21812182
knative.dev/reconciler-test v0.0.0-20220818122349-177f8264c28c/go.mod h1:A437yxlDVDVKQv779WlB9Nj9lWAMoOKHQXFXls24Sps=
2182-
knative.dev/serving v0.34.0/go.mod h1:IyfedOBq3KzcD5dZONjbix2BfS0jOwDq5td8UE9CjCk=
2183+
knative.dev/serving v0.34.1/go.mod h1:IyfedOBq3KzcD5dZONjbix2BfS0jOwDq5td8UE9CjCk=
21832184
mvdan.cc/gofumpt v0.1.1/go.mod h1:yXG1r1WqZVKWbVRtBWKWX9+CxGYfA51nSomhM0woR48=
21842185
mvdan.cc/interfacer v0.0.0-20180901003855-c20040233aed/go.mod h1:Xkxe497xwlCKkIaQYRfC7CSLworTXY9RMqwhhCm+8Nc=
21852186
mvdan.cc/lint v0.0.0-20170908181259-adc824a0674b/go.mod h1:2odslEg/xrtNQqCYg2/jCoyKnw3vv5biOc3JnIcYfL4=

vendor/knative.dev/hack/go.work

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
go 1.18
2+
3+
use (
4+
.
5+
schema
6+
test/e2e
7+
)

vendor/knative.dev/hack/library.sh

Lines changed: 40 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ function patch_version() {
9797
# Print error message and exit 1
9898
# Parameters: $1..$n - error message to be displayed
9999
function abort() {
100-
echo "error: $*"
100+
echo "error: $*" >&2
101101
exit 1
102102
}
103103

@@ -126,7 +126,7 @@ function subheader() {
126126

127127
# Simple warning banner for logging purposes.
128128
function warning() {
129-
make_banner "!" "$1"
129+
make_banner '!' "$*" >&2
130130
}
131131

132132
# Checks whether the given function exists.
@@ -567,7 +567,6 @@ function go_run() {
567567
export GORUN_PATH
568568
GOPATH="${GORUN_PATH}" \
569569
GOFLAGS='' \
570-
GO111MODULE='' \
571570
go run "$package" "$@"
572571
}
573572

@@ -577,6 +576,7 @@ function go_run() {
577576
# $3..$n - parameters passed to the tool.
578577
# Deprecated: use go_run instead
579578
function run_go_tool() {
579+
warning 'The "run_go_tool" function is deprecated. Use "go_run" instead.'
580580
local package=$1
581581
# If no `@version` is provided, default to adding `@latest`
582582
if [[ "$package" != *@* ]]; then
@@ -601,6 +601,26 @@ function add_trap {
601601
done
602602
}
603603

604+
# Run a command, described by $1, for every go module in the project.
605+
# Parameters: $1 - Description of the command being run,
606+
# $2 - $n - Arguments to pass to the command.
607+
function foreach_go_module() {
608+
local failed=0
609+
local -r cmd="$1"
610+
shift
611+
local gomod_filepath gomod_dir
612+
while read -r gomod_filepath; do
613+
gomod_dir="$(dirname "$gomod_filepath")"
614+
pushd "$gomod_dir" > /dev/null
615+
"$cmd" "$@" || failed=$?
616+
popd > /dev/null
617+
if (( failed )); then
618+
echo "Command '${cmd}' failed in module $gomod_dir: $failed" >&2
619+
return $failed
620+
fi
621+
done < <(find . -name go.mod -type f ! -path "*/vendor/*" ! -path "*/third_party/*")
622+
}
623+
604624
# Update go deps.
605625
# Parameters (parsed as flags):
606626
# "--upgrade", bool, do upgrade.
@@ -613,14 +633,18 @@ function add_trap {
613633
# global env var: FLOATING_DEPS
614634
# --upgrade will set GOPROXY to direct unless it is already set.
615635
function go_update_deps() {
616-
cd "${REPO_ROOT_DIR}" || return 1
636+
foreach_go_module __go_update_deps_for_module "$@"
637+
}
638+
639+
function __go_update_deps_for_module() {
640+
( # do not modify the environment
641+
set -Eeuo pipefail
617642

618-
export GO111MODULE=on
619643
export GOFLAGS=""
620644
export GONOSUMDB="${GONOSUMDB:-},knative.dev/*"
621645
export GONOPROXY="${GONOPROXY:-},knative.dev/*"
622646

623-
echo "=== Update Deps for Golang"
647+
echo "=== Update Deps for Golang module: $(go_mod_module_name)"
624648

625649
local UPGRADE=0
626650
local RELEASE="v9000.1" # release v9000 is so far in the future, it will always pick the default branch.
@@ -646,7 +670,7 @@ function go_update_deps() {
646670
else
647671
group "Upgrading to release ${RELEASE}"
648672
fi
649-
FLOATING_DEPS+=( $(go_run knative.dev/test-infra/buoy@latest float ${REPO_ROOT_DIR}/go.mod "${buoyArgs[@]}") )
673+
FLOATING_DEPS+=( $(go_run knative.dev/test-infra/buoy@latest float ./go.mod "${buoyArgs[@]}") )
650674
if [[ ${#FLOATING_DEPS[@]} > 0 ]]; then
651675
echo "Floating deps to ${FLOATING_DEPS[@]}"
652676
go get -d ${FLOATING_DEPS[@]}
@@ -664,6 +688,9 @@ function go_update_deps() {
664688
go mod vendor 2>&1 | grep -v "ignoring symlink" || true
665689
eval "$orig_pipefail_opt"
666690

691+
if ! [ -d vendor ]; then
692+
return 0
693+
fi
667694
group "Removing unwanted vendor files"
668695

669696
# Remove unwanted vendor files
@@ -680,13 +707,15 @@ function go_update_deps() {
680707

681708
group "Removing broken symlinks"
682709
remove_broken_symlinks ./vendor
710+
)
683711
}
684712

713+
685714
# Return the go module name of the current module.
686715
# Intended to be used like:
687716
# export MODULE_NAME=$(go_mod_module_name)
688717
function go_mod_module_name() {
689-
go mod graph | cut -d' ' -f 1 | grep -v '@' | head -1
718+
grep -E '^module ' go.mod | cut -d' ' -f2
690719
}
691720

692721
# Return a GOPATH to a temp directory. Works around the out-of-GOPATH issues
@@ -717,19 +746,18 @@ function run_kntest() {
717746
# Parameters: $1 - output file, relative to repo root dir.
718747
# $2 - directory to inspect.
719748
function update_licenses() {
720-
cd "${REPO_ROOT_DIR}" || return 1
721749
local dst=$1
722750
local dir=$2
723751
shift
724-
go_run github.com/google/[email protected].0 \
752+
go_run github.com/google/[email protected].1 \
725753
save "${dir}" --save_path="${dst}" --force || \
726754
{ echo "--- FAIL: go-licenses failed to update licenses"; return 1; }
727755
}
728756

729757
# Run go-licenses to check for forbidden licenses.
730758
function check_licenses() {
731759
# Check that we don't have any forbidden licenses.
732-
go_run github.com/google/[email protected].0 \
760+
go_run github.com/google/[email protected].1 \
733761
check "${REPO_ROOT_DIR}/..." || \
734762
{ echo "--- FAIL: go-licenses failed the license check"; return 1; }
735763
}
@@ -762,7 +790,7 @@ function is_protected_project() {
762790
# Remove symlinks in a path that are broken or lead outside the repo.
763791
# Parameters: $1 - path name, e.g. vendor
764792
function remove_broken_symlinks() {
765-
for link in $(find $1 -type l); do
793+
for link in $(find "$1" -type l); do
766794
# Remove broken symlinks
767795
if [[ ! -e ${link} ]]; then
768796
unlink ${link}

vendor/knative.dev/hack/presubmit-tests.sh

Lines changed: 27 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,12 @@ function report_build_test() {
122122
# * `go build` on the entire repo
123123
# * check licenses in all go packages
124124
function default_build_test_runner() {
125+
foreach_go_module __build_test_runner_for_module
126+
}
127+
128+
function __build_test_runner_for_module() {
125129
local failed=0
130+
subheader "Build tests for $(go_mod_module_name)"
126131
# Run verify-codegen check
127132
if [[ -f ./hack/verify-codegen.sh ]]; then
128133
subheader "Checking autogenerated code is up-to-date"
@@ -132,18 +137,26 @@ function default_build_test_runner() {
132137
# verify-codegen (as md files can be auto-generated in some repos).
133138
(( IS_DOCUMENTATION_PR )) && return ${failed}
134139
# Don't merge these two lines, or return code will always be 0.
140+
# Get all build tags in go code (ignore /vendor, /hack and /third_party)
141+
local tags
142+
tags="$(grep -I -r '// +build' . | \
143+
grep -v '/vendor/' | \
144+
grep -v '/hack/' | \
145+
grep -v '/third_party' | \
146+
cut -f3 -d' ' | \
147+
tr ',' '\n' | \
148+
sort | uniq | \
149+
grep -v '^!' | \
150+
tr '\n' ' ')"
135151
local go_pkg_dirs
136-
go_pkg_dirs="$(go list ./...)" || return 1
137-
# Skip build test if there is no go code
138-
[[ -z "${go_pkg_dirs}" ]] && return ${failed}
152+
go_pkg_dirs="$(go list -tags "${tags}" ./...)" || return $?
153+
if [[ -z "${go_pkg_dirs}" ]]; then
154+
subheader "No golang code found, skipping build tests"
155+
return 0
156+
fi
139157
# Ensure all the code builds
140158
subheader "Checking that go code builds"
141-
# Get all build tags in go code (ignore /vendor, /hack and /third_party)
142-
local tags
143-
tags="$(find . \
144-
-path './vendor' -prune -o -path './hack' -prune -o -path './third_party' -prune \
145-
-o -type f -name '*.go' -exec grep '// +build' {} + \
146-
| cut -f3 -d' ' | tr ',' '\n' | uniq | sort | tr '\n' ' ')"
159+
147160
report_build_test Build_Go \
148161
go test -vet=off -tags "${tags}" -exec echo ./... || failed=2
149162

@@ -185,6 +198,11 @@ function run_unit_tests() {
185198

186199
# Default unit test runner that runs all go tests in the repo.
187200
function default_unit_test_runner() {
201+
foreach_go_module __unit_test_runner_for_module
202+
}
203+
204+
function __unit_test_runner_for_module() {
205+
subheader "Unit tests for $(go_mod_module_name)"
188206
report_go_test -short -race -count 1 ./...
189207
}
190208

vendor/modules.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,9 @@ gotest.tools/v3/internal/assert
2828
gotest.tools/v3/internal/difflib
2929
gotest.tools/v3/internal/format
3030
gotest.tools/v3/internal/source
31-
# knative.dev/client v0.34.0
31+
# knative.dev/client v0.34.1-0.20220825103419-794cdef8e4e0
3232
## explicit; go 1.18
3333
knative.dev/client/pkg/kn/plugin
34-
# knative.dev/hack v0.0.0-20220823140917-8d1e4ccf9dc3
35-
## explicit; go 1.17
34+
# knative.dev/hack v0.0.0-20220902220419-664eac5c391e
35+
## explicit; go 1.18
3636
knative.dev/hack

0 commit comments

Comments
 (0)