Skip to content
cybozuPublic

About

Normalization and validation system for Protocol Buffers

Topics

Resources

Stars

14 stars

Watchers

6 watching

Forks

Repository files navigation

Cybozu Public Protocol Buffers Schema

This repository contains public Protocol Buffer files and related tools from Cybozu.

This repository forms a Buf module to publish protobuf files on BSR. You can import packages in this repository by adding the following lines to buf.yaml.

version: v1
deps:
- buf.build/cybozu/protobuf

If you are not familiar with buf, read https://docs.buf.build/manuals/cli/overview

cybozu.validate

This protobuf package provides custom options to normalize and validate messages. Read examples/validation.proto for example usage.

You can get the code generator for Go as follows:

$ go install github.com/cybozu/protobuf/cmd/protoc-gen-go-cybozu-validate@latest

or download prebuilt binaries from Releases.

Use the same version of this repository for the protos and the code generator. The generator fails when they disagree on the extension numbers of the options.

The following is an example buf.gen.yaml to generate validation code:

version: v1
plugins:
  - plugin: go
    out: .
    opt: paths=source_relative
  - plugin: go-cybozu-validate
    out: .
    opt: paths=source_relative

cybozu.stability

This protobuf package provides custom options to declare the stability of API elements: services, methods, messages, fields, enums and enum values. An element without the option, or with STAGE_UNSPECIFIED, is stable. An option on a service, message or enum also covers every element inside it, so an element inside a preview container is always preview. Nothing is inferred from use: a stable element must not refer to a preview message or enum. Read examples/stability.proto for example usage.

The options generate no code. Tools read them from the descriptors, for example to leave preview elements out of a breaking change check.

API documentation

Visit https://buf.build/cybozu/protobuf

Versioning and backward-compatibility

We keep backward-compatibility of Protocol Buffers files. When we want to add breaking changes to Protocol Buffers files, we create a different package like cybozu.foo.v2 not to break the current package.

However, the generated code in this repository may not be backward compatible. For example, Go code generated by protoc-gen-go may not be always backward compatible.

So, we use a semver with major version zero (0.y.z) to tag this repository to declare the generated code may bring breaking changes.

For developers

Running make create-tag creates a new tag and push it to GitHub automatically. The rest of the release process will be done by GitHub Actions.

Development

You need Go. The go line in go.mod is the minimum Go version for users of this module; the toolchain line is the Go version we build and test with.

aqua manages the CLI tools such as buf and GoReleaser. aqua.yaml pins their versions, and aqua-checksums.json holds the checksums of every download. make installs aqua and the tools on first use with scripts/setup-aqua.sh; you do not need to install aqua yourself.

To change a tool version, edit aqua.yaml, then run ./scripts/setup-aqua.sh --update-checksum and commit both files. CI fails when aqua-checksums.json is out of date.

Dependency updates

Dependencies are updated with Claude Code skills in .claude/skills/, each of which opens a pull request for review:

Skill Updates
update-go the go and toolchain lines of go.mod
update-go-deps Go modules, and the generated code when google.golang.org/protobuf changes
update-aqua-deps the tools in aqua.yaml, the aqua registry and aqua itself
update-actions-deps GitHub Actions

They choose only releases published at least 72 hours ago, and review the upstream changes first. Three exceptions are accepted risks:

  • A Go module version without a GitHub release is dated by its commit time, which its author sets, and checked against the Go module index.
  • Go releases have too many changes to review; the go command verifies the toolchain it downloads against the Go checksum database.
  • GitHub official actions (actions/*, github/*) are referenced by major tags such as @v6, so their minor and patch releases are used as soon as GitHub moves the tag. Third-party actions are pinned to commit SHAs.

The go line is at least go 1.N.0, where 1.N is the minor release before the latest Go; it may carry a patch version, such as go 1.N.3, when a dependency requires one. The toolchain line is the latest patch release of that minor release. On the first day of every month, a workflow opens an issue with the checklist in .github/DEPENDENCY_PASS.md.

License

All code in this repository is licensed under the Apache License Version 2.0. Read LICENSE for terms and conditions.

About

Normalization and validation system for Protocol Buffers

Topics

Resources

Stars

14 stars

Watchers

6 watching

Forks

Releases

Packages

Used by

Contributors

Languages