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

gazelle deletes go_library for protos on second run when map_kind go_proto_library is used #4204

Open
gonzojive opened this issue Dec 27, 2024 · 0 comments

Comments

@gonzojive
Copy link

gonzojive commented Dec 27, 2024

What version of rules_go are you using?

0.51.0

What version of gazelle are you using?

0.40.0

What version of Bazel are you using?

8.0.0

Does this issue reproduce with the latest releases of all the above?

Yes

What operating system and processor architecture are you using?

Linux amd64 (Ubuntu)

Any other potentially useful information about your toolchain?

n/a

What did you do?

I tried to use a custom go_proto_library macro using map kind in the root BUILD.bazel file:

# gazelle:map_kind go_proto_library go_proto_library //bazel:go_proto_library.bzl

What did you expect to see?

I expected to see the usual behavior of gazelle for protos, except load("@io_bazel_rules_go//proto:def.bzl", "go_proto_library") would be replaced by load("//bazel:go_proto_library.bzl", "go_proto_library").

What did you see instead?

When gazelle is first run, the behavior is as I would expect. When gazelle is run again, go_library entries disappear from BUILD.bazel files.

example/proto/BUILD.bazel after first //:gazelle run:

load("@io_bazel_rules_go//go:def.bzl", "go_library")
load("@rules_proto//proto:defs.bzl", "proto_library")
load("//bazel:go_proto_library.bzl", "go_proto_library")

proto_library(
    name = "example_proto",
    srcs = ["example.proto"],
    visibility = ["//visibility:public"],
)

go_proto_library(
    name = "example_go_proto",
    compilers = ["@io_bazel_rules_go//proto:go_grpc"],
    importpath = "github.com/gonzojive/gazelle-idempotency-bug/proto/example",
    proto = ":example_proto",
    visibility = ["//visibility:public"],
)

go_library(
    name = "example",
    embed = [":example_go_proto"],
    importpath = "github.com/gonzojive/gazelle-idempotency-bug/proto/example",
    visibility = ["//visibility:public"],
)

After second //:gazelle run:

load("@rules_proto//proto:defs.bzl", "proto_library")
load("//bazel:go_proto_library.bzl", "go_proto_library")

proto_library(
    name = "example_proto",
    srcs = ["example.proto"],
    visibility = ["//visibility:public"],
)

go_proto_library(
    name = "example_go_proto",
    compilers = ["@io_bazel_rules_go//proto:go_grpc"],
    importpath = "github.com/gonzojive/gazelle-idempotency-bug/proto/example",
    proto = ":example_proto",
    visibility = ["//visibility:public"],
)

Reproduction

I created a repo for reproducing the issue: https://github.com/gonzojive/gazelle-idempotency-bug

git clone https://github.com/gonzojive/gazelle-idempotency-bug
cd gazelle-idempotency-bug
SOURCE_REPO_PATH=$PWD go test gazelletest/gazelletest_test.go
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant