Skip to content
Open
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
25 changes: 25 additions & 0 deletions .github/workflows/check-gen-dep.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: Check generated SDK dependency
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like this idea. One suggestion: instead of exit 1 (which shows a red X and looks like broken CI), consider using the GitHub Checks API with an action_required conclusion. This still blocks merging when set as a required check, but shows as a distinct warning rather than a failure. Making it clear this is "waiting on upstream" not "something is broken."

Rough sketch:

- name: Check for zeroed-out version
  uses: actions/github-script@v7
  with:
    script: |
      const gomod = require('fs').readFileSync('go.mod', 'utf8');
      const zeroed = /buf\.build\/gen\/go\/bufbuild\/protovalidate\/protocolbuffers\/go.*00000000000000/.test(gomod);
      if (zeroed) {
        await github.rest.checks.create({
          owner: context.repo.owner,
          repo: context.repo.repo,
          name: 'Upstream dependency check',
          head_sha: context.sha,
          status: 'completed',
          conclusion: 'action_required',
          output: {
            title: 'Waiting for upstream protovalidate merge',
            summary: '`go.mod` has a zeroed-out pseudo-version. Update `PROTOVALIDATE_VERSION` once the upstream PR is merged and re-run `make sync-upstream`.'
          },
          details_url: 'https://github.com/bufbuild/protovalidate/pulls'
        });
      }

on:
push:
branches: [main]
pull_request:
branches: [main]

permissions:
contents: read

jobs:
check:
name: Check gen dependency version
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v6
with:
fetch-depth: 1
- name: Check for zeroed-out version
run: |
if grep -q 'buf.build/gen/go/bufbuild/protovalidate/protocolbuffers/go.*00000000000000' go.mod; then
echo "::error::buf.build/gen/go/bufbuild/protovalidate/protocolbuffers/go has a zeroed-out pseudo-version in go.mod. This happens when depending on a non-main version of protovalidate. Update PROTOVALIDATE_VERSION in the Makefile to a release or commit on the main branch of protovalidate and run 'make sync-upstream'."
exit 1
fi
22 changes: 15 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,19 @@ LICENSE_IGNORE := -e internal/testdata/
GO ?= go
ARGS ?= --strict_message --strict_error
GOLANGCI_LINT_VERSION ?= v2.9.0
# Set to use a different version of protovalidate-conformance.
# Should be kept in sync with the version referenced in buf.yaml and
# 'buf.build/gen/go/bufbuild/protovalidate/protocolbuffers/go' in go.mod.
CONFORMANCE_VERSION ?= v1.1.0
# Set the protovalidate version, can be a commit, branch, or tag
PROTOVALIDATE_VERSION ?= 8b6fa0a9cbff5b0e600f1d2a3024e135b5594db7
PROTOVALIDATE_PROTO_VERSION := $(shell PATH="$(abspath $(BIN)):$(PATH)" ./make/scripts/resolve_bsr_commit.sh buf.build/bufbuild/protovalidate $(PROTOVALIDATE_VERSION))
PROTOVALIDATE_TESTING_PROTO_VERSION := $(shell PATH="$(abspath $(BIN)):$(PATH)" ./make/scripts/resolve_bsr_commit.sh buf.build/bufbuild/protovalidate-testing $(PROTOVALIDATE_VERSION))
PROTOBUF_GO_VERSION := $(shell go list -json -m google.golang.org/protobuf | jq -r '.Version')
PROTOVALIDATE_GEN_SDK_VERSION := $(shell buf registry sdk version --module=buf.build/bufbuild/protovalidate:$(PROTOVALIDATE_PROTO_VERSION) --plugin=buf.build/protocolbuffers/go:$(PROTOBUF_GO_VERSION))

.PHONY: help
help: ## Describe useful make targets
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "%-15s %s\n", $$1, $$2}'

.PHONY: all
all: generate test conformance lint ## Generate and run all tests and lint (default)
all: sync-upstream generate test conformance lint ## Generate and run all tests and lint (default)

