kender 0.3.3 → 0.6.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 7c3a61d765517036eca70bcc232cc2e162f28fb2
4
- data.tar.gz: 8ca7e07d9b9c496b79c3bb007bd51ffae07f46e4
2
+ SHA256:
3
+ metadata.gz: ec3d8fbca30fbb5a95f44d8a3ca031428b9370cfb9fee30281d8227af1a63d59
4
+ data.tar.gz: 6be9094d370dea4781f4fccfb8b62bdc0f74a4a75d32f4f28d66568597acc470
5
5
  SHA512:
6
- metadata.gz: 50d67e0864377a86834e2199f347e735657187045aa1181e92ae710606916405f645582273b9376791ec2ae99df743ac34e55505c293b05f081a4834ad73778b
7
- data.tar.gz: f13e1d4dedc8de2a6e5ce6a7084881a11dec8a37c5df657eab20a93e980a2d9fbb4c742dd1e32261eb93aadf5e329cd4b51ca39847492a86d930d81737c3cd17
6
+ metadata.gz: d8de5beffee352b80dbe89f861f3929d0a139556c4f8cecb278d490b7dbf94fcfae1f115729ce86a41414e220e5b216891bfa43b30e1d17c7db7914da1c49663
7
+ data.tar.gz: 2a924b56f3b53c47fffb73d6bb17a9368182710c7a6ed7786fd714562e78cb89341899873bf05811b0ea94073559758aba417d053cf99f161978c866558b2f3f
@@ -8,9 +8,9 @@ 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
- And I run `bundle install`
13
+ And I run `bundle install --path vendor/`
14
14
 
15
15
  Scenario: The project has no specs but Rspec is executed
16
16
  When I run `bundle exec rake ci`
@@ -33,6 +33,18 @@ Feature: Rspec
33
33
  """
34
34
  1 example, 0 failures
35
35
  """
36
+
37
+ Scenario: A project with failing specs should fail when running the ci:run task
38
+ Given a file named "spec/testing_spec.rb" with:
39
+ """
40
+ describe "My software" do
41
+ it "fails miserably" do
42
+ expect(false).to be_true
43
+ end
44
+ end
45
+ """
46
+ When I run `bundle exec rake ci:run`
47
+ Then the exit status should not be 0
36
48
 
37
49
  Scenario: The project has some non passing specs to run
38
50
  Given a file named "spec/testing_spec.rb" with:
@@ -6,11 +6,13 @@ Feature: Scenarios
6
6
  Given a file named "Gemfile" with:
