jumpup 0.0.6 → 0.0.7

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0ed0c9528c69588fdb4ceeb4c0903e2a1d3031a3
4
- data.tar.gz: f97154f489694aacfa37c24c85b4b8be5c493523
3
+ metadata.gz: ff68a671a142a27009322cfb38911217cf84f588
4
+ data.tar.gz: 691e3f44c7dcfbf8f6c30145b7605bb54a973722
5
5
  SHA512:
6
- metadata.gz: 1fd5bc4b91d8d3f279d4f0618009b3475d60a8e5dcf7c3056f9db4965b43ceda7e3b8579ef5221032c17e91f4afe3634f288f49af3ad5d22c39c0023a140e8f4
7
- data.tar.gz: f769f6316fc344fddc4e025016fc4e9fd24d38248688e5ce6057d87a267b78379c1184a4ca31c8f9311ead56d559d3e379349a12577e967bf61a244ea8eca80d
6
+ metadata.gz: 47dd5dd1d4dfd1f973e10143b65a5c5b0aed496a4b5166c205a09d6ef3340e6f5bd6d30ebbf10f97499b8eea2e7d22801905f7016524afc7e919b7020678b7d9
7
+ data.tar.gz: 33ba51c18acbe2b644e35c704333f17fb1610ea8c705e48e7376b3a1286a8fc9e8168e7a3b61aa965823f425397f8a3d0233d2e5042215f4e268e3e726d8e2b9
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --format progress
@@ -0,0 +1,2 @@
1
+ Style/Documentation:
2
+ Enabled: false
@@ -0,0 +1 @@
1
+ jumpup
@@ -0,0 +1 @@
1
+ 2.1.2
@@ -0,0 +1,6 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.1.2
4
+ before_script:
5
+ - git config --global user.email "johndoe@example.com"
6
+ - git config --global user.name "John Doe"
@@ -1,12 +1,17 @@
1
1
  # Changelog
2
2
 
3
- ## 0.0.7 (unreleased)
3
+ ## 0.0.7 (September 15, 2014)
4
4
 
5
5
  ### features
6
+ - Implements tasks jumpup:integration:check, jumpup:integration:lock, jumpup:integration:unlock to block a user from integrating while another one is already integrating at same time. It is useful when the project have a lot of tests because it avoids the second user to receive the reject message from git, and have to run all tests again.
7
+ - Add quiet git messages on rake integrate.
6
8
 
7
9
  ### improvements
10
+ - Add tests with rspec and aruba
8
11
 
9
12
  ### bug fixes
13
+ - Delete integrating local tag before fetching remote tags
14
+ - Fix "uninitialized constant Jumpup::GitCommand::Rake"
10
15
 
11
16
  ## 0.0.6 (July 11, 2014)
12
17
 
@@ -1,109 +1,132 @@
1
1
  # Jumpup
2
+ [![Build Status][travis_badge]][travis]
2
3
  [![RubyGems][gem_version_badge]][ruby_gems]
3
4
 
4
- ## What
5
+ Jumpup is a gem that provides a set of tasks to automate all steps of a [synchronous continuous integration][sci] process for [Ruby on Rails][ror] apps, that is, [continuous integration][ci] without a server such as [Travis][travis].
5
6
 
6
- Jumpup is a [Ruby on Rails][ror] gem that provides a set of tasks to automate all steps of a [synchronous continuous integration][sci] process, that is, [continuous integration][ci] without a server such as [Travis][travis]. Why? Because that's the way we like it!
7
+ ## Why?
7
8
 
8
- ## Installing
9
+ Because that's the way [we][helabs] like it!
9
10
 
10
- Add it to your Gemfile:
11
+ ## Installation
11
12
 
12
- group :development do
13
- gem 'jumpup'
14
- end
13
+ Add the gem to the `development` section of your `Gemfile` and run `bundle install`:
15
14
 
16
- After installing the gem is ready to be used and you will need to execute only one task in order to integrate your code safely:
15
+ ```ruby
16
+ group :development do
17
+ gem 'jumpup'
18
+ end
19
+ ```
17
20
 
18
- rake integrate
21
+ ## Usage
19
22
 
20
- ## Dependencies
21
-
22
- * Git
23
- * [Rcov][rc](Ruby 1.8) or [Simplecov][sc](Ruby 1.9) (optional)
24
-
25
- ## [ProTip] Using Simplecov
26
-
27
- Using simplecov on your test suite will make your tests to run slower. You can fix it using an environment variable called "coverage" on test_helper.rb/spec_helper.rb to turn on/off the simplecov. See below:
28
-
29
- spec_helper.rb or test_helper.rb
30
-
31
- if ENV['coverage'] == 'on'
32
- require 'simplecov'
33
- SimpleCov.start 'rails'
34
- end
35
-
36
- The "coverage" variable is set to "on" by the integration process. When running tests/specs while you're developing, simplecov doesn't run, unless you set "coverage" environment variable by hand.
23
+ After installing the gem, you'll need to configure the set of tasks you'll want to run as part of your integration process before using it. The configuration is done by setting an array of Rake task names as the `INTEGRATION_TASKS` constant on your `lib/tasks/jumpup.rake`. For example:
37
24
 
