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
10 changes: 3 additions & 7 deletions .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,14 @@ Next, install dependencies. You will need:

* [uv](https://docs.astral.sh/uv/)

We use a Makefile to test and lint our code, so you'll also need a few non-Python tools:
Some tasks require additional non-Python tools:

* GNU Make (to use the Makefile): part of the `build-essential` package on
Debian-derived Linux distributions (including Ubuntu), and part of
`xcode-select --install` on Macs.
* Go (for the conformance test runner): often available in your system package
manager (`apt`, `dnf`, `brew`, etc.), but most reliable when [installed
directly from upstream](https://go.dev/doc/install).

With Go and GNU Make installed, you can verify that your changes pass tests and
lint checks by running `make`. For a list of other useful commands, run `make
help`.
With Go installed, you can verify that your changes pass tests and
lint checks by running `uv run poe check`. For a list of other useful commands, run `uv run poe`.

### Reporting Bugs

Expand Down
24 changes: 12 additions & 12 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,14 @@ jobs:
- uses: actions/setup-go@4a3601121dd01d1626a1e23e37211e3254c1c06c # v6.4.0
with:
go-version: stable
# We use this to install `buf`, and the `buf` version is controlled by the Makefile.
cache-dependency-path: Makefile
# We use this to install certain tools defined in poe tasks
cache-dependency-path: poe_tasks.toml
- uses: astral-sh/setup-uv@08807647e7069bb48b6ef5acd8ec9567f424441b # v8.1.0
with:
python-version: ${{ matrix.python-version }}
- run: make install
- run: make test
- run: make conformance
- run: uv sync
- run: uv run poe test
- run: uv run poe test-conformance

lint:
runs-on: ubuntu-latest
Expand All @@ -43,15 +43,15 @@ jobs:
- uses: actions/setup-go@4a3601121dd01d1626a1e23e37211e3254c1c06c # v6.4.0
with:
go-version: stable
# We use this to install `buf`, and the `buf` version is controlled by the Makefile.
cache-dependency-path: Makefile
# We use this to install certain tools defined in poe tasks
cache-dependency-path: poe_tasks.toml
- uses: astral-sh/setup-uv@08807647e7069bb48b6ef5acd8ec9567f424441b # v8.1.0
with:
python-version: ${{ matrix.python-version }}
- run: make install
- run: make lint
- run: make format
# When running with matrix.resolution == lowest-direct, we expect uv.lock to change, but we don't want that file checked in.
- run: make checkgenerate
- run: uv sync --locked
- run: uv run poe lint
- run: uv run poe format
- run: uv run poe generate
env:
BUF_TOKEN: ${{ secrets.BUF_TOKEN }}
- run: uv run poe diffcheck
3 changes: 0 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
# tools, see ./Makefile
/.tmp/

# python writes compiled bytecode to .pyc files in __pycache__ directories
__pycache__

Expand Down
97 changes: 0 additions & 97 deletions Makefile

This file was deleted.

3 changes: 1 addition & 2 deletions packages/protovalidate-proto/buf.gen.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
version: v2
managed:
enabled: true
clean: true
plugins:
# NOTE: v26.0 is the earliest version supporting protobuf==5.
- remote: buf.build/protocolbuffers/python:v26.0
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
// 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.

syntax = "proto3";

package buf.validate.conformance.cases;

import "buf/validate/validate.proto";

message BoolNone {
bool val = 1;
}
message BoolConstTrue {
bool val = 1 [(buf.validate.field).bool.const = true];
}
message BoolConstFalse {
bool val = 1 [(buf.validate.field).bool.const = false];
}
message BoolExample {
bool val = 1 [(buf.validate.field).bool.example = true];
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
// 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.

syntax = "proto3";

package buf.validate.conformance.cases;

import "buf/validate/validate.proto";

message BytesNone {
bytes val = 1;
}
message BytesConst {
bytes val = 1 [(buf.validate.field).bytes.const = "foo"];
}
message BytesIn {
bytes val = 1 [(buf.validate.field).bytes = {
in: [
"bar",
"baz"
]
}];
}
message BytesNotIn {
bytes val = 1 [(buf.validate.field).bytes = {
not_in: [
"fizz",
"buzz"
]
}];
}
message BytesLen {
bytes val = 1 [(buf.validate.field).bytes.len = 3];
}
message BytesMinLen {
bytes val = 1 [(buf.validate.field).bytes.min_len = 3];
}
message BytesMaxLen {
bytes val = 1 [(buf.validate.field).bytes.max_len = 5];
}
message BytesMinMaxLen {
bytes val = 1 [(buf.validate.field).bytes = {
min_len: 3
max_len: 5
}];
}
message BytesEqualMinMaxLen {
bytes val = 1 [(buf.validate.field).bytes = {
min_len: 5
max_len: 5
}];
}
message BytesPattern {
bytes val = 1 [(buf.validate.field).bytes.pattern = "^[\\x00-\\x7F]+$"];
}
message BytesPrefix {
bytes val = 1 [(buf.validate.field).bytes.prefix = "\x99"];
}
message BytesContains {
bytes val = 1 [(buf.validate.field).bytes.contains = "bar"];
}
message BytesSuffix {
bytes val = 1 [(buf.validate.field).bytes.suffix = "buz\x7a"];
}
message BytesIP {
bytes val = 1 [(buf.validate.field).bytes.ip = true];
}
message BytesNotIP {
bytes val = 1 [(buf.validate.field).bytes.ip = false];
}
message BytesIPv4 {
bytes val = 1 [(buf.validate.field).bytes.ipv4 = true];
}
message BytesNotIPv4 {
bytes val = 1 [(buf.validate.field).bytes.ipv4 = false];
}
message BytesIPv6 {
bytes val = 1 [(buf.validate.field).bytes.ipv6 = true];
}
message BytesNotIPv6 {
bytes val = 1 [(buf.validate.field).bytes.ipv6 = false];
}
message BytesIPv6Ignore {
bytes val = 1 [
(buf.validate.field).bytes.ipv6 = true,
(buf.validate.field).ignore = IGNORE_IF_ZERO_VALUE
];
}
message BytesUUID {
bytes val = 1 [(buf.validate.field).bytes.uuid = true];
}
message BytesNotUUID {
bytes val = 1 [(buf.validate.field).bytes.uuid = false];
}
message BytesUUIDIgnore {
bytes val = 1 [
(buf.validate.field).bytes.uuid = true,
(buf.validate.field).ignore = IGNORE_IF_ZERO_VALUE
];
}
message BytesExample {
bytes val = 1 [(buf.validate.field).bytes.example = "\x99"];
}
Loading
Loading