From c35ba9227081d3767edfb5ad5f1d5e8390e592be Mon Sep 17 00:00:00 2001 From: Akshay Shah Date: Tue, 3 Oct 2023 17:01:58 -0700 Subject: [PATCH] Update CI dependencies (#50) --- .github/workflows/ci.yaml | 4 ++-- .golangci.yml | 1 + Makefile | 47 +++++++++++++++------------------------ client_test.go | 2 +- 4 files changed, 22 insertions(+), 32 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index e29a008..8ddd15e 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -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 @@ -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 diff --git a/.golangci.yml b/.golangci.yml index 0adcf5a..d6b2014 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -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 diff --git a/Makefile b/Makefile index 09294d4..4fdc7e8 100644 --- a/Makefile +++ b/Makefile @@ -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 @@ -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: @@ -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/license-header@v1.12.0 + go install github.com/bufbuild/buf/private/pkg/licenseheader/cmd/license-header@v1.26.1 $(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/checklocks@v0.0.0-20230606234206-115cc12055ce + go install gvisor.dev/gvisor/tools/checklocks/cmd/checklocks@v0.0.0-20231003185701-9d5198a863bf diff --git a/client_test.go b/client_test.go index 6a20f5b..09e4b34 100644 --- a/client_test.go +++ b/client_test.go @@ -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 }), }