.PHONY: clean
clean: ## Delete intermediate build artifacts
Expand Down Expand Up @@ -72,9 +74,15 @@ generate: generate-proto generate-license ## Regenerate code and license headers
.PHONY: generate-proto
generate-proto: $(BIN)/buf
rm -rf internal/gen/*/
$(BIN)/buf generate buf.build/bufbuild/protovalidate-testing:$(CONFORMANCE_VERSION)
$(BIN)/buf generate buf.build/bufbuild/protovalidate-testing:$(PROTOVALIDATE_TESTING_PROTO_VERSION)
$(BIN)/buf generate

.PHONY: sync-upstream
sync-upstream:
yq -i '(.deps[] | select(. == "buf.build/bufbuild/protovalidate:*")) = "buf.build/bufbuild/protovalidate:$(PROTOVALIDATE_PROTO_VERSION)"' buf.yaml
buf dep update
go get buf.build/gen/go/bufbuild/protovalidate/protocolbuffers/go@$(PROTOVALIDATE_GEN_SDK_VERSION)

.PHONY: generate-license
generate-license: $(BIN)/license-header
@# We want to operate on a list of modified and new files, excluding
Expand Down Expand Up @@ -132,7 +140,7 @@ $(BIN)/golangci-lint: $(BIN) Makefile

$(BIN)/protovalidate-conformance: $(BIN) Makefile
GOBIN=$(abspath $(BIN)) $(GO) install \
github.com/bufbuild/protovalidate/tools/protovalidate-conformance@$(CONFORMANCE_VERSION)
github.com/bufbuild/protovalidate/tools/protovalidate-conformance@$(PROTOVALIDATE_VERSION)

.PHONY: protovalidate-conformance-go
protovalidate-conformance-go: $(BIN)
Expand Down
4 changes: 2 additions & 2 deletions buf.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
version: v2
deps:
- name: buf.build/bufbuild/protovalidate
commit: 2a1774d888024a9b93ce7eb4b59f6a83
digest: b5:6b7f9bc919b65e5b79d7b726ffc03d6f815a412d6b792970fa6f065cae162107bd0a9d47272c8ab1a2c9514e87b13d3fbf71df614374d62d2183afb64be2d30a
commit: 5dcec42a7ef94f16ac710abcd02271f7
digest: b5:ac3cd336344af698d3f81aafad90a360cbd650788f019677a65629d6032c8f50bb29530af67b6ffdac08f026fb4453a3674b8bdf229ba278e2fbfc22489dc024
- name: buf.build/rodaine/protogofakeit
commit: 9caf0fc578d3413590962a1764b81b94
digest: b5:eeead7373f2f598ebc8f91aa3a68d6b50630076341d875b22dc6760126bc56c82cf1e98f5a2eff9815ba55fa48ab81745c93a5aeefd5e4697bf43c9ea4694735
3 changes: 2 additions & 1 deletion buf.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ version: v2
modules:
- path: proto
deps:
- buf.build/bufbuild/protovalidate:v1.1.0
# DO NOT EDIT. This is set via make.
- buf.build/bufbuild/protovalidate:5dcec42a7ef94f16ac710abcd02271f7
- buf.build/rodaine/protogofakeit
lint:
use:
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module buf.build/go/protovalidate
go 1.24.0

require (
buf.build/gen/go/bufbuild/protovalidate/protocolbuffers/go v1.36.11-20260209202127-80ab13bee0bf.1
buf.build/gen/go/bufbuild/protovalidate/protocolbuffers/go v1.36.11-00000000000000-5dcec42a7ef9.1
buf.build/go/hyperpb v0.1.3
github.com/brianvoe/gofakeit/v6 v6.28.0
github.com/google/cel-go v0.27.0
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
buf.build/gen/go/bufbuild/hyperpb-examples/protocolbuffers/go v1.36.7-20250725192734-0dd56aa9cbbc.1 h1:bFnppdLYActzr2F0iomSrkjUnGgVufb0DtZxjKgTLGc=
buf.build/gen/go/bufbuild/hyperpb-examples/protocolbuffers/go v1.36.7-20250725192734-0dd56aa9cbbc.1/go.mod h1:x7jYNX5/7EPnsKHEq596krkOGzvR97/MsZw2fw3Mrq0=
buf.build/gen/go/bufbuild/protovalidate/protocolbuffers/go v1.36.11-20260209202127-80ab13bee0bf.1 h1:PMmTMyvHScV9Mn8wc6ASge9uRcHy0jtqPd+fM35LmsQ=
buf.build/gen/go/bufbuild/protovalidate/protocolbuffers/go v1.36.11-20260209202127-80ab13bee0bf.1/go.mod h1:tvtbpgaVXZX4g6Pn+AnzFycuRK3MOz5HJfEGeEllXYM=
buf.build/gen/go/bufbuild/protovalidate/protocolbuffers/go v1.36.11-00000000000000-5dcec42a7ef9.1 h1:yAgJbCjF8l3uAD3cBNJydUWYxEMa8q22BGofzt8IbiQ=
buf.build/gen/go/bufbuild/protovalidate/protocolbuffers/go v1.36.11-00000000000000-5dcec42a7ef9.1/go.mod h1:tvtbpgaVXZX4g6Pn+AnzFycuRK3MOz5HJfEGeEllXYM=
buf.build/go/hyperpb v0.1.3 h1:wiw2F7POvAe2VA2kkB0TAsFwj91lXbFrKM41D3ZgU1w=
buf.build/go/hyperpb v0.1.3/go.mod h1:IHXAM5qnS0/Fsnd7/HGDghFNvUET646WoHmq1FDZXIE=
cel.dev/expr v0.25.1 h1:1KrZg61W6TWSxuNZ37Xy49ps13NUovb66QLprthtwi4=
Expand Down

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

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

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

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

Loading
Loading