38
- ## Integration Steps
39
-
40
- The integration process is composed of several steps that are explained ahead. It's possible to skip one or more steps and add other steps of your own. This will be demonstrated shortly. The complete set of steps are:
41
-
42
- 1. task git:status_check
25
+ ```ruby
26
+ INTEGRATION_TASKS = %w(
27
+ jumpup:start
28
+ jumpup:bundle_install
29
+ db:migrate
30
+ spec
31
+ jumpup:finish
32
+ )
33
+ ```
43
34
 
44
- Check if all local files are under control of your scm.
35
+ With that in place, you can execute a single task in order to integrate your code safely:
45
36
 
46
- * task log:clear
37
+ ```
38
+ rake integrate
39
+ ```
47
40
 
48
- Remove log files.
41
+ For more information, please have a look at the "[Integration Steps](#integration-steps)" section below.
49
42
 
50
- * task tmp:clear
43
+ ## Plugins
51
44
 
52
- Remove temporary files.
45
+ * [jumpup-heroku][jumpup-heroku]
46
+ * [jumpup-hipchat][jumpup-hipchat]
53
47
 
54
- * task git:pull
48
+ ## Dependencies
55
49
 
56
- Update local files from your remote scm repository.
50
+ * Git
51
+ * [Rcov][rc] (Ruby 1.8) or [Simplecov][sc] (Ruby 1.9+) (optional)
57
52
 
58
- * task db:migrate
53
+ ## [ProTip] Using Simplecov
59
54
 
60
- Execute any new database migration created by other team members since the last integration.
55
+ Using Simplecov on your test suite will make your tests run slower. You can fix it using an environment variable called `coverage` on your test / spec helper files to enable Simplecov when needed like:
61
56
 
62
- * Your test/spec suite
57
+ ```ruby
58
+ # On your spec_helper.rb / test_helper.rb
59
+ if ENV['coverage'] == 'on'
60
+ require 'simplecov'
61
+ SimpleCov.start 'rails'
62
+ end
63
+ ```
63
64
 
64
- Set the rake task your test/spec suite needs to run. Use a command that generate the coverage files.
65
+ The `coverage` variable is set to "on" automatically by the integration process. When running tests while you're developing, Simplecov will not run unless you set the `coverage` environment variable yourself.
65
66
 
66
- * git:push
67
+ ## Integration Steps
67
68
 
68
- Push your changes. If any of the previous tasks break, because one test failed, for instance, the script won't push. Actually this task runs only if every checking done before work well.
69
+ The integration process is composed of several Rake tasks that are explained below. It's possible to skip one or more steps and add other steps of your own. The complete set of tasks we normally use are:
70
+
71
+ | Rake Task | Description |
72
+ | --------- | ----------- |
73
+ | `jumpup:integration:check` | Check if other user is already integrating, to avoid reject message from git after runing all tests. |
74
+ | `jumpup:integration:lock` | Lock the integration to current user. |
75
+ | `git:status_check` | Check if all local files have been commited to the local git repository. |
76
+ | `log:clear` | Remove log files. |
77
+ | `tmp:clear` | Remove temporary files. |
78
+ | `git:pull` | Update local files from the remote git repository. |
79
+ | `jumpup:start` | Run all the previous tasks on this order |
80
+ | `jumpup:bundle_install` | Run `bundle install` on quiet mode |
81
+ | `db:migrate` | Execute any new database migration created by other team members since the last integration. |
82
+ | `test` or `spec` | Set the rake task your test/spec suite needs to run. Use a command that generate the coverage files. |
83
+ | `git:push` | Push your changes. If any of the previous tasks break, because one test failed, for instance, the script won't push. Actually this task runs only if every checking done before work well. |
84
+ | `jumpup:integration:unlock` | Unlock the integration to current user. |
85
+ | `jumpup:finish` | Run tasks: `git:push` and `jumpup:integration:unlock` |
69
86
 
70
87
  Using this almost paranoid sequence of steps it will be hard to check in bad code in your repository, which is good, very good. The idea is that you should treat your repository as a sacred place, where only good code should ever enter.
71
88
 
72
89
  ### More examples
73
90
 
74
- * Reckless programmer
91
+ #### Reckless programmer
75
92
 
76
- So you don't have tests, nor specs but you still want to use the jumpup. You might get away with this customized lib/tasks/integration.rake:
93
+ Let's say your project don't have tests but you still want to use jumpup. You might get away with this `lib/tasks/jumpup.rake`:
77
94
 
78
- INTEGRATION_TASKS = %w(
79
- jumpup:start
80
- db:migrate
81
- jumpup:finish
82
- )
95
+ ```ruby
96
+ INTEGRATION_TASKS = %w(
97
+ jumpup:start
98
+ jumpup:bundle_install
99
+ db:migrate
100
+ jumpup:finish
101
+ )
102
+ ```
83
103
 
