semaphore_test_boosters 1.2.3 → 1.2.4

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
2
  SHA1:
3
- metadata.gz: ed293810759ad0c77be71fe83a4074ac16111377
4
- data.tar.gz: d5b355fc1d0ff450971cb79e3c0a18a707ff6321
3
+ metadata.gz: 16ee85bdadc0f19aaf4b16c3e5f98a710540a999
4
+ data.tar.gz: 9c912cc4b2fa96df2ad02eddd132fec18651eb6e
5
5
  SHA512:
6
- metadata.gz: 81776f5163c2664b11a07bf337203709e69f98093e1eac53f4514a04e8480929abd53d2b5ba95ada52ed7e2cf1fde06848d8c030746e057aaa730c9b9f1e9fb2
7
- data.tar.gz: 2edf0360a6fd2841985414e31120687f2e05fbc55698e06cf0b11daadb9d38560dfa9ef6b92f9fa624c0ee69298ea196c2cf8ebcddf44a456c092880d722bbb8
6
+ metadata.gz: 0ae6310f2469127c089493e9adfb979628c0b00a6ce52f99ab17f559325b57324343f2eb0b08d26aab665fc47404eff5326ddc6f6e53865d6b8cbbae481d181b
7
+ data.tar.gz: b2ef54cccb3df907ddd682ae57242225aa9bbe32922b64a97873903325e45d35b16e3d59306081f53b6f878e5bb6c63d0845d873fc9c01ab32d3a84e3ec126bf
@@ -1 +1,2 @@
1
- default: --format pretty
1
+ default: --format pretty --profile semaphoreci
2
+ semaphoreci: --format json --out=../cucumber_report.json
@@ -2,14 +2,14 @@
2
2
 
3
3
  require "test_boosters"
4
4
 
5
- Semaphore::run_cucumber_config
5
+ TestBoosters.run_cucumber_config
6
6
 
7
- cli_options = Semaphore::parse
7
+ cli_options = TestBoosters::CliParser.parse
8
8
  thread_index = cli_options[:index] - 1
9
- cucumber_booster = Semaphore::CucumberBooster.new(thread_index)
9
+ cucumber_booster = TestBoosters::CucumberBooster.new(thread_index)
10
10
  exit_status = cucumber_booster.run
11
11
 
12
12
  report_path = cucumber_booster.report_path
13
- Semaphore::InsightsUploader.new.upload("cucumber", report_path)
13
+ TestBoosters::InsightsUploader.new.upload("cucumber", report_path)
14
14
 
15
15
  exit(exit_status)
@@ -2,12 +2,12 @@
2
2
 
3
3
  require "test_boosters"
4
4
 
5
- cli_options = Semaphore::parse
5
+ cli_options = TestBoosters::CliParser.parse
6
6
  thread_index = cli_options[:index] - 1
7
- rspec_booster = Semaphore::RspecBooster.new(thread_index)
7
+ rspec_booster = TestBoosters::RspecBooster.new(thread_index)
8
8
  exit_status = rspec_booster.run
9
9
 
10
10
  report_path = rspec_booster.report_path
11
- Semaphore::InsightsUploader.new.upload("rspec", report_path)
11
+ TestBoosters::InsightsUploader.new.upload("rspec", report_path)
12
12
 
13
13
  exit(exit_status)
@@ -1,9 +1,27 @@
1
- require "test_boosters/version"
2
- require "test_boosters/rspec_booster"
3
- require "test_boosters/cucumber_booster"
4
- require "test_boosters/insights_uploader"
5
- require "test_boosters/run_cucumber_config"
1
+ require "optparse"
2
+ require "json"
3
+ require "cucumber_booster_config"
6
4
 
7
5
  module TestBoosters
