From 8f046c1231a5c75d675274727b4c61870933dbdb Mon Sep 17 00:00:00 2001 From: ValarDragon Date: Fri, 22 Jun 2018 11:23:28 -0700 Subject: [PATCH 1/2] Switch gometalinter to stable --- .circleci/config.yml | 11 ++- CHANGELOG.md | 1 + Makefile | 2 +- tools/Gopkg.lock | 56 -------------- tools/Gopkg.toml | 34 --------- tools/Makefile | 34 ++------- tools/go-vendorinstall/main.go | 129 --------------------------------- tools/main.go | 11 --- 8 files changed, 14 insertions(+), 264 deletions(-) delete mode 100644 tools/Gopkg.lock delete mode 100644 tools/Gopkg.toml delete mode 100644 tools/go-vendorinstall/main.go delete mode 100644 tools/main.go diff --git a/.circleci/config.yml b/.circleci/config.yml index a873c8190f34..9464e110c6a9 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -61,14 +61,13 @@ jobs: name: Get metalinter command: | export PATH="$GOBIN:$PATH" - go get -u github.com/tendermint/lint/golint - go get -u github.com/alecthomas/gometalinter + make get_tools - run: name: Lint source command: | export PATH="$GOBIN:$PATH" - gometalinter --disable-all --enable='golint' --vendor ./... - + gometalinter.v2 --disable-all --enable='golint' --vendor ./... + test_unit: <<: *defaults parallelism: 4 @@ -84,7 +83,7 @@ jobs: command: | export PATH="$GOBIN:$PATH" make test_unit - + test_cli: <<: *defaults parallelism: 1 @@ -100,7 +99,7 @@ jobs: command: | export PATH="$GOBIN:$PATH" make test_cli_retry - + test_cover: <<: *defaults parallelism: 4 diff --git a/CHANGELOG.md b/CHANGELOG.md index a97a18bd10be..f544b43fbe7b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,6 +19,7 @@ FEATURES * Proposals need deposits to be votable; deposits are burned if proposal fails * Delegators delegate votes to validator by default but can override (for their stake) * [tools] make get_tools installs tendermint's linter, and gometalinter +* [tools] Switch gometalinter to the stable version FIXES * \#1259 - fix bug where certain tests that could have a nil pointer in defer diff --git a/Makefile b/Makefile index 8d7fb0593b35..a4d7e29c31a7 100644 --- a/Makefile +++ b/Makefile @@ -108,7 +108,7 @@ test_cover: @bash tests/test_cover.sh test_lint: - gometalinter --disable-all --enable='golint' --vendor ./... + gometalinter.v2 --disable-all --enable='golint' --vendor ./... benchmark: @go test -bench=. $(PACKAGES_NOCLITEST) diff --git a/tools/Gopkg.lock b/tools/Gopkg.lock deleted file mode 100644 index 92fe1e260caf..000000000000 --- a/tools/Gopkg.lock +++ /dev/null @@ -1,56 +0,0 @@ -# This file is autogenerated, do not edit; changes may be undone by the next 'dep ensure'. - - -[[projects]] - name = "github.com/alecthomas/gometalinter" - packages = ["."] - revision = "46cc1ea3778b247666c2949669a3333c532fa9c6" - version = "v2.0.5" - -[[projects]] - branch = "master" - name = "github.com/alecthomas/units" - packages = ["."] - revision = "2efee857e7cfd4f3d0138cc3cbb1b4966962b93a" - -[[projects]] - branch = "master" - name = "github.com/google/shlex" - packages = ["."] - revision = "6f45313302b9c56850fc17f99e40caebce98c716" - -[[projects]] - name = "github.com/nicksnyder/go-i18n" - packages = [ - "i18n", - "i18n/bundle", - "i18n/language", - "i18n/translation" - ] - revision = "0dc1626d56435e9d605a29875701721c54bc9bbd" - version = "v1.10.0" - -[[projects]] - name = "github.com/pelletier/go-toml" - packages = ["."] - revision = "acdc4509485b587f5e675510c4f2c63e90ff68a8" - version = "v1.1.0" - -[[projects]] - branch = "v3-unstable" - name = "gopkg.in/alecthomas/kingpin.v3-unstable" - packages = ["."] - revision = "b8d601de6db1f3b56a99ffe9051eb708574bc1cd" - -[[projects]] - name = "gopkg.in/yaml.v2" - packages = ["."] - revision = "7f97868eec74b32b0982dd158a51a446d1da7eb5" - version = "v2.1.1" - -[solve-meta] - analyzer-name = "dep" - analyzer-version = 1 - inputs-digest = "bb8cda576a5c4dda202435f43a46ae50a254181a4bf22c6af6f4d3d03079d509" - solver-name = "gps-cdcl" - solver-version = 1 diff --git a/tools/Gopkg.toml b/tools/Gopkg.toml deleted file mode 100644 index 97fb629752ce..000000000000 --- a/tools/Gopkg.toml +++ /dev/null @@ -1,34 +0,0 @@ -# Gopkg.toml example -# -# Refer to https://github.com/golang/dep/blob/master/docs/Gopkg.toml.md -# for detailed Gopkg.toml documentation. -# -# required = ["github.com/user/thing/cmd/thing"] -# ignored = ["github.com/user/project/pkgX", "bitbucket.org/user/project/pkgA/pkgY"] -# -# [[constraint]] -# name = "github.com/user/project" -# version = "1.0.0" -# -# [[constraint]] -# name = "github.com/user/project2" -# branch = "dev" -# source = "github.com/myfork/project2" -# -# [[override]] -# name = "github.com/x/y" -# version = "2.4.0" -# -# [prune] -# non-go = false -# go-tests = true -# unused-packages = true - -[[constraint]] - name = "github.com/alecthomas/gometalinter" - version = "2.0.5" - -[prune] - go-tests = true - unused-packages = true - diff --git a/tools/Makefile b/tools/Makefile index 41178a2f1a19..c623ba46ff24 100644 --- a/tools/Makefile +++ b/tools/Makefile @@ -1,4 +1,4 @@ -all: install +all: get_tools ######################################## @@ -6,10 +6,10 @@ all: install DEP = github.com/golang/dep/cmd/dep GOLINT = github.com/tendermint/lint/golint -GOMETALINTER = github.com/alecthomas/gometalinter +GOMETALINTER = gopkg.in/alecthomas/gometalinter.v2 DEP_CHECK := $(shell command -v dep 2> /dev/null) GOLINT_CHECK := $(shell command -v golint 2> /dev/null) -GOMETALINTER_CHECK := $(shell command -v gometalinter 2> /dev/null) +GOMETALINTER_CHECK := $(shell command -v gometalinter.v2 2> /dev/null) check_tools: ifndef DEP_CHECK @@ -42,9 +42,9 @@ else go get -v $(GOLINT) endif ifdef GOMETALINTER_CHECK - @echo "Gometalinter is already installed. Run 'make update_tools' to update." + @echo "Gometalinter.v2 is already installed. Run 'make update_tools' to update." else - @echo "Installing gometalinter" + @echo "Installing gometalinter.v2" go get -v $(GOMETALINTER) endif @@ -53,30 +53,10 @@ update_tools: go get -u -v $(DEP) @echo "Updating tendermint/golint" go get -u -v $(GOLINT) - @echo "Updating gometalinter" + @echo "Updating gometalinter.v2" go get -u -v $(GOMETALINTER) - -######################################## -### Install tools - - -get_vendor_deps: check_tools - @rm -rf vendor/ - @echo "--> Running dep ensure" - @dep ensure -v - -install: get_vendor_deps - @echo "Installing tools" - @echo "Install go-vendorinstall" - go build -o bin/go-vendorinstall go-vendorinstall/*.go - - @echo "Install gometalinter.v2" - GOBIN="$(CURDIR)/bin" ./bin/go-vendorinstall github.com/alecthomas/gometalinter - - @echo "Done installing tools" - # To avoid unintended conflicts with file names, always add to .PHONY # unless there is a reason not to. # https://www.gnu.org/software/make/manual/html_node/Phony-Targets.html -.PHONY: check_tools install_tools update_tools get_vendor_deps install +.PHONY: check_tools get_tools update_tools diff --git a/tools/go-vendorinstall/main.go b/tools/go-vendorinstall/main.go deleted file mode 100644 index c42e678f2fbc..000000000000 --- a/tools/go-vendorinstall/main.go +++ /dev/null @@ -1,129 +0,0 @@ -// https://raw.githubusercontent.com/roboll/go-vendorinstall/a3e9f0a5d5861b3bb16b93200b2c359c9846b3c5/main.go - -package main - -import ( - "errors" - "flag" - "fmt" - "io/ioutil" - "os" - "os/exec" - "path/filepath" - "strings" -) - -var ( - source = flag.String("source", "vendor", "source directory") - target = flag.String("target", "", "target directory (defaults to $GOBIN, if not set $GOPATH/bin)") - commands = flag.String("commands", "", "comma separated list of commands to execute after go install in temporary environment") - quiet = flag.Bool("quiet", false, "disable output") -) - -func main() { - flag.Parse() - - packages := flag.Args() - if len(packages) < 1 { - fail(errors.New("no packages: specify a package")) - } - - gopath, err := ioutil.TempDir("", "go-vendorinstall-gopath") - if err != nil { - fail(err) - } - print(fmt.Sprintf("gopath: %s", gopath)) - defer func() { - if err := os.RemoveAll(gopath); err != nil { - fail(err) - } - }() - - if len(*target) == 0 { - if gobin := os.Getenv("GOBIN"); len(gobin) > 0 { - target = &gobin - } else { - bin := fmt.Sprintf("%s/bin", os.Getenv("GOPATH")) - target = &bin - } - } - - gobin, err := filepath.Abs(*target) - if err != nil { - fail(err) - } - print(fmt.Sprintf("gobin: %s", gobin)) - - if err := link(gopath, *source); err != nil { - fail(err) - } - - oldpath := os.Getenv("PATH") - path := fmt.Sprintf("%s%s%s", gobin, string(os.PathListSeparator), os.Getenv("PATH")) - os.Setenv("PATH", fmt.Sprintf("%s%s%s", gobin, string(os.PathListSeparator), os.Getenv("PATH"))) - defer os.Setenv("PATH", oldpath) - - env := []string{fmt.Sprintf("PATH=%s", path), fmt.Sprintf("GOPATH=%s", gopath), fmt.Sprintf("GOBIN=%s", gobin)} - args := append([]string{"install"}, packages...) - if out, err := doexec("go", gopath, args, env); err != nil { - print(string(out)) - fail(err) - } - - if len(*commands) > 0 { - for _, cmd := range strings.Split(*commands, ",") { - split := strings.Split(cmd, " ") - if out, err := doexec(split[0], gopath, split[1:], env); err != nil { - print(string(out)) - fail(err) - } - } - } -} - -func print(msg string) { - if !*quiet { - fmt.Println(msg) - } -} - -func fail(err error) { - fmt.Printf("error: %s", err.Error()) - os.Exit(1) -} - -func link(gopath, source string) error { - srcdir, err := filepath.Abs(source) - if err != nil { - return err - } - - linkto := filepath.Join(gopath, "src") - if err := os.MkdirAll(linkto, 0777); err != nil { - return err - } - - files, err := ioutil.ReadDir(srcdir) - if err != nil { - return err - } - - for _, file := range files { - real := filepath.Join(srcdir, file.Name()) - link := filepath.Join(linkto, file.Name()) - if err := os.Symlink(real, link); err != nil { - return err - } - } - - return nil -} - -func doexec(bin, dir string, args []string, env []string) ([]byte, error) { - print(fmt.Sprintf("%s %s", bin, strings.Join(args, " "))) - cmd := exec.Command(bin, args...) - cmd.Env = env - cmd.Dir = dir - - return cmd.CombinedOutput() -} diff --git a/tools/main.go b/tools/main.go deleted file mode 100644 index 104268010a27..000000000000 --- a/tools/main.go +++ /dev/null @@ -1,11 +0,0 @@ -package main - -// Include dependencies here so dep picks them up -// and installs sub-dependencies. - -// TODO: Ideally this gets auto-imported on dep update. -// Any way to make that happen? -// NOTE: problems with this import because its a main not a lib -// _ "github.com/alecthomas/gometalinter" - -func main() {} From 2ac974751217796597f04d8938343bac90e66cad Mon Sep 17 00:00:00 2001 From: Christopher Goes Date: Fri, 22 Jun 2018 21:39:16 +0200 Subject: [PATCH 2/2] Delete empty folder --- tools/bin/.gitkeep | 0 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 tools/bin/.gitkeep diff --git a/tools/bin/.gitkeep b/tools/bin/.gitkeep deleted file mode 100644 index e69de29bb2d1..000000000000