Skip to content

Commit

Permalink
Fix protoschema-plugins build
Browse files Browse the repository at this point in the history
The build failed as the buf.gen.yaml file didn't pin to a specific
plugin version, which caused generation checks to fail as the generated
code updated since the latest time it was run.

Other minor fixes:
- Enable dependabot for Go modules.
- Update to go 1.23.
- Update golangci-lint.
- Pin the buf CLI version used in the Makefile for reproducible builds.
- Update the 'upgrade' make target to only update direct dependencies
  and update the protocolbuffers/go plugin in buf.gen.yaml to match the
  version found in go.mod.
- Regenerate the protobuf code and golden input (it changed after
  upgrading protovalidate).
  • Loading branch information
pkwarren committed Dec 12, 2024
1 parent 587beba commit a8ac9ee
Show file tree
Hide file tree
Showing 13 changed files with 146 additions and 218 deletions.
4 changes: 4 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,7 @@ updates:
directory: "/"
schedule:
interval: "weekly"
- package-ecosystem: "gomod"
directory: "/"
schedule:
interval: "weekly"
6 changes: 1 addition & 5 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,6 @@ permissions:
jobs:
ci:
runs-on: ubuntu-latest
strategy:
matrix:
go-version: [1.22.x, 1.23.x]
steps:
- name: Checkout Code
uses: actions/checkout@v4
Expand All @@ -24,13 +21,12 @@ jobs:
- name: Install Go
uses: actions/setup-go@v5
with:
go-version: ${{ matrix.go-version }}
go-version: '1.23.x'
- name: Test
run: make test
- name: Lint
# Often, lint & gofmt guidelines depend on the Go version. To prevent
# 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.23.x'
run: make checkgenerate && make lint
5 changes: 1 addition & 4 deletions .github/workflows/windows.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,6 @@ permissions:
jobs:
ci:
runs-on: windows-latest
strategy:
matrix:
go-version: [1.22.x]
steps:
- name: Checkout Code
uses: actions/checkout@v4
Expand All @@ -22,7 +19,7 @@ jobs:
- name: Install Go
uses: actions/setup-go@v5
with:
go-version: ${{ matrix.go-version }}
go-version: '1.23.x'
- id: go-cache-paths
shell: bash
run: |
Expand Down
3 changes: 1 addition & 2 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,13 @@ linters:
- cyclop # covered by gocyclo
- depguard
- exhaustive
- execinquery # deprecated in golangci v1.58
- exhaustruct
- exportloopref # deprecated since v1.60.2
- funlen # rely on code review to limit function length
- gochecknoglobals # globals are fine
- gocognit # dubious "cognitive overhead" quantification
- gofumpt # prefer standard gofmt
- goimports # rely on gci instead
- gomnd # deprecated in golangci v1.58 in favor of mnd
- mnd # some unnamed constants are okay
- ireturn # "accept interfaces, return structs" isn't ironclad
- lll # don't want hard limits for line length
Expand Down
31 changes: 25 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,22 @@ MAKEFLAGS += --no-print-directory
BIN := .tmp/bin
export PATH := $(BIN):$(PATH)
export GOBIN := $(abspath $(BIN))
BUF_VERSION = $(shell go list -m -f '{{.Version}}' github.com/bufbuild/buf)
COPYRIGHT_YEARS := 2024
GOLANGCI_LINT_VERSION := v1.62.2
LICENSE_IGNORE := --ignore testdata/

UNAME_OS := $(shell uname -s)
ifeq ($(UNAME_OS),Darwin)
# Explicitly use the "BSD" sed shipped with Darwin. Otherwise if the user has a
# different sed (such as gnu-sed) on their PATH this will fail in an opaque
# manner. /usr/bin/sed can only be modified if SIP is disabled, so this should
# be relatively safe.
SED_I := /usr/bin/sed -i ''
else
SED_I := sed -i
endif

.PHONY: help
help: ## Describe useful make targets
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "%-30s %s\n", $$1, $$2}'
Expand Down Expand Up @@ -70,9 +83,15 @@ generate: $(BIN)/license-header $(BIN)/buf ## Regenerate code and licenses

.PHONY: upgrade
upgrade: ## Upgrade dependencies
go get -u -t ./...
go mod tidy -v
buf mod update internal/proto
@UPDATE_PKGS=$$(go list -u -f '{{if and .Update (not (or .Main .Indirect .Replace))}}{{.Path}}@{{.Update.Version}}{{end}}' -m all); \
if [[ -n "$${UPDATE_PKGS}" ]]; then \
go get $${UPDATE_PKGS}; \
go mod tidy -v; \
fi
buf dep update internal/proto
# Update protobuf version to match version in go.mod after upgrade
PROTOBUF_VERSION=$$(go list -m -f '{{.Version}}' google.golang.org/protobuf); \
$(SED_I) -e "s|buf.build/protocolbuffers/go:.*|buf.build/protocolbuffers/go:$${PROTOBUF_VERSION}|" buf.gen.yaml

