Zack Williams | e940c7a | 2019-08-21 14:25:39 -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: checkgofmt |
| 29 | checkgofmt: |
| 30 | gofmt -s -l . |
| 31 | @if [ -n "$$(gofmt -s -l .)" ]; then \ |
| 32 | exit 1; \ |
| 33 | fi |
| 34 | |
| 35 | .PHONY: vet |
| 36 | vet: |
| 37 | go vet ./... |
| 38 | |
| 39 | # TODO: remove the ignored check; need it for now because it |
| 40 | # is complaining about a deprecated comment added to grpc, |
| 41 | # but it's not yet released. Once the new (non-deprecated) |
| 42 | # API is included in a release, we can move to that new |
| 43 | # version and fix the call site to no longer use deprecated |
| 44 | # method. |
| 45 | # This all works fine with Go modules, but without modules, |
| 46 | # CI is just getting latest master for dependencies like grpc. |
| 47 | .PHONY: staticcheck |
| 48 | staticcheck: |
| 49 | @go get honnef.co/go/tools/cmd/staticcheck |
| 50 | staticcheck ./... |
| 51 | |
| 52 | .PHONY: ineffassign |
| 53 | ineffassign: |
| 54 | @go get github.com/gordonklaus/ineffassign |
| 55 | ineffassign . |
| 56 | |
| 57 | .PHONY: predeclared |
| 58 | predeclared: |
| 59 | @go get github.com/nishanths/predeclared |
| 60 | predeclared . |
| 61 | |
| 62 | # Intentionally omitted from CI, but target here for ad-hoc reports. |
| 63 | .PHONY: golint |
| 64 | golint: |
| 65 | @go get golang.org/x/lint/golint |
| 66 | golint -min_confidence 0.9 -set_exit_status ./... |
| 67 | |
| 68 | # Intentionally omitted from CI, but target here for ad-hoc reports. |
| 69 | .PHONY: errcheck |
| 70 | errcheck: |
| 71 | @go get github.com/kisielk/errcheck |
| 72 | errcheck ./... |
| 73 | |
| 74 | .PHONY: test |
| 75 | test: |
| 76 | go test -race ./... |