You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Add a Rails app to the examples folder if and when possible. #144
Not sure if the rules can already be used on a Rails App, but I think that this should be ultimately a goal because so many huge monolithic applications can benefit from partial Bazel builds (that would likely be mostly running tests on sub-sections of the app that changed).
Perhaps leave this as a placeholder for now, or comment why this isn't a goal, or what do you think about Rails support down the road.
@J-Swift I don't think there is that much to be done to make Rails work via Bazel. In fact, there should not be a big need to change the codebase structure in any way except for adding BUILD files in specific directories and making the dependencies more explicit.
I was thinking more about trying to actually leverage bazel in a rails app so you could eg slice up the test suite and not run the whole thing
That's what I mean by "making the dependencies more explicit". For example, you can create separate targets for app/models/user.rb and test/models/user_test.rb. The latter would depend on the former. Now, whenever the model is changed, the bazel test ... would run the model test. But if the model was not changed, it would re-use the cached test result until one of the test target dependencies change.
I guess I just think rails apps typically are not operating with such explicit boundaries and so really the only way I imagined it being possible is if things were split into code modules (eg engines, or gems)
Nothing really stops you from doing the dependencies only with Bazel. In this case, during the test execution, Bazel will symlink dependencies into a test runfiles tree, allowing you to see when the boundaries are violated.
Activity
p0deje commentedon Jul 27, 2024
I think it would be great to have a Rails example, PRs are welcome!
J-Swift commentedon Aug 21, 2024
I was just thinking through what it would mean to put a Rails app in bazel and landed here : D
Agreed, Id love to see the intended way to split code to be more 'bazely' for a rails app.
p0deje commentedon Aug 21, 2024
@J-Swift I don't think there is that much to be done to make Rails work via Bazel. In fact, there should not be a big need to change the codebase structure in any way except for adding
BUILDfiles in specific directories and making the dependencies more explicit.J-Swift commentedon Aug 21, 2024
I was thinking more about trying to actually leverage bazel in a rails app so you could eg slice up the test suite and not run the whole thing
p0deje commentedon Aug 21, 2024
That's what I mean by "making the dependencies more explicit". For example, you can create separate targets for
app/models/user.rbandtest/models/user_test.rb. The latter would depend on the former. Now, whenever the model is changed, thebazel test ...would run the model test. But if the model was not changed, it would re-use the cached test result until one of the test target dependencies change.J-Swift commentedon Aug 21, 2024
I guess I just think rails apps typically are not operating with such explicit boundaries and so really the only way I imagined it being possible is if things were split into code modules (eg engines, or gems)
p0deje commentedon Aug 21, 2024
Nothing really stops you from doing the dependencies only with Bazel. In this case, during the test execution, Bazel will symlink dependencies into a test
runfilestree, allowing you to see when the boundaries are violated.J-Swift commentedon Aug 21, 2024
Ok interesting Ill have to test it out when I get time
p0deje commentedon Sep 30, 2025
Added in #258