forked from rilldata/rill
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use Buf to generate protos and standardize layout (rilldata#1276)
* Move proto to root and generate using buf * Update developer docs * Reconfig and regen Orval * Add buf linting * Fix test failures * Fix lint errors not related to analytical APIs * Add details to proto ci * Merge main * Fix yaml errors * Fix yaml error 2 * Restore openapi error types * Restore error types * Fix orval generation rules * Fix prettier
- Loading branch information
1 parent
b0cacbc
commit 4be36d8
Showing
75 changed files
with
8,089 additions
and
9,722 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
name: Check .proto files | ||
on: | ||
pull_request: | ||
paths: | ||
- "proto/**" | ||
jobs: | ||
check: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: bufbuild/buf-setup-action@v1 | ||
- uses: bufbuild/buf-lint-action@v1 | ||
with: | ||
input: "proto" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# `proto/` | ||
|
||
This directory contains the protocol buffer definitions for all Rill components. Instead of placing `.proto` files in their respective sub-projects, we follow the convention of having a single `proto` folder to make cross-component imports and codegen easier. | ||
|
||
We use [Buf](https://buf.build) to lint and generate protocol buffers. The layout and style of our `.proto` files follow their [style guide](https://docs.buf.build/best-practices/style-guide). | ||
|
||
## Defining APIs | ||
|
||
We define APIs as gRPC services. All APIs should be defined centrally in this directory, but implemented in their respective sub-package of the monorepo. | ||
|
||
For all APIs, we setup [gRPC-Gateway](https://grpc-ecosystem.github.io/grpc-gateway/) to map the gRPC definitions to a RESTful API. The mapping rules are done inline in the `proto` file, using `google.api.http` annotations ([docs here](https://github.com/googleapis/googleapis/blob/master/google/api/http.proto#L44)). | ||
|
||
Using protocol buffers to define dual RPC and REST interfaces is a technique widely used at Google. We suggest taking a look at their excellent [API design guide](https://cloud.google.com/apis/design/resources), which describes this pattern (notice it's multiple pages). | ||
|
||
## Generating | ||
|
||
After changing a `.proto` file, you should re-generate the bindings: | ||
|
||
1. Install Buf if you haven't already ([docs](https://docs.buf.build/installation)) | ||
2. From the repo root, run: | ||
```bash | ||
make proto.generate | ||
``` | ||
|
||
### Typescript runtime client | ||
|
||
We separately have a generated TypeScript client for the runtime in `web-common/src/runtime-client`. If relevant, you can re-generate it by running: | ||
|
||
```bash | ||
npm run generate:runtime-client -w web-common | ||
``` | ||
|
||
(This is not automated as the frontend may currently be pinned to an older version of the runtime.) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
version: v1 | ||
managed: | ||
enabled: true | ||
go_package_prefix: | ||
default: github.com/rilldata/rill | ||
except: | ||
- buf.build/googleapis/googleapis | ||
plugins: | ||
- remote: buf.build/protocolbuffers/plugins/go:v1.28.1-1 | ||
out: gen | ||
opt: | ||
- paths=source_relative | ||
- remote: buf.build/grpc/plugins/go:v1.2.0-1 | ||
out: gen | ||
opt: | ||
- paths=source_relative | ||
- remote: buf.build/grpc-ecosystem/plugins/grpc-gateway:v2.13.0-1 | ||
out: gen | ||
opt: | ||
- paths=source_relative | ||
- logtostderr=true | ||
- generate_unbound_methods=true | ||
- remote: buf.build/grpc-ecosystem/plugins/openapiv2:v2.13.0-1 | ||
out: gen | ||
opt: | ||
- logtostderr=true | ||
- allow_merge=true,merge_file_name=rill/runtime/v1/runtime | ||
- output_format=yaml | ||
# - openapi_naming_strategy=simple # Removes "V1" prefix from types | ||
# - simple_operation_ids=true # Removes "RuntimeService_" prefix from operations |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# Generated by buf. DO NOT EDIT. | ||
version: v1 | ||
deps: | ||
- remote: buf.build | ||
owner: googleapis | ||
repository: googleapis | ||
commit: 5abafbf55b5c4c07ad5fb06d2599560f | ||
- remote: buf.build | ||
owner: grpc-ecosystem | ||
repository: grpc-gateway | ||
commit: b98ae2f8ce63452e97e6bae65c5add1b |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
version: v1 | ||
name: buf.build/rilldata/rill | ||
lint: | ||
use: | ||
- DEFAULT | ||
breaking: | ||
use: | ||
- FILE | ||
deps: | ||
- buf.build/googleapis/googleapis | ||
- buf.build/grpc-ecosystem/grpc-gateway |
Oops, something went wrong.