kender 0.4.0 → 0.5.0

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: ac270550b14a38b579283a3e690ce6de2fa5e447
4
- data.tar.gz: 5366326ba394b1712055d05fc276ef2368162b2d
3
+ metadata.gz: 394bb137f24d300e3d8384d7f3cd1304e195ff47
4
+ data.tar.gz: 85e1d60e97dd0fbebabf07ed51fed3ca88dcb102
5
5
  SHA512:
6
- metadata.gz: 60855155613e396b76705c75696026b2dda1cb375a6c4e248872c3d1ee649d2966033abd372729221ccd2f2152709b5d448e52359d12db9c7f4d78b2a9def4f5
7
- data.tar.gz: a58bb520ffe2d7e9a7259d36abcb0f6772557f45df17d5f484e20552d176f1a8a902d2e82dfd7e4b3e50dbb520f936a6af51856fe6a68884b9562a552e408e67
6
+ metadata.gz: 6e2eac7366d870455da737d7ef36a1bc402cd276b0561062c9cd143228e61908b3bad2d14fc8c8103982ede7e4222755efd4ca3d61ebbfbc257da03658536722
7
+ data.tar.gz: eee79f9dec4cd2e2253d6bb39bd23cc176d30682ff6ec5757a039a1bcd646367a144bcc530ceba03964b27600e02af361eae8021857944f5768be8b45c8d9413
@@ -8,7 +8,7 @@ Feature: Rspec
8
8
  source 'https://rubygems.org'
9
9
  gem 'rspec', '~> 2.14'
10
10
  gem 'kender', path: '../../' # needed to use the latest code
11
- gem 'dice_bag', '~> 0.7'
11
+ gem 'dice_bag', '~> 1.0'
12
12
  """
13
13
  And I run `bundle install --path vendor/`
14
14
 
@@ -8,7 +8,7 @@ Feature: Scenarios
8
8
  source 'https://rubygems.org'
9
9
  gem 'cucumber', '~> 1.3'
10
10
  gem 'kender', path: '../../' # needed to use the latest code
11
- gem 'dice_bag', '~> 0.7'
11
+ gem 'dice_bag', '~> 1.0'
12
12
  """
13
13
  # Running this twice because sometimes the install command will timeout.
14
14
  And I run `bundle install --path vendor/ --jobs=4`
@@ -1,6 +1,7 @@
1
1
  module Kender
2
2
  # This class abstracts the shell commands we use
3
3
  class Command
4
+ attr_reader :success
4
5
 
5
6
  def name
6
7
  self.class.name.split("::").last.downcase.to_sym
@@ -11,7 +12,7 @@ module Kender
11
12
  end
12
13
 
13
14
  def execute
14
- abort "Command failed: #{command}" unless run.success?
15
+ @success = run.success?
15
16
  end
16
17
 
17
18
  #TODO: system reload all the gems again, avoid this.
@@ -22,6 +23,10 @@ module Kender
22
23
 
23
24
  class << self
24
25
 
26
+ def all_success?
27
+ all.inject(true) {|all_result, command_result| all_result && command_result }
28
+ end
29
+
25
30
  def commands
26
31
  @commands ||= []
27
32
  end
@@ -35,7 +40,17 @@ module Kender
35
40
  end
36
41
 
37
42
  def all
38
- @all ||= commands.select(&:available?)
43
+ @all ||= begin
44
+ all_commands = commands.select(&:available?)
45
+ # move rspec and cucumber to last places so faster tools run first
46
+ if command = all_commands.find{ |command| command.name == :rspec }
47
+ all_commands.delete_if{ |command| command.name == :rspec }.push(command)
48
+ end
49
+ if command = all_commands.find{ |command| command.name == :cucumber }
50
+ all_commands.delete_if{ |command| command.name == :cucumber }.push(command)
51
+ end
52
+ all_commands
53
+ end
39
54
  end
40
55
 
41
56
  end
@@ -1,5 +1,4 @@
1
1
  require 'kender/configuration'
2
- require 'kender/github'
3
2
  require 'kender/command'
4
3
 
5
4
  # Helper method to call rake tasks without blowing up when they do not exists
@@ -12,15 +11,10 @@ end
12
11
 
13
12
  # This is the task we want the user to use all the time.
14
13
  desc "Configure and run continuous integration tests then clean up"
15
- task :ci => ['ci:status:pending'] do
14
+ task :ci do
16
15
  begin
17
16
  Rake::Task["ci:config"].invoke
18
- Rake::Task["ci:run"].invoke
19
- Rake::Task["ci:status:success"].invoke
20
- rescue Exception => e
21
- Rake::Task["ci:status:failure"].invoke
22
- # Ensure that this task still fails.
23
- raise e
17
+ Rake::Task["ci:fail_fast"].invoke
24
18
  ensure
25
19
  Rake::Task["ci:clean"].invoke
26
20
  end
@@ -32,14 +26,32 @@ namespace :ci do
32
26
  desc "Configure the app to run continuous integration tests."
33
27
  task :config => ['ci:env', 'ci:config_project', 'ci:setup_db']
34
28
 
35
- desc "Run continuous integration tests with the current configuration"
36
- task :run => ['ci:env'] do
29
+ desc "Run continuous integration tests and aborts when one suite fails"
30
+ task :fail_fast => ['ci:env', 'ci:list'] do
37
31
  #make sure we require all the tools we need loaded in memory
