Speed up your builds, fully utilize your Travis Pro capacity!
When using Travis Pro we had five available executors, of which only two were being used, one by Jasmine and one by Rspec. This allows you to split your spec suite into multiple, but equal parts. We wanted to split our rspec suite into four parts to fully utilize our remaining executors.
This sped up our Travis Pro builds from running one travis process in 70 minutes to running four processes in 15 minutes each.
See the blog post about how we went about configuring this gem for Travis.
Add this line to your application's Gemfile:
And then execute:
Or install it yourself as:
$ gem install rspec-parts
Now you can run the following:
This will divide your specs into four equal parts, then run the first part of the four.
rake spec:part[2,4] will run the second part, and so on.
Travis CI set up
See the file .travis.example.yml for an example on how to configure travis to run these builds.
This gem should work pretty well with rspec. If you need to configure something, however, you must create the file
spec/support/rspec-parts.rb, and configure as below:
Rspec::Parts.configure do |config| config.file_list_exclusions = ['spec/controllers/jasmine_fixture_generation/*.rb'] config.spec_directory_glob = 'spec/*' config.rspec_opts = '--profile --tag ~nginx --format progress' config.default_number_of_parts = 2 end
file_list_exclusionswill exclude the following files or directories from running.
spec_directory_globallows you to choose which directories to include
rspec_optsallows you to tack on rspec options to the
default_number_of_partsdefaults to 4. This gets overridden by the second parameter in the command
rake spec:part[1,4]but can be useful if you want to run a shortened version of the command:
rspec_parts.rake file for the usage of configuration variables.
After checking out the repo, run
bin/setup to install dependencies. Then, run
rake spec to run the tests. You can also run
bin/console for an interactive prompt that will allow you to experiment.
To install this gem onto your local machine, run
bundle exec rake install. To release a new version, update the version number in
version.rb, and then run
bundle exec rake release, which will create a git tag for the version, push git commits and tags, and push the
.gem file to rubygems.org.
Bug reports and pull requests are welcome on GitHub at https://github.com/hjhart/rspec-parts. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the Contributor Covenant code of conduct.
The gem is available as open source under the terms of the MIT License.