-
Notifications
You must be signed in to change notification settings - Fork 7
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
Test data must be on 'testdata' directory not to break bazel / gazelle #102
Comments
Thanks for reporting! The error msg doesn't seem to suggest issue with the directory naming convention. |
Now I feel silly :). Up to now I've being only invoking |
Sorry for reverting myself, but but simply invoking |
I am also struggling importing this repository with Gazelle. Especially when working with This is what I tried
I have also tried to build with build_file_generation set to on, and updating the build_directives to the default gazelle targets, but in that case Gazelle is not creating the build files as expected. I get the following error.
Seems like a Gazelle issue. Not sure how to work around it. |
We did fix a bazel target naming issue in v0.1.1, so if you try that in your go.mod file, it should work. |
The project I created to reproduce the issue was already using v0.1.1. I also faced the issue after org_golang_google_api added this project as a dependnecy, but this minimally reproducible project only include this project. I don't know if the google api repo has an issue, but to me it looks clear that this one has its own problem with gazelle. |
@FranciscoKurpiel do you mind share the errors messages with the v0.1.1 release? thanks |
Gladly. The original post was with v0.1.1, so is the same error: git clone https://gitlab.com/xyko/s2a-go-bazelisk-issue
cd s2a-go-bazelisk-issue
go mod vendor
bazel run //:gazelle update-repos -- -from_file=go.mod -prune=true # this line makes no difference
bazel run //:gazelle
bazel test //...
# Output:
# ERROR: /home/xyko/tmp/s2a-go-bazelisk-issue/vendor/github.com/google/s2a-go/internal/v2/BUILD:41:8: no such package 'internal/proto/common_go_proto': BUILD file not found in any of the following directories. Add a BUILD file to a directory to mark it as a package.
# - /home/xyko/tmp/s2a-go-bazelisk-issue/internal/proto/common_go_proto and referenced by '//vendor/github.com/google/s2a-go/internal/v2:v2_test'
# ERROR: /home/xyko/tmp/s2a-go-bazelisk-issue/vendor/github.com/google/s2a-go/internal/v2/BUILD:41:8: no such package 'internal/v2/tlsconfigstore/example_cert_key': BUILD file not found in any of the following directories. Add a BUILD file to a directory to mark it as a package.
# - /home/xyko/tmp/s2a-go-bazelisk-issue/internal/v2/tlsconfigstore/example_cert_key and referenced by '//vendor/github.com/google/s2a-go/internal/v2:v2_test'
# ERROR: Analysis of target '//vendor/github.com/google/s2a-go/internal/v2:v2_test' failed; build aborted: Analysis failed
# INFO: Elapsed time: 0.244s
# INFO: 0 processes.
# FAILED: Build did NOT complete successfully (0 packages loaded, 31 targets configured)
# ERROR: Couldn't start the build. Unable to run tests |
@FranciscoKurpiel please take a look at #99 (comment) for a potential short-term fix. |
fwiw @xmenxk when utilizing the
Could be an issue in how I set it up, but that looks like an issue in how gazelle handles the testdata files. In the meantime, I've reverted my project (Go client library generation for |
Thanks @noahdietz I'm working two things to address the issue: 1. remove existing bazel BUILD files from the s2a repo, and 2. make sure gazelle can properly generate BUILD.bazel files for the repo. will keep you updated. |
Removing preexisting BUILD files fixes the issue. I noticed the original reported reproduction steps was missing one step, and the error message on the description of this issue were both incorrect. I was totally blind to it up to now. Sorry for it. |
@FranciscoKurpiel @psalaberria002 created a new release v0.1.2, which should work with bazel/gazelle now |
The updated dependency will be present in the upcoming |
v0.1.2 works perfectly on my side. Thanks for the super quick fix. |
Rename
internal/v2/tlsconfigstore/example_cert_key
tointernal/v2/tlsconfigstore/testdata
to avoid breaking bazel users. Make sure this project can be used by bazel users with gazelle out-of-the-box, without the need for workarounds.Context
Projects that use bazel will frequently also use gazelle to generate
BUILD.bazel
files. Since bazel can also run tests it needs to know what files are accessed by tests for hermicity reasons, allowing tests to be rerun when data changes. Gazelle automatically declares test data for all files inside directories that are namedtestdata
. If a test uses files from outside oftestdata
directory, bazel will fail to analyze the build files with a build error. Ideally code that depends on this project should be usable out-of-the-box by bazel users with gazelle.Workarounds are possible, but requiring a workaround will make using anything that depends on this project annoying to use.
Minimally reproducible example
Project: https://gitlab.com/xyko/s2a-go-bazelisk-issue
Step-by-step
Please have bazelisk installed, then:
Expected
Successful run.
Observed
--edit: fixed steps to reproduce the issue and the error message. The previous steps missed the vendoring step, and the result error message was reflecting that, instead of showing the issue I was trying to show. Sorry for the confusion.
The text was updated successfully, but these errors were encountered: