From daae4f8746c03808557aeb57af1f898cee5838d9 Mon Sep 17 00:00:00 2001 From: Paul Meyer <49727155+katexochen@users.noreply.github.com> Date: Fri, 17 Mar 2023 17:35:03 +0100 Subject: [PATCH] bazel: get gofumpt as binary download Signed-off-by: Paul Meyer <49727155+katexochen@users.noreply.github.com> --- bazel/ci/BUILD.bazel | 12 ++++++++- bazel/toolchains/BUILD.gofumpt.bazel | 8 ++++++ bazel/toolchains/ci_deps.bzl | 37 +++++++++++++++++++++++++++- bazel/toolchains/go_module_deps.bzl | 8 ------ hack/tools/BUILD.bazel | 1 - hack/tools/go.mod | 5 ---- hack/tools/go.sum | 9 ------- hack/tools/tools.go | 1 - 8 files changed, 55 insertions(+), 26 deletions(-) create mode 100644 bazel/toolchains/BUILD.gofumpt.bazel diff --git a/bazel/ci/BUILD.bazel b/bazel/ci/BUILD.bazel index 936752fbe..4237deda5 100644 --- a/bazel/ci/BUILD.bazel +++ b/bazel/ci/BUILD.bazel @@ -120,6 +120,16 @@ repo_command( command = ":com_github_rhysd_actionlint", ) +alias( + name = "com_github_mvdan_gofumpt", + actual = select({ + "@io_bazel_rules_go//go/platform:darwin_amd64": "@com_github_mvdan_gofumpt_darwin_amd64//file", + "@io_bazel_rules_go//go/platform:darwin_arm64": "@com_github_mvdan_gofumpt_darwin_arm64//file", + "@io_bazel_rules_go//go/platform:linux_amd64": "@com_github_mvdan_gofumpt_linux_amd64//file", + "@io_bazel_rules_go//go/platform:linux_arm64": "@com_github_mvdan_gofumpt_linux_arm64//file", + }), +) + repo_command( name = "gofumpt", args = [ @@ -127,7 +137,7 @@ repo_command( "-w", ".", ], - command = "@cc_mvdan_gofumpt//:gofumpt", + command = ":com_github_mvdan_gofumpt", ) sh_template( diff --git a/bazel/toolchains/BUILD.gofumpt.bazel b/bazel/toolchains/BUILD.gofumpt.bazel new file mode 100644 index 000000000..d9daaf46a --- /dev/null +++ b/bazel/toolchains/BUILD.gofumpt.bazel @@ -0,0 +1,8 @@ +genrule( + name = "gofumpt_bin", + srcs = ["gofumpt"], + outs = ["gofumpt_bin_out"], + cmd = "cp $< $@", # Copy the binary to the output directory. + executable = True, + visibility = ["//visibility:public"], +) diff --git a/bazel/toolchains/ci_deps.bzl b/bazel/toolchains/ci_deps.bzl index ccae63c4c..b8567b038 100644 --- a/bazel/toolchains/ci_deps.bzl +++ b/bazel/toolchains/ci_deps.bzl @@ -1,12 +1,13 @@ """CI dependencies""" -load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") +load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive", "http_file") def ci_deps(): """Install CI dependencies""" _shellcheck_deps() _terraform_deps() _actionlint_deps() + _gofumpt_deps() def _shellcheck_deps(): http_archive( @@ -104,3 +105,37 @@ def _actionlint_deps(): ], sha256 = "ddd0263968f7f024e49bd8721cd2b3d27c7a4d77081b81a4b376d5053ea25cdc", ) + +def _gofumpt_deps(): + http_file( + name = "com_github_mvdan_gofumpt_linux_amd64", + urls = [ + "https://github.com/mvdan/gofumpt/releases/download/v0.4.0/gofumpt_v0.4.0_linux_amd64", + ], + executable = True, + sha256 = "d3ca535e6b0b230a9c4f05a3ec54e358336b5e7474d239c15514e63a0b2a8041", + ) + http_file( + name = "com_github_mvdan_gofumpt_linux_arm64", + urls = [ + "https://github.com/mvdan/gofumpt/releases/download/v0.4.0/gofumpt_v0.4.0_linux_arm64", + ], + executable = True, + sha256 = "186faa7b7562cc4c1a34f2cb89f9b09d9fad949bc2f3ce293ea2726b23c28695", + ) + http_file( + name = "com_github_mvdan_gofumpt_darwin_amd64", + urls = [ + "https://github.com/mvdan/gofumpt/releases/download/v0.4.0/gofumpt_v0.4.0_darwin_amd64", + ], + executable = True, + sha256 = "3f550baa6d4c071b01e9c68b9308bd2ca3bae6b3b09d203f19ed8626ee0fe487", + ) + http_file( + name = "com_github_mvdan_gofumpt_darwin_arm64", + urls = [ + "https://github.com/mvdan/gofumpt/releases/download/v0.4.0/gofumpt_v0.4.0_darwin_arm64", + ], + executable = True, + sha256 = "768263452749a3a3cabf412f29f8a14e8bbdc7f6c6471427e977eebc6592ddb8", + ) diff --git a/bazel/toolchains/go_module_deps.bzl b/bazel/toolchains/go_module_deps.bzl index f5cd5b2d0..17618c1a2 100644 --- a/bazel/toolchains/go_module_deps.bzl +++ b/bazel/toolchains/go_module_deps.bzl @@ -23,14 +23,6 @@ def go_dependencies(): sum = "h1:XL+7ys6ls/RKrkUNFQvEwIvNHh+JKx8Mj1pUV5wQxQE=", version = "v0.2.0", ) - go_repository( - name = "cc_mvdan_gofumpt", - build_file_generation = "on", - build_file_proto_mode = "disable_global", - importpath = "mvdan.cc/gofumpt", - sum = "h1:JVf4NN1mIpHogBj7ABpgOyZc65/UUOkKQFkoURsz4MM=", - version = "v0.4.0", - ) go_repository( name = "co_honnef_go_tools", diff --git a/hack/tools/BUILD.bazel b/hack/tools/BUILD.bazel index ff8235f42..9c5f77f93 100644 --- a/hack/tools/BUILD.bazel +++ b/hack/tools/BUILD.bazel @@ -8,7 +8,6 @@ go_library( visibility = ["//visibility:private"], deps = select({ "//bazel/settings:select_never_enabled": [ - "@cc_mvdan_gofumpt//:gofumpt", "@com_github_aquasecurity_tfsec//cmd/tfsec", "@com_github_katexochen_sh_v3//cmd/shfmt", ], diff --git a/hack/tools/go.mod b/hack/tools/go.mod index 43539751c..db7071faa 100644 --- a/hack/tools/go.mod +++ b/hack/tools/go.mod @@ -5,7 +5,6 @@ go 1.20 require ( github.com/aquasecurity/tfsec v1.28.1 github.com/katexochen/sh/v3 v3.6.0 - mvdan.cc/gofumpt v0.4.0 ) require ( @@ -36,7 +35,6 @@ require ( github.com/gobwas/glob v0.2.3 // indirect github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect github.com/golang/protobuf v1.5.2 // indirect - github.com/google/go-cmp v0.5.9 // indirect github.com/google/renameio/v2 v2.0.0 // indirect github.com/google/uuid v1.3.0 // indirect github.com/googleapis/gax-go/v2 v2.1.1 // indirect @@ -85,14 +83,11 @@ require ( github.com/zclconf/go-cty-yaml v1.0.2 // indirect go.opencensus.io v0.23.0 // indirect golang.org/x/crypto v0.0.0-20220525230936-793ad666bf5e // indirect - golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4 // indirect golang.org/x/net v0.0.0-20220909164309-bea034e7d591 // indirect golang.org/x/oauth2 v0.0.0-20220223155221-ee480838109b // indirect - golang.org/x/sync v0.1.0 // indirect golang.org/x/sys v0.4.0 // indirect golang.org/x/term v0.3.0 // indirect golang.org/x/text v0.3.8 // indirect - golang.org/x/tools v0.1.12 // indirect golang.org/x/xerrors v0.0.0-20220411194840-2f41105eb62f // indirect google.golang.org/api v0.62.0 // indirect google.golang.org/appengine v1.6.7 // indirect diff --git a/hack/tools/go.sum b/hack/tools/go.sum index c4c68b01e..b24283686 100644 --- a/hack/tools/go.sum +++ b/hack/tools/go.sum @@ -216,7 +216,6 @@ github.com/google/go-cmp v0.5.4/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/ github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38= -github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/google/martian v2.1.0+incompatible h1:/CP5g8u/VJHijgedC/Legn3BAbAaWPgecwXBIDzw5no= github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs= github.com/google/martian/v3 v3.0.0/go.mod h1:y5Zk1BBys9G+gd6Jrk0W3cC1+ELVxBWuIGO+w/tUAp0= @@ -464,8 +463,6 @@ golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.4.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.4.1/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4 h1:6zppjxzCulZykYSLyVDYbneBfbaBIQPYMevg0bEwv2s= -golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180811021610-c39426892332/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= @@ -535,8 +532,6 @@ golang.org/x/sync v0.0.0-20200625203802-6e8e738ad208/go.mod h1:RxMgew5VJxzue5/jJ golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20201207232520-09787c993a3a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.1.0 h1:wsuoTGHzEhffawBOhz5CYhcrV4IdKZbEyZjBMuTp12o= -golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= @@ -668,8 +663,6 @@ golang.org/x/tools v0.1.2/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= golang.org/x/tools v0.1.3/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= golang.org/x/tools v0.1.4/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= golang.org/x/tools v0.1.5/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= -golang.org/x/tools v0.1.12 h1:VveCTK38A2rkS8ZqFY25HIDFscX5X9OoEhJd3quQmXU= -golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= @@ -853,8 +846,6 @@ honnef.co/go/tools v0.0.1-2020.1.3/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9 honnef.co/go/tools v0.0.1-2020.1.4/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k= mvdan.cc/editorconfig v0.2.0 h1:XL+7ys6ls/RKrkUNFQvEwIvNHh+JKx8Mj1pUV5wQxQE= mvdan.cc/editorconfig v0.2.0/go.mod h1:lvnnD3BNdBYkhq+B4uBuFFKatfp02eB6HixDvEz91C0= -mvdan.cc/gofumpt v0.4.0 h1:JVf4NN1mIpHogBj7ABpgOyZc65/UUOkKQFkoURsz4MM= -mvdan.cc/gofumpt v0.4.0/go.mod h1:PljLOHDeZqgS8opHRKLzp2It2VBuSdteAgqUfzMTxlQ= rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8= rsc.io/quote/v3 v3.1.0/go.mod h1:yEA65RcK8LyAZtP9Kv3t0HmxON59tX3rD+tICJqUlj0= rsc.io/sampler v1.3.0/go.mod h1:T1hPZKmBbMNahiBKFy5HrXp6adAjACjK9JXDnKaTXpA= diff --git a/hack/tools/tools.go b/hack/tools/tools.go index 5f5bb1f25..c04eecd59 100644 --- a/hack/tools/tools.go +++ b/hack/tools/tools.go @@ -11,5 +11,4 @@ package main import ( _ "github.com/aquasecurity/tfsec/cmd/tfsec" _ "github.com/katexochen/sh/v3/cmd/shfmt" - _ "mvdan.cc/gofumpt" )