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

Use buf.build to generate go from proto #73

Closed
wants to merge 1 commit into from
Closed
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
22 changes: 22 additions & 0 deletions .github/workflows/buf-pull-request.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: buf-pull-request
on:
pull_request:
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v4
with:
go-version-file: go/go.mod
cache-dependency-path: go/go.sum
- uses: bufbuild/buf-setup-action@v1
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
- run: buf generate --template buf.gen.go.yaml
- run: go mod tidy
working-directory: go
- run: |
git add .
git diff --name-only --exit-code HEAD -- .

28 changes: 28 additions & 0 deletions .github/workflows/buf-push.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: buf-push
on:
push:
branches:
- main
tags:
- "*"
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v4
with:
go-version-file: go/go.mod
cache-dependency-path: go/go.sum
- uses: bufbuild/buf-setup-action@v1
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
- run: buf generate --template buf.gen.go.yaml
- run: go mod tidy
working-directory: go
- run: |
git add .
git diff --name-only --exit-code HEAD -- .
- uses: bufbuild/buf-push-action@v1
with:
buf_token: ${{ secrets.BUF_TOKEN }}
39 changes: 19 additions & 20 deletions bazel/dependency_imports.bzl
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
load("@com_google_protobuf//:protobuf_deps.bzl", "protobuf_deps")
load("@bazel_gazelle//:deps.bzl", "gazelle_dependencies", "go_repository")
load("@com_envoyproxy_protoc_gen_validate//bazel:repositories.bzl", "pgv_dependencies")
load("@com_google_googleapis//:repository_rules.bzl", "switched_rules_by_language")
load("@com_google_protobuf//:protobuf_deps.bzl", "protobuf_deps")
load("@io_bazel_rules_go//go:deps.bzl", "go_register_toolchains", "go_rules_dependencies")
load("@com_envoyproxy_protoc_gen_validate//bazel:repositories.bzl", "pgv_dependencies")
load("@rules_proto//proto:repositories.bzl", "rules_proto_dependencies", "rules_proto_toolchains")

# go version for rules_go
Expand Down Expand Up @@ -39,57 +39,57 @@ def xds_dependency_imports(go_version = GO_VERSION):
go_repository(
name = "com_github_iancoleman_strcase",
importpath = "github.com/iancoleman/strcase",
sum = "h1:ux/56T2xqZO/3cP1I2F86qpeoYPCOzk+KF/UH/Ar+lk=",
version = "v0.0.0-20180726023541-3605ed457bf7",
sum = "h1:05I4QRnGpI0m37iZQRuskXh+w77mr6Z41lwQzuHLwW0=",
version = "v0.2.0",
build_external = "external",
# project_url = "https://pkg.go.dev/github.com/iancoleman/strcase",
# last_update = "2020-11-22"
# use_category = ["api"],
# source = "https://github.com/bufbuild/protoc-gen-validate/blob/v0.6.1/dependencies.bzl#L23-L28"
# source = "https://github.com/bufbuild/protoc-gen-validate/blob/v1.0.2/dependencies.bzl#L170-L175"
)
go_repository(
name = "org_golang_x_net",
importpath = "golang.org/x/net",
sum = "h1:0mm1VjtFUOIlE1SbDlwjYaDxZVDP2S5ou6y0gSgXHu8=",
version = "v0.0.0-20200226121028-0de0cce0169b",
sum = "h1:1WGATo9HAhkWMbfyuVU0tEFP88OIkUvwaHFveQPvzCQ=",
version = "v0.0.0-20220907135653-1e95f45603a7",
build_external = "external",
# project_url = "https://pkg.go.dev/golang.org/x/net",
# last_update = "2020-02-26"
# use_category = ["api"],
# source = "https://github.com/bufbuild/protoc-gen-validate/blob/v0.6.1/dependencies.bzl#L129-L134"
# source = "https://github.com/bufbuild/protoc-gen-validate/blob/v1.0.2/dependencies.bzl#L436-L441"
)
go_repository(
name = "org_golang_x_text",
importpath = "golang.org/x/text",
sum = "h1:cokOdA+Jmi5PJGXLlLllQSgYigAEfHXJAERHVMaCc2k=",
version = "v0.3.3",
sum = "h1:olpwvP2KacW1ZWvsR7uQhoyTYvKAupfQrRGBFM352Gk=",
version = "v0.3.7",
build_external = "external",
# project_url = "https://pkg.go.dev/golang.org/x/text",
# last_update = "2021-06-16"
# use_category = ["api"],
# source = "https://github.com/bufbuild/protoc-gen-validate/blob/v0.6.1/dependencies.bzl#L148-L153"
# source = "https://github.com/bufbuild/protoc-gen-validate/blob/v1.0.2/dependencies.bzl#L468-L473"
)
go_repository(
name = "com_github_spf13_afero",
importpath = "github.com/spf13/afero",
sum = "h1:8q6vk3hthlpb2SouZcnBVKboxWQWMDNF38bwholZrJc=",
version = "v1.3.4",
sum = "h1:j49Hj62F0n+DaZ1dDCvhABaPNSGNkt32oRFxI33IEMw=",
version = "v1.9.2",
build_external = "external",
# project_url = "https://pkg.go.dev/github.com/spf13/afero",
# last_update = "2021-03-20"
# use_category = ["api"],
# source = "https://github.com/bufbuild/protoc-gen-validate/blob/v0.6.1/dependencies.bzl#L60-L65"
# source = "https://github.com/bufbuild/protoc-gen-validate/blob/v1.0.2/dependencies.bzl#L257-L262"
)
go_repository(
name = "com_github_lyft_protoc_gen_star",
name = "com_github_lyft_protoc_gen_star_v2",
importpath = "github.com/lyft/protoc-gen-star/v2",
sum = "h1:keaAo8hRuAT0O3DfJ/wM3rufbAjGeJ1lAtWZHDjKGB0=",
version = "v2.0.1",
sum = "h1:/3+/2sWyXeMLzKd1bX+ixWKgEMsULrIivpDsuaF441o=",
version = "v2.0.3",
build_external = "external",
# project_url = "https://pkg.go.dev/github.com/lyft/protoc-gen-star",
# last_update = "2023-01-06"
# use_category = ["api"],
# source = "https://github.com/bufbuild/protoc-gen-validate/blob/v0.10.1/dependencies.bzl#L35-L40"
# source = "https://github.com/bufbuild/protoc-gen-validate/blob/v1.0.2/dependencies.bzl#L220-L225"
)
go_repository(
name = "org_golang_google_protobuf",
Expand All @@ -106,8 +106,7 @@ def xds_dependency_imports(go_version = GO_VERSION):
version = "v1.40.0",
)


