Skip to content

Commit fe4fae0

Browse files
authored
Merge pull request kubernetes#92212 from thockin/verify-typecheck-no-gopath
Make verify-typecheck not depend on GOPATH
2 parents 66ff1ae + d187d7e commit fe4fae0

File tree

10 files changed

+390
-421
lines changed

10 files changed

+390
-421
lines changed

hack/update-vendor.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -366,3 +366,5 @@ cat <<__EOF__ > "vendor/OWNERS"
366366
approvers:
367367
- dep-approvers
368368
__EOF__
369+
370+
kube::log::status "NOTE: don't forget to handle vendor/* files that were added or removed"

hack/verify-staticcheck.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ while IFS='' read -r line; do
6868
all_packages+=("./$line")
6969
done < <( hack/make-rules/helpers/cache_go_dirs.sh "${KUBE_ROOT}/_tmp/all_go_dirs" |
7070
grep "^${FOCUS:-.}" |
71-
grep -vE "(third_party|generated|clientset_generated|hack|/_)" |
71+
grep -vE "(third_party|generated|clientset_generated|hack|testdata|/_)" |
7272
grep -vE "$ignore_pattern" )
7373

7474
failing_packages=()

hack/verify-typecheck.sh

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,12 @@ cd "${KUBE_ROOT}"
3030

3131
make --no-print-directory -C "${KUBE_ROOT}" generated_files
3232

33+
# As of June, 2020 the typecheck tool is written in terms of go/packages, but
34+
# that library doesn't work well with multiple modules. Until that is done,
35+
# force this tooling to run in a fake GOPATH.
3336
ret=0
34-
go run test/typecheck/main.go "$@" || ret=$?
37+
hack/run-in-gopath.sh \
38+
go run test/typecheck/main.go "$@" || ret=$?
3539
if [[ $ret -ne 0 ]]; then
3640
echo "!!! Type Check has failed. This may cause cross platform build failures." >&2
3741
echo "!!! Please see https://git.k8s.io/kubernetes/test/typecheck for more information." >&2

test/typecheck/BUILD

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# gazelle:exclude testdata
12
package(default_visibility = ["//visibility:public"])
23

34
load(
@@ -16,10 +17,7 @@ go_library(
1617
name = "go_default_library",
1718
srcs = ["main.go"],
1819
importpath = "k8s.io/kubernetes/test/typecheck",
19-
deps = [
20-
"//third_party/go-srcimporter:go_default_library",
21-
"//vendor/golang.org/x/crypto/ssh/terminal:go_default_library",
22-
],
20+
deps = ["//vendor/golang.org/x/tools/go/packages:go_default_library"],
2321
)
2422

2523
filegroup(
@@ -43,5 +41,12 @@ go_binary(
4341
go_test(
4442
name = "go_default_test",
4543
srcs = ["main_test.go"],
44+
# The "../../" is because $(location) gives a relative path, but
45+
# relative to some root for which I can't find a variable. Empirically
46+
# this is 2 levels up (since this file is 2 levels down from the repo
47+
# root). Hack.
48+
args = ["--go=../../$(location @go_sdk//:bin/go)"],
49+
data = ["@go_sdk//:bin/go"] + glob(["testdata/**"]),
4650
embed = [":go_default_library"],
51+
deps = ["//vendor/golang.org/x/tools/go/packages:go_default_library"],
4752
)

0 commit comments

Comments
 (0)