Scott Baker | 1fe7273 | 2019-10-21 10:58:51 -0700 | [diff] [blame] | 1 | dev_build_version=$(shell git describe --tags --always --dirty) |
| 2 | |
| 3 | # TODO: run golint and errcheck, but only to catch *new* violations and |
| 4 | # decide whether to change code or not (e.g. we need to be able to whitelist |
| 5 | # violations already in the code). They can be useful to catch errors, but |
| 6 | # they are just too noisy to be a requirement for a CI -- we don't even *want* |
| 7 | # to fix some of the things they consider to be violations. |
| 8 | .PHONY: ci |
| 9 | ci: deps checkgofmt vet staticcheck ineffassign predeclared test |
| 10 | |
| 11 | .PHONY: deps |
| 12 | deps: |
| 13 | go get -d -v -t ./... |
| 14 | |
| 15 | .PHONY: updatedeps |
| 16 | updatedeps: |
| 17 | go get -d -v -t -u -f ./... |
| 18 | |
| 19 | .PHONY: install |
| 20 | install: |
| 21 | go install -ldflags '-X "main.version=dev build $(dev_build_version)"' ./... |
| 22 | |
| 23 | .PHONY: release |
| 24 | release: |
| 25 | @GO111MODULE=off go get github.com/goreleaser/goreleaser |
| 26 | goreleaser --rm-dist |
| 27 | |
| 28 | .PHONY: docker |
| 29 | docker: |
| 30 | @echo $(dev_build_version) > VERSION |
| 31 | docker build -t fullstorydev/grpcurl:$(dev_build_version) . |
| 32 | @rm VERSION |
| 33 | |
| 34 | .PHONY: checkgofmt |
| 35 | checkgofmt: |
| 36 | gofmt -s -l . |
| 37 | @if [ -n "$$(gofmt -s -l .)" ]; then \ |
| 38 | exit 1; \ |
| 39 | fi |
| 40 | |
| 41 | .PHONY: vet |
| 42 | vet: |
| 43 | go vet ./... |
| 44 | |
| 45 | # TODO: remove the ignored check; need it for now because it |
| 46 | # is complaining about a deprecated comment added to grpc, |
| 47 | # but it's not yet released. Once the new (non-deprecated) |
| 48 | # API is included in a release, we can move to that new |
| 49 | # version and fix the call site to no longer use deprecated |
| 50 | # method. |
| 51 | # This all works fine with Go modules, but without modules, |
| 52 | # CI is just getting latest master for dependencies like grpc. |
| 53 | .PHONY: staticcheck |
| 54 | staticcheck: |
| 55 | @go get honnef.co/go/tools/cmd/staticcheck |
| 56 | staticcheck ./... |
| 57 | |
| 58 | .PHONY: ineffassign |
| 59 | ineffassign: |
| 60 | @go get github.com/gordonklaus/ineffassign |
| 61 | ineffassign . |
| 62 | |
| 63 | .PHONY: predeclared |
| 64 | predeclared: |
| 65 | @go get github.com/nishanths/predeclared |
| 66 | predeclared . |
| 67 | |
| 68 | # Intentionally omitted from CI, but target here for ad-hoc reports. |
| 69 | .PHONY: golint |
| 70 | golint: |
| 71 | @go get golang.org/x/lint/golint |
| 72 | golint -min_confidence 0.9 -set_exit_status ./... |
| 73 | |
| 74 | # Intentionally omitted from CI, but target here for ad-hoc reports. |
| 75 | .PHONY: errcheck |
| 76 | errcheck: |
| 77 | @go get github.com/kisielk/errcheck |
| 78 | errcheck ./... |
| 79 | |
| 80 | .PHONY: test |
| 81 | test: |
| 82 | go test -race ./... |