-
Notifications
You must be signed in to change notification settings - Fork 425
iox-#2370 Fix Bzlmod dev_dependency setup #2371
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
base: main
Are you sure you want to change the base?
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #2371 +/- ##
=======================================
Coverage 78.25% 78.25%
=======================================
Files 445 445
Lines 17091 17091
Branches 2373 2373
=======================================
+ Hits 13374 13375 +1
Misses 2835 2835
+ Partials 882 881 -1
Flags with carried forward coverage won't be shown. Click here to find out more. 🚀 New features to boost your workflow:
|
@lalten looks fine. The MinGW CI failure is a flaky test, which we can ignore, but the Ubuntu bazel target fails. I assigned @elBoberido since he may has some more insights here. |
@lalten the bzlmod code came from a community member and I'm not that familiar with the code. Can you specify which public targets are affected by the dev dependencies? |
Buildifier is unconditionally depended on in the root BUILD Line 18 in d628cb7
Lines 61 to 65 in d628cb7
Googletest is depended on in a regular cc_library with public visibility: iceoryx/iceoryx_hoofs/BUILD.bazel Line 107 in d628cb7
|
Okay, the Is there another way to mark this library as a dev dependency but still make it available to users? In the end, I guess it should not matter and as long as one does depend only on e.g. |
dev dependencies can not be depended on outside the root module, i.e. as soon as iceoryx is used as Bzlmod dependency of another project (which of course is the intended use case), dev dependencies are not there anymore. See https://bazel.build/rules/lib/globals/module#parameters_1
|
Looks like the buildifier usage is actually ok, here is another repo with the same setup: |
🤷 ❯ cat MODULE.bazel
module(name = "test")
bazel_dep(name = "org_eclipse_iceoryx")
git_override(
module_name = "org_eclipse_iceoryx",
commit = "d628cb7111051ae1cd27620d9a621a366d5cac82",
remote = "https://github.com/eclipse-iceoryx/iceoryx",
)
❯ bazel build @org_eclipse_iceoryx//:iceoryx_binding_c
WARNING: Target pattern parsing failed.
ERROR: Skipping '@org_eclipse_iceoryx//:iceoryx_binding_c': error loading package '@@org_eclipse_iceoryx~//': Unable to find package for @@[unknown repo 'buildifier_prebuilt' requested from @@org_eclipse_iceoryx~]//:rules.bzl: The repository '@@[unknown repo 'buildifier_prebuilt' requested from @@org_eclipse_iceoryx~]' could not be resolved: No repository visible as '@buildifier_prebuilt' from repository '@@org_eclipse_iceoryx~'.
ERROR: error loading package '@@org_eclipse_iceoryx~//': Unable to find package for @@[unknown repo 'buildifier_prebuilt' requested from @@org_eclipse_iceoryx~]//:rules.bzl: The repository '@@[unknown repo 'buildifier_prebuilt' requested from @@org_eclipse_iceoryx~]' could not be resolved: No repository visible as '@buildifier_prebuilt' from repository '@@org_eclipse_iceoryx~'.
INFO: Elapsed time: 1.897s
INFO: 0 processes.
ERROR: Build did NOT complete successfully |
Okay, this is weird. Why should the Do you have time to check it there is an obvious flaw in the bzlmod setup? |
This is still required, without this patch consumers can not depend on the repo as a library. |
The reason that buildifier_prebuilt must be available is that it is Line 18 in 7592b2a
this BUILD must go through build graph analysis by all consumers of iceoryx as a library. Since iceoryx does not state a dependency on buildifier_prebuilt (dev_dependencies are invisible when not the root repo) this load fails and breaks the consumer's build graph. |
I rebased the commit. There isn't really any drawback to just depending on buildifier and googletest. Users don't need to install anything or do any other action, Bazel will handle everything for them. The change is completely transparent for developers of the repo who use it as root module, and it enables use of the repo as a library for downstream consumers. |
Add https://github.com/eclipse-iceoryx/iceoryx/releases/tag/v2.95.4 Includes patches for these PRs: * eclipse-iceoryx/iceoryx#2371 * eclipse-iceoryx/iceoryx#2433 * eclipse-iceoryx/iceoryx#2436 * eclipse-iceoryx/iceoryx#2437 * eclipse-iceoryx/iceoryx#2439 Added `test_targets` in presubmit as well, except for those that are failing due to lack of resources in ci
Okay, just out of interest. Assuming I would not want to declare this as public dependency but keep it as dev dependency. Would it be possible to adjust the root |
I think it may work if you only load() the buildifier repo in BUILD files that don't contain any targets that are dependencies of publicly visible targets. Would need to try that out. Keep in mind consumers may actually want to run the tests (like in the presubmit CI of the BCR), so the BUILDs that contain the tests should work. |
Having the tests for the users is perfectly fine. It's the Currently, the |
tbh I don't think you need the buildifier to be part of the Bazel build graph at all. It's much more common to put it in pre-commit instead: https://github.com/warchant/pre-commit-buildifier |
Agreed with the buildifier not being part of the bazel grahp. But since not all of our contributors are using bazel, we cannot rely on the commit hooks. A CI check would be sufficient, though. Could you add a buildifier action to the bazel job and adjust the If it is easier, it would also be fine to add the prebuild buildifier to |
I sent #2441 |
Add https://github.com/eclipse-iceoryx/iceoryx/releases/tag/v2.95.4 Includes patches for these PRs: * eclipse-iceoryx/iceoryx#2371 * eclipse-iceoryx/iceoryx#2433 * eclipse-iceoryx/iceoryx#2436 * eclipse-iceoryx/iceoryx#2437 * eclipse-iceoryx/iceoryx#2439 Added `test_targets` in presubmit as well, except for those that are failing due to lack of resources in ci
Notes for Reviewer
Fix Bzlmod dev_dependency setup
Pre-Review Checklist for the PR Author
iox-123-this-is-a-branch
)iox-#123 commit text
)task-list-completed
)Checklist for the PR Reviewer
iceoryx_hoofs
have been added to./clang-tidy-diff-scans.txt
Post-review Checklist for the PR Author
References