Skip to content

Commit

Permalink
Run CI on Go 1.21.0 (#57)
Browse files Browse the repository at this point in the history
  • Loading branch information
akshayjshah authored Aug 21, 2023
1 parent 63d2be4 commit 8581189
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 36 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 @@ -36,5 +36,5 @@ jobs:
- name: Lint
# Often, lint & gofmt guidelines depend on the Go version. To prevent
# conflicting guidance, run only 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 @@ -30,6 +30,7 @@ linters:
disable:
- cyclop # covered by gocyclo
- deadcode # abandoned
- depguard # unnecessary for small libraries
- exhaustivestruct # replaced by exhaustruct
- funlen # rely on code review to limit function length
- gocognit # dubious "cognitive overhead" quantification
Expand Down
49 changes: 20 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=$(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
Expand All @@ -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
Expand All @@ -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
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@ func main() {

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, `grpchealth` follows semantic versioning.
Expand Down
4 changes: 1 addition & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@ module connectrpc.com/grpchealth

go 1.19

retract (
v1.1.1 // module cache poisoned, use v1.1.2
)
retract v1.1.1 // module cache poisoned, use v1.1.2

require (
connectrpc.com/connect v1.11.0
Expand Down
1 change: 1 addition & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ connectrpc.com/connect v1.11.0 h1:Av2KQXxSaX4vjqhf5Cl01SX4dqYADQ38eBtr84JSUBk=
connectrpc.com/connect v1.11.0/go.mod h1:3AGaO6RRGMx5IKFfqbe3hvK1NqLosFNP2BxDYTPmNPo=
github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk=
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw=
google.golang.org/protobuf v1.31.0 h1:g0LDEJHgrBl9N9r17Ru3sqWhkIx2NB67okBHPwC7hs8=
Expand Down
2 changes: 1 addition & 1 deletion internal/gen/go/connectext/grpc/health/v1/health.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 8581189

Please sign in to comment.