84
- The fact that you can get away with this doesn't mean you should. Don't you think it's already time to grow up and become more professional about software development? I know you believe you have a great excuse to avoid writing those tests or specs. Still it's just an excuse. Write tests or write specs and make a better world!
104
+ The fact that you can get away with this doesn't mean you should. Don't you think it's already time to grow up and become more professional about software development? I know you believe you have a great excuse to avoid writing those tests. Still it's just an excuse. Write tests and make a better world!
85
105
 
86
- * Test conscious programmer
106
+ #### Test conscious programmer
87
107
 
88
- You haven't jumped on the [BDD][BDD] bandwagon yet. Instead, you write tests, which is good, but they don't cover all of your code yet, which is bad. We believe you will improve it and make sure your tests cover 100% of your code. In the meantime you might need to skip coverage checkings. Oh, you also don't use [Selenium][sor]. Shame on you! Try this:
108
+ You haven't jumped on the [BDD][BDD] bandwagon yet. Instead, you write tests, which is good, but they don't cover all of your code yet, which is bad. We believe you will improve it and make sure your tests cover 100% of your code. In the meantime you might need to skip coverage checkings. Try this:
89
109
 
90
- INTEGRATION_TASKS = %w(
91
- jumpup:start
92
- db:migrate
93
- test
94
- jumpup:finish
95
- )
110
+ ```ruby
111
+ INTEGRATION_TASKS = %w(
112
+ jumpup:start
113
+ jumpup:bundle_install
114
+ db:migrate
115
+ spec
116
+ jumpup:finish
117
+ )
118
+ ```
96
119
 
97
- * Spec infected programmer
120
+ #### Spec infected programmer
98
121
 
99
- So you used to [TDD][TDD] all around but then someone told you that this is for gramma. The new wave has a name on it: [BDD][BDD]. So, of course, you now have specs covering 100% of your code and doesn't have any more tests. Great! Just change your test_helper.rb/spec_helper.rb with:
122
+ So you used to [TDD][TDD] all around but then someone told you that this is for gramma. The new wave has a name on it: [BDD][BDD]. So, of course, you now have specs covering 100% of your code and doesn't have any more tests. Great! Just change your test_helper.rb/spec_helper.rb with:
100
123
 
101
- ```ruby
102
- require 'simplecov'
103
- SimpleCov.start 'rails' do
104
- minimum_coverage 100
105
- end
106
- ```
124
+ ```ruby
125
+ require 'simplecov'
126
+ SimpleCov.start 'rails' do
127
+ minimum_coverage 100
128
+ end
129
+ ```
107
130
 
108
131
  ## Versioning
109
132
 
