From 763d0d6bdcf110eacab646d3b7af40d82cbaafd2 Mon Sep 17 00:00:00 2001 From: Preston Van Loon Date: Tue, 2 Oct 2018 22:04:36 -0400 Subject: [PATCH] Add Go tools in bazel (#608) * add atlassian bazel tools * Add bazel entrypoints for native go stuff * gazelle --- BUILD.bazel | 28 ++++++++++++++++++++++++- WORKSPACE | 28 +++++++++++++++++++++++++ beacon-chain/blockchain/service_test.go | 2 +- beacon-chain/powchain/service.go | 2 +- beacon-chain/powchain/service_test.go | 2 +- 5 files changed, 58 insertions(+), 4 deletions(-) diff --git a/BUILD.bazel b/BUILD.bazel index c2ce5c842..f2ab814e7 100644 --- a/BUILD.bazel +++ b/BUILD.bazel @@ -1,7 +1,33 @@ load("@bazel_gazelle//:def.bzl", "gazelle") +load("@com_github_atlassian_bazel_tools//gometalinter:def.bzl", "gometalinter") +load("@com_github_atlassian_bazel_tools//goimports:def.bzl", "goimports") +load("@io_kubernetes_build//defs:run_in_workspace.bzl", "workspace_binary") + +prefix = "github.com/prysmaticlabs/prysm" # gazelle:prefix github.com/prysmaticlabs/prysm gazelle( name = "gazelle", - prefix = "github.com/prysmaticlabs/prysm", + prefix = prefix, +) + +gometalinter( + name = "gometalinter", + config = "//:.gometalinter.json", + paths = [ + "./...", + ], + prefix = prefix, +) + +goimports( + name = "goimports", + display_diffs = True, + write = False, + prefix = prefix, +) + +workspace_binary( + name = "golint", + cmd = "@com_github_golang_lint//golint", ) diff --git a/WORKSPACE b/WORKSPACE index 35b52fbd5..b921621d7 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -12,6 +12,12 @@ http_archive( sha256 = "c0a5739d12c6d05b6c1ad56f2200cb0b57c5a70e03ebd2f7b87ce88cabf09c7b", ) +http_archive( + name = "com_github_atlassian_bazel_tools", + strip_prefix = "bazel-tools-6fef37f33dfa0189be9df4d3d60e6291bfe71177", + urls = ["https://github.com/atlassian/bazel-tools/archive/6fef37f33dfa0189be9df4d3d60e6291bfe71177.zip"], +) + git_repository( name = "io_bazel_rules_docker", commit = "7401cb256222615c497c0dee5a4de5724a4f4cc7", # 2018-06-22 @@ -61,6 +67,10 @@ load("@bazel_gazelle//:deps.bzl", "gazelle_dependencies", "go_repository") gazelle_dependencies() +load("@com_github_atlassian_bazel_tools//gometalinter:deps.bzl", "gometalinter_dependencies") + +gometalinter_dependencies() + load( "@io_bazel_rules_docker//go:image.bzl", _go_image_repos = "repositories", @@ -68,6 +78,12 @@ load( _go_image_repos() +git_repository( + name = "io_kubernetes_build", + commit = "4ce715fbe67d8fbed05ec2bb47a148e754100a4b", + remote = "https://github.com/kubernetes/repo-infra.git", +) + git_repository( name = "com_github_jmhodges_bazel_gomock", commit = "5b73edb74e569ff404b3beffc809d6d9f205e0e4", @@ -594,6 +610,18 @@ go_repository( importpath = "golang.org/x/sync", ) +go_repository( + name = "com_github_golang_lint", + commit = "06c8688daad7faa9da5a0c2f163a3d14aac986ca", + importpath = "github.com/golang/lint", +) + +go_repository( + name = "org_golang_x_lint", + commit = "06c8688daad7faa9da5a0c2f163a3d14aac986ca", + importpath = "golang.org/x/lint", +) + go_repository( name = "com_github_aristanetworks_goarista", commit = "ff33da284e760fcdb03c33d37a719e5ed30ba844", diff --git a/beacon-chain/blockchain/service_test.go b/beacon-chain/blockchain/service_test.go index fd7edbb57..78e146665 100644 --- a/beacon-chain/blockchain/service_test.go +++ b/beacon-chain/blockchain/service_test.go @@ -10,7 +10,7 @@ import ( "testing" "time" - "github.com/ethereum/go-ethereum" + ethereum "github.com/ethereum/go-ethereum" "github.com/ethereum/go-ethereum/common" gethTypes "github.com/ethereum/go-ethereum/core/types" "github.com/prysmaticlabs/prysm/beacon-chain/params" diff --git a/beacon-chain/powchain/service.go b/beacon-chain/powchain/service.go index d402c5406..d87df3b46 100644 --- a/beacon-chain/powchain/service.go +++ b/beacon-chain/powchain/service.go @@ -7,7 +7,7 @@ import ( "math/big" "strings" - "github.com/ethereum/go-ethereum" + ethereum "github.com/ethereum/go-ethereum" "github.com/ethereum/go-ethereum/common" gethTypes "github.com/ethereum/go-ethereum/core/types" "github.com/prysmaticlabs/prysm/beacon-chain/types" diff --git a/beacon-chain/powchain/service_test.go b/beacon-chain/powchain/service_test.go index bf7e4def9..b55875775 100644 --- a/beacon-chain/powchain/service_test.go +++ b/beacon-chain/powchain/service_test.go @@ -7,7 +7,7 @@ import ( "strings" "testing" - "github.com/ethereum/go-ethereum" + ethereum "github.com/ethereum/go-ethereum" "github.com/ethereum/go-ethereum/common" gethTypes "github.com/ethereum/go-ethereum/core/types" "github.com/prysmaticlabs/prysm/shared/event"