# Old name for backward compatibility.
# TODO(roth): Remove this once callers are migrated to the new name.
def udpa_dependency_imports(go_version = GO_VERSION):
xds_dependency_imports(go_version=go_version)
xds_dependency_imports(go_version = go_version)
8 changes: 4 additions & 4 deletions bazel/repository_locations.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ REPOSITORY_LOCATIONS = dict(
urls = ["https://mirror.bazel.build/github.com/bazelbuild/bazel-skylib/releases/download/1.0.3/bazel-skylib-1.0.3.tar.gz"],
),
com_envoyproxy_protoc_gen_validate = dict(
sha256 = "c695fc5a2e5a1b52904cd8a58ce7a1c3a80f7f50719496fd606e551685c01101",
strip_prefix = "protoc-gen-validate-0.6.1",
urls = ["https://github.com/envoyproxy/protoc-gen-validate/archive/refs/tags/v0.6.1.tar.gz"],
sha256 = "27b3202ba6e9eb37dca0f902c8f96b6330670b33d8669ad739f60ab61bdaf296",
strip_prefix = "protoc-gen-validate-1.0.2",
urls = ["https://github.com/envoyproxy/protoc-gen-validate/archive/refs/tags/v1.0.2.tar.gz"],
Comment on lines +11 to +13
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

),
com_github_grpc_grpc = dict(
sha256 = "916f88a34f06b56432611aaa8c55befee96d0a7b7d7457733b9deeacbc016f99",
Expand Down Expand Up @@ -38,6 +38,6 @@ REPOSITORY_LOCATIONS = dict(
rules_proto = dict(
sha256 = "80d3a4ec17354cccc898bfe32118edd934f851b03029d63ef3fc7c8663a7415c",
strip_prefix = "rules_proto-5.3.0-21.5",
urls = ["https://github.com/bazelbuild/rules_proto/archive/refs/tags/5.3.0-21.5.tar.gz",],
urls = ["https://github.com/bazelbuild/rules_proto/archive/refs/tags/5.3.0-21.5.tar.gz"],
),
)
16 changes: 16 additions & 0 deletions buf.gen.go.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
version: v1
managed:
enabled: true
plugins:
- plugin: buf.build/protocolbuffers/go:v1.28.1
out: go
opt:
- paths=source_relative
- plugin: buf.build/bufbuild/validate-go:v1.0.2
out: go
opt:
- paths=source_relative
- plugin: buf.build/grpc/go:v1.3.0
out: go
opt:
- paths=source_relative
13 changes: 13 additions & 0 deletions buf.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Generated by buf. DO NOT EDIT.
version: v1
deps:
- remote: buf.build
owner: envoyproxy
repository: protoc-gen-validate
commit: 6607b10f00ed4a3d98f906807131c44a
digest: shake256:acc7b2ededb2f88d296862943a003b157bdb68ec93ed13dcd8566b2d06e47993ea6daf12013b9655658aaf6bbdb141cf65bfe400ce2870f4654b0a5b45e57c09
- remote: buf.build
owner: googleapis
repository: googleapis
commit: 28151c0d0a1641bf938a7672c500e01d
digest: shake256:49215edf8ef57f7863004539deff8834cfb2195113f0b890dd1f67815d9353e28e668019165b9d872395871eeafcbab3ccfdb2b5f11734d3cca95be9e8d139de
11 changes: 11 additions & 0 deletions buf.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
version: v1
name: buf.build/cncf/xds
breaking:
use:
- FILE
deps:
- buf.build/envoyproxy/protoc-gen-validate:fab737efbb4b4d03e7c771393708f75594b121e4
- buf.build/googleapis/googleapis:28151c0d0a1641bf938a7672c500e01d
lint:
use:
- DEFAULT
2 changes: 1 addition & 1 deletion go/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ go 1.19

require (
github.com/envoyproxy/protoc-gen-validate v1.0.2
github.com/golang/protobuf v1.5.3
google.golang.org/genproto/googleapis/api v0.0.0-20230822172742-b8732ec3820d
google.golang.org/grpc v1.59.0
google.golang.org/protobuf v1.31.0
)

require (
github.com/golang/protobuf v1.5.3 // indirect
golang.org/x/net v0.14.0 // indirect
golang.org/x/sys v0.11.0 // indirect
golang.org/x/text v0.12.0 // indirect
Expand Down
31 changes: 25 additions & 6 deletions go/udpa/annotations/migrate.pb.go

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

Loading
Loading