Skip to content

Commit 94c5dff

Browse files
Split gencode into a publishable subpackage and a part only needed for unit tests
1 parent 223313e commit 94c5dff

File tree

106 files changed

+15876
-24
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

106 files changed

+15876
-24
lines changed

Makefile

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,32 @@ clean: ## Delete intermediate build artifacts
3535
git clean -Xdf
3636

3737
.PHONY: generate
38-
generate: $(BIN)/buf $(BIN)/license-header ## Regenerate code and license headers
39-
rm -rf gen
40-
$(BIN)/buf generate buf.build/bufbuild/protovalidate:$(PROTOVALIDATE_VERSION)
38+
generate: generate-protovalidate-pypi-package generate-protobuf-tests $(BIN)/license-header ## Regenerate code and license headers
39+
$(ADD_LICENSE_HEADER)
40+
41+
.PHONY: generate-protobuf-tests
42+
generate-protobuf-tests: $(BIN)/buf ## Regenerate protobuf gencode used in unit tests
43+
rm -rf test/gen
44+
# generate protovalidate-testing into test/gen/buf/validate
4145
$(BIN)/buf generate buf.build/bufbuild/protovalidate-testing:$(PROTOVALIDATE_VERSION)
46+
47+
# generate cel-spec into test/gen/cel/expr
4248
$(BIN)/buf generate buf.build/google/cel-spec:$(CEL_SPEC_VERSION) --exclude-path cel/expr/conformance/proto2 --exclude-path cel/expr/conformance/proto3
49+
# we need to update the `from cel.expr` imports in those generated files to `from test.gen.cel.expr`
50+
LC_ALL=C find test/gen/cel -type f -exec sed -i "" 's/from cel.expr/from test.gen.cel.expr/g' {} +
51+
52+
# generate proto/tests/example/v1/validations.proto into test/gen/tests/example/v1
4353
$(BIN)/buf generate
44-
$(ADD_LICENSE_HEADER)
54+
55+
.PHONY:
56+
generate-protovalidate-pypi-package: $(BIN)/buf ## Regenerate protobuf gencode for the bufbuild-protovalidate-protocolbuffers pypi package
57+
rm -rf bufbuild-protovalidate-protocolbuffers/buf/validate/proto5
58+
rm -rf bufbuild-protovalidate-protocolbuffers/buf/validate/proto6
59+
# generate gencode for both proto5 and proto6 for buf.build/bufbuild/protovalidate
60+
cd bufbuild-protovalidate-protocolbuffers && ../$(BIN)/buf generate buf.build/bufbuild/protovalidate:$(PROTOVALIDATE_VERSION)
61+
62+
# set the version of bufbuild-protovalidate-protocolbuffers to the used PROTOVALIDATE_VERSION
63+
sed -i '' 's/^version = "[^"]*"/version = "$(PROTOVALIDATE_VERSION)"/' bufbuild-protovalidate-protocolbuffers/pyproject.toml
4564

4665
.PHONY: format
4766
format: install $(BIN)/buf $(BIN)/license-header ## Format code

buf.gen.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@ managed:
44
plugins:
55
# NOTE: v26.0 is the earliest version supporting protobuf==5.
66
- remote: buf.build/protocolbuffers/python:v26.0
7-
out: gen
7+
out: test/gen
88
- remote: buf.build/protocolbuffers/pyi:v26.0
9-
out: gen
9+
out: test/gen
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# bufbuild-protovalidate-protocolbuffers
2+
3+
Messages, enum types and stubs for [buf.build/bufbuild/protovalidate](https://buf.build/bufbuild/protovalidate) for python.
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
version: v2
2+
managed:
3+
enabled: true
4+
plugins:
5+
# NOTE: v26.0 is the earliest version supporting protobuf==5.
6+
- remote: buf.build/protocolbuffers/python:v26.0
7+
out: buf/validate/proto5
8+
- remote: buf.build/protocolbuffers/pyi:v26.0
9+
out: buf/validate/proto5
10+
# NOTE: v30.0 is the earliest version supporting protobuf==6.
11+
- remote: buf.build/protocolbuffers/python:v30.0
12+
out: buf/validate/proto6
13+
- remote: buf.build/protocolbuffers/pyi:v30.0
14+
out: buf/validate/proto6
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# Generated by buf. DO NOT EDIT.
2+
version: v2
3+
deps:
4+
- name: buf.build/bufbuild/protovalidate
5+
commit: d22d418d82d84932ba4ba554ce4208ca
6+
digest: b5:8b454cb411e14f0024bdb58ac2689aed2321e81617b61ef8a22c8147a7a9757eeb049ebfb899a699d37051bdb3251e172ba1c1ae2f5005d7c3f47a202109136a
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
version: v2
2+
modules:
3+
- path: proto
4+
deps:
5+
- buf.build/bufbuild/protovalidate:v0.14.0
6+
lint:
7+
use:
8+
- STANDARD
9+
ignore_only:
10+
PROTOVALIDATE:
11+
- proto/tests/example/v1/validations.proto
12+
breaking:
13+
use:
14+
- FILE

bufbuild-protovalidate-protocolbuffers/buf/validate/proto5/buf/validate/validate_pb2.py

Lines changed: 454 additions & 0 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)