@@ -158,25 +181,22 @@ This gem was created and is maintained by [HE:labs](https://github.com/Helabs).
158
181
 
159
182
  [gem_version_badge]: https://badge.fury.io/rb/jumpup.png
160
183
  [ruby_gems]: http://rubygems.org/gems/jumpup
161
- [piston]: http://piston.rubyforge.org/
162
184
  [mt]: https://github.com/tapajos
163
185
  [sm]: https://github.com/mergulhao
164
186
  [vt]: http://www.improveit.com.br/vinicius
165
- [f]: http://rubyforge.org/forum/?group_id=4662
166
- [s]: http://subversion.tigris.org
167
- [git]: http://git.or.cz/
168
187
  [rc]: http://eigenclass.org/hiki.rb?rcov
169
188
  [sc]: https://github.com/colszowka/simplecov
170
- [sor]: http://selenium-on-rails.openqa.org
171
189
  [rs]: http://rspec.info
172
- [rz]: http://rubyzip.sourceforge.net/
173
190
  [ror]: http://www.rubyonrails.org
174
191
  [sci]: http://jamesshore.com/Blog/Why%20I%20Dont%20Like%20CruiseControl.html
175
- [co]: http://www.improveit.com.br/en/contact
176
192
  [mit]: http://www.opensource.org/licenses/mit-license.php
177
193
  [ci]: http://martinfowler.com/articles/continuousIntegration.html
178
194
  [travis]: http://travis-ci.org
179
- [tar]: http://en.wikipedia.org/wiki/Tar_%28file_format%29
180
195
  [BDD]: http://en.wikipedia.org/wiki/Behavior_driven_development
181
196
  [TDD]: http://en.wikipedia.org/wiki/Test-driven_development
182
197
  [ii]: http://www.improveit.com.br
198
+ [helabs]: http://helabs.com.br/en/
199
+ [jumpup-heroku]: https://github.com/Helabs/jumpup-heroku
200
+ [jumpup-hipchat]: https://github.com/Helabs/jumpup-hipchat
201
+ [travis]: https://travis-ci.org/Helabs/jumpup
202
+ [travis_badge]: https://travis-ci.org/Helabs/jumpup.svg?branch=master
data/Rakefile CHANGED
@@ -1 +1,10 @@
1
- require "bundler/gem_tasks"
1
+ require 'bundler/gem_tasks'
2
+ require 'cucumber/rake/task'
3
+ require 'rspec/core/rake_task'
4
+
5
+ RSpec::Core::RakeTask.new do |t|
6
+ t.pattern = 'spec/**/*_spec.rb'
7
+ end
8
+
9
+ Cucumber::Rake::Task.new
10
+ task default: [:spec, :cucumber]
@@ -0,0 +1,14 @@
1
+ Feature: Coverage
2
+ Scenario: run jumpup:bundle_install
3
+ Given an empty file named "Gemfile"
4
+ Given a file named "Rakefile" with:
5
+ """
6
+ require "jumpup"
7
+
8
+ INTEGRATION_TASKS = %w(
9
+ jumpup:bundle_install
10
+ )
11
+ """
12
+ When I run `rake integrate`
13
+ Then the following files should exist:
14
+ | Gemfile.lock |
@@ -0,0 +1,67 @@
1
+ Feature: Git
2
+ Scenario: running jumpup:git:status_check task with dirty files
3
+ Given a file named "Rakefile" with:
4
+ """
5
+ require "jumpup"
6
+
7
+ INTEGRATION_TASKS = %w(
8
+ jumpup:git:status_check
9
+ )
10
+ """
11
+ When I setup a git repo
12
+ And I run `rake integrate`
13
+ Then the stdout should contain:
14
+ """
15
+ On branch master
16
+ """
17
+ Scenario: running jumpup:git:status_check task without dirty files
18
+ Given a file named "Rakefile" with:
19
+ """
20
+ require "jumpup"
21
+
22
+ INTEGRATION_TASKS = %w(
23
+ jumpup:git:status_check
24
+ )
25
+ """
26
+ When I setup a git repo
27
+ And I run `git add .`
28
+ And I run `git commit -m "Initial commit" -q`
29
+ And I run `rake integrate`
30
+ Then the stdout should not contain:
31
+ """
32
+ On branch master
33
+ """
34
+
35
+ Scenario: jumpup:git:pull task
36
+ Given a file named "Rakefile" with:
37
+ """
38
+ require "jumpup"
39
+
40
+ INTEGRATION_TASKS = %w(
41
+ jumpup:git:pull
42
+ )
43
+ """
44
+ # TODO Use "When I setup a git repo" instead
45
+ When I run `git init -q`
46
+ And I run `rake integrate`
47
+ Then the stderr should contain:
48
+ """
49
+ No remote repository specified
50
+ """
51
+
52
+ Scenario: jumpup:git:push task
53
+ Given a file named "Rakefile" with:
54
+ """
55
+ require "jumpup"
56
+
57
+ INTEGRATION_TASKS = %w(
58
+ jumpup:git:push
59
+ )
60
+ """
61
+ # TODO Use "When I setup a git repo" instead
62
+ When I run `git init -q`
63
+ And I run `rake integrate`
64
+ Then the stderr should contain:
65
+ """
66
+ No configured push destination
67
+ """
@@ -0,0 +1,60 @@
1
+ Feature: Integration
2
+ Scenario: running jumpup:integration:check task with no one integrating
3
+ Given a file named "Rakefile" with:
4
+ """
5
+ require "jumpup"
6
+
7
+ INTEGRATION_TASKS = %w(
8
+ jumpup:integration:check
9
+ )
10
+ """
11
+ When I setup a git repo
12
+ And I run `rake integrate`
13
+ Then the stdout should contain "--> Checking if there's someone integrating..."
14
+ Then the stdout should contain "--> No, go ahead!"
15
+ Scenario: running jumpup:integration:check task when the same user is integrating
16
+ Given a file named "Rakefile" with:
17
+ """
18
+ require "jumpup"
19
+
20
+ INTEGRATION_TASKS = %w(
21
+ jumpup:integration:check
22
+ )
23
+ """
24
+ When I setup a git repo
25
+ And I run `git commit --allow-empty -am 'first commit'`
26
+ And I run `git tag -a integrating -m ''`
27
+ And I run `git push -f origin integrating`
28
+ And I run `rake integrate`
29
+ Then the stdout should contain "--> Checking if there's someone integrating..."
30
+ Then the stdout should contain "--> Project is locked to you"
31
+ Scenario: running jumpup:integration:lock task
32
+ Given a file named "Rakefile" with:
33
+ """
34
+ require "jumpup"
35
+
36
+ INTEGRATION_TASKS = %w(
37
+ jumpup:integration:lock
38
+ )
39
+ """
40
+ When I setup a git repo
41
+ And I run `git commit --allow-empty -am 'first commit'`
42
+ And I run `rake integrate`
43
+ Then the stdout should contain "--> Locking integration..."
44
+ Then the stdout should contain "--> OK!"
45
+ Scenario: running jumpup:integration:unlock task
46
+ Given a file named "Rakefile" with:
47
+ """
48
+ require "jumpup"
49
+
50
+ INTEGRATION_TASKS = %w(
51
+ jumpup:integration:unlock
52
+ )
53
+ """
54
+ When I setup a git repo
55
+ And I run `git commit --allow-empty -am 'first commit'`
56
+ And I run `git tag -a -f integrating -m "Integration started"`
57
+ And I run `rake integrate`
58
+ Then the stdout should contain "--> Unlocking integration..."
59
+ Then the stdout should contain "Deleted tag 'integrating'"
60
+ Then the stdout should contain "--> OK!"
@@ -0,0 +1,74 @@
1
+ Feature: Lifecycle tasks
2
+ Scenario: running jumpup:start task without dirty files
3
+ Given a file named "Rakefile" with:
4
+ """
5
+ require "jumpup"
6
+
7
+ # dummy rails rake tasks
8
+ namespace :log do
9
+ task :clear do
10
+ puts "Clearing log files"
11
+ end
12
+ end
13
+
14
+ namespace :tmp do
15
+ task :clear do
16
+ puts "Clearing tmp files"
17
+ end
18
+ end
19
+
20
+ INTEGRATION_TASKS = %w(
21
+ jumpup:start
22
+ )
23
+ """
24
+ # TODO Use "When I setup a git repo" instead
25
+ When I run `git init -q`
26
+ And I run `git add .`
27
+ And I run `git commit -m "Initial commit" -q`
28
+ And I run `rake integrate`
29
+ Then the stdout should contain "Clearing log files"
30
+ Then the stdout should contain "Clearing tmp files"
31
+ Then the stderr should contain "No remote repository specified"
32
+
33
+ Scenario: running jumpup:start task with dirty files should abort after jumpup:git:status_check task
34
+ Given a file named "Rakefile" with:
35
+ """
36
+ require "jumpup"
37
+
38
+ # dummy rails rake tasks
39
+ namespace :log do
40
+ task :clear do
41
+ puts "Clearing log files"
42
+ end
43
+ end
44
+
45
+ namespace :tmp do
46
+ task :clear do
47
+ puts "Clearing tmp files"
48
+ end
49
+ end
50
+
51
+ INTEGRATION_TASKS = %w(
52
+ jumpup:start
53
+ )
54
+ """
55
+ When I setup a git repo
56
+ And I run `rake integrate`
57
+ Then the stdout should contain "On branch master"
58
+ Then the stdout should not contain "Clearing log files"
59
+ Then the stdout should not contain "Clearing tmp files"
60
+ Then the stdout should not contain "No remote repository specified"
61
+
62
+ Scenario: running jumpup:finish task does a git push
63
+ Given a file named "Rakefile" with:
64
+ """
65
+ require "jumpup"
66
+
67
+ INTEGRATION_TASKS = %w(
68
+ jumpup:finish
69
+ )
70
+ """
71
+ # TODO Use "When I setup a git repo" instead
72
+ When I run `git init -q`
73
+ And I run `rake integrate`
74
+ Then the stderr should contain "No configured push destination"
@@ -0,0 +1,8 @@
1
+ Given(/^I setup a git repo$/) do
2
+ steps %(
3
+ When I run `git init -q`
4
+ And a directory named "/tmp/jumpup-git-repo"
5
+ And I run `git init --bare -q /tmp/jumpup-git-repo`
6
+ And I run `git remote add origin /tmp/jumpup-git-repo`
7
+ )
8
+ end
@@ -0,0 +1,11 @@
1
+ require 'aruba/cucumber'
2
+ require 'pry'
3
+
4
+ Before do
5
+ @aruba_timeout_seconds = 60 * 5
6
+ end
7
+
8
+ After do
9
+ system 'rm -rf tmp/aruba'
10
+ system 'rm -rf /tmp/jumpup-git-repo'
11
+ end
@@ -4,20 +4,24 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
4
  require 'jumpup/version'
5
5
 
6
6
  Gem::Specification.new do |spec|
7
- spec.name = "jumpup"
7
+ spec.name = 'jumpup'
8
8
  spec.version = Jumpup::VERSION
9
- spec.authors = ["HE:labs"]
10
- spec.email = ["contato@helabs.com.br"]
11
- spec.description = %q{A synchronous continuous integration gem.}
12
- spec.summary = %q{Jumpup gem help people that want to do synchronous continuous integration on their ruby projects.}
13
- spec.homepage = "https://github.com/Helabs/jumpup"
14
- spec.license = "MIT"
9
+ spec.authors = ['HE:labs']
10
+ spec.email = ['contato@helabs.com.br']
11
+ spec.description = 'A synchronous continuous integration gem.'
12
+ spec.summary = 'Jumpup gem help people that want to do synchronous continuous integration on their ruby projects.'
13
+ spec.homepage = 'https://github.com/Helabs/jumpup'
14
+ spec.license = 'MIT'
15
15
 
16
- spec.files = `git ls-files`.split($/)
17
- spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
- spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
- spec.require_paths = ["lib"]
16
+ spec.files = `git ls-files`.split($INPUT_RECORD_SEPARATOR)
17
+ spec.executables = spec.files.grep(/^bin\//) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(/^(test|spec|features)\//)
19
+ spec.require_paths = ['lib']
20
20
 
21
- spec.add_development_dependency "bundler", "~> 1.3"
22
- spec.add_development_dependency "rake", "~> 0"
21
+ spec.add_development_dependency 'bundler', '~> 1.3'
22
+ spec.add_development_dependency 'rspec', '~> 3.0'
23
+ spec.add_development_dependency 'aruba'
24
+ spec.add_development_dependency 'pry'
25
+ spec.add_dependency 'rake'
26
+ spec.add_dependency 'colorize'
23
27
  end
@@ -1 +1,49 @@
1
- Dir["#{Gem::Specification.find_by_name('jumpup').full_gem_path}/lib/tasks/*.rake"].each { |ext| load ext } if defined?(Rake)
1
+
2
+ module Jumpup
3
+ class << self
4
+ MISSING_INTEGRATION_TASKS_CONSTANT_MESSAGE = %{
5
+ You should define INTEGRATION_TASKS constant. We recommend that you define it on lib/tasks/jumpup.rake file. The file doesn't exists. You should create it in your project.
6
+
7
+ You'll probably want to add coverage/ to your .gitignore file.
8
+
9
+ A sample content look like this:
10
+
11
+ INTEGRATION_TASKS = %w(
12
+ jumpup:start
13
+ jumpup:bundle_install
14
+ db:migrate
15
+ spec
16
+ jumpup:finish
17
+ )
18
+
19
+ }
20
+
21
+ def perform_integration
22
+ unless defined?(INTEGRATION_TASKS)
23
+ Jumpup::UI.header MISSING_INTEGRATION_TASKS_CONSTANT_MESSAGE
24
+ exit
25
+ end
26
+
27
+ invoke_tasks
28
+ end
29
+
30
+ def load_tasks
31
+ Dir["#{Gem::Specification.find_by_name('jumpup').full_gem_path}/lib/tasks/*.rake"].each { |ext| load ext } if defined?(Rake)
32
+ end
33
+
34
+ private
35
+
36
+ def invoke_tasks
37
+ INTEGRATION_TASKS.each do |subtask|
38
+ Jumpup::UI.header("--> Executing #{subtask}...".white) do
39
+ Rake::Task[subtask].invoke
40
+ end
41
+ end
42
+ end
43
+ end
44
+ end
45
+
46
+ Jumpup.load_tasks
47
+
48
+ require 'jumpup/ui'
49
+ require 'jumpup/commands'
@@ -0,0 +1,2 @@
1
+ require 'jumpup/commands/git_command'
2
+ require 'jumpup/commands/bundler_command'
@@ -0,0 +1,15 @@
1
+ require 'rake'
2
+
3
+ module Jumpup
4
+ module BundlerCommand
5
+ extend ::Rake::DSL
6
+
7
+ class << self
8
+ def install_with_clean_env
9
+ Bundler.with_clean_env do
10
+ sh 'bundle install --quiet'
11
+ end
12
+ end
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,64 @@
1
+ require 'rake'
2
+
3
+ module Jumpup
4
+ module GitCommand
5
+ extend ::Rake::DSL
6
+
7
+ class << self
8
+ def status_check
9
+ result = `git status`
10
+ return unless result.include?('Untracked files:') || result.include?('unmerged:') || result.include?('modified:')
11
+ Jumpup::UI.say result
12
+ exit
13
+ end
14
+
15
+ def pull
16
+ sh 'git pull --rebase --quiet'
17
+ end
18
+
19
+ def push
20
+ sh 'git push --quiet'
21
+ end
22
+
23
+ def check_integration
24
+ Jumpup::UI.say " --> Checking if there's someone integrating...".yellow
25
+ Jumpup::UI.say `git tag -d integrating`
26
+ Jumpup::UI.say `git fetch --tags --quiet`
27
+
28
+ tags = `git tag`.strip.split("\n")
29
+ if tags.include?('integrating')
30
+ tag_info = `git show integrating`
31
+ integrating_by = /Tagger: (.*) <.*>/.match(tag_info)[1]
32
+ if integrating_by == user
33
+ Jumpup::UI.say " --> Project is locked to you ('#{integrating_by}'), go ahead!".green
34
+ else
35
+ Jumpup::UI.say " --> Project is already being integrated by '#{integrating_by}', halting!".red
36
+ exit
37
+ end
38
+ else
39
+ Jumpup::UI.say ' --> No, go ahead!'.green
40
+ end
41
+ end
42
+
43
+ def lock_integration
44
+ Jumpup::UI.say ' --> Locking integration...'.yellow
45
+ Jumpup::UI.say `git tag -a -f integrating -m "Integration started at #{Time.now.strftime('%d/%m/%Y %T %Z')}"`
46
+ Jumpup::UI.say `git push -f origin integrating --quiet`
47
+ Jumpup::UI.say ' --> OK!'.green
48
+ end
49
+
50
+ def unlock_integration
51
+ Jumpup::UI.say ' --> Unlocking integration...'.yellow
52
+ Jumpup::UI.say `git tag -d integrating`
53
+ Jumpup::UI.say `git push origin :refs/tags/integrating`
54
+ Jumpup::UI.say ' --> OK!'.green
55
+ end
56
+
57
+ private
58
+
59
+ def user
60
+ @user = `git config --get user.name`.strip
61
+ end
62
+ end
63
+ end
64
+ end
@@ -0,0 +1,18 @@
1
+ require 'colorize'
2
+
3
+ module Jumpup
4
+ module UI
5
+ class << self
6
+ def header(message)
7
+ separator = '-' * 80
8
+ puts separator.white
9
+ puts message if message
10
+ yield if block_given?
11
+ end
12
+
13
+ def say(message)
14
+ puts message
15
+ end
16
+ end
17
+ end
18
+ end
@@ -1,3 +1,3 @@
1
1
  module Jumpup
2
- VERSION = '0.0.6'
2
+ VERSION = '0.0.7'
3
3
  end
@@ -1,73 +1,52 @@
1
- require 'find'
2
-
3
1
  namespace :jumpup do
4
2
 
5
- def p80(message)
6
- puts "-"*80
7
- puts message if message
8
- yield if block_given?
9
- end
10
-
11
3
  namespace :git do
12
4
  desc 'Check if project can be committed to the repository.'
13
5
  task :status_check do
14
- result = `git status`
15
- if result.include?('Untracked files:') || result.include?('unmerged:') || result.include?('modified:')
16
- puts result
17
- exit
18
- end
6
+ Jumpup::GitCommand.status_check
19
7
  end
20
8
 
21
9
  desc 'Update files from repository.'
22
10
  task :pull do
23
- sh "git pull --rebase"
11
+ Jumpup::GitCommand.pull
24
12
  end
25
13
 
26
14
  desc 'Push project.'
27
15
  task :push do
28
- sh "git push"
16
+ Jumpup::GitCommand.push
17
+ end
18
+ end
19
+
20
+ namespace :integration do
21
+ desc 'Checks if there\'s someone integrating.'
22
+ task :check do
23
+ Jumpup::GitCommand.check_integration
24
+ end
25
+
26
+ desc 'Lock integration.'
27
+ task :lock do
28
+ Jumpup::GitCommand.lock_integration
29
+ end
30
+
31
+ desc 'Unlock integration.'
32
+ task :unlock do
33
+ Jumpup::GitCommand.unlock_integration
29
34
  end
30
35
  end
31
36
 
32
- task :start => ["git:status_check", "log:clear", "tmp:clear", "git:pull"] do
37
+ task start: ['integration:check', 'integration:lock', 'git:status_check', 'log:clear', 'tmp:clear', 'git:pull'] do
33
38
  ENV['coverage'] = 'on'
34
39
  end
35
- task :finish => ["git:push"]
40
+ task finish: ['git:push', 'integration:unlock']
36
41
 
37
42
  desc 'Run bundle install'
38
43
  task :bundle_install do
39
- Bundler.with_clean_env do
40
- sh 'bundle install --quiet'
41
- end
44
+ Jumpup::BundlerCommand.install_with_clean_env
42
45
  end
43
46
 
44
47
  end
45
48
 
46
49
  desc 'Integrate new code to repository'
47
50
  task :integrate do
48
- if !defined?(INTEGRATION_TASKS)
49
- p80 %{
50
- You should define INTEGRATION_TASKS constant. We recommend that you define it on lib/tasks/jumpup.rake file. The file doesn't exists. You should create it in your project.
51
-
52
- You'll probably want to add coverage/ to your .gitignore file.
53
-
54
- A sample content look like this:
55
-
56
- INTEGRATION_TASKS = %w(
57
- jumpup:start
58
- jumpup:bundle_install
59
- db:migrate
60
- spec
61
- jumpup:finish
62
- )
63
-
64
- }
65
- exit
66
- end
67
-
68
- INTEGRATION_TASKS.each do |subtask|
69
- p80("Executing #{subtask}...") do
70
- Rake::Task[subtask].invoke
71
- end
72
- end
51
+ Jumpup.perform_integration
73
52
  end
@@ -0,0 +1,17 @@
1
+ task :one do
2
+ puts 'One'
3
+ end
4
+
5
+ task :two do
6
+ puts 'Two'
7
+ end
8
+
9
+ task :three do
10
+ puts 'Three'
11
+ end
12
+
13
+ INTEGRATION_TASKS = %w(
14
+ one
15
+ two
16
+ three
17
+ )
@@ -0,0 +1,29 @@
1
+ require 'spec_helper'
2
+
3
+ RSpec.describe Jumpup do
4
+ include_examples 'capture stdout'
5
+
6
+ before do
7
+ Object.send(:remove_const, :INTEGRATION_TASKS) if Object.const_defined?(:INTEGRATION_TASKS)
8
+ end
9
+
10
+ describe 'INTEGRATION_TASKS is not defined' do
11
+ it { expect { rake_integrate }.to raise_exception(SystemExit) }
12
+ it 'show a help message about the missing constant' do
13
+ begin
14
+ rake_integrate
15
+ rescue SystemExit
16
+ expect(@output.string).to include('You should define INTEGRATION_TASKS constant.')
17
+ end
18
+ end
19
+ end
20
+
21
+ describe 'INTEGRATION_TASKS is defined' do
22
+ before { load_tasks }
23
+ before { rake_integrate }
24
+
25
+ it { expect(@output.string).to include('One') }
26
+ it { expect(@output.string).to include('Two') }
27
+ it { expect(@output.string).to include('Three') }
28
+ end
29
+ end
@@ -0,0 +1,23 @@
1
+ require 'bundler/setup'
2
+
3
+ require 'pry'
4
+ require 'rake'
5
+ require 'jumpup'
6
+
7
+ Dir[File.expand_path('../support/**/*.rb', __FILE__)].each { |f| require f }
8
+
9
+ RSpec.configure do |config|
10
+ config.disable_monkey_patching!
11
+ config.order = :random
12
+ Kernel.srand config.seed
13
+ config.filter_run focus: true
14
+ config.run_all_when_everything_filtered = true
15
+ config.expect_with :rspec do |expectations|
16
+ expectations.syntax = :expect
17
+ end
18
+ config.mock_with :rspec do |mocks|
19
+ mocks.syntax = :expect
20
+ mocks.verify_partial_doubles = true
21
+ end
22
+ config.default_formatter = 'doc' if config.files_to_run.one?
23
+ end
@@ -0,0 +1,21 @@
1
+ def rake_integrate
2
+ begin
3
+ [:one, :two, :three].each do |task|
4
+ Rake::Task[task].reenable
5
+ end
6
+ rescue RuntimeError
7
+ # TODO: improve this
8
+ # Ignore the tasks if not defined
9
+ false
10
+ end
11
+ Rake::Task['integrate'].reenable
12
+ Rake::Task['integrate'].invoke
13
+ end
14
+
15
+ def load_tasks
16
+ load File.expand_path('../../fixtures/integration.rake', __FILE__)
17
+
18
+ [:one, :two, :three].each do |task|
19
+ Rake::Task.define_task(task)
20
+ end
21
+ end
@@ -0,0 +1,11 @@
1
+ RSpec.shared_examples 'capture stdout' do
2
+ before do
3
+ require 'stringio'
4
+ $stdout = StringIO.new
5
+ @output = $stdout
6
+ end
7
+
8
+ after do
9
+ $stdout = STDOUT
10
+ end
11
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jumpup
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6
4
+ version: 0.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - HE:labs
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-07-11 00:00:00.000000000 Z
11
+ date: 2014-09-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -25,17 +25,73 @@ dependencies:
25
25
  - !ruby/object:Gem::Version
26
26
  version: '1.3'
27
27
  - !ruby/object:Gem::Dependency
28
- name: rake
28
+ name: rspec
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '0'
33
+ version: '3.0'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '3.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: aruba
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: pry
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rake
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: colorize
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :runtime
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
39
95
  - !ruby/object:Gem::Version
40
96
  version: '0'
41
97
  description: A synchronous continuous integration gem.
@@ -46,16 +102,36 @@ extensions: []
46
102
  extra_rdoc_files: []
47
103
  files:
48
104
  - ".gitignore"
105
+ - ".rspec"
106
+ - ".rubocop.yml"
107
+ - ".ruby-gemset"
108
+ - ".ruby-version"
109
+ - ".travis.yml"
49
110
  - CHANGELOG.md
50
111
  - CONTRIBUTING.md
51
112
  - Gemfile
52
113
  - MIT-LICENSE
53
114
  - README.mkdn
54
115
  - Rakefile
116
+ - features/bundler.feature
117
+ - features/git.feature
118
+ - features/integration.feature
119
+ - features/lifecycle.feature
120
+ - features/step_definitions/setup_git_repo.rb
121
+ - features/support/env.rb
55
122
  - jumpup.gemspec
56
123
  - lib/jumpup.rb
124
+ - lib/jumpup/commands.rb
125
+ - lib/jumpup/commands/bundler_command.rb
126
+ - lib/jumpup/commands/git_command.rb
127
+ - lib/jumpup/ui.rb
57
128
  - lib/jumpup/version.rb
58
129
  - lib/tasks/integrate.rake
130
+ - spec/fixtures/integration.rake
131
+ - spec/jumpup/integration_spec.rb
132
+ - spec/spec_helper.rb
133
+ - spec/support/rake_helpers.rb
134
+ - spec/support/shared_examples.rb
59
135
  homepage: https://github.com/Helabs/jumpup
60
136
  licenses:
61
137
  - MIT
@@ -81,4 +157,15 @@ signing_key:
81
157
  specification_version: 4
82
158
  summary: Jumpup gem help people that want to do synchronous continuous integration
83
159
  on their ruby projects.
84
- test_files: []
160
+ test_files:
161
+ - features/bundler.feature
162
+ - features/git.feature
163
+ - features/integration.feature
164
+ - features/lifecycle.feature
165
+ - features/step_definitions/setup_git_repo.rb
166
+ - features/support/env.rb
167
+ - spec/fixtures/integration.rake
168
+ - spec/jumpup/integration_spec.rb
169
+ - spec/spec_helper.rb
170
+ - spec/support/rake_helpers.rb
171
+ - spec/support/shared_examples.rb