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

wanted: rules_ruby #1083

Closed
1 task
alexeagle opened this issue Nov 1, 2023 · 4 comments
Closed
1 task

wanted: rules_ruby #1083

alexeagle opened this issue Nov 1, 2023 · 4 comments
Labels
module wanted Users want a certain module to be available in the BCR, contributions are welcome!

Comments

@alexeagle
Copy link
Contributor

Module location

Various forks

Link to bzlmod issue in the module's repository

No response

Any other context to provide?

protobuf is in the registry, but cannot be updated to a more recent release due to a newly introduced dependency on rules_ruby, see protocolbuffers/protobuf#14569

Unfortunately rules_ruby has gone through a series of forks, and I don't think any of them are canonical.

The Rules Authors SIG has some funding now, so my sense is that we need to jump in front of this situation, determine which of these is the "canonical" and then put some effort into converging some of them again.

Fund our work

  • Sponsor our community's open source work by donating a feature bounty
@alexeagle alexeagle added the module wanted Users want a certain module to be available in the BCR, contributions are welcome! label Nov 1, 2023
@alexeagle
Copy link
Contributor Author

As I announced on Bazel slack in #ruby we are planning to publish https://github.com/p0deje/rules_ruby to BCR

@alexeagle
Copy link
Contributor Author

https://registry.bazel.build/modules/rules_ruby

@p0deje yay!

@kigster
Copy link

kigster commented Nov 28, 2023

Honestly, I think it might be helpful to get the bazelruby rules up to date and compare.

The focus when we wrote them was on staying as close as possible to a typical ruby developer flow. I don't know if we succeeded, but let's look at an example:

https://github.com/p0deje/rules_ruby/blob/main/examples/gem/spec/BUILD

Versus

https://github.com/bazelruby/rules_ruby/blob/master/examples/simple_script/BUILD.bazel#L53

There are just a lot more features that developers might want. Like running rspec against all files under spec folder, being able to pass arguments, and so on.

The idea is that we don't want to create a BUILD file in each folder, and it's probably not desirable to have to have a target per test file.

So my focus is on productivity and having Bazel co-exist with rhe ruby ecosystem, and definitely avoid requiring a BUILD file in every subdirectory of a spec folder or lib folder.

I want to make sure the examples from this folder in rhe bazelruby/rules_ruby still works with new rules. Otherwise porting projects would be a nightmare.

I'll try to find the time to get the old rules up to the latest versions of everything...

@p0deje
Copy link

p0deje commented Nov 28, 2023

The idea is that we don't want to create a BUILD file in each folder, and it's probably not desirable to have to have a target per test file.

The ruleset supports both.

You can create a single test target that will run all the specs and pass extra arguments to it like this:

rb_test(
    name = "spec",
    srcs = glob(["spec/**/*.rb"],
    main = "@bundle//:bin/rspec",
    args = ["--format", "progress"],
    deps = ["@bundle"],
)
bazel test --test_arg="--fail-fast" :spec

This is more common in Ruby projects. However, you can also create a tree of build files nested in directories which is more common in Bazel with a target per each spec file. The benefits of this approach are:

  1. better caching of test results (one dependency change invalidates results only for the tests having this dependency)
  2. out-of-the-box parallelism since Bazel runs each target in a separate process
  3. ability to run individual tests w/o --test_arg usage
  4. ability to use --flaky_test_attempts to run spec files that fail with flakiness

I made a small video back for Selenium showing why per-test targets are useful - https://youtu.be/lqqXHEBvU0Y

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
module wanted Users want a certain module to be available in the BCR, contributions are welcome!
Projects
None yet
Development

No branches or pull requests

3 participants