Skip to content

Commit

Permalink
Update to V2
Browse files Browse the repository at this point in the history
  • Loading branch information
doriable committed Oct 16, 2024
1 parent 5a27533 commit c656b12
Show file tree
Hide file tree
Showing 42 changed files with 1,470 additions and 877 deletions.
9 changes: 6 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,14 @@ This repo houses example projects for learning how to use [Buf]. For more inform

## Version

The examples in this repo currently use version [1.8.0][version] of the [`buf` CLI][cli].
The examples in this repo use [v2 `buf.yaml`][v2-buf-yaml] and [v2 `buf.gen.yaml`][v2-buf-gen-yaml]
configurations. All examples require the `buf` CLI at version [v1.32.0][min-version] or higher.

## Projects

Project | Directory | Category
:-------|:----------|:--------
Buf [workspace] | [`workspace-modules`](./workspace) | Code organization
Buf [workspace] | [`workspace`](./workspace) | Code organization
[Linting][lint] Protobuf sources | [`linting`](./linting) | Maintenance
[Breaking change detection][breaking] | [`breaking-change-detection`](./breaking-change-detection) | Maintenance
[Remote plugin execution][remote] | [`plugin-execution-remote`](./plugin-execution-remote) | Code generation
Expand All @@ -36,5 +37,7 @@ Several of these projects available as modules on the [Buf Schema Registry][bsr]
[modules]: https://docs.buf.build/bsr/overview#modules
[plugin]: https://docs.buf.build/bsr/remote-generation/concepts#plugins
[remote]: https://docs.buf.build/bsr/remote-generation/remote-plugin-execution
[version]: https://github.com/bufbuild/buf/releases/tag/v1.8.0
[workspace]: https://docs.buf.build/reference/workspaces
[min-version]: https://github.com/bufbuild/buf/releases/tag/v1.32.0
[v2-buf-yaml]: https://buf.build/docs/configuration/v2/buf-yaml
[v2-buf-gen-yaml]: https://buf.build/docs/configuration/v2/buf-gen-yaml
1 change: 1 addition & 0 deletions breaking-change-detection/README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Breaking change detection

> [!NOTE]
> You need to have the [`buf` CLI][install] installed to follow along with this example.
This project shows Buf [breaking change detection][breaking] in action. There are three different [Buf inputs][inputs] in play here:
Expand Down
15 changes: 11 additions & 4 deletions breaking-change-detection/compatible/buf.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
version: v1
version: v2
name: buf.build/acme/weather
breaking:
use:
- FILE
lint:
use:
- DEFAULT
except:
- FIELD_NOT_REQUIRED
- PACKAGE_NO_IMPORT_CYCLE
disallow_comment_ignores: true
breaking:
use:
- FILE
except:
- EXTENSION_NO_DELETE
- FIELD_SAME_DEFAULT
15 changes: 11 additions & 4 deletions breaking-change-detection/incompatible/buf.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
version: v1
version: v2
name: buf.build/acme/weather
breaking:
use:
- FILE
lint:
use:
- DEFAULT
except:
- FIELD_NOT_REQUIRED
- PACKAGE_NO_IMPORT_CYCLE
disallow_comment_ignores: true
breaking:
use:
- FILE
except:
- EXTENSION_NO_DELETE
- FIELD_SAME_DEFAULT
15 changes: 11 additions & 4 deletions breaking-change-detection/initial/buf.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
version: v1
version: v2
name: buf.build/acme/weather
breaking:
use:
- FILE
lint:
use:
- DEFAULT
except:
- FIELD_NOT_REQUIRED
- PACKAGE_NO_IMPORT_CYCLE
disallow_comment_ignores: true
breaking:
use:
- FILE
except:
- EXTENSION_NO_DELETE
- FIELD_SAME_DEFAULT
3 changes: 0 additions & 3 deletions github-actions/buf.work.yaml

This file was deleted.

16 changes: 16 additions & 0 deletions github-actions/buf.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
version: v2
modules:
- path: proto
lint:
use:
- DEFAULT
except:
- FIELD_NOT_REQUIRED
- PACKAGE_NO_IMPORT_CYCLE
disallow_comment_ignores: true
breaking:
use:
- FILE
except:
- EXTENSION_NO_DELETE
- FIELD_SAME_DEFAULT
7 changes: 0 additions & 7 deletions github-actions/proto/buf.yaml

This file was deleted.

4 changes: 2 additions & 2 deletions limit-output-types/README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Limit types

> You need to install the [`buf` CLI][install] and [jq] to follow along with this example. Requires
> v1.1.0 or above.
> [!NOTE]
> You need to install the [`buf` CLI][install] and [jq] to follow along with this example.
The [`buf build`][build] command creates a [Buf image][image] (or
[`FileDescriptorSet`][filedescriptorset]) out of a [Buf input][input]. By default, the image or
Expand Down
15 changes: 11 additions & 4 deletions limit-output-types/buf.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
version: v1
version: v2
name: buf.build/buf-examples/limit-output-types
breaking:
use:
- FILE
lint:
use:
- DEFAULT
except:
- FIELD_NOT_REQUIRED
- PACKAGE_NO_IMPORT_CYCLE
disallow_comment_ignores: true
breaking:
use:
- FILE
except:
- EXTENSION_NO_DELETE
- FIELD_SAME_DEFAULT
3 changes: 2 additions & 1 deletion linting/README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Protobuf linting