8
- # Your code goes here...
6
+ require "test_boosters/version"
7
+
8
+ require "test_boosters/cli_parser"
9
+ require "test_boosters/logger"
10
+ require "test_boosters/shell"
11
+ require "test_boosters/leftover_files"
12
+
13
+ require "test_boosters/rspec_booster"
14
+ require "test_boosters/cucumber_booster"
15
+ require "test_boosters/insights_uploader"
16
+
17
+ module_function
18
+
19
+ def run_cucumber_config
20
+ puts
21
+ puts "================== Running Cucumber Booster Config ==================="
22
+ puts
23
+
24
+ CucumberBoosterConfig::CLI.start ["inject", "."]
25
+ end
26
+
9
27
  end
@@ -1,17 +1,17 @@
1
- module Semaphore
2
- module_function
1
+ module TestBoosters
2
+ module CliParser
3
+ module_function
3
4
 
4
- require "optparse"
5
+ def parse
6
+ options = {}
5
7
 
6
- def parse
7
- options = {}
8
+ parser = OptionParser.new do |opts|
9
+ opts.on("--thread INDEX") { |index| options[:index] = index.to_i }
10
+ end
8
11
 
9
- parser = OptionParser.new do |opts|
10
- opts.on("--thread INDEX") { |index| options[:index] = index.to_i }
11
- end
12
-
13
- parser.parse!
12
+ parser.parse!
14
13
 
15
- options
14
+ options
15
+ end
16
16
  end
17
17
  end
@@ -1,11 +1,4 @@
1
- module Semaphore
2
- require "json"
3
- require "test_boosters/cli_parser"
4
- require "test_boosters/logger"
5
- require "test_boosters/executor"
6
- require "test_boosters/display_files"
7
- require "test_boosters/leftover_files"
8
-
1
+ module TestBoosters
9
2
  class CucumberBooster
10
3
  attr_reader :report_path
11
4
 
@@ -39,7 +32,7 @@ module Semaphore
39
32
  puts "========================= Running Cucumber =========================="
40
33
  puts
41
34
 
42
- Semaphore::execute("bundle exec cucumber #{specs}")
35
+ TestBoosters::Shell.execute("bundle exec cucumber #{specs}")
43
36
  end
44
37
 
45
38
  def select
@@ -52,13 +45,13 @@ module Semaphore
52
45
  all_known_features = file_distribution.map { |t| t["files"] }.flatten.sort
53
46
 
54
47
  all_leftover_features = all_features - all_known_features
55
- thread_leftover_features = LeftoverFiles.select(all_leftover_features, thread_count, @thread_index)
48
+ thread_leftover_features = TestBoosters::LeftoverFiles.select(all_leftover_features, thread_count, @thread_index)
56
49
  thread_features = all_features & thread["files"].sort
57
50
  features_to_run = thread_features + thread_leftover_features
58
51
 
59
- Semaphore.display_files("This thread features:", thread_features)
60
- Semaphore.display_title_and_count("All leftover features:", all_leftover_features)
61
- Semaphore.display_files("This thread leftover features:", thread_leftover_features)
52
+ TestBoosters::Shell.display_files("This thread features:", thread_features)
53
+ TestBoosters::Shell.display_title_and_count("All leftover features:", all_leftover_features)
54
+ TestBoosters::Shell.display_files("This thread leftover features:", thread_leftover_features)
62
55
 
63
56
  features_to_run
64
57
  end
@@ -76,7 +69,7 @@ module Semaphore
76
69
 
