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 +4 -4
- data/config/cucumber.yml +2 -1
- data/exe/cucumber_booster +4 -4
- data/exe/rspec_booster +3 -3
- data/lib/test_boosters.rb +24 -6
- data/lib/test_boosters/cli_parser.rb +11 -11
- data/lib/test_boosters/cucumber_booster.rb +7 -14
- data/lib/test_boosters/insights_uploader.rb +2 -4
- data/lib/test_boosters/leftover_files.rb +22 -21
- data/lib/test_boosters/logger.rb +15 -5
- data/lib/test_boosters/rspec_booster.rb +9 -15
- data/lib/test_boosters/run_cucumber_config.rb +0 -13
- data/lib/test_boosters/shell.rb +26 -0
- data/lib/test_boosters/version.rb +1 -1
- data/test_boosters.gemspec +6 -6
- data/test_data_fail/fail_spec.rb +1 -3
- data/test_data_pass/pass_spec.rb +1 -1
- metadata +16 -17
- data/lib/test_boosters/display_files.rb +0 -15
- data/lib/test_boosters/executor.rb +0 -11
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 16ee85bdadc0f19aaf4b16c3e5f98a710540a999
|
4
|
+
data.tar.gz: 9c912cc4b2fa96df2ad02eddd132fec18651eb6e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0ae6310f2469127c089493e9adfb979628c0b00a6ce52f99ab17f559325b57324343f2eb0b08d26aab665fc47404eff5326ddc6f6e53865d6b8cbbae481d181b
|
7
|
+
data.tar.gz: b2ef54cccb3df907ddd682ae57242225aa9bbe32922b64a97873903325e45d35b16e3d59306081f53b6f878e5bb6c63d0845d873fc9c01ab32d3a84e3ec126bf
|
data/config/cucumber.yml
CHANGED
@@ -1 +1,2 @@
|
|
1
|
-
default: --format pretty
|
1
|
+
default: --format pretty --profile semaphoreci
|
2
|
+
semaphoreci: --format json --out=../cucumber_report.json
|
data/exe/cucumber_booster
CHANGED
@@ -2,14 +2,14 @@
|
|
2
2
|
|
3
3
|
require "test_boosters"
|
4
4
|
|
5
|
-
|
5
|
+
TestBoosters.run_cucumber_config
|
6
6
|
|
7
|
-
cli_options =
|
7
|
+
cli_options = TestBoosters::CliParser.parse
|
8
8
|
thread_index = cli_options[:index] - 1
|
9
|
-
cucumber_booster =
|
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
|
-
|
13
|
+
TestBoosters::InsightsUploader.new.upload("cucumber", report_path)
|
14
14
|
|
15
15
|
exit(exit_status)
|
data/exe/rspec_booster
CHANGED
@@ -2,12 +2,12 @@
|
|
2
2
|
|
3
3
|
require "test_boosters"
|
4
4
|
|
5
|
-
cli_options =
|
5
|
+
cli_options = TestBoosters::CliParser.parse
|
6
6
|
thread_index = cli_options[:index] - 1
|
7
|
-
rspec_booster =
|
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
|
-
|
11
|
+
TestBoosters::InsightsUploader.new.upload("rspec", report_path)
|
12
12
|
|
13
13
|
exit(exit_status)
|
data/lib/test_boosters.rb
CHANGED
@@ -1,9 +1,27 @@
|
|
1
|
-
require "
|
2
|
-
require "
|
3
|
-
require "
|
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
|
-
|
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
|
2
|
-
|
1
|
+
module TestBoosters
|
2
|
+
module CliParser
|
3
|
+
module_function
|
3
4
|
|
4
|
-
|
5
|
+
def parse
|
6
|
+
options = {}
|
5
7
|
|
6
|
-
|
7
|
-
|
8
|
+
parser = OptionParser.new do |opts|
|
9
|
+
opts.on("--thread INDEX") { |index| options[:index] = index.to_i }
|
10
|
+
end
|
8
11
|
|
9
|
-
|
10
|
-
opts.on("--thread INDEX") { |index| options[:index] = index.to_i }
|
11
|
-
end
|
12
|
-
|
13
|
-
parser.parse!
|
12
|
+
parser.parse!
|
14
13
|
|
15
|
-
|
14
|
+
options
|
15
|
+
end
|
16
16
|
end
|
17
17
|
end
|
@@ -1,11 +1,4 @@
|
|
1
|
-
module
|
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
|
-
|
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
|
-
|
60
|
-
|
61
|
-
|
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
|
-
|
72
|
+
TestBoosters::Logger.error(error)
|
80
73
|
|
81
74
|
raise
|
82
75
|
end
|
@@ -1,6 +1,4 @@
|
|
1
|
-
module
|
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
|
-
|
16
|
+
TestBoosters::Shell.execute("#{cmd} > ~/insights_uploader.log")
|
19
17
|
end
|
20
18
|
end
|
21
19
|
end
|
@@ -1,29 +1,30 @@
|
|
1
|
-
module
|
2
|
-
|
1
|
+
module TestBoosters
|
2
|
+
module LeftoverFiles
|
3
|
+
module_function
|
3
4
|
|
4
|
-
|
5
|
-
|
5
|
+
def select(all_leftover_files, thread_count, thread_index)
|
6
|
+
all_leftover_files = sort_descending_by_size(all_leftover_files)
|
6
7
|
|
7
|
-
|
8
|
+
return [] if all_leftover_files.empty?
|
8
9
|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
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
|
-
|
15
|
-
|
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
|
data/lib/test_boosters/logger.rb
CHANGED
@@ -1,9 +1,19 @@
|
|
1
|
-
module
|
2
|
-
|
1
|
+
module TestBoosters
|
2
|
+
module Logger
|
3
|
+
module_function
|
3
4
|
|
4
|
-
|
5
|
-
|
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
|
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
|
-
|
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
|
-
|
62
|
-
|
63
|
-
|
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
|
-
|
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
|
data/test_boosters.gemspec
CHANGED
@@ -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
|
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
|
26
|
-
spec.bindir
|
27
|
-
spec.executables
|
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 "
|
34
|
+
spec.add_development_dependency "activesupport", "~> 4.0"
|
35
|
+
spec.add_development_dependency "cucumber-rails", "~> 1.4.3"
|
36
36
|
end
|
data/test_data_fail/fail_spec.rb
CHANGED
data/test_data_pass/pass_spec.rb
CHANGED
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.
|
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-
|
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:
|
28
|
+
name: rake
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '
|
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: '
|
40
|
+
version: '10.0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
|
-
name:
|
42
|
+
name: rspec
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
45
|
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: '
|
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: '
|
54
|
+
version: '3.0'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
|
-
name:
|
56
|
+
name: activesupport
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
59
|
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: '
|
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: '
|
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:
|
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:
|
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
|