Skip to content

Commit

Permalink
Include Go 1.21.0 in CI (#566)
Browse files Browse the repository at this point in the history
Include Go 1.21.0 in CI, and update `golangci-lint` to a version that supports the new runtime. Along the way, clean up the Makefile a bit and update some tool dependencies.

As part of this change, we're committing to support for the last 3 versions of Go. This ends up including a version of Go that no longer receives security patches, but it matches AWS and some large companies' very slow upgrade cycles.
  • Loading branch information
akshayjshah authored Aug 16, 2023
1 parent 8aa51de commit 5bfdd3c
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 19 deletions.
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@v3
Expand All @@ -38,5 +38,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
2 changes: 1 addition & 1 deletion .github/workflows/windows.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
runs-on: windows-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@v3
Expand Down
5 changes: 1 addition & 4 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,6 @@ linters-settings:
include:
# No zero values for param structs.
- 'connectrpc\.com/connect\..*[pP]arams'
# No zero values for ClientStream, ServerStream, and friends.
- 'connectrpc\.com/connect\.ClientStream.*'
- 'connectrpc\.com/connect\.ServerStream.*'
- 'connectrpc\.com/connect\.BidiStream.*'
forbidigo:
forbid:
- '^fmt\.Print'
Expand Down Expand Up @@ -38,6 +34,7 @@ linters:
enable-all: true
disable:
- cyclop # covered by gocyclo
- depguard # unnecessary for small libraries
- deadcode # abandoned
- exhaustivestruct # replaced by exhaustruct
- funlen # rely on code review to limit function length
Expand Down
23 changes: 12 additions & 11 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ 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 := 2021-2023
LICENSE_IGNORE := --ignore /testdata/
# Set to use a different compiler. For example, `GO=go1.18rc1 make test`.
Expand Down Expand Up @@ -42,20 +44,20 @@ install: ## Install all binaries
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
$(BIN)/buf format -d --exit-code
golangci-lint run
buf lint
buf format -d --exit-code

.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)/protoc-gen-connect-go $(BIN)/license-header ## Regenerate code and licenses
rm -rf internal/gen
PATH="$(abspath $(BIN))" $(BIN)/buf generate
$(BIN)/license-header \
license-header \
--license-type apache \
--copyright-holder "Buf Technologies, Inc." \
--year-range "$(COPYRIGHT_YEARS)" $(LICENSE_IGNORE)
Expand All @@ -76,19 +78,18 @@ $(BIN)/protoc-gen-connect-go:

$(BIN)/buf: Makefile
@mkdir -p $(@D)
GOBIN="$(abspath $(@D))" $(GO) install github.com/bufbuild/buf/cmd/[email protected]
$(GO) install github.com/bufbuild/buf/cmd/[email protected]

$(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 go.mod
@mkdir -p $(@D)
@# The version of protoc-gen-go is determined by the version in go.mod
GOBIN="$(abspath $(@D))" $(GO) install google.golang.org/protobuf/cmd/protoc-gen-go
$(GO) install google.golang.org/protobuf/cmd/protoc-gen-go

3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,8 @@ configuring timeouts, connection pools, observability, and h2c.

This module is stable. It supports:

* The [two most recent major releases][go-support-policy] of Go.
* The three most recent major releases of Go. Keep in mind that [only the last
two releases receive security patches][go-support-policy].
* [APIv2] of Protocol Buffers in Go (`google.golang.org/protobuf`).

Within those parameters, `connect` follows semantic versioning. We will
Expand Down

0 comments on commit 5bfdd3c

Please sign in to comment.