77
70
  error += %{Exception: #{e.message}}
78
71
 
79
- Semaphore.log(error)
72
+ TestBoosters::Logger.error(error)
80
73
 
81
74
  raise
82
75
  end
@@ -1,6 +1,4 @@
1
- module Semaphore
2
- module_function
3
-
1
+ module TestBoosters
4
2
  class InsightsUploader
5
3
  def initialize
6
4
  @project_hash_id = ENV["SEMAPHORE_PROJECT_UUID"]
@@ -15,7 +13,7 @@ module Semaphore
15
13
  "&project_hash_id=#{@project_hash_id}"
16
14
  cmd = "http POST '#{url}' #{booster_type}:=@#{file}"
17
15
 
18
- Semaphore.execute("#{cmd} > ~/insights_uploader.log")
16
+ TestBoosters::Shell.execute("#{cmd} > ~/insights_uploader.log")
19
17
  end
20
18
  end
21
19
  end
@@ -1,29 +1,30 @@
1
- module LeftoverFiles
2
- module_function
1
+ module TestBoosters
2
+ module LeftoverFiles
3
+ module_function
3
4
 
4
- def self.select(all_leftover_files, thread_count, thread_index)
5
- all_leftover_files = sort_by_size(all_leftover_files)
5
+ def select(all_leftover_files, thread_count, thread_index)
6
+ all_leftover_files = sort_descending_by_size(all_leftover_files)
6
7
 
7
- return [] if all_leftover_files.empty?
8
+ return [] if all_leftover_files.empty?
8
9
 
9
- files = all_leftover_files
10
- .each_slice(thread_count)
11
- .reduce{ |acc, slice| acc.map{|a| a}.zip(slice.reverse) }
12
- .map{ |f| f.kind_of?(Array) ? f.flatten : [f] } [thread_index]
10
+ files = all_leftover_files
11
+ .each_slice(thread_count)
12
+ .reduce{ |acc, slice| acc.map{|a| a}.zip(slice.reverse) }
13
+ .map{ |f| f.kind_of?(Array) ? f.flatten : [f] } [thread_index]
13
14
 
14
- if files.nil? then []
15
- elsif files.kind_of?(Array) then files.compact
15
+ if files.nil? then []
16
+ elsif files.kind_of?(Array) then files.compact
17
+ end
16
18
  end
17
- end
18
-
19
- def self.sort_by_size(files) # descending
20
- files
21
- .select { |f| File.file?(f) }
22
- .map{ |f| [f, File.size(f)] }
23
- .sort_by{ |a| a[1] }
24
- .map{ |a| a[0] }
25
- .reverse
26
- end
27
19
 
20
+ def sort_descending_by_size(files)
21
+ files
22
+ .select { |f| File.file?(f) }
23
+ .map { |f| [f, File.size(f)] }
24
+ .sort_by { |a| a[1] }
25
+ .map { |a| a[0] }
26
+ .reverse
27
+ end
28
28
 
29
+ end
29
30
  end
@@ -1,9 +1,19 @@
1
- module Semaphore
2
- module_function
1
+ module TestBoosters
2
+ module Logger
3
+ module_function
3
4
 
4
- def log(message)
5
- error_log_path = ENV["ERROR_LOG_PATH"] || "#{ENV["HOME"]}/test_booster_error.log"
5
+ # TODO: why are we logging info messages into the error log?
6
+ def info(message)
7
+ error_log_path = ENV["ERROR_LOG_PATH"] || "#{ENV["HOME"]}/test_booster_error.log"
8
+
9
+ File.open(error_log_path, "a") { |f| f.write("#{message}\n") }
10
+ end
11
+
12
+ def error(message)
13
+ error_log_path = ENV["ERROR_LOG_PATH"] || "#{ENV["HOME"]}/test_booster_error.log"
14
+
15
+ File.open(error_log_path, "a") { |f| f.write("#{message}\n") }
16
+ end
6
17
 
7
- File.open(error_log_path, "a") { |f| f.write("#{message}\n") }
8
18
  end
9
19
  end
@@ -1,11 +1,4 @@
1
- module Semaphore
2
- require "json"
3
- require "test_boosters/cli_parser"
4
- require "test_boosters/logger"
5
- require "test_boosters/executor"
6
- require "test_boosters/display_files"
7
- require "test_boosters/leftover_files"
8
-
1
+ module TestBoosters
9
2
  class RspecBooster
10
3
  attr_reader :report_path
11
4
 
@@ -41,7 +34,7 @@ module Semaphore
41
34
  puts "========================= Running Rspec =========================="
42
35
  puts
43
36
 
44
- Semaphore.execute("bundle exec rspec #{options} #{specs}")
37
+ TestBoosters::Shell.execute("bundle exec rspec #{options} #{specs}")
45
38
  end
46
39
 
47
40
  def select
@@ -50,23 +43,24 @@ module Semaphore
50
43
  thread_count = file_distribution.count
51
44
  thread = file_distribution[@thread_index]
52
45
 
46
+ puts "Running RSpec thread #{@thread_index + 1} out of #{thread_count} threads\n"
47
+
53
48
  all_specs = Dir["#{@spec_path}/**/*_spec.rb"].sort
54
49
  all_known_specs = file_distribution.map { |t| t["files"] }.flatten.sort
55
50
 
56
51
  all_leftover_specs = all_specs - all_known_specs
57
- thread_leftover_specs = LeftoverFiles.select(all_leftover_specs, thread_count, @thread_index)
52
+ thread_leftover_specs = TestBoosters::LeftoverFiles.select(all_leftover_specs, thread_count, @thread_index)
58
53
  thread_specs = all_specs & thread["files"].sort
59
54
  specs_to_run = thread_specs + thread_leftover_specs
60
55
 
61
- Semaphore.display_files("This thread specs:", thread_specs)
62
- Semaphore.display_title_and_count("All leftover specs:", all_leftover_specs)
63
- Semaphore.display_files("This thread leftover specs:", thread_leftover_specs)
56
+ TestBoosters::Shell.display_files("This thread specs:", thread_specs)
57
+ TestBoosters::Shell.display_title_and_count("All leftover specs:", all_leftover_specs)
58
+ TestBoosters::Shell.display_files("This thread leftover specs:", thread_leftover_specs)
64
59
 
65
60
  specs_to_run
66
61
  end
67
62
  end
68
63
 
69
-
70
64
  def with_fallback
71
65
  yield
72
66
  rescue StandardError => e
@@ -78,7 +72,7 @@ module Semaphore
78
72
  error += %{Exception: #{e.message}\n#{e.backtrace.join("\n")}}
79
73
 
80
74
  puts error
81
- Semaphore.log(error)
75
+ TestBoosters::Logger.error(error)
82
76
 
83
77
  raise
84
78
  end
@@ -1,13 +0,0 @@
1
- require 'cucumber_booster_config'
2
-
3
- module Semaphore
4
- module_function
5
-
6
- def run_cucumber_config()
7
- puts
8
- puts "================== Running Cucumber Booster Config ==================="
9
- puts
10
-
11
- CucumberBoosterConfig::CLI.start ["inject", "."]
12
- end
13
- end
@@ -0,0 +1,26 @@
1
+ module TestBoosters
2
+ module Shell
3
+ module_function
4
+
5
+ def execute(command)
6
+ TestBoosters::Logger.info("Running command: #{command}")
7
+ system(command)
8
+ TestBoosters::Logger.info("Command finished, exit status : #{$?.exitstatus}")
9
+
10
+ $?.exitstatus
11
+ end
12
+
13
+ def display_files(title, files)
14
+ display_title_and_count(title, files)
15
+
16
+ files.each { |file| puts "- #{file}" }
17
+
18
+ puts "\n"
19
+ end
20
+
21
+ def display_title_and_count(title, files)
22
+ puts "#{title} #{files.count}\n"
23
+ end
24
+
25
+ end
26
+ end
@@ -1,3 +1,3 @@
1
1
  module TestBoosters
2
- VERSION = "1.2.3"
2
+ VERSION = "1.2.4"
3
3
  end
@@ -1,7 +1,7 @@
1
1
  # coding: utf-8
2
2
  lib = File.expand_path('../lib', __FILE__)
3
3
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
- require 'test_boosters/version'
4
+ require "test_boosters/version"
5
5
 
6
6
  Gem::Specification.new do |spec|
7
7
  spec.name = "semaphore_test_boosters"
@@ -22,15 +22,15 @@ Gem::Specification.new do |spec|
22
22
  raise "RubyGems 2.0 or newer is required to protect against public gem pushes."
23
23
  end
24
24
 
25
- spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
26
- spec.bindir = "exe"
27
- spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
25
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
26
+ spec.bindir = "exe"
27
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
28
28
  spec.require_paths = ["lib"]
29
29
 
30
30
  spec.add_dependency "semaphore_cucumber_booster_config", "~> 1.1"
31
31
 
32
- spec.add_development_dependency "bundler", "~> 1.12"
33
32
  spec.add_development_dependency "rake", "~> 10.0"
34
33
  spec.add_development_dependency "rspec", "~> 3.0"
35
- spec.add_development_dependency "cucumber-rails"
34
+ spec.add_development_dependency "activesupport", "~> 4.0"
35
+ spec.add_development_dependency "cucumber-rails", "~> 1.4.3"
36
36
  end
@@ -1,8 +1,6 @@
1
1
  require 'spec_helper'
2
2
 
3
- # Booster = Semaphore::RspecBooster
4
-
5
- describe Semaphore::RspecBooster do
3
+ describe TestBoosters::RspecBooster do
6
4
  it 'fails' do
7
5
  expect(TestBoosters::VERSION).to be "wrong"
8
6
  end
@@ -1,6 +1,6 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe Semaphore::RspecBooster do
3
+ describe TestBoosters::RspecBooster do
4
4
  it 'passes' do
5
5
  expect(0).to eq(0)
6
6
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: semaphore_test_boosters
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.3
4
+ version: 1.2.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - MAINTAINER Rendered Text
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-03-14 00:00:00.000000000 Z
11
+ date: 2017-03-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: semaphore_cucumber_booster_config
@@ -25,61 +25,61 @@ dependencies:
25
25
  - !ruby/object:Gem::Version
26
26
  version: '1.1'
27
27
  - !ruby/object:Gem::Dependency
28
- name: bundler
28
+ name: rake
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '1.12'
33
+ version: '10.0'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '1.12'
40
+ version: '10.0'
41
41
  - !ruby/object:Gem::Dependency
42
- name: rake
42
+ name: rspec
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: '10.0'
47
+ version: '3.0'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: '10.0'
54
+ version: '3.0'
55
55
  - !ruby/object:Gem::Dependency
56
- name: rspec
56
+ name: activesupport
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
59
  - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: '3.0'
61
+ version: '4.0'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
- version: '3.0'
68
+ version: '4.0'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: cucumber-rails
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - ">="
73
+ - - "~>"
74
74
  - !ruby/object:Gem::Version
75
- version: '0'
75
+ version: 1.4.3
76
76
  type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
- - - ">="
80
+ - - "~>"
81
81
  - !ruby/object:Gem::Version
82
- version: '0'
82
+ version: 1.4.3
83
83
  description: Gem for auto-parallelizing builds across Semaphore jobs.
84
84
  email:
85
85
  - devops@renderedtext.com
@@ -103,13 +103,12 @@ files:
103
103
  - lib/test_boosters.rb
104
104
  - lib/test_boosters/cli_parser.rb
105
105
  - lib/test_boosters/cucumber_booster.rb
106
- - lib/test_boosters/display_files.rb
107
- - lib/test_boosters/executor.rb
108
106
  - lib/test_boosters/insights_uploader.rb
109
107
  - lib/test_boosters/leftover_files.rb
110
108
  - lib/test_boosters/logger.rb
111
109
  - lib/test_boosters/rspec_booster.rb
112
110
  - lib/test_boosters/run_cucumber_config.rb
111
+ - lib/test_boosters/shell.rb
113
112
  - lib/test_boosters/version.rb
114
113
  - test_boosters.gemspec
115
114
  - test_data/a.feature
@@ -1,15 +0,0 @@
1
- module Semaphore
2
- module_function
3
-
4
- def display_files(title, files)
5
- display_title_and_count(title, files)
6
-
7
- files.each { |file| puts "- #{file}" }
8
-
9
- puts "\n"
10
- end
11
-
12
- def display_title_and_count(title, files)
13
- puts "#{title} #{files.count}\n"
14
- end
15
- end
@@ -1,11 +0,0 @@
1
- module Semaphore
2
- module_function
3
-
4
- def execute(command)
5
- log("Running command: #{command}")
6
- system(command)
7
- log("Command finished, exit status : #{$?.exitstatus}")
8
-
9
- $?.exitstatus
10
- end
11
- end