github.com/bufbuild/connect-grpchealth-go@v1.1.1/Makefile (about) 1 # See https://tech.davis-hansson.com/p/make/ 2 SHELL := bash 3 .DELETE_ON_ERROR: 4 .SHELLFLAGS := -eu -o pipefail -c 5 .DEFAULT_GOAL := all 6 MAKEFLAGS += --warn-undefined-variables 7 MAKEFLAGS += --no-builtin-rules 8 MAKEFLAGS += --no-print-directory 9 BIN=$(abspath .tmp/bin) 10 COPYRIGHT_YEARS := 2022-2023 11 LICENSE_IGNORE := -e /testdata/ -e internal/proto/connectext/ 12 # Set to use a different compiler. For example, `GO=go1.18rc1 make test`. 13 GO ?= go 14 15 .PHONY: help 16 help: ## Describe useful make targets 17 @grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "%-30s %s\n", $$1, $$2}' 18 19 .PHONY: all 20 all: ## Build, test, and lint (default) 21 $(MAKE) test 22 $(MAKE) lint 23 24 .PHONY: clean 25 clean: ## Delete intermediate build artifacts 26 @# -X only removes untracked files, -d recurses into directories, -f actually removes files/dirs 27 git clean -Xdf 28 29 .PHONY: test 30 test: build ## Run unit tests 31 $(GO) test -vet=off -race -cover ./... 32 33 .PHONY: build 34 build: generate ## Build all packages 35 $(GO) build ./... 36 37 .PHONY: lint 38 lint: $(BIN)/golangci-lint $(BIN)/buf ## Lint Go and protobuf 39 test -z "$$($(BIN)/buf format -d . | tee /dev/stderr)" 40 $(GO) vet ./... 41 $(BIN)/golangci-lint run 42 $(BIN)/buf lint 43 44 .PHONY: lintfix 45 lintfix: $(BIN)/golangci-lint $(BIN)/buf ## Automatically fix some lint errors 46 $(BIN)/golangci-lint run --fix 47 $(BIN)/buf format -w . 48 49 .PHONY: generate 50 generate: $(BIN)/buf $(BIN)/protoc-gen-go $(BIN)/license-header ## Regenerate code and licenses 51 rm -rf internal/gen 52 PATH=$(BIN) $(BIN)/buf generate 53 @# We want to operate on a list of modified and new files, excluding 54 @# deleted and ignored files. git-ls-files can't do this alone. comm -23 takes 55 @# two files and prints the union, dropping lines common to both (-3) and 56 @# those only in the second file (-2). We make one git-ls-files call for 57 @# the modified, cached, and new (--others) files, and a second for the 58 @# deleted files. 59 comm -23 \ 60 <(git ls-files --cached --modified --others --no-empty-directory --exclude-standard | sort -u | grep -v $(LICENSE_IGNORE) ) \ 61 <(git ls-files --deleted | sort -u) | \ 62 xargs $(BIN)/license-header \ 63 --license-type apache \ 64 --copyright-holder "Buf Technologies, Inc." \ 65 --year-range "$(COPYRIGHT_YEARS)" 66 67 .PHONY: upgrade 68 upgrade: ## Upgrade dependencies 69 go get -u -t ./... && go mod tidy -v 70 71 .PHONY: checkgenerate 72 checkgenerate: 73 @# Used in CI to verify that `make generate` doesn't produce a diff. 74 test -z "$$(git status --porcelain | tee /dev/stderr)" 75 76 $(BIN)/buf: Makefile 77 @mkdir -p $(@D) 78 GOBIN=$(abspath $(@D)) $(GO) install github.com/bufbuild/buf/cmd/buf@v1.17.0 79 80 $(BIN)/license-header: Makefile 81 @mkdir -p $(@D) 82 GOBIN=$(abspath $(@D)) $(GO) install \ 83 github.com/bufbuild/buf/private/pkg/licenseheader/cmd/license-header@v1.8.0 84 85 $(BIN)/golangci-lint: Makefile 86 @mkdir -p $(@D) 87 GOBIN=$(abspath $(@D)) $(GO) install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.52.2 88 89 $(BIN)/protoc-gen-go: Makefile 90 @mkdir -p $(@D) 91 GOBIN=$(abspath $(@D)) $(GO) install google.golang.org/protobuf/cmd/protoc-gen-go@v1.30.0