Skip to content
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

build: migrate to buf v2 #197

Draft
wants to merge 5 commits into
base: main
Choose a base branch
from
Draft
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
4 changes: 2 additions & 2 deletions .github/workflows/push.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ jobs:
with:
fetch-depth: 0

- uses: bufbuild/buf-setup-action@35c243d7f2a909b1d4e40399b348a7fdab27d78d # v1.34.0
- uses: bufbuild/buf-push-action@a654ff18effe4641ebea4a4ce242c49800728459 # v1.2.0
- uses: bufbuild/buf-action@d4b43256b3a511e94e6c0d38d478e1bd39f8690e # v1.0.1
with:
push: true
buf_token: ${{ secrets.BUF_TOKEN }}
- name: Send PagerDuty alert on failure
if: ${{ failure() }}
Expand Down
22 changes: 12 additions & 10 deletions .github/workflows/review.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,27 +9,29 @@ permissions:
contents: read

jobs:
build:
build-proto:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@1d96c772d19495a3b5c517cd2bc0cb401ea0529f # v4.1.3
- name: Lint, format, and calculate breaking changes
uses: bufbuild/buf-action@d4b43256b3a511e94e6c0d38d478e1bd39f8690e # v1.0.1
with:
fetch-depth: 0
- uses: bufbuild/buf-setup-action@35c243d7f2a909b1d4e40399b348a7fdab27d78d # v1.34.0
- uses: bufbuild/buf-lint-action@06f9dd823d873146471cfaaf108a993fe00e5325 # v1.1.1
- uses: bufbuild/buf-breaking-action@c57b3d842a5c3f3b454756ef65305a50a587c5ba # v1.1.4
with:
# The 'main' branch of the GitHub repository that defines the module.
against: "https://github.com/${GITHUB_REPOSITORY}.git#branch=${GITHUB_BASE_REF}"
- run: buf format -d --exit-code
format: true
lint: true
breaking: true
pr_comment: false
breaking_against: "https://github.com/openfga/api.git#branch=main"

diff-openapi:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@1d96c772d19495a3b5c517cd2bc0cb401ea0529f # v4.1.3
with:
fetch-depth: 0
- uses: bufbuild/buf-setup-action@35c243d7f2a909b1d4e40399b348a7fdab27d78d # v1.34.0
- name: Install Buf CLI
uses: bufbuild/buf-action@d4b43256b3a511e94e6c0d38d478e1bd39f8690e # v1.0.1
with:
setup_only: true
- name: "Generate OpenAPI & Diff"
run: |
make all
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
all: patch-swagger-doc format

buf-gen:
./buf.gen.yaml
buf generate

patch-swagger-doc: buf-gen
./scripts/update_swagger.sh docs/openapiv2/apidocs.swagger.json
Expand Down
39 changes: 19 additions & 20 deletions buf.gen.yaml
Original file line number Diff line number Diff line change
@@ -1,33 +1,32 @@
#!/usr/bin/env -S buf generate --template
---
version: v1
version: v2
managed:
enabled: true
go_package_prefix:
default: github.com/openfga/api/proto
except:
- buf.build/googleapis/googleapis
- buf.build/envoyproxy/protoc-gen-validate
- buf.build/grpc-ecosystem/grpc-gateway
disable:
- file_option: go_package
module: buf.build/googleapis/googleapis
- file_option: go_package
module: buf.build/envoyproxy/protoc-gen-validate
- file_option: go_package
module: buf.build/grpc-ecosystem/grpc-gateway
override:
- file_option: go_package_prefix
value: github.com/openfga/api/proto
plugins:
- plugin: buf.build/protocolbuffers/go:v1.34.0
- remote: buf.build/protocolbuffers/go:v1.34.2
out: proto/
opt:
- paths=source_relative
- plugin: buf.build/grpc/go:v1.3.0
opt: paths=source_relative
- remote: buf.build/grpc/go:v1.5.1
out: proto/
opt:
- paths=source_relative
- plugin: buf.build/bufbuild/validate-go:v1.0.4
opt: paths=source_relative
- remote: buf.build/bufbuild/validate-go:v1.1.0
out: proto/
opt:
- paths=source_relative
- plugin: buf.build/grpc-ecosystem/gateway:v2.19.1
opt: paths=source_relative
- remote: buf.build/grpc-ecosystem/gateway:v2.22.0
out: proto/
opt:
- paths=source_relative
- logtostderr=true
- plugin: buf.build/grpc-ecosystem/openapiv2:v2.16.0
- remote: buf.build/grpc-ecosystem/openapiv2:v2.22.0
out: docs/openapiv2
opt:
- openapi_naming_strategy=simple
Expand Down
26 changes: 10 additions & 16 deletions buf.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 13 additions & 9 deletions buf.yaml
Original file line number Diff line number Diff line change
@@ -1,18 +1,22 @@
version: v1
version: v2
name: buf.build/openfga/api
deps:
- buf.build/envoyproxy/protoc-gen-validate
- buf.build/grpc-ecosystem/grpc-gateway
- buf.build/googleapis/googleapis
breaking:
ignore_unstable_packages: true

- buf.build/grpc-ecosystem/grpc-gateway
lint:
allow_comment_ignores: true
use:
- STANDARD
ignore_only:
ENUM_VALUE_UPPER_SNAKE_CASE:
- openfga/v1/errors_ignore.proto
ENUM_VALUE_PREFIX:
- openfga/v1/errors_ignore.proto
ENUM_VALUE_UPPER_SNAKE_CASE:
- openfga/v1/errors_ignore.proto
ENUM_ZERO_VALUE_SUFFIX:
- openfga/v1/errors_ignore.proto
- openfga/v1/errors_ignore.proto
breaking:
use:
- FILE
- PACKAGE
- WIRE_JSON
- WIRE
Loading