-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
63d2be4
commit 8581189
Showing
7 changed files
with
28 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,10 +7,10 @@ MAKEFLAGS += --warn-undefined-variables | |
MAKEFLAGS += --no-builtin-rules | ||
MAKEFLAGS += --no-print-directory | ||
BIN=$(abspath .tmp/bin) | ||
export PATH := $(BIN):$(PATH) | ||
export GOBIN := $(abspath $(BIN)) | ||
COPYRIGHT_YEARS := 2022-2023 | ||
LICENSE_IGNORE := -e /testdata/ -e internal/proto/connectext/ | ||
# Set to use a different compiler. For example, `GO=go1.18rc1 make test`. | ||
GO ?= go | ||
LICENSE_IGNORE := --ignore /testdata/ --ignore internal/proto/connectext/ | ||
|
||
.PHONY: help | ||
help: ## Describe useful make targets | ||
|
@@ -28,41 +28,32 @@ clean: ## Delete intermediate build artifacts | |
|
||
.PHONY: test | ||
test: build ## Run unit tests | ||
$(GO) test -vet=off -race -cover ./... | ||
go test -vet=off -race -cover ./... | ||
|
||
.PHONY: build | ||
build: generate ## Build all packages | ||
$(GO) build ./... | ||
go build ./... | ||
|
||
.PHONY: lint | ||
lint: $(BIN)/golangci-lint $(BIN)/buf ## Lint Go and protobuf | ||
test -z "$$($(BIN)/buf format -d . | tee /dev/stderr)" | ||
$(GO) vet ./... | ||
$(BIN)/golangci-lint run | ||
$(BIN)/buf lint | ||
go vet ./... | ||
golangci-lint run | ||
buf lint | ||
|
||
.PHONY: lintfix | ||
lintfix: $(BIN)/golangci-lint $(BIN)/buf ## Automatically fix some lint errors | ||
$(BIN)/golangci-lint run --fix | ||
$(BIN)/buf format -w . | ||
golangci-lint run --fix | ||
buf format -w . | ||
|
||
.PHONY: generate | ||
generate: $(BIN)/buf $(BIN)/protoc-gen-go $(BIN)/license-header ## Regenerate code and licenses | ||
rm -rf internal/gen | ||
PATH=$(BIN) $(BIN)/buf generate | ||
@# We want to operate on a list of modified and new files, excluding | ||
@# deleted and ignored files. git-ls-files can't do this alone. comm -23 takes | ||
@# two files and prints the union, dropping lines common to both (-3) and | ||
@# those only in the second file (-2). We make one git-ls-files call for | ||
@# the modified, cached, and new (--others) files, and a second for the | ||
@# deleted files. | ||
comm -23 \ | ||
<(git ls-files --cached --modified --others --no-empty-directory --exclude-standard | sort -u | grep -v $(LICENSE_IGNORE) ) \ | ||
<(git ls-files --deleted | sort -u) | \ | ||
xargs $(BIN)/license-header \ | ||
--license-type apache \ | ||
--copyright-holder "Buf Technologies, Inc." \ | ||
--year-range "$(COPYRIGHT_YEARS)" | ||
PATH=$(abspath $(BIN)) buf generate | ||
license-header \ | ||
--license-type apache \ | ||
--copyright-holder "Buf Technologies, Inc." \ | ||
--year-range "$(COPYRIGHT_YEARS)" $(LICENSE_IGNORE) | ||
|
||
.PHONY: upgrade | ||
upgrade: ## Upgrade dependencies | ||
|
@@ -75,17 +66,17 @@ checkgenerate: | |
|
||
$(BIN)/buf: Makefile | ||
@mkdir -p $(@D) | ||
GOBIN=$(abspath $(@D)) $(GO) install github.com/bufbuild/buf/cmd/buf@v1.17.0 | ||
go install github.com/bufbuild/buf/cmd/buf@v1.26.1 | ||
|
||
$(BIN)/license-header: Makefile | ||
@mkdir -p $(@D) | ||
GOBIN=$(abspath $(@D)) $(GO) install \ | ||
github.com/bufbuild/buf/private/pkg/licenseheader/cmd/[email protected] | ||
go install github.com/bufbuild/buf/private/pkg/licenseheader/cmd/[email protected] | ||
|
||
$(BIN)/golangci-lint: Makefile | ||
@mkdir -p $(@D) | ||
GOBIN=$(abspath $(@D)) $(GO) install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.52.2 | ||
go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.54.1 | ||
|
||
$(BIN)/protoc-gen-go: Makefile | ||
@mkdir -p $(@D) | ||
GOBIN=$(abspath $(@D)) $(GO) install google.golang.org/protobuf/cmd/[email protected] | ||
@# The version of protoc-gen-go is determined by the version in go.mod | ||
go install google.golang.org/protobuf/cmd/protoc-gen-go |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.