-
Notifications
You must be signed in to change notification settings - Fork 9
Improve initial developer experience #473
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,3 +6,4 @@ __pycache__ | |
|
|
||
| # VS Code configuration | ||
| /.vscode/ | ||
| .envrc | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,13 +6,10 @@ SHELL := bash | |
| MAKEFLAGS += --warn-undefined-variables | ||
| MAKEFLAGS += --no-builtin-rules | ||
| MAKEFLAGS += --no-print-directory | ||
| BIN := .tmp/bin | ||
| export PATH := $(BIN):$(PATH) | ||
| export GOBIN := $(abspath $(BIN)) | ||
| export PYTHONPATH ?= gen | ||
| BUF_VERSION := 1.69.0 | ||
| CONFORMANCE_ARGS ?= --strict_message --expected_failures=test/conformance/nonconforming.yaml --timeout 10s | ||
| ADD_LICENSE_HEADER := $(BIN)/license-header \ | ||
| ADD_LICENSE_HEADER := go run github.com/bufbuild/buf/private/pkg/licenseheader/cmd/license-header@v${BUF_VERSION} \ | ||
| --ignore .github \ | ||
| --ignore buf.yaml \ | ||
| --ignore buf.gen.yaml \ | ||
|
|
@@ -47,39 +44,38 @@ clean: ## Delete intermediate build artifacts | |
| @echo $(CEL_SPEC_VERSION) | ||
|
|
||
| .PHONY: generate | ||
| generate: $(BIN)/buf $(BIN)/license-header upstream ## Regenerate code and license headers | ||
| rm -rf gen | ||
| $(BIN)/buf generate $(PROTOVALIDATE_PROTO_PATH) | ||
| $(BIN)/buf generate $(PROTOVALIDATE_TESTING_PROTO_PATH) | ||
| $(BIN)/buf generate buf.build/google/cel-spec:$(CEL_SPEC_VERSION) --exclude-path cel/expr/conformance/proto2 --exclude-path cel/expr/conformance/proto3 | ||
| $(BIN)/buf generate | ||
| $(ADD_LICENSE_HEADER) | ||
| generate: ## Regenerate code and license headers | ||
| cd packages/protovalidate-proto && \ | ||
| rm -rf src && mkdir -p src/buf/validate && touch src/buf/validate/__init__.py && \ | ||
| uv run -- buf generate $(PROTOVALIDATE_PROTO_PATH) && \ | ||
| uv run -- buf generate $(PROTOVALIDATE_TESTING_PROTO_PATH) | ||
|
|
||
| cd test && \ | ||
| rm -rf gen && \ | ||
| uv run -- buf generate buf.build/google/cel-spec:$(CEL_SPEC_VERSION) --exclude-path cel/expr/conformance/proto2 --exclude-path cel/expr/conformance/proto3 && \ | ||
| uv run -- buf generate | ||
|
|
||
| .PHONY: upstream | ||
| upstream: $(BIN)/buf | ||
| rm -rf upstream | ||
| $(BIN)/buf export $(PROTOVALIDATE_PROTO_PATH) -o upstream/proto | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @timostamm I have removed this, looking at #409 I couldn't find a particular reason for vendoring in the proto file itself with this line. We have
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What we need for development:
Because upstream's Protobuf definitions are not pushed to the BSR until release, we need the ability to reference arbitrary upstream Git commits. This enables testing changes to If you pull an upstream change in here, it is very possible that you encounter a conformance test failure and need to investigate the problem further. You'll need to add local test protos, and sometimes you may want to modify validate.proto with a patch that you expect will fix the problem, but want to verify locally before going through an upstream commit. The setup in protovalidate-es checks all boxes. I'm not sure that the setup here ever did. Are there any gaps in the new setup?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks for the context!
This makes sense. This means probably the step that generated code with upstream before downloading locally and generating again had both a redundant generation step and possibly a frustrating overwrite of local changes when not desired. Will tweak to resolve these.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's a "may", and some complications with that are acceptable. But keep in mind that local test protos cannot import from a Git commit.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks. I have filed to track this. I would like to fix forward (technically refix) since many things will open up when migrating off of Makefile and in the meantime, the repo not being easily openable in an IDE should be fixed first. I'll address it soon. |
||
| $(ADD_LICENSE_HEADER) | ||
|
|
||
| .PHONY: format | ||
| format: install $(BIN)/buf $(BIN)/license-header ## Format code | ||
| format: install ## Format code | ||
| $(ADD_LICENSE_HEADER) | ||
| buf format --write . | ||
| uv run -- buf format --write . | ||
| uv run -- ruff format protovalidate test | ||
| uv run -- ruff check --fix protovalidate test | ||
| uv run -- tombi format | ||
|
|
||
| .PHONY: test | ||
| test: generate install $(TESTDATA_FILE) ## Run unit tests | ||
| test: install $(TESTDATA_FILE) ## Run unit tests | ||
| uv run -- pytest | ||
|
|
||
| .PHONY: conformance | ||
| conformance: $(BIN)/protovalidate-conformance generate install ## Run conformance tests | ||
| protovalidate-conformance $(CONFORMANCE_ARGS) uv run test/conformance/runner.py | ||
| conformance: install ## Run conformance tests | ||
| go run github.com/bufbuild/protovalidate/tools/protovalidate-conformance@$(PROTOVALIDATE_VERSION) $(CONFORMANCE_ARGS) uv run test/conformance/runner.py | ||
|
|
||
| .PHONY: lint | ||
| lint: install $(BIN)/buf ## Lint code | ||
| buf format -d --exit-code | ||
| lint: install ## Lint code | ||
| uv run -- buf format -d --exit-code | ||
| uv run -- ruff format --check --diff protovalidate test | ||
| uv run -- ty check protovalidate | ||
| uv run -- ruff check protovalidate test | ||
|
|
@@ -89,7 +85,7 @@ lint: install $(BIN)/buf ## Lint code | |
|
|
||
| .PHONY: install | ||
| install: ## Install dependencies | ||
| uv sync --dev | ||
| uv sync | ||
|
|
||
| .PHONY: checkgenerate | ||
| checkgenerate: generate | ||
|
|
@@ -99,15 +95,3 @@ checkgenerate: generate | |
| $(TESTDATA_FILE): | ||
| mkdir -p $(dir @) | ||
| curl -fsSL -o $@ https://raw.githubusercontent.com/google/cel-spec/refs/tags/$(CEL_SPEC_VERSION)/tests/simple/testdata/string_ext.textproto | ||
|
|
||
| $(BIN): | ||
| @mkdir -p $(BIN) | ||
|
|
||
| $(BIN)/buf: Makefile | $(BIN) | ||
| go install github.com/bufbuild/buf/cmd/buf@v${BUF_VERSION} | ||
|
|
||
| $(BIN)/license-header: Makefile | $(BIN) | ||
| go install github.com/bufbuild/buf/private/pkg/licenseheader/cmd/license-header@v${BUF_VERSION} | ||
|
|
||
| $(BIN)/protovalidate-conformance: Makefile | $(BIN) | ||
| go install github.com/bufbuild/protovalidate/tools/protovalidate-conformance@$(PROTOVALIDATE_VERSION) | ||
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| ../../LICENSE |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| # protovalidate-proto | ||
|
|
||
| Generated stubs for [protovalidate.proto](https://github.com/bufbuild/protovalidate). These are currently | ||
| only used for tests in this repository and are not published. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| version: v2 | ||
| managed: | ||
| enabled: true | ||
| plugins: | ||
| # NOTE: v26.0 is the earliest version supporting protobuf==5. | ||
| - remote: buf.build/protocolbuffers/python:v26.0 | ||
| out: src | ||
| - remote: buf.build/protocolbuffers/pyi:v26.0 | ||
| out: src |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,7 +1,6 @@ | ||
| version: v2 | ||
| modules: | ||
| - path: proto | ||
| - path: upstream/proto | ||
| lint: | ||
| use: | ||
| - STANDARD | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| [project] | ||
| name = "protovalidate-proto" | ||
| version = "0.1.0" | ||
| description = "Protocol Buffer Stubs for protovalidate-python" | ||
| readme = "README.md" | ||
| requires-python = ">=3.10" | ||
| license = "Apache-2.0" | ||
| license-files = ["LICENSE"] | ||
| keywords = ["protobuf", "protocol buffer", "validate"] | ||
| classifiers = [ | ||
| "Operating System :: OS Independent", | ||
| "Private :: Do Not Upload", | ||
| "Programming Language :: Python :: 3.10", | ||
| "Programming Language :: Python :: 3.11", | ||
| "Programming Language :: Python :: 3.12", | ||
| "Programming Language :: Python :: 3.13", | ||
| "Programming Language :: Python :: 3.14", | ||
| "Typing :: Typed", | ||
| ] | ||
| dependencies = [] | ||
|
|
||
| [project.urls] | ||
| Documentation = "https://protovalidate.com" | ||
| Homepage = "https://github.com/bufbuild/protovalidate-python" | ||
| Issues = "https://github.com/bufbuild/protovalidate-python/issues" | ||
| Source = "https://github.com/bufbuild/protovalidate-python" | ||
|
|
||
| [build-system] | ||
| requires = ["uv_build>=0.11.2,<0.12"] | ||
| build-backend = "uv_build" | ||
|
|
||
| [tool.uv.build-backend] | ||
| module-name = ["buf.validate"] |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| # Copyright 2023-2026 Buf Technologies, Inc. | ||
| # | ||
| # Licensed under the Apache License, Version 2.0 (the "License"); | ||
| # you may not use this file except in compliance with the License. | ||
| # You may obtain a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, software | ||
| # distributed under the License is distributed on an "AS IS" BASIS, | ||
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| # Generated by buf. DO NOT EDIT. | ||
| version: v2 | ||
| deps: | ||
| - name: buf.build/bufbuild/protovalidate | ||
| commit: 50325440f8f24053b047484a6bf60b76 | ||
| digest: b5:74cb6f5c0853c3c10aafc701614194bbd63326bdb8ef4068214454b8894b03ba4113e04b3a33a8321cdf05336e37db4dc14a5e2495db8462566914f36086ba31 |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| version: v2 | ||
| modules: | ||
| - path: proto | ||
| deps: | ||
| - buf.build/bufbuild/protovalidate | ||
| lint: | ||
| use: | ||
| - STANDARD | ||
| breaking: | ||
| use: | ||
| - FILE |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While there is a slight issue in having this version and the buf version in pyproject.toml, the version of the license header tool isn't that important, and the correct fix will be in the future, using the Python version of the tool we will share among Buf's repos