bake-heroku 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 00538ff16af4937680d001b288326269a3a3ad6b
4
+ data.tar.gz: 7fa252d5d1f6f39d677c62199e2e88b70f56f586
5
+ SHA512:
6
+ metadata.gz: c562d9b98b77af8613768db4c7f10c13df5dda394ea4ca124498cb886655d27edbf95ad6cd8f79982f513b24f99ebd456d9bb8fc1025a04562ba7dbb1bef0a15
7
+ data.tar.gz: 0102fca74715bad5e3d7008c4f3845919d0974fb7d721a962385eec900cf9a73ff66a711a88e6e53f86fb4961b6bda3997d32ee7b2d6ef5808130325fb126cf9
data/.gitignore ADDED
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/.ruby-gemset ADDED
@@ -0,0 +1 @@
1
+ bake
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ 2.1.2
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 Vic Ramon
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,41 @@
1
+ # Bake
2
+
3
+ ### WARNING: This is a work in progress.
4
+
5
+ Run your Rails test suite in parallel on multiple Heroku instances. The goal of this project is to cut the running time of >10 minute test suites to <1 minute.
6
+
7
+ ## Requirements
8
+
9
+ * Heroku Toolbelt -- installed with brew. If you downloaded it from Heroku you may need to uninstall it and run `brew install heroku`. Heroku's version relies on Ruby 1.9.3, which can cause problems.
10
+
11
+ * Be logged in to Heroku through the toolbelt.
12
+
13
+ ## Setup
14
+
15
+ Add `bake-heroku` to your Gemfile. Make sure it's under the test group.
16
+
17
+ ```
18
+ group :test do
19
+ gem 'bake-heroku'
20
+ end
21
+ ```
22
+
23
+ Run bundle.
24
+
25
+ ```
26
+ $ bundle
27
+ ```
28
+
29
+ Setup bake with `bake init`. Pass the number of Heroku instances you want to create to the `-n` flag:
30
+
31
+ ```
32
+ $ bake init -n 5
33
+ ```
34
+
35
+ ## Run
36
+
37
+ Run your cucumber tests with:
38
+
39
+ ```
40
+ $ bake
41
+ ```
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
data/bake.gemspec ADDED
@@ -0,0 +1,22 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'bake/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "bake-heroku"
8
+ spec.version = Bake::VERSION
9
+ spec.authors = ["Vic Ramon"]
10
+ spec.email = ["vic@vicramon.com"]
11
+ spec.summary = %q{Run your test suite in the cloud.}
12
+ spec.description = %q{Bake: Run your test suite in the cloud.}
13
+ spec.license = "MIT"
14
+
15
+ spec.files = `git ls-files -z`.split("\x0")
16
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
17
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
18
+ spec.require_paths = ["lib"]
19
+
20
+ spec.add_development_dependency "bundler", "~> 1.5"
21
+ spec.add_runtime_dependency "thor", "~> 0.19"
22
+ end
data/bin/bake ADDED
@@ -0,0 +1,5 @@
1
+ #!bin/bash
2
+
3
+ require_relative '../lib/bake'
4
+
5
+ BakeCLI.start
data/lib/bake.rb ADDED
@@ -0,0 +1,118 @@
1
+ require "bake/version"
2
+ require 'thor'
3
+ require 'securerandom'
4
+
5
+ class BakeCLI < Thor
6
+
7
+ default_task :bake
8
+
9
+ desc 'help', 'Display options'
10
+ def help
11
+ puts """Usage:
12
+ bake init [-n number-of-instances] # Prepares your app for Bake.
13
+ bake # Runs your test suite
14
+ """
15
+ end
16
+
17
+ desc 'init', 'Setup curent directory to use bake'
18
+ method_option :instances, aliases: "-n", desc: "Number of instances to setup",
19
+ type: :numeric, default: 1
20
+ def init
21
+ create_bake_repo
22
+ create_herokus(options[:instances])
23
+ git_add_all
24
+ git_push
25
+ puts "You're all ready to bake!"
26
+ end
27
+
28
+ desc 'bake', 'Run your test suite in the cloud'
29
+ def bake
30
+ unless File.directory?('.bake')
31
+ not_setup ; return
32
+ end
33
+ puts "Running your test suite in *THE CLOUD*..."
34
+ git_add_all
35
+ git_push
36
+ cucumber
37
+ end
38
+
39
+ desc 'cucumber', 'Run cucumber tests'
40
+ def cucumber
41
+ features = Dir['features/**/*.feature']
42
+ slice_length = features.count / instances.count
43
+
44
+ threads = features.each_slice(slice_length).to_a.map.with_index do |group, index|
45
+ Thread.new do
46
+ puts `heroku run cucumber -f pretty #{group.join(" ")} --app #{instances[index]}`
47
+ end
48
+ end
49
+ threads.each(&:join)
50
+ end
51
+
52
+ private
53
+
54
+ def git_push
55
+ puts "Pushing to test instances..."
56
+ threads = instances.map do |name|
57
+ Thread.new do
58
+ system "git --git-dir .bake push -f #{name} master"
59
+ prepare_for_tests(name)
60
+ end
61
+ end
62
+ threads.each(&:join)
63
+ puts "Push completed."
64
+ end
65
+
66
+ def not_setup
67
+ puts "Your app isn't prepared to bake. Run 'bake init' first."
68
+ end
69
+
70
+ def create_bake_repo
71
+ puts "Creating a bake repo..."
72
+ return puts "Bake repo already exists." if File.directory?('.bake')
73
+ system """
74
+ mv .git .gitorig
75
+ git init
76
+ mv .git .bake
77
+ mv .gitorig .git
78
+ echo /.bake >> .gitignore
79
+ """
80
+ puts "Bake repo created."
81
+ end
82
+
83
+ def instances
84
+ `git --git-dir .bake remote`.split("\n")
85
+ end
86
+
87
+ def prepare_for_tests(name)
88
+ system """
89
+ heroku config:set RAILS_ENV=test RACK_ENV=test --app #{name}
90
+ heroku run rake db:migrate --app #{name}
91
+ """
92
+ end
93
+
94
+ def create_herokus(number)
95
+ puts "Creating Heroku test instances..."
96
+ threads = number.times.map do
97
+ Thread.new do
98
+ name = "bake-" + SecureRandom.hex(10)
99
+ system """
100
+ heroku create #{name}
101
+ heroku ps:scale web=0
102
+ heroku config:set BUNDLE_WITHOUT=development --app #{name}
103
+ git --git-dir .bake remote add #{name} git@heroku.com:#{name}.git
104
+ """
105
+ end
106
+ end
107
+ threads.each(&:join)
108
+ puts "Instances created."
109
+ end
110
+
111
+ def git_add_all
112
+ system """
113
+ git --git-dir .bake add .
114
+ git --git-dir .bake commit -m 'mmmm...this code smells tasty' >/dev/null
115
+ """
116
+ end
117
+
118
+ end
@@ -0,0 +1,3 @@
1
+ module Bake
2
+ VERSION = "0.0.1"
3
+ end
metadata ADDED
@@ -0,0 +1,84 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: bake-heroku
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Vic Ramon
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-06-25 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.5'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.5'
27
+ - !ruby/object:Gem::Dependency
28
+ name: thor
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '0.19'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '0.19'
41
+ description: 'Bake: Run your test suite in the cloud.'
42
+ email:
43
+ - vic@vicramon.com
44
+ executables:
45
+ - bake
46
+ extensions: []
47
+ extra_rdoc_files: []
48
+ files:
49
+ - ".gitignore"
50
+ - ".ruby-gemset"
51
+ - ".ruby-version"
52
+ - Gemfile
53
+ - LICENSE.txt
54
+ - README.md
55
+ - Rakefile
56
+ - bake.gemspec
57
+ - bin/bake
58
+ - lib/bake.rb
59
+ - lib/bake/version.rb
60
+ homepage:
61
+ licenses:
62
+ - MIT
63
+ metadata: {}
64
+ post_install_message:
65
+ rdoc_options: []
66
+ require_paths:
67
+ - lib
68
+ required_ruby_version: !ruby/object:Gem::Requirement
69
+ requirements:
70
+ - - ">="
71
+ - !ruby/object:Gem::Version
72
+ version: '0'
73
+ required_rubygems_version: !ruby/object:Gem::Requirement
74
+ requirements:
75
+ - - ">="
76
+ - !ruby/object:Gem::Version
77
+ version: '0'
78
+ requirements: []
79
+ rubyforge_project:
80
+ rubygems_version: 2.2.1
81
+ signing_key:
82
+ specification_version: 4
83
+ summary: Run your test suite in the cloud.
84
+ test_files: []