> [!NOTE]
> You need to have the [`buf` CLI][install] installed to follow along with this example.
Buf enables you to [lint] Protobuf sources in accordance with [lint rules][rules] that you specify in your [`buf.yaml`][buf-yaml] configuration file. This project shows linting in action with two different [Buf inputs][inputs]:
Expand Down Expand Up @@ -50,7 +51,7 @@ buf lint ./good
[bsr]: https://docs.buf.build/bsr
[bsr-bad]: https://buf.build/buf-examples/linting-bad
[bsr-good]: https://buf.build/buf-examples/linting-good
[buf-yaml]: https://docs.buf.build/configuration/v1/buf-yaml
[buf-yaml]: https://docs.buf.build/configuration/v2/buf-yaml
[default]: https://docs.buf.build/lint/rules#default
[inputs]: https://docs.buf.build/reference/inputs
[install]: https://docs.buf.build/installation
Expand Down
7 changes: 3 additions & 4 deletions linting/bad/buf.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# Generated by buf. DO NOT EDIT.
version: v1
version: v2
deps:
- remote: buf.build
owner: googleapis
repository: googleapis
- name: buf.build/googleapis/googleapis
commit: 783e4b5374fa488ab068d08af9658438
digest: b5:2d674e2936711677a6c4572193f1cfb204f28f01366d570b617bf308fa59869f64be0407880451df2888cc371c7e1069b813c5450b4d8719d639c4a4f7889efe
15 changes: 11 additions & 4 deletions linting/bad/buf.yaml
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
version: v1
version: v2
name: buf.build/buf-examples/linting-bad
deps:
- buf.build/googleapis/googleapis:783e4b5374fa488ab068d08af9658438
breaking:
use:
- FILE
lint:
use:
- DEFAULT
except:
- FIELD_NOT_REQUIRED
- PACKAGE_NO_IMPORT_CYCLE
disallow_comment_ignores: true
breaking:
use:
- FILE
except:
- EXTENSION_NO_DELETE
- FIELD_SAME_DEFAULT
7 changes: 3 additions & 4 deletions linting/good/buf.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# Generated by buf. DO NOT EDIT.
version: v1
version: v2
deps:
- remote: buf.build
owner: googleapis
repository: googleapis
- name: buf.build/googleapis/googleapis
commit: 783e4b5374fa488ab068d08af9658438
digest: b5:2d674e2936711677a6c4572193f1cfb204f28f01366d570b617bf308fa59869f64be0407880451df2888cc371c7e1069b813c5450b4d8719d639c4a4f7889efe
15 changes: 11 additions & 4 deletions linting/good/buf.yaml
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
version: v1
version: v2
name: buf.build/buf-examples/linting-good
deps:
- buf.build/googleapis/googleapis:783e4b5374fa488ab068d08af9658438
breaking:
use:
- FILE
lint:
use:
- DEFAULT
except:
- FIELD_NOT_REQUIRED
- PACKAGE_NO_IMPORT_CYCLE
disallow_comment_ignores: true
breaking:
use:
- FILE
except:
- EXTENSION_NO_DELETE
- FIELD_SAME_DEFAULT
2 changes: 1 addition & 1 deletion managed-mode/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ When you run this command, the `buf` CLI uses the configuration in [`buf.gen.yam
* [Ruby](./gen/proto/ruby)

[arena]: https://developers.google.com/protocol-buffers/docs/reference/arenas
[buf-gen-yaml]: https://docs.buf.build/configuration/v1/buf-gen-yaml#managed
[buf-gen-yaml]: https://docs.buf.build/configuration/v2/buf-gen-yaml#managed
[install]: https://docs.buf.build/installation
[managed]: https://docs.buf.build/generate/managed-mode
[plugins]: https://docs.buf.build/bsr/remote-generation/overview#hosted-plugins
Expand Down
42 changes: 21 additions & 21 deletions managed-mode/buf.gen.yaml
Original file line number Diff line number Diff line change
@@ -1,31 +1,31 @@
version: v1
version: v2
managed:
enabled: true
optimize_for: CODE_SIZE

# C++
cc_enable_arenas: true

# Go
go_package_prefix:
default: github.com/acme/weather/v1

# Java
java_multiple_files: false
java_package_prefix: io
java_string_check_utf8: false
override:
- file_option: cc_enable_arenas
value: true
- file_option: java_multiple_files
value: false
- file_option: java_string_check_utf8
value: false
- file_option: java_package_prefix
value: io
- file_option: optimize_for
value: CODE_SIZE
- file_option: go_package_prefix
value: github.com/acme/weather/v1
plugins:
- plugin: buf.build/protocolbuffers/cpp
- remote: buf.build/protocolbuffers/cpp
out: gen/proto/cpp
- plugin: buf.build/protocolbuffers/csharp
- remote: buf.build/protocolbuffers/csharp
out: gen/proto/csharp
- plugin: buf.build/protocolbuffers/go
- remote: buf.build/protocolbuffers/go
out: gen/proto/go
- plugin: buf.build/protocolbuffers/java
- remote: buf.build/protocolbuffers/java
out: gen/proto/java
- plugin: buf.build/protocolbuffers/objc
- remote: buf.build/protocolbuffers/objc
out: gen/proto/objc
- plugin: buf.build/protocolbuffers/php
- remote: buf.build/protocolbuffers/php
out: gen/proto/php
- plugin: buf.build/protocolbuffers/ruby
- remote: buf.build/protocolbuffers/ruby
out: gen/proto/ruby
11 changes: 9 additions & 2 deletions managed-mode/buf.yaml
Original file line number Diff line number Diff line change
@@ -1,9 +1,16 @@
version: v1
version: v2
name: buf.build/acme/weather
lint:
use:
- DEFAULT
except:
- FIELD_NOT_REQUIRED
- PACKAGE_NO_IMPORT_CYCLE
enum_zero_value_suffix: _UNKNOWN
disallow_comment_ignores: true
breaking:
use:
- FILE
- FILE
except:
- EXTENSION_NO_DELETE
- FIELD_SAME_DEFAULT
Loading

0 comments on commit c656b12

Please sign in to comment.