Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update CI dependencies #50

Merged
merged 2 commits into from
Oct 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
go-version: [1.19.x, 1.20.x]
go-version: [1.19.x, 1.20.x, 1.21.x]
steps:
- name: Checkout Code
uses: actions/checkout@v4
Expand All @@ -32,5 +32,5 @@ jobs:
# conflicting guidance, run only on the most recent supported version.
# For the same reason, only check generated code on the most recent
# supported version.
if: matrix.go-version == '1.20.x'
if: matrix.go-version == '1.21.x'
run: make checkgenerate && make lint
1 change: 1 addition & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ linters:
enable-all: true
disable:
- cyclop # covered by gocyclo
- depguard # unnecessary for small libraries
- deadcode # abandoned
- exhaustivestruct # replaced by exhaustruct
- exhaustruct # not helpful, prevents idiomatic struct literals
Expand Down
47 changes: 18 additions & 29 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ MAKEFLAGS += --warn-undefined-variables
MAKEFLAGS += --no-builtin-rules
MAKEFLAGS += --no-print-directory
BIN := .tmp/bin
export PATH := $(BIN):$(PATH)
export GOBIN := $(abspath $(BIN))
COPYRIGHT_YEARS := 2023
LICENSE_IGNORE := -e testdata/
# Set to use a different compiler. For example, `GO=go1.18rc1 make test`.
GO ?= go
LICENSE_IGNORE := --ignore /testdata/

.PHONY: help
help: ## Describe useful make targets
Expand All @@ -28,47 +28,37 @@ 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: generate
generate: $(BIN)/license-header ## Regenerate code and licenses
go mod tidy
@# 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)"
license-header \
--license-type apache \
--copyright-holder "Buf Technologies, Inc." \
--year-range "$(COPYRIGHT_YEARS)" $(LICENSE_IGNORE)

.PHONY: lint
lint: $(BIN)/golangci-lint $(BIN)/checklocks ## Lint
$(GO) vet ./...
$(GO) vet -vettool=$(BIN)/checklocks ./...
$(BIN)/golangci-lint run
go vet ./...
go vet -vettool=$(BIN)/checklocks ./...
golangci-lint run

.PHONY: lintfix
lintfix: $(BIN)/golangci-lint ## Automatically fix some lint errors
$(BIN)/golangci-lint run --fix
golangci-lint run --fix

.PHONY: install
install: ## Install all binaries
$(GO) install ./...
go install ./...

.PHONY: upgrade
upgrade: ## Upgrade dependencies
go get -u -t ./...
go mod tidy -v
go get -u -t ./... && go mod tidy -v

.PHONY: checkgenerate
checkgenerate:
Expand All @@ -77,13 +67,12 @@ checkgenerate:

$(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.0
go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.54.1

$(BIN)/checklocks: Makefile
@mkdir -p $(@D)
GOBIN="$(abspath $(@D))" $(GO) install gvisor.dev/gvisor/tools/checklocks/cmd/[email protected]20230606234206-115cc12055ce
go install gvisor.dev/gvisor/tools/checklocks/cmd/[email protected]20231003185701-9d5198a863bf
2 changes: 1 addition & 1 deletion client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ func TestNewClient_CustomRoundTripper(t *testing.T) {
return RoundTripperResult{
RoundTripper: roundTripperFunc(func(req *http.Request) (*http.Response, error) {
recorder := httptest.NewRecorder()
_, _ = recorder.Write([]byte("foo bar"))
_, _ = recorder.WriteString("foo bar")
return recorder.Result(), nil
}),
}
Expand Down