From 785921700b1286cfb8080403d4ef110ddd6ee9be Mon Sep 17 00:00:00 2001 From: Abhinav Gupta Date: Mon, 11 Nov 2019 12:55:09 -0800 Subject: [PATCH] Migrate to Go modules (#38) This switches goleak to Go modules, at the same time simplifying the CI and build setup. --- .gitignore | 4 ++++ .travis.yml | 24 +++++++++--------------- CHANGELOG.md | 3 ++- Makefile | 42 +++++++++++++++++++++++------------------- README.md | 2 -- glide.lock | 17 ----------------- go.mod | 11 +++++++++++ go.sum | 30 ++++++++++++++++++++++++++++++ scripts/coverage.sh | 12 ------------ tools.go | 28 ++++++++++++++++++++++++++++ 10 files changed, 107 insertions(+), 66 deletions(-) delete mode 100644 glide.lock create mode 100644 go.mod create mode 100644 go.sum delete mode 100755 scripts/coverage.sh create mode 100644 tools.go diff --git a/.gitignore b/.gitignore index 48b8bf9..0fff519 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,5 @@ vendor/ +/bin +/lint.log +/cover.out +/cover.html diff --git a/.travis.yml b/.travis.yml index 359b0a1..b215cef 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,29 +2,23 @@ sudo: false language: go go_import_path: go.uber.org/goleak -go: - - 1.10.x - - 1.11.x - - 1.12.x env: -- TEST=yes + global: + - GO111MODULE=on matrix: include: - go: 1.12.x - env: COVERAGE=yes LINT=yes - -cache: - directories: - - vendor + - go: 1.13.x + env: LINT=1 install: - - make install_deps + - make install script: - - test -z "$TEST" || make test - - test -z "$COVERAGE" || scripts/coverage.sh - - test -z "$LINT" || make install_lint lint + - test -z "$LINT" || make lint + - make test after_success: - - test -z "$COVERAGE" || bash <(curl -s https://codecov.io/bash) + - make cover + - bash <(curl -s https://codecov.io/bash) diff --git a/CHANGELOG.md b/CHANGELOG.md index abc1a3b..4cb7fdc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,7 +5,8 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html). ## [Unreleased] -- No changes yet. +### Changed +- Migrate to Go modules. ## 0.10.0 - Initial release. diff --git a/Makefile b/Makefile index df5bfc7..d419e66 100644 --- a/Makefile +++ b/Makefile @@ -1,36 +1,40 @@ -PACKAGES := $(shell glide nv) -# Many Go tools take file globs or directories as arguments instead of packages. -PACKAGE_FILES ?= *.go $(shell find internal -type f -iname '*.go') +export GOBIN ?= $(shell pwd)/bin -.PHONY: build -build: - go build -i $(PACKAGES) +GOLINT = $(GOBIN)/golint +GO_FILES := $(shell \ + find . '(' -path '*/.*' -o -path './vendor' ')' -prune \ + -o -name '*.go' -print | cut -b3-) -.PHONY: install_deps -install_deps: - glide --version || go get github.com/Masterminds/glide - glide install +.PHONY: build +build: + go build ./... +.PHONY: install +install: + go mod download .PHONY: test test: - go test -v -race $(PACKAGES) + go test -v -race ./... + +.PHONY: cover +cover: + go test -race -coverprofile=cover.out -coverpkg=./... ./... + go tool cover -html=cover.out -o cover.html -.PHONY: install_lint -install_lint: - go get golang.org/x/lint/golint +$(GOLINT): + go install golang.org/x/lint/golint .PHONY: lint -lint: +lint: $(GOLINT) @rm -rf lint.log @echo "Checking formatting..." - @gofmt -d -s $(PACKAGE_FILES) 2>&1 | tee lint.log + @gofmt -d -s $(GO_FILES) 2>&1 | tee lint.log @echo "Checking vet..." - @go vet $(PACKAGES) 2>&1 | tee -a lint.log + @go vet ./... 2>&1 | tee -a lint.log @echo "Checking lint..." - @$(foreach dir,$(PACKAGES),golint $(dir) 2>&1 | tee -a lint.log;) + @$(GOLINT) ./... 2>&1 | tee -a lint.log @echo "Checking for unresolved FIXMEs..." @git grep -i fixme | grep -v -e '^vendor/' -e '^Makefile' | tee -a lint.log @[ ! -s lint.log ] - diff --git a/README.md b/README.md index 48e3e4e..8702de9 100644 --- a/README.md +++ b/README.md @@ -68,5 +68,3 @@ TestLeakyTest failed [ci]: https://travis-ci.com/uber-go/goleak [cov-img]: https://codecov.io/gh/uber-go/goleak/branch/master/graph/badge.svg [cov]: https://codecov.io/gh/uber-go/goleak -[benchmarking suite]: https://github.com/uber-go/goleak/tree/master/benchmarks -[glide.lock]: https://github.com/uber-go/goleak/blob/master/glide.lock diff --git a/glide.lock b/glide.lock deleted file mode 100644 index bafd3be..0000000 --- a/glide.lock +++ /dev/null @@ -1,17 +0,0 @@ -hash: b4576f8060ebfcac0fa8f64e01324a30233a4e49dde3724ada74b9f055a48f91 -updated: 2017-11-14T08:37:48.249991169-08:00 -imports: [] -testImports: -- name: github.com/davecgh/go-spew - version: 6d212800a42e8ab5c146b8ace3490ee17e5225f9 - subpackages: - - spew -- name: github.com/pmezard/go-difflib - version: d8ed2627bdf02c080bf22230dbb337003b7aba2d - subpackages: - - difflib -- name: github.com/stretchr/testify - version: 69483b4bd14f5845b5a1e55bca19e954e827f1d0 - subpackages: - - assert - - require diff --git a/go.mod b/go.mod new file mode 100644 index 0000000..742547a --- /dev/null +++ b/go.mod @@ -0,0 +1,11 @@ +module go.uber.org/goleak + +go 1.13 + +require ( + github.com/kr/pretty v0.1.0 // indirect + github.com/stretchr/testify v1.4.0 + golang.org/x/lint v0.0.0-20190930215403-16217165b5de + golang.org/x/tools v0.0.0-20191108193012-7d206e10da11 // indirect + gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 // indirect +) diff --git a/go.sum b/go.sum new file mode 100644 index 0000000..09b27d7 --- /dev/null +++ b/go.sum @@ -0,0 +1,30 @@ +github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8= +github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI= +github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= +github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= +github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE= +github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= +github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJyk= +github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= +golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= +golang.org/x/lint v0.0.0-20190930215403-16217165b5de h1:5hukYrvBGR8/eNkX5mdUezrA6JiaEZDtJb9Ei+1LlBs= +golang.org/x/lint v0.0.0-20190930215403-16217165b5de/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= +golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= +golang.org/x/tools v0.0.0-20191108193012-7d206e10da11 h1:Yq9t9jnGoR+dBuitxdo9l6Q7xh/zOyNnYUtDKaQ3x0E= +golang.org/x/tools v0.0.0-20191108193012-7d206e10da11/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY= +gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw= +gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= diff --git a/scripts/coverage.sh b/scripts/coverage.sh deleted file mode 100755 index b074ca5..0000000 --- a/scripts/coverage.sh +++ /dev/null @@ -1,12 +0,0 @@ -#!/usr/bin/env bash - -set -e -echo "" > coverage.txt - -for d in $(go list ./...); do - go test -race -coverprofile=profile.out -covermode=atomic $d - if [ -f profile.out ]; then - cat profile.out >> coverage.txt - rm profile.out - fi -done diff --git a/tools.go b/tools.go new file mode 100644 index 0000000..6a87612 --- /dev/null +++ b/tools.go @@ -0,0 +1,28 @@ +// Copyright (c) 2019 Uber Technologies, Inc. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +// +build tools + +package goleak + +import ( + // Tools we use during development. + _ "golang.org/x/lint/golint" +)