bufbuild / rules_buf

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

Add bzlmod support #42

Closed alexeagle closed 1 year ago

alexeagle commented 1 year ago

Bazel modules are moving away from setup in WORKSPACE files, towards a 'package manager' called bzlmod. Such modules are published on https://registry.bazel.build and are easier for developers to consume in their Bazel projects.

CLAassistant commented 1 year ago

CLA assistant check
All committers have signed the CLA.

alexeagle commented 1 year ago

Here's what it looks like going into the Bazel module registry: https://github.com/bazelbuild/bazel-central-registry/pull/997

srikrsna-buf commented 1 year ago

Thank you so much for this PR! Could you also add an example of using the buf_dependencies repo rule?

srikrsna-buf commented 1 year ago

Closes #33

alexeagle commented 1 year ago

@srikrsna-buf done

alexeagle commented 1 year ago

Ping @srikrsna-buf

srikrsna-buf commented 1 year ago

Was caught up with something I'll take a closer look at this today.

debkanchan commented 1 year ago

plis merge i cri everyday

alexeagle commented 1 year ago

I am also in emotional distress @srikrsna-buf

srikrsna-buf commented 1 year ago

Hey @alexeagle! I am not sure if you can see this, but I reviewed it last week asking about the examples.

If you have, then don't you think we should update all the examples?

debkanchan commented 1 year ago

Hey @alexeagle , any update?

srikrsna-buf commented 1 year ago

I'll merge this and take up examples in a later PR, @DebkanchanSamadder you can use modules already based on thanks to @alexeagle for using a patch: https://github.com/bazelbuild/bazel-central-registry/pull/997

srikrsna-buf commented 1 year ago

@alexeagle I don't have permission to push to the fork, could you resolve the merge conflicts? Alternatively, I've resolved conflicts and pushed it to bzlmod branch on this repo, you can push that branch to your fork

debkanchan commented 1 year ago

Can't seem to make it work with gazelle. Getting the following error error loading package '@rules_buf~0.1.1//gazelle/buf': Unable to find package for @[unknown repo 'io_bazel_rules_go' requested from @rules_buf~0.1.1]//go:def.bzl: The repository '@[unknown repo 'io_bazel_rules_go' requested from @rules_buf~0.1.1]' could not be resolved: No repository visible as '@io_bazel_rules_go' from repository '@rules_buf~0.1.1'. and referenced by '//:gazelle-buf'

here's the BUILD file

load("@gazelle//:def.bzl", "DEFAULT_LANGUAGES", "gazelle", "gazelle_binary")

gazelle_binary(
    name = "gazelle-buf",
    languages = DEFAULT_LANGUAGES + [
        # Loads the Buf extension
        "@rules_buf//gazelle/buf:buf",
        # NOTE: This needs to be loaded after the proto language
    ],
)

# gazelle:prefix github.com/ride-app/driver-service
# gazelle:build_file_name BUILD.bazel
# gazelle:exclude infra
# gazelle:proto disable_global
gazelle(
    name = "gazelle",
    gazelle = ":gazelle-buf",
)
alexeagle commented 1 year ago

@srikrsna-buf I rebased it.

Sorry I forgot about your request to merge the examples. I'll do that, but I'm not sure I can get to it right away, so yeah if you're okay to merge in this state, it would help folks who are trying to turn on bzlmod with Bazel 7 right now.

srikrsna-buf commented 1 year ago

I can merge this without the examples but was just looking at https://github.com/bufbuild/rules_buf/pull/42#issuecomment-1797519771 to see if it works with gazelle.

srikrsna-buf commented 1 year ago

Actually lets merge this as is, I'll take up fixing it for gazelle in a followup pr as that is not being read from here.

alexeagle commented 12 months ago

@srikrsna-buf thanks, can we work on publishing a release now?