.PHONY: checkgenerate
checkgenerate:
Expand All @@ -83,13 +102,13 @@ $(BIN):
@mkdir -p $(BIN)

$(BIN)/buf: $(BIN) Makefile
go install github.com/bufbuild/buf/cmd/buf@latest
go install github.com/bufbuild/buf/cmd/buf@$(BUF_VERSION)

$(BIN)/license-header: $(BIN) Makefile
go install github.com/bufbuild/buf/private/pkg/licenseheader/cmd/license-header@latest
go install github.com/bufbuild/buf/private/pkg/licenseheader/cmd/license-header@$(BUF_VERSION)

$(BIN)/golangci-lint: $(BIN) Makefile
go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.60.0
go install github.com/golangci/golangci-lint/cmd/golangci-lint@$(GOLANGCI_LINT_VERSION)

$(BIN)/jv: $(BIN) Makefile
go install github.com/santhosh-tekuri/jsonschema/cmd/jv@latest
4 changes: 2 additions & 2 deletions buf.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
version: v2
deps:
- name: buf.build/bufbuild/protovalidate
commit: 46a4cf4ba1094a34bcd89a6c67163b4b
digest: b5:2076a950fdf4a8047064d55fd1d20ef21e6d745bf56e3edf557071abd4488ed48c9466d60831d8a03489dc1fcc8ceaa073d197411b59ecd873e28b1328034e0b
commit: a3320276596649bcad929ac829d451f4
digest: b5:285a6d3a423b195a21f45aacc97ee222ac09cfb01a42f0d546aa51d92177b0b9d00eb9ae93e72dabbbefdc77f35a4c7a11f15d913cc08da764fcb6071f85d148
43 changes: 20 additions & 23 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,37 +1,34 @@
module github.com/bufbuild/protoschema-plugins

go 1.22
go 1.23.0

require (
buf.build/gen/go/bufbuild/protovalidate/protocolbuffers/go v1.34.2-20240508200655-46a4cf4ba109.2
github.com/bufbuild/buf v1.34.0
github.com/bufbuild/protoplugin v0.0.0-20240323223605-e2735f6c31ee
github.com/jhump/protoreflect v1.16.0
github.com/stretchr/testify v1.9.0
google.golang.org/protobuf v1.34.2
buf.build/gen/go/bufbuild/protovalidate/protocolbuffers/go v1.35.2-20241127180247-a33202765966.1
github.com/bufbuild/buf v1.47.2
github.com/bufbuild/protoplugin v0.0.0-20240911180120-7bb73e41a54a
github.com/jhump/protoreflect v1.17.0
github.com/stretchr/testify v1.10.0
google.golang.org/protobuf v1.35.2
)

require (
buf.build/go/protoyaml v0.2.0 // indirect
cel.dev/expr v0.18.0 // indirect
github.com/antlr4-go/antlr/v4 v4.13.1 // indirect
github.com/bufbuild/protocompile v0.14.0 // indirect
github.com/bufbuild/protovalidate-go v0.6.2 // indirect
github.com/bufbuild/protoyaml-go v0.1.9 // indirect
github.com/bufbuild/protocompile v0.14.1 // indirect
github.com/bufbuild/protovalidate-go v0.7.3-0.20241015162221-1446f1e1d576 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/gofrs/uuid/v5 v5.2.0 // indirect
github.com/golang/protobuf v1.5.4 // indirect
github.com/google/cel-go v0.20.1 // indirect
github.com/google/cel-go v0.22.0 // indirect
github.com/google/uuid v1.6.0 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/stoewer/go-strcase v1.3.0 // indirect
go.opentelemetry.io/otel v1.27.0 // indirect
go.opentelemetry.io/otel/trace v1.27.0 // indirect
go.uber.org/atomic v1.11.0 // indirect
go.uber.org/multierr v1.11.0 // indirect
golang.org/x/crypto v0.24.0 // indirect
golang.org/x/exp v0.0.0-20240613232115-7f521ea00fb8 // indirect
golang.org/x/sync v0.7.0 // indirect
golang.org/x/sys v0.21.0 // indirect
golang.org/x/text v0.16.0 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20240624140628-dc46fd24d27d // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240624140628-dc46fd24d27d // indirect
golang.org/x/crypto v0.29.0 // indirect
golang.org/x/exp v0.0.0-20241108190413-2d47ceb2692f // indirect
golang.org/x/sync v0.9.0 // indirect
golang.org/x/sys v0.27.0 // indirect
golang.org/x/text v0.20.0 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20241104194629-dd2ea8efbc28 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20241104194629-dd2ea8efbc28 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
Loading

0 comments on commit a8ac9ee

Please sign in to comment.