Project

fast_rake

0.0
No commit activity in last 3 years
No release in over 3 years
Runs a small number of setup tasks, followed by a bunch of expensive tasks in parallel. This manages the number of running tasks and keeps the visible output to a small and useful amount. It was created to make developer pre-commit builds really fast, but still able to cover a lot of tests.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 3.0.0
 Project Readme

fast_rake

SYNOPSIS

This is a spinoff from making our local developer build faster. The intention is to run a whole bunch of independant tests in parallel without overloading the computer by spinning them all up at once. We were able to reduce our total build time from about 40 mins to about 10 mins, and our total frustration by more than 100 times!

Usage

For example, in lib/tasks/fast.rake require 'fast_rake'

namespace :fast do
  
  setup_tasks = [
    "environment:testing",
    "clean_and_package",
    "db:migrate"
  ]

  tests = [
    "spec:covered",
    "cucumber:firefox_g1",
    "cucumber:firefox_g2",
    "cucumber:firefox_g2",
    "cucumber:firefox_ungrouped",
    "cucumber:firefox_offline_g1",
    "cucumber:firefox_offline_g2",
    "cucumber:firefox_offline_g2",
    "cucumber:firefox_offline_ungrouped",
    "jasmine:integration",
    "jasmine:chrome_integration",
    "jasmine:phantom",
    "quality"
  ]
  
  FastRake::fast_runner_task(:all, setup_tasks, tests, true)
end
task :fast, [:count, :list] => "fast:all"

Then task:all will have been created, which when run will run the full set of your tests.

This will autodetect the number of processors that you have available to run your tasks. If you want to specify the number of processes that should run in parallel, then this accepts a fifth positional parameter. Or you can pass an integer from the command line

rake fast[4]

The fourth parameter specifies whether it should fail fast (stop after the first failure) or instead execute every task (and show all failures).

These tasks can also be executed with a specific list of tasks (with or without a processor count):

rake fast:all[,'task1 task2']"

or rake fast:all[4,'task1 task2']"

Or you can use:

FastRake::fast_runner_task(:smaller_set, setup_tasks, a_smaller_subset, false)

to create a single task named fast:smaller_set that runs a specific subset of tasks.

Databases

A database is created for each task by the name of the task, to use these you should modify your database.yml to contain something like:

test:
  adapter: postgresql
  host: localhost
  database: <%= ENV["TEST_DB_NAME"] %>
  username: <%= ENV['USER'] %>
  min_messages: WARNING

Environment variables

Some environment variables are setup for your use.

TEST_DB_NAME: this is the name of the database that has been created

TEST_ENV_NUMBER: this is an incrementing number for each task that is started. Useful for ensuring unique resources for running tests (ports etc)

INSTALLATION

Include in your Gemfile

gem 'fast_rake'

LICENSE

(The MIT License)

Copyright (c) 2012 Jonathan Ricketson

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.