38
32
  Kender::Command.all.each do |command|
39
33
  command.execute
34
+ abort "#{command.name} failed" unless command.success
40
35
  end
41
36
  end
42
37
 
38
+
39
+ desc "Run all continuous integration tests and reports a list of failed suites at the end."
40
+ task :run => ['ci:env', 'ci:list'] do
41
+ #make sure we require all the tools we need loaded in memory
42
+ Kender::Command.all.each do |command|
43
+ command.execute
44
+ end
45
+ # Nice summary of failures at the end of the run.
46
+ Kender::Command.all.each do |command|
47
+ puts "#{command.name} failed" unless command.success
48
+ end
49
+ abort "Command failed: #{command}" unless Kender::Command.all_success?
50
+ end
51
+
52
+
53
+
54
+
43
55
  desc "Destroy resources created externally for the continuous integration run, e.g. drops databases"
44
56
  task :clean => ['ci:env', 'ci:drop_db']
45
57
 
@@ -106,18 +118,4 @@ namespace :ci do
106
118
  end
107
119
  end
108
120
 
109
- namespace :status do
110
-
111
- config = Kender::Configuration.new
112
-
113
- task :pending do
114
- Kender::GitHub.update_commit_status(:pending, config)
115
- end
116
- task :success do
117
- Kender::GitHub.update_commit_status(:success, config)
118
- end
119
- task :failure do
120
- Kender::GitHub.update_commit_status(:failure, config)
121
- end
122
- end
123
121
  end
@@ -1,3 +1,3 @@
1
1
  module Kender
2
- VERSION = '0.4.0'.freeze
2
+ VERSION = '0.5.0'.freeze
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kender
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Smith
@@ -11,7 +11,7 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2016-06-15 00:00:00.000000000 Z
14
+ date: 2017-08-24 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: bundler
@@ -107,7 +107,6 @@ files:
107
107
  - lib/kender/commands/shamus.rb
108
108
  - lib/kender/commands/test_unit.rb
109
109
  - lib/kender/configuration.rb
110
- - lib/kender/github.rb
111
110
  - lib/kender/railtie.rb
112
111
  - lib/kender/tasks.rb
113
112
  - lib/kender/tasks/ci.rake
@@ -132,7 +131,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
132
131
  version: '0'
133
132
  requirements: []
134
133
  rubyforge_project:
135
- rubygems_version: 2.5.1
134
+ rubygems_version: 2.6.8
136
135
  signing_key:
137
136
  specification_version: 4
138
137
  summary: Rake tasks for continuous integration (CI).
@@ -142,4 +141,3 @@ test_files:
142
141
  - features/scenarios.feature
143
142
  - features/support/env.rb
144
143
  - features/support/hooks.rb
145
- has_rdoc:
@@ -1,71 +0,0 @@
1
- require 'net/https'
2
-
3
- module Kender
4
-
5
- # This module abstracts access to GitHub. It's current, sole purpose is to
6
- # allow commit statuses to be created.
7
- #
8
- # See: https://github.com/blog/1227-commit-status-api
9
- #
10
- module GitHub
11
- extend self
12
-
13
- # Update the commit status for the current HEAD commit. Assumes the working
14
- # directory is a git repo and the "origin" remote points to a GitHub repo.
15
- # The +state+ variable must be one of :pending, :success or :failure. The
16
- # +config+ object must respond to +build_number+, +build_url+ and
17
- # +github_auth_token+.
18
- #
19
- def update_commit_status(state, config)
20
-
21
- # TODO: Refactor the following code to use gems like git/grit/rugged and
22
- # octokit. ~asmith
23
-
24
- unless config.github_auth_token
25
- puts "Skipping setting the status on Github to #{state} because the access token is not configured"
26
- return
27
- end
28
-
29
- body = %Q({
30
- "state": "#{state.to_s}",
31
- "target_url": "#{config.build_url}",
32
- "description": "Continuous integration run #{config.build_number}"
33
- })
34
- commit = `git log -1 --format=format:%H`
35
- remotes = `git remote --verbose`
36
- remote_name = ENV['GITHUB_REMOTE'] || 'origin'
37
-
38
- unless repo = /^#{remote_name}\s+git@(\w+\.)?github.com:([\w-]+\/[\w-]+)\b/.match(remotes).to_a.last
39
- puts "Could not establish GitHub repo name from '#{remote_name}' remote"
40
- return
41
- end
42
- uri = URI("https://api.github.com/repos/#{repo}/statuses/#{commit}?access_token=#{config.github_auth_token}")
43
-
44
- puts "Setting #{repo} commit #{commit} status to '#{state}' on GitHub"
45
-
46
- ensure_real_connection do
47
- Net::HTTP.start(uri.host, uri.port, :use_ssl => true) do |http|
48
- response = http.post(uri.request_uri, body)
49
- unless response.is_a?(Net::HTTPCreated)
50
- puts "Setting commit status FAILED", response
51
- end
52
- end
53
- end
54
- end
55
-
56
- def ensure_real_connection
57
- if !defined?(WebMock)
58
- return yield
59
- end
60
- if !WebMock.net_connect_allowed?
61
- WebMock.allow_net_connect!
62
- yield
63
- WebMock.disable_net_connect!
64
- else
65
- yield
66
- end
67
- end
68
-
69
- end
70
- end
71
-