Formerly canonical rules for ruby, that are about 2-3 years behind current Bazel. If they work for you great, but if not — please try the new rules ruby by Alex Radionov: https://github.com/bazel-contrib/rules_ruby
Apache License 2.0
99
stars
37
forks
source link
Adds ruby_rspec and refactors the ruby_bundle rule, plus some more #60
This is a PR that improves and refactors the bundle install command, its steps, build file generation and making installed gems and their binaries available for consumption by the ruby libraries, binaries and tests in the BUILD files.
We also spent considerable amount of time testing various ways of running rspec tests and were able to add three examples to simple script that show three ways of running rspec against a library: 1. Using RubyOpt with -rrspec/autorun, 2. Specifying rspec binary as @bundle//:bin/rspec, and finally 3. By using a new macro and a rule ruby_rspec, which provides sensible defaults and implements (2) in starlark.
We moved a lot of hard coded definitions into the constants file. Most defaults are now specified there.
We added a facility to declare a used attribute as deprecated and log it to the output,
We renamed bundle_install into ruby_bundle to be more consistent and more meaningful in this context, as ruby_bundle not only installs gems but makes them accessible later individually.
We refactored starlark code implementation of ruby_bundle to be modular making it easy to invoke bundler with different commands during the installation.
Other notable changes
We can't disable gems because Bundler fails to work at all
Changing the default of bundle_install to ruby_bundle, but keeping bundle_install as a backwards compatible alias.
Now calling bundle configto set bundler configuration instead of passing command line options, which have been deprecated and are now causing errors with Bundler 2.1.2
Added buildifier for the generated BUILD.bazel file
What’s Changed?
This is a PR that improves and refactors the bundle install command, its steps, build file generation and making installed gems and their binaries available for consumption by the ruby libraries, binaries and tests in the BUILD files.
We also spent considerable amount of time testing various ways of running rspec tests and were able to add three examples to simple script that show three ways of running rspec against a library: 1. Using RubyOpt with -rrspec/autorun, 2. Specifying rspec binary as
@bundle//:bin/rspec
, and finally 3. By using a new macro and a ruleruby_rspec
, which provides sensible defaults and implements (2) in starlark.We moved a lot of hard coded definitions into the constants file. Most defaults are now specified there.
We added a facility to declare a used attribute as deprecated and log it to the output,
We renamed
bundle_install
intoruby_bundle
to be more consistent and more meaningful in this context, asruby_bundle
not only installs gems but makes them accessible later individually.We refactored starlark code implementation of ruby_bundle to be modular making it easy to invoke bundler with different commands during the installation.
Other notable changes
We can't disable gems because Bundler fails to work at all
Changing the default of
bundle_install
toruby_bundle
, but keepingbundle_install
as a backwards compatible alias.Now calling
bundle config
to set bundler configuration instead of passing command line options, which have been deprecated and are now causing errors with Bundler 2.1.2Added buildifier for the generated BUILD.bazel file