bufbuild / rules_buf

Bazel rules for Buf.
Apache License 2.0
47 stars 17 forks source link

Support gazelle in bzlmod #46

Closed srikrsna-buf closed 11 months ago

srikrsna-buf commented 11 months ago

Support gazelle in bzlmod. #42 added support for bzlmod but it did not support the gazelle plugin, this updates the module file to support gazelle.

Geethree commented 11 months ago

Oh yeah! I want this =)

Geethree commented 11 months ago

Any chance we can get a new patch release out? ;)

srikrsna-buf commented 11 months ago

@Geethree Yes, I'd like get some cleanup work before I tag a release (mainly update deps). Should be soon

debkanchan commented 11 months ago

@srikrsna-buf any updates on release? This has been a blocker for weeks for us

srikrsna-buf commented 11 months ago

@srikrsna-buf any updates on release? This has been a blocker for weeks for us

After #48 is merged, I have to update the docs and then we can cut a release. In the meantime you can use the git_override

debkanchan commented 11 months ago

@srikrsna-buf I'm trying to follow the example but I'm getting the following error

ERROR: Analysis of target '//internal/api-handlers:api-handlers_test' failed; build aborted: module extension "buf" from "@rules_buf~override//buf:extensions.bzl" does not generate repository "buf_deps", yet it is imported as "buf_deps" in the usage at /Users/debkanchan/Code/ride/backend/driver-service/MODULE.bazel:15:20

MODULE.bazel

bazel_dep(name = "rules_go", version = "0.42.0")
bazel_dep(name = "gazelle", version = "0.34.0")
bazel_dep(name = "rules_pkg", version = "0.9.1")
bazel_dep(name = "rules_buf", version = "0.1.1")
bazel_dep(name = "rules_proto", version = "5.3.0-21.7")
bazel_dep(name = "rules_oci", version = "1.4.0")
bazel_dep(name = "container_structure_test", version = "1.16.0")

git_override(
    module_name = "rules_buf",
    commit = "ade38fc",
    remote = "https://github.com/bufbuild/rules_buf.git",
)

buf = use_extension("@rules_buf//buf:extensions.bzl", "buf")

# Override the default version of buf
buf.toolchains(version = "v1.27.0")

# Allow references to labels under @buf_deps
use_repo(buf, "buf_deps")

go_deps = use_extension("@gazelle//:extensions.bzl", "go_deps")
go_deps.from_file(go_mod = "//:go.mod")
use_repo(go_deps, "build_buf_gen_go_bufbuild_protovalidate_protocolbuffers_go", "build_buf_gen_go_ride_wallet_connectrpc_go", "build_buf_gen_go_ride_wallet_protocolbuffers_go", "com_connectrpc_connect", "com_github_bufbuild_protovalidate_go", "com_github_golang_jwt_jwt_v5", "com_github_google_wire", "com_github_ilyakaznacheev_cleanenv", "com_github_micahparks_keyfunc_v2", "com_github_mmcloughlin_geohash", "com_github_onsi_ginkgo_v2", "com_github_onsi_gomega", "com_google_cloud_go_firestore", "com_google_firebase_go_v4", "org_golang_google_genproto", "org_golang_google_genproto_googleapis_api", "org_golang_google_grpc", "org_golang_google_protobuf", "org_golang_x_net", "org_uber_go_mock", "org_uber_go_zap")

oci = use_extension("@rules_oci//oci:extensions.bzl", "oci")
oci.pull(
    name = "distroless",
    digest = "sha256:e7e79fb2947f38ce0fab6061733f7e1959c12b843079042fe13f56ca7b9d178c",
    image = "gcr.io/distroless/static",
    platforms = [
        "linux/amd64",
        "linux/arm64/v8",
    ],
)
use_repo(oci, "distroless")
srikrsna-buf commented 11 months ago

@DebkanchanSamadder If you don't need to use buf.dependency like in the example no need to call use_repo(buf, "buf_deps")

debkanchan commented 11 months ago

There's an existing issue with cel naming convention which is causing build with bzlmod to fail when using protovalidate. Any bzlmod specific workaround @srikrsna-buf ?

srikrsna-buf commented 11 months ago

@DebkanchanSamadder Maybe a better place to open the issue is the protovalidate repo? Also could you give a reproducible example? Maybe the module file?