7
7
  """
8
8
  source 'https://rubygems.org'
9
- gem 'cucumber', '~>1.3'
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
- And I run `bundle install`
13
+ # Running this twice because sometimes the install command will timeout.
14
+ And I run `bundle install --path vendor/ --jobs=4`
15
+ And I run `bundle install --path vendor/ --jobs=4`
14
16
 
15
17
  Scenario: The project has no scenarios to run but cucumber is executed
16
18
  When I run `bundle exec rake ci`
@@ -1,9 +1,9 @@
1
1
  require 'aruba/cucumber'
2
2
  require 'kender'
3
3
 
4
- Before do
5
- #scenarios bundle to set up gems and it takes forever
6
- @aruba_timeout_seconds = 30
4
+ # scenarios bundle to set up gems and it takes forever
5
+ Aruba.configure do |config|
6
+ config.startup_wait_time = 12
7
7
  end
8
8
 
9
9
  # Unset bundle vars so when we create new bundle files in the scenarios
@@ -1,5 +1,5 @@
1
1
  Before do
2
2
  write_file("Rakefile", "require 'kender/tasks'")
3
- create_dir('features')
4
- create_dir('spec')
3
+ create_directory('features')
4
+ create_directory('spec')
5
5
  end
@@ -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.all?(&:success)
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
@@ -7,7 +7,10 @@ module Kender
7
7
 
8
8
  def command
9
9
  extra_env = ENV['HEADED_BROWSER'] ? "HEADED_BROWSER=#{ENV['HEADED_BROWSER']}" : ''
10
- if defined?(ParallelTests)
10
+ if defined?(Knapsack)
11
+ knapsack_env = "CI_NODE_TOTAL=#{ENV['CI_NODE_TOTAL']} CI_NODE_INDEX=#{ENV['CI_NODE_INDEX']}"
12
+ "#{extra_env} #{knapsack_env} bundle exec rake knapsack:cucumber"
13
+ elsif defined?(ParallelTests)
11
14
  "#{extra_env} bundle exec rake parallel:features"
12
15
  else
13
16
  "#{extra_env} bundle exec cucumber"
@@ -8,7 +8,10 @@ module Kender
8
8
  end
9
9
 
10
10
  def command
11
- if defined?(ParallelTests)
11
+ if defined?(Knapsack)
12
+ knapsack_env = "CI_NODE_TOTAL=#{ENV['CI_NODE_TOTAL']} CI_NODE_INDEX=#{ENV['CI_NODE_INDEX']}"
13
+ "#{knapsack_env} bundle exec rake knapsack:rspec"
14
+ elsif defined?(ParallelTests)
12
15
  'bundle exec rake parallel:spec'
13
16
  else
14
17
  'bundle exec rspec'
@@ -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(s) failed" 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
 
@@ -71,7 +83,14 @@ namespace :ci do
71
83
  task :setup_db do
72
84
  if Rake::Task.task_defined?('db:create')
73
85
  if !defined?(ParallelTests)
74
- unless run_successfully?(['db:create', 'db:migrate'])
86
+ # Use db:schema:load instead of db:migrate because of this issue
87
+ # https://github.com/rails/rails/issues/19001
88
+ db_task = if File.exist?('db/schema.rb')
89
+ 'db:schema:load'
90
+ else
91
+ 'db:migrate'
92
+ end
93
+ unless run_successfully?(['db:create', db_task])
75
94
  puts 'The DB could not be set up successfully.'
76
95
  end
77
96
  else
@@ -99,18 +118,4 @@ namespace :ci do
99
118
  end
100
119
  end
101
120
 
102
- namespace :status do
103
-
104
- config = Kender::Configuration.new
105
-
106
- task :pending do
107
- Kender::GitHub.update_commit_status(:pending, config)
108
- end
109
- task :success do
110
- Kender::GitHub.update_commit_status(:success, config)
111
- end
112
- task :failure do
113
- Kender::GitHub.update_commit_status(:failure, config)
114
- end
115
- end
116
121
  end
@@ -1,3 +1,3 @@
1
1
  module Kender
2
- VERSION = '0.3.3'
2
+ VERSION = '0.6.2'.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.3.3
4
+ version: 0.6.2
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: 2015-12-22 00:00:00.000000000 Z
14
+ date: 2022-01-13 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: bundler
@@ -53,28 +53,28 @@ dependencies:
53
53
  requirements:
54
54
  - - "~>"
55
55
  - !ruby/object:Gem::Version
56
- version: '0.5'
56
+ version: '1.0'
57
57
  type: :development
58
58
  prerelease: false
59
59
  version_requirements: !ruby/object:Gem::Requirement
60
60
  requirements:
61
61
  - - "~>"
62
62
  - !ruby/object:Gem::Version
63
- version: '0.5'
63
+ version: '1.0'
64
64
  - !ruby/object:Gem::Dependency
65
65
  name: rake
66
66
  requirement: !ruby/object:Gem::Requirement
67
67
  requirements:
68
- - - "~>"
68
+ - - ">="
69
69
  - !ruby/object:Gem::Version
70
- version: '0'
70
+ version: '13'
71
71
  type: :development
72
72
  prerelease: false
73
73
  version_requirements: !ruby/object:Gem::Requirement
74
74
  requirements:
75
- - - "~>"
75
+ - - ">="
76
76
  - !ruby/object:Gem::Version
77
- version: '0'
77
+ version: '13'
78
78
  description: Kender is a library of rake tasks that provides a consistent framework
79
79
  for continuous integration (CI).
80
80
  email:
@@ -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
@@ -131,15 +130,13 @@ required_rubygems_version: !ruby/object:Gem::Requirement
131
130
  - !ruby/object:Gem::Version
132
131
  version: '0'
133
132
  requirements: []
134
- rubyforge_project:
135
- rubygems_version: 2.4.8
133
+ rubygems_version: 3.0.6
136
134
  signing_key:
137
135
  specification_version: 4
138
136
  summary: Rake tasks for continuous integration (CI).
139
137
  test_files:
140
- - features/install.feature
141
138
  - features/rspec.feature
142
- - features/scenarios.feature
143
- - features/support/env.rb
144
139
  - features/support/hooks.rb
145
- has_rdoc:
140
+ - features/support/env.rb
141
+ - features/install.feature
142
+ - features/scenarios.feature
data/lib/kender/github.rb DELETED
@@ -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
-