From 98470fdb13ff3a60bc291776d70d3baa5b6ea7e8 Mon Sep 17 00:00:00 2001 From: Preston Van Loon Date: Mon, 31 Jan 2022 01:06:07 -0600 Subject: [PATCH] Update rules_go to v0.29.0 (#10064) * Update rules_go, delete patch, fix analyzers, remove old deployContract code, and prune old dependency which was broken in rules_go update * Undo some WORKSPACE diffs * Gazelle * remove nofuzz, fix build issue Co-authored-by: prylabs-bulldozer[bot] <58059840+prylabs-bulldozer[bot]@users.noreply.github.com> --- BUILD.bazel | 80 +++++++++---------- WORKSPACE | 15 ++-- third_party/io_bazel_rules_go.patch | 22 ----- tools/analyzers/comparesame/BUILD.bazel | 13 --- tools/analyzers/cryptorand/BUILD.bazel | 13 --- tools/analyzers/errcheck/BUILD.bazel | 13 --- tools/analyzers/featureconfig/BUILD.bazel | 13 --- tools/analyzers/ineffassign/BUILD.bazel | 16 ---- tools/analyzers/interfacechecker/BUILD.bazel | 13 --- tools/analyzers/maligned/BUILD.bazel | 16 ---- tools/analyzers/nop/BUILD.bazel | 13 --- tools/analyzers/properpermissions/BUILD.bazel | 13 --- tools/analyzers/recursivelock/BUILD.bazel | 15 ---- tools/analyzers/shadowpredecl/BUILD.bazel | 13 --- tools/analyzers/slicedirect/BUILD.bazel | 13 --- 15 files changed, 46 insertions(+), 235 deletions(-) delete mode 100644 third_party/io_bazel_rules_go.patch diff --git a/BUILD.bazel b/BUILD.bazel index 4e4367179..2b7289878 100644 --- a/BUILD.bazel +++ b/BUILD.bazel @@ -86,50 +86,50 @@ nogo( config = "nogo_config.json", visibility = ["//visibility:public"], deps = [ - "@org_golang_x_tools//go/analysis/passes/unsafeptr:go_tool_library", - "@org_golang_x_tools//go/analysis/passes/unreachable:go_tool_library", - "@org_golang_x_tools//go/analysis/passes/unmarshal:go_tool_library", - "@org_golang_x_tools//go/analysis/passes/tests:go_tool_library", - "@org_golang_x_tools//go/analysis/passes/structtag:go_tool_library", - "@org_golang_x_tools//go/analysis/passes/stdmethods:go_tool_library", - "@org_golang_x_tools//go/analysis/passes/shift:go_tool_library", - # "@org_golang_x_tools//go/analysis/passes/shadow:go_tool_library", - "@org_golang_x_tools//go/analysis/passes/printf:go_tool_library", - "@org_golang_x_tools//go/analysis/passes/pkgfact:go_tool_library", - "@org_golang_x_tools//go/analysis/passes/nilness:go_tool_library", - "@org_golang_x_tools//go/analysis/passes/nilfunc:go_tool_library", - "@org_golang_x_tools//go/analysis/passes/loopclosure:go_tool_library", - "@org_golang_x_tools//go/analysis/passes/httpresponse:go_tool_library", - "@org_golang_x_tools//go/analysis/passes/findcall:go_tool_library", - "@org_golang_x_tools//go/analysis/passes/deepequalerrors:go_tool_library", - "@org_golang_x_tools//go/analysis/passes/ctrlflow:go_tool_library", - "@org_golang_x_tools//go/analysis/passes/copylock:go_tool_library", - # "@org_golang_x_tools//go/analysis/passes/cgocall:go_tool_library", - "@org_golang_x_tools//go/analysis/passes/buildtag:go_tool_library", - "@org_golang_x_tools//go/analysis/passes/buildssa:go_tool_library", - "@org_golang_x_tools//go/analysis/passes/bools:go_tool_library", - "@org_golang_x_tools//go/analysis/passes/atomicalign:go_tool_library", - "@org_golang_x_tools//go/analysis/passes/atomic:go_tool_library", - "@org_golang_x_tools//go/analysis/passes/assign:go_tool_library", - "@org_golang_x_tools//go/analysis/passes/inspect:go_tool_library", - "@org_golang_x_tools//go/analysis/passes/asmdecl:go_tool_library", - "//tools/analyzers/maligned:go_tool_library", - "//tools/analyzers/cryptorand:go_tool_library", - "//tools/analyzers/errcheck:go_tool_library", - "//tools/analyzers/featureconfig:go_tool_library", - "//tools/analyzers/comparesame:go_tool_library", - "//tools/analyzers/shadowpredecl:go_tool_library", - "//tools/analyzers/nop:go_tool_library", - "//tools/analyzers/slicedirect:go_tool_library", - "//tools/analyzers/interfacechecker:go_tool_library", - "//tools/analyzers/ineffassign:go_tool_library", - "//tools/analyzers/properpermissions:go_tool_library", + "@org_golang_x_tools//go/analysis/passes/unsafeptr:go_default_library", + "@org_golang_x_tools//go/analysis/passes/unreachable:go_default_library", + "@org_golang_x_tools//go/analysis/passes/unmarshal:go_default_library", + "@org_golang_x_tools//go/analysis/passes/tests:go_default_library", + "@org_golang_x_tools//go/analysis/passes/structtag:go_default_library", + "@org_golang_x_tools//go/analysis/passes/stdmethods:go_default_library", + "@org_golang_x_tools//go/analysis/passes/shift:go_default_library", + # "@org_golang_x_tools//go/analysis/passes/shadow:go_default_library", + "@org_golang_x_tools//go/analysis/passes/printf:go_default_library", + "@org_golang_x_tools//go/analysis/passes/pkgfact:go_default_library", + "@org_golang_x_tools//go/analysis/passes/nilness:go_default_library", + "@org_golang_x_tools//go/analysis/passes/nilfunc:go_default_library", + "@org_golang_x_tools//go/analysis/passes/loopclosure:go_default_library", + "@org_golang_x_tools//go/analysis/passes/httpresponse:go_default_library", + "@org_golang_x_tools//go/analysis/passes/findcall:go_default_library", + "@org_golang_x_tools//go/analysis/passes/deepequalerrors:go_default_library", + "@org_golang_x_tools//go/analysis/passes/ctrlflow:go_default_library", + "@org_golang_x_tools//go/analysis/passes/copylock:go_default_library", + # "@org_golang_x_tools//go/analysis/passes/cgocall:go_default_library", + "@org_golang_x_tools//go/analysis/passes/buildtag:go_default_library", + "@org_golang_x_tools//go/analysis/passes/buildssa:go_default_library", + "@org_golang_x_tools//go/analysis/passes/bools:go_default_library", + "@org_golang_x_tools//go/analysis/passes/atomicalign:go_default_library", + "@org_golang_x_tools//go/analysis/passes/atomic:go_default_library", + "@org_golang_x_tools//go/analysis/passes/assign:go_default_library", + "@org_golang_x_tools//go/analysis/passes/inspect:go_default_library", + "@org_golang_x_tools//go/analysis/passes/asmdecl:go_default_library", + "//tools/analyzers/maligned:go_default_library", + "//tools/analyzers/cryptorand:go_default_library", + "//tools/analyzers/errcheck:go_default_library", + "//tools/analyzers/featureconfig:go_default_library", + "//tools/analyzers/comparesame:go_default_library", + "//tools/analyzers/shadowpredecl:go_default_library", + "//tools/analyzers/nop:go_default_library", + "//tools/analyzers/slicedirect:go_default_library", + "//tools/analyzers/interfacechecker:go_default_library", + "//tools/analyzers/ineffassign:go_default_library", + "//tools/analyzers/properpermissions:go_default_library", ] + select({ # nogo checks that fail with coverage enabled. ":coverage_enabled": [], "//conditions:default": [ - "@org_golang_x_tools//go/analysis/passes/lostcancel:go_tool_library", - "@org_golang_x_tools//go/analysis/passes/composite:go_tool_library", + "@org_golang_x_tools//go/analysis/passes/lostcancel:go_default_library", + "@org_golang_x_tools//go/analysis/passes/composite:go_default_library", ], }), ) diff --git a/WORKSPACE b/WORKSPACE index 870c8d8d5..232e8b837 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -60,10 +60,10 @@ bazel_skylib_workspace() http_archive( name = "bazel_gazelle", - sha256 = "62ca106be173579c0a167deb23358fdfe71ffa1e4cfdddf5582af26520f1c66f", + sha256 = "de69a09dc70417580aabf20a28619bb3ef60d038470c7cf8442fafcf627c21cb", urls = [ - "https://mirror.bazel.build/github.com/bazelbuild/bazel-gazelle/releases/download/v0.23.0/bazel-gazelle-v0.23.0.tar.gz", - "https://github.com/bazelbuild/bazel-gazelle/releases/download/v0.23.0/bazel-gazelle-v0.23.0.tar.gz", + "https://mirror.bazel.build/github.com/bazelbuild/bazel-gazelle/releases/download/v0.24.0/bazel-gazelle-v0.24.0.tar.gz", + "https://github.com/bazelbuild/bazel-gazelle/releases/download/v0.24.0/bazel-gazelle-v0.24.0.tar.gz", ], ) @@ -85,16 +85,13 @@ http_archive( name = "io_bazel_rules_go", patch_args = ["-p1"], patches = [ - # Required until https://github.com/bazelbuild/rules_go/pull/2450 merges otherwise nilness - # nogo check fails for certain third_party dependencies. - "//third_party:io_bazel_rules_go.patch", # Expose internals of go_test for custom build transitions. "//third_party:io_bazel_rules_go_test.patch", ], - sha256 = "7c10271940c6bce577d51a075ae77728964db285dac0a46614a7934dc34303e6", + sha256 = "2b1641428dff9018f9e85c0384f03ec6c10660d935b750e3fa1492a281a53b0f", urls = [ - "https://mirror.bazel.build/github.com/bazelbuild/rules_go/releases/download/v0.26.0/rules_go-v0.26.0.tar.gz", - "https://github.com/bazelbuild/rules_go/releases/download/v0.26.0/rules_go-v0.26.0.tar.gz", + "https://mirror.bazel.build/github.com/bazelbuild/rules_go/releases/download/v0.29.0/rules_go-v0.29.0.zip", + "https://github.com/bazelbuild/rules_go/releases/download/v0.29.0/rules_go-v0.29.0.zip", ], ) diff --git a/third_party/io_bazel_rules_go.patch b/third_party/io_bazel_rules_go.patch deleted file mode 100644 index 306b3397d..000000000 --- a/third_party/io_bazel_rules_go.patch +++ /dev/null @@ -1,22 +0,0 @@ -diff --git a/go/tools/builders/nogo_main.go b/go/tools/builders/nogo_main.go -index 2830a666..ce0e6e39 100644 ---- a/go/tools/builders/nogo_main.go -+++ b/go/tools/builders/nogo_main.go -@@ -386,13 +386,11 @@ func checkAnalysisResults(actions []*action, pkg *goPackage) string { - } - // Discard diagnostics based on the analyzer configuration. - for _, d := range act.diagnostics { -- // NOTE(golang.org/issue/31008): nilness does not set positions, -- // so don't assume the position is valid. -- f := pkg.fset.File(d.Pos) -- filename := "-" -- if f != nil { -- filename = f.Name() -+ file := pkg.fset.File(d.Pos) -+ if file == nil { -+ continue - } -+ filename := file.Name() - include := true - if len(config.onlyFiles) > 0 { - // This analyzer emits diagnostics for only a set of files. diff --git a/tools/analyzers/comparesame/BUILD.bazel b/tools/analyzers/comparesame/BUILD.bazel index f92915767..a7253608c 100644 --- a/tools/analyzers/comparesame/BUILD.bazel +++ b/tools/analyzers/comparesame/BUILD.bazel @@ -1,5 +1,4 @@ load("@prysm//tools/go:def.bzl", "go_library") -load("@io_bazel_rules_go//go:def.bzl", "go_tool_library") go_library( name = "go_default_library", @@ -13,16 +12,4 @@ go_library( ], ) -go_tool_library( - name = "go_tool_library", - srcs = ["analyzer.go"], - importpath = "github.com/prysmaticlabs/prysm/tools/analyzers/comparesame", - visibility = ["//visibility:public"], - deps = [ - "@org_golang_x_tools//go/analysis:go_tool_library", - "@org_golang_x_tools//go/analysis/passes/inspect:go_tool_library", - "@org_golang_x_tools//go/ast/inspector:go_tool_library", - ], -) - # gazelle:exclude analyzer_test.go diff --git a/tools/analyzers/cryptorand/BUILD.bazel b/tools/analyzers/cryptorand/BUILD.bazel index d10a1dd6c..3850de629 100644 --- a/tools/analyzers/cryptorand/BUILD.bazel +++ b/tools/analyzers/cryptorand/BUILD.bazel @@ -1,5 +1,4 @@ load("@prysm//tools/go:def.bzl", "go_library") -load("@io_bazel_rules_go//go:def.bzl", "go_tool_library") go_library( name = "go_default_library", @@ -13,16 +12,4 @@ go_library( ], ) -go_tool_library( - name = "go_tool_library", - srcs = ["analyzer.go"], - importpath = "github.com/prysmaticlabs/prysm/tools/analyzers/cryptorand", - visibility = ["//visibility:public"], - deps = [ - "@org_golang_x_tools//go/analysis:go_tool_library", - "@org_golang_x_tools//go/analysis/passes/inspect:go_tool_library", - "@org_golang_x_tools//go/ast/inspector:go_tool_library", - ], -) - # gazelle:exclude analyzer_test.go diff --git a/tools/analyzers/errcheck/BUILD.bazel b/tools/analyzers/errcheck/BUILD.bazel index 6579b7717..469c8f48c 100644 --- a/tools/analyzers/errcheck/BUILD.bazel +++ b/tools/analyzers/errcheck/BUILD.bazel @@ -1,5 +1,4 @@ load("@prysm//tools/go:def.bzl", "go_library", "go_test") -load("@io_bazel_rules_go//go:def.bzl", "go_tool_library") go_library( name = "go_default_library", @@ -13,18 +12,6 @@ go_library( ], ) -go_tool_library( - name = "go_tool_library", - srcs = ["analyzer.go"], - importpath = "errcheck", - visibility = ["//visibility:public"], - deps = [ - "@org_golang_x_tools//go/analysis:go_tool_library", - "@org_golang_x_tools//go/analysis/passes/inspect:go_tool_library", - "@org_golang_x_tools//go/ast/inspector:go_tool_library", - ], -) - go_test( name = "go_default_test", srcs = ["embedded_walker_test.go"], diff --git a/tools/analyzers/featureconfig/BUILD.bazel b/tools/analyzers/featureconfig/BUILD.bazel index 73ca9c9e3..1764ab79a 100644 --- a/tools/analyzers/featureconfig/BUILD.bazel +++ b/tools/analyzers/featureconfig/BUILD.bazel @@ -1,5 +1,4 @@ load("@prysm//tools/go:def.bzl", "go_library") -load("@io_bazel_rules_go//go:def.bzl", "go_tool_library") go_library( name = "go_default_library", @@ -12,15 +11,3 @@ go_library( "@org_golang_x_tools//go/ast/inspector:go_default_library", ], ) - -go_tool_library( - name = "go_tool_library", - srcs = ["analyzer.go"], - importpath = "featureconfig", - visibility = ["//visibility:public"], - deps = [ - "@org_golang_x_tools//go/analysis:go_tool_library", - "@org_golang_x_tools//go/analysis/passes/inspect:go_tool_library", - "@org_golang_x_tools//go/ast/inspector:go_tool_library", - ], -) diff --git a/tools/analyzers/ineffassign/BUILD.bazel b/tools/analyzers/ineffassign/BUILD.bazel index 4e86791af..70ed1469d 100644 --- a/tools/analyzers/ineffassign/BUILD.bazel +++ b/tools/analyzers/ineffassign/BUILD.bazel @@ -1,5 +1,4 @@ load("@prysm//tools/go:def.bzl", "go_library") -load("@io_bazel_rules_go//go:def.bzl", "go_tool_library") go_library( name = "go_default_library", @@ -16,19 +15,4 @@ go_library( ], ) -go_tool_library( - name = "go_tool_library", - srcs = [ - "analyzer.go", - "ineffassign.go", - ], - importpath = "github.com/prysmaticlabs/prysm/tools/analyzers/ineffassign", - visibility = ["//visibility:public"], - deps = [ - "@org_golang_x_tools//go/analysis:go_tool_library", - "@org_golang_x_tools//go/analysis/passes/inspect:go_tool_library", - "@org_golang_x_tools//go/ast/inspector:go_tool_library", - ], -) - # gazelle:exclude analyzer_test.go diff --git a/tools/analyzers/interfacechecker/BUILD.bazel b/tools/analyzers/interfacechecker/BUILD.bazel index 6ac94a8a6..5f6e85c64 100644 --- a/tools/analyzers/interfacechecker/BUILD.bazel +++ b/tools/analyzers/interfacechecker/BUILD.bazel @@ -1,5 +1,4 @@ load("@prysm//tools/go:def.bzl", "go_library") -load("@io_bazel_rules_go//go:def.bzl", "go_tool_library") go_library( name = "go_default_library", @@ -12,15 +11,3 @@ go_library( "@org_golang_x_tools//go/ast/inspector:go_default_library", ], ) - -go_tool_library( - name = "go_tool_library", - srcs = ["analyzer.go"], - importpath = "interfacechecker", - visibility = ["//visibility:public"], - deps = [ - "@org_golang_x_tools//go/analysis:go_tool_library", - "@org_golang_x_tools//go/analysis/passes/inspect:go_tool_library", - "@org_golang_x_tools//go/ast/inspector:go_tool_library", - ], -) diff --git a/tools/analyzers/maligned/BUILD.bazel b/tools/analyzers/maligned/BUILD.bazel index 2080fe7a7..061acefa9 100644 --- a/tools/analyzers/maligned/BUILD.bazel +++ b/tools/analyzers/maligned/BUILD.bazel @@ -1,20 +1,4 @@ load("@prysm//tools/go:def.bzl", "go_library") -load("@io_bazel_rules_go//go:def.bzl", "go_tool_library") - -go_tool_library( - name = "go_tool_library", - srcs = [ - "analyzer.go", - "maligned.go", - ], - importpath = "maligned", - visibility = ["//visibility:public"], - deps = [ - "@org_golang_x_tools//go/analysis:go_tool_library", - "@org_golang_x_tools//go/analysis/passes/inspect:go_tool_library", - "@org_golang_x_tools//go/ast/inspector:go_tool_library", - ], -) go_library( name = "go_default_library", diff --git a/tools/analyzers/nop/BUILD.bazel b/tools/analyzers/nop/BUILD.bazel index 2e1a05666..94960147a 100644 --- a/tools/analyzers/nop/BUILD.bazel +++ b/tools/analyzers/nop/BUILD.bazel @@ -1,5 +1,4 @@ load("@prysm//tools/go:def.bzl", "go_library") -load("@io_bazel_rules_go//go:def.bzl", "go_tool_library") go_library( name = "go_default_library", @@ -13,16 +12,4 @@ go_library( ], ) -go_tool_library( - name = "go_tool_library", - srcs = ["analyzer.go"], - importpath = "github.com/prysmaticlabs/prysm/tools/analyzers/nop", - visibility = ["//visibility:public"], - deps = [ - "@org_golang_x_tools//go/analysis:go_tool_library", - "@org_golang_x_tools//go/analysis/passes/inspect:go_tool_library", - "@org_golang_x_tools//go/ast/inspector:go_tool_library", - ], -) - # gazelle:exclude analyzer_test.go diff --git a/tools/analyzers/properpermissions/BUILD.bazel b/tools/analyzers/properpermissions/BUILD.bazel index ed2765984..99c121697 100644 --- a/tools/analyzers/properpermissions/BUILD.bazel +++ b/tools/analyzers/properpermissions/BUILD.bazel @@ -1,5 +1,4 @@ load("@prysm//tools/go:def.bzl", "go_library") -load("@io_bazel_rules_go//go:def.bzl", "go_tool_library") go_library( name = "go_default_library", @@ -13,16 +12,4 @@ go_library( ], ) -go_tool_library( - name = "go_tool_library", - srcs = ["analyzer.go"], - importpath = "github.com/prysmaticlabs/prysm/tools/analyzers/properpermissions", - visibility = ["//visibility:public"], - deps = [ - "@org_golang_x_tools//go/analysis:go_tool_library", - "@org_golang_x_tools//go/analysis/passes/inspect:go_tool_library", - "@org_golang_x_tools//go/ast/inspector:go_tool_library", - ], -) - # gazelle:exclude analyzer_test.go diff --git a/tools/analyzers/recursivelock/BUILD.bazel b/tools/analyzers/recursivelock/BUILD.bazel index 834763404..6352087f2 100644 --- a/tools/analyzers/recursivelock/BUILD.bazel +++ b/tools/analyzers/recursivelock/BUILD.bazel @@ -1,4 +1,3 @@ -load("@io_bazel_rules_go//go:def.bzl", "go_tool_library") load("@prysm//tools/go:def.bzl", "go_library") go_library( @@ -15,18 +14,4 @@ go_library( ], ) -go_tool_library( - name = "go_tool_library", - srcs = ["analyzer.go"], - importpath = "github.com/prysmaticlabs/prysm/tools/analyzers/recursivelock", - visibility = ["//visibility:public"], - deps = [ - "@org_golang_x_tools//go/analysis:go_tool_library", - "@org_golang_x_tools//go/analysis/passes/inspect:go_tool_library", - "@org_golang_x_tools//go/ast/astutil:go_tool_library", - "@org_golang_x_tools//go/ast/inspector:go_tool_library", - "@org_golang_x_tools//go/types/typeutil:go_tool_library", - ], -) - # gazelle:exclude analyzer_test.go diff --git a/tools/analyzers/shadowpredecl/BUILD.bazel b/tools/analyzers/shadowpredecl/BUILD.bazel index 5372acc8d..b923bdf5a 100644 --- a/tools/analyzers/shadowpredecl/BUILD.bazel +++ b/tools/analyzers/shadowpredecl/BUILD.bazel @@ -1,5 +1,4 @@ load("@prysm//tools/go:def.bzl", "go_library") -load("@io_bazel_rules_go//go:def.bzl", "go_tool_library") go_library( name = "go_default_library", @@ -13,16 +12,4 @@ go_library( ], ) -go_tool_library( - name = "go_tool_library", - srcs = ["analyzer.go"], - importpath = "github.com/prysmaticlabs/prysm/tools/analyzers/shadowpredecl", - visibility = ["//visibility:public"], - deps = [ - "@org_golang_x_tools//go/analysis:go_tool_library", - "@org_golang_x_tools//go/analysis/passes/inspect:go_tool_library", - "@org_golang_x_tools//go/ast/inspector:go_tool_library", - ], -) - # gazelle:exclude analyzer_test.go diff --git a/tools/analyzers/slicedirect/BUILD.bazel b/tools/analyzers/slicedirect/BUILD.bazel index 2eedb0165..54a0ae7fa 100644 --- a/tools/analyzers/slicedirect/BUILD.bazel +++ b/tools/analyzers/slicedirect/BUILD.bazel @@ -1,5 +1,4 @@ load("@prysm//tools/go:def.bzl", "go_library") -load("@io_bazel_rules_go//go:def.bzl", "go_tool_library") go_library( name = "go_default_library", @@ -13,16 +12,4 @@ go_library( ], ) -go_tool_library( - name = "go_tool_library", - srcs = ["analyzer.go"], - importpath = "github.com/prysmaticlabs/prysm/tools/analyzers/slicedirect", - visibility = ["//visibility:public"], - deps = [ - "@org_golang_x_tools//go/analysis:go_tool_library", - "@org_golang_x_tools//go/analysis/passes/inspect:go_tool_library", - "@org_golang_x_tools//go/ast/inspector:go_tool_library", - ], -) - # gazelle:exclude analyzer_test.go