sleet 0.3.8 → 0.3.9
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/.circleci/config.yml +1 -1
- data/.rubocop.yml +12 -2
- data/.rubocop_todo.yml +4 -32
- data/CHANGELOG.md +13 -0
- data/lib/sleet/{circle_ci_branch.rb → branch.rb} +1 -1
- data/lib/sleet/{circle_ci_build.rb → build.rb} +1 -1
- data/lib/sleet/build_selector.rb +47 -0
- data/lib/sleet/circle_ci.rb +4 -0
- data/lib/sleet/cli.rb +9 -90
- data/lib/sleet/config.rb +107 -0
- data/lib/sleet/error.rb +4 -1
- data/lib/sleet/fetch_command.rb +46 -0
- data/lib/sleet/job_fetcher.rb +54 -0
- data/lib/sleet/repo.rb +35 -10
- data/lib/sleet/version.rb +1 -1
- data/lib/sleet.rb +9 -4
- data/sleet.gemspec +4 -2
- metadata +46 -10
- data/lib/sleet/fetcher.rb +0 -81
- data/lib/sleet/option_defaults.rb +0 -37
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b394aa63feaea3c3def2bd2ab1fcedc94311c8a0cd1bca488d5e89106110a07f
|
4
|
+
data.tar.gz: 9f450c4b7efa54b1d58abd92bb54e265f012fc6ca7830d7d2f9f20896b4fb07c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7a9e20fa664683bc37695cb3b57191f3baa111e03f9c89febf073af2a7fcbbcb09a5050a10bb64d82d8aae7b9cd02bb4503a89aefae43bf00b60254a16bd4c98
|
7
|
+
data.tar.gz: b9699434ad49685fc96c506075f7b855e4d9f5e7bca3ce15511afb28a0bb53d9acf83ff9b3360dc80e0b044c76329ecd7dcd587d41425b6eecf2ee782223bc66
|
data/.circleci/config.yml
CHANGED
@@ -19,7 +19,7 @@ jobs:
|
|
19
19
|
- gem-cache-{{ checksum "ruby-version.txt" }}-
|
20
20
|
- gem-cache-
|
21
21
|
# Install
|
22
|
-
- run: bundle check || sudo apt-get install cmake && bundle install --path vendor/bundle
|
22
|
+
- run: bundle check --path vendor/bundle || sudo apt-get install cmake && bundle install --path vendor/bundle
|
23
23
|
# Store Cache
|
24
24
|
- save_cache:
|
25
25
|
key: gem-cache-{{ checksum "ruby-version.txt" }}-{{ checksum "sleet.gemspec" }}-{{ checksum "date-cache-key.txt" }}
|
data/.rubocop.yml
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
require: rubocop-rspec
|
2
|
+
|
1
3
|
inherit_from: .rubocop_todo.yml
|
2
4
|
|
3
5
|
AllCops:
|
@@ -7,8 +9,6 @@ AllCops:
|
|
7
9
|
|
8
10
|
Metrics/LineLength:
|
9
11
|
Max: 120
|
10
|
-
Exclude:
|
11
|
-
- 'spec/**/*'
|
12
12
|
|
13
13
|
Metrics/ClassLength:
|
14
14
|
Exclude:
|
@@ -30,3 +30,13 @@ Style/StringLiterals:
|
|
30
30
|
SupportedStyles:
|
31
31
|
- single_quotes
|
32
32
|
- double_quotes
|
33
|
+
|
34
|
+
RSpec/MultipleExpectations:
|
35
|
+
Enabled: false
|
36
|
+
|
37
|
+
RSpec/DescribeClass:
|
38
|
+
Exclude:
|
39
|
+
- 'spec/cli/**/*.rb'
|
40
|
+
|
41
|
+
RSpec/ExampleLength:
|
42
|
+
Max: 10
|
data/.rubocop_todo.yml
CHANGED
@@ -1,41 +1,13 @@
|
|
1
1
|
# This configuration was generated by
|
2
2
|
# `rubocop --auto-gen-config`
|
3
|
-
# on 2018-
|
3
|
+
# on 2018-03-04 17:57:32 -0500 using RuboCop version 0.52.1.
|
4
4
|
# The point is for the user to remove these configuration records
|
5
5
|
# one by one as the offenses are removed from the code base.
|
6
6
|
# Note that changes in the inspected code, or installation of new
|
7
7
|
# versions of RuboCop, may require this file to be generated again.
|
8
8
|
|
9
9
|
# Offense count: 1
|
10
|
-
#
|
11
|
-
|
12
|
-
Layout/EmptyLineBetweenDefs:
|
10
|
+
# Configuration parameters: Max.
|
11
|
+
RSpec/NestedGroups:
|
13
12
|
Exclude:
|
14
|
-
- '
|
15
|
-
|
16
|
-
# Offense count: 1
|
17
|
-
# Cop supports --auto-correct.
|
18
|
-
Layout/EmptyLines:
|
19
|
-
Exclude:
|
20
|
-
- 'lib/sleet/fetcher.rb'
|
21
|
-
|
22
|
-
# Offense count: 1
|
23
|
-
# Configuration parameters: CountComments.
|
24
|
-
Metrics/ClassLength:
|
25
|
-
Max: 107
|
26
|
-
|
27
|
-
# Offense count: 1
|
28
|
-
# Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns.
|
29
|
-
# URISchemes: http, https
|
30
|
-
Metrics/LineLength:
|
31
|
-
Max: 128
|
32
|
-
|
33
|
-
# Offense count: 2
|
34
|
-
# Configuration parameters: CountComments.
|
35
|
-
Metrics/MethodLength:
|
36
|
-
Max: 15
|
37
|
-
|
38
|
-
# Offense count: 1
|
39
|
-
# Configuration parameters: CountKeywordArgs.
|
40
|
-
Metrics/ParameterLists:
|
41
|
-
Max: 7
|
13
|
+
- 'spec/cli/fetch_spec.rb'
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,18 @@
|
|
1
1
|
# Change Log
|
2
2
|
|
3
|
+
## [v0.3.9](https://github.com/coreyja/sleet/tree/v0.3.9) (2018-03-04)
|
4
|
+
[Full Changelog](https://github.com/coreyja/sleet/compare/v0.3.8...v0.3.9)
|
5
|
+
|
6
|
+
**Closed issues:**
|
7
|
+
|
8
|
+
- There are No Specs [\#6](https://github.com/coreyja/sleet/issues/6)
|
9
|
+
|
10
|
+
**Merged pull requests:**
|
11
|
+
|
12
|
+
- Refactor [\#18](https://github.com/coreyja/sleet/pull/18) ([coreyja](https://github.com/coreyja))
|
13
|
+
- Update rake requirement to ~\> 12.3 [\#17](https://github.com/coreyja/sleet/pull/17) ([dependabot[bot]](https://github.com/apps/dependabot))
|
14
|
+
- Update faraday requirement to \>= 0.13.1, \< 0.15.0 [\#16](https://github.com/coreyja/sleet/pull/16) ([dependabot[bot]](https://github.com/apps/dependabot))
|
15
|
+
|
3
16
|
## [v0.3.8](https://github.com/coreyja/sleet/tree/v0.3.8) (2018-02-25)
|
4
17
|
[Full Changelog](https://github.com/coreyja/sleet/compare/v0.3.7...v0.3.8)
|
5
18
|
|
@@ -0,0 +1,47 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Sleet
|
4
|
+
class BuildSelector
|
5
|
+
def initialize(repo:, job_name:)
|
6
|
+
@repo = repo
|
7
|
+
@job_name = job_name
|
8
|
+
end
|
9
|
+
|
10
|
+
def build
|
11
|
+
@_build ||= repo.build_for(chosen_build_num)
|
12
|
+
end
|
13
|
+
|
14
|
+
def validate!
|
15
|
+
must_find_a_build_with_artifacts!
|
16
|
+
chosen_build_must_have_input_file!
|
17
|
+
end
|
18
|
+
|
19
|
+
private
|
20
|
+
|
21
|
+
attr_reader :repo, :job_name
|
22
|
+
|
23
|
+
def branch
|
24
|
+
repo.branch
|
25
|
+
end
|
26
|
+
|
27
|
+
def chosen_build_num
|
28
|
+
chosen_build_json['build_num']
|
29
|
+
end
|
30
|
+
|
31
|
+
def chosen_build_json
|
32
|
+
branch.builds_with_artificats.find do |b|
|
33
|
+
b.fetch('workflows', nil)&.fetch('job_name', nil) == job_name
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
def must_find_a_build_with_artifacts!
|
38
|
+
!chosen_build_json.nil? ||
|
39
|
+
raise(Error, "No builds with artifcats found#{" for job name [#{job_name}]" if job_name}")
|
40
|
+
end
|
41
|
+
|
42
|
+
def chosen_build_must_have_input_file!
|
43
|
+
build.artifacts.any? ||
|
44
|
+
raise(Error, "No Rspec example file found in the latest build (##{chosen_build_num}) with artifacts")
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
data/lib/sleet/circle_ci.rb
CHANGED
data/lib/sleet/cli.rb
CHANGED
@@ -23,18 +23,14 @@ module Sleet
|
|
23
23
|
option :workflows, type: :hash, aliases: [:w], desc: <<~DESC
|
24
24
|
To use Sleet with CircleCI Workflows you need to tell Sleet which build(s) to look in, and where each output should be saved. The input is a hash, where the key is the build name and the value is the output_file for that build. Sleet supports saving the artifacts to multiple builds, meaning it can support a mono-repo setup.
|
25
25
|
DESC
|
26
|
+
option :print_config, type: :boolean, default: false
|
26
27
|
def fetch
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
workflow_fetch
|
32
|
-
else
|
33
|
-
single_fetch
|
28
|
+
sleet_config = Sleet::Config.new(cli_hash: options, dir: Dir.pwd)
|
29
|
+
if options[:print_config]
|
30
|
+
sleet_config.print!
|
31
|
+
exit
|
34
32
|
end
|
35
|
-
|
36
|
-
error(e.message)
|
37
|
-
exit 1
|
33
|
+
Sleet::FetchCommand.new(sleet_config).do!
|
38
34
|
end
|
39
35
|
|
40
36
|
desc 'version', 'Display the version'
|
@@ -42,86 +38,9 @@ module Sleet
|
|
42
38
|
puts "Sleet v#{Sleet::VERSION}"
|
43
39
|
end
|
44
40
|
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
Sleet::Fetcher.new(
|
49
|
-
base_fetcher_params.merge(
|
50
|
-
output_filename: options.fetch(:output_file, '.rspec_example_statuses')
|
51
|
-
)
|
52
|
-
).do!
|
53
|
-
rescue Sleet::Error => e
|
54
|
-
error(e.message)
|
55
|
-
exit 1
|
56
|
-
end
|
57
|
-
|
58
|
-
def workflow_fetch
|
59
|
-
failed = false
|
60
|
-
options[:workflows].each do |job_name, output_filename|
|
61
|
-
begin
|
62
|
-
Sleet::Fetcher.new(
|
63
|
-
base_fetcher_params.merge(
|
64
|
-
output_filename: output_filename,
|
65
|
-
job_name: job_name
|
66
|
-
)
|
67
|
-
).do!
|
68
|
-
rescue Sleet::Error => e
|
69
|
-
failed = true
|
70
|
-
error(e.message)
|
71
|
-
end
|
72
|
-
end
|
73
|
-
exit 1 if failed
|
74
|
-
end
|
75
|
-
|
76
|
-
def circle_ci_branch
|
77
|
-
@_circle_ci_branch ||= Sleet::CircleCiBranch.new(
|
78
|
-
github_user: repo.github_user,
|
79
|
-
github_repo: repo.github_repo,
|
80
|
-
branch: repo.remote_branch
|
81
|
-
)
|
82
|
-
end
|
83
|
-
|
84
|
-
def must_be_on_branch!
|
85
|
-
repo.on_branch? ||
|
86
|
-
error('Not on a branch')
|
87
|
-
end
|
88
|
-
|
89
|
-
def must_have_an_upstream_branch!
|
90
|
-
repo.remote? ||
|
91
|
-
error("No upstream branch set for the current branch of #{repo.current_branch_name}")
|
92
|
-
end
|
93
|
-
|
94
|
-
def upstream_remote_must_be_github!
|
95
|
-
repo.github? ||
|
96
|
-
error('Upstream remote is not GitHub')
|
97
|
-
end
|
98
|
-
|
99
|
-
def repo
|
100
|
-
@_repo ||= Sleet::Repo.from_dir(options.fetch(:source_dir, default_dir))
|
101
|
-
end
|
102
|
-
|
103
|
-
def base_fetcher_params
|
104
|
-
{
|
105
|
-
source_dir: options.fetch(:source_dir, default_dir),
|
106
|
-
circle_ci_branch: circle_ci_branch,
|
107
|
-
input_filename: options.fetch(:input_file, '.rspec_example_statuses'),
|
108
|
-
github_user: repo.github_user,
|
109
|
-
github_repo: repo.github_repo
|
110
|
-
}
|
111
|
-
end
|
112
|
-
|
113
|
-
def error(message)
|
114
|
-
puts "ERROR: #{message}".red
|
115
|
-
end
|
116
|
-
|
117
|
-
def default_dir
|
118
|
-
Rugged::Repository.discover(Dir.pwd).path + '..'
|
119
|
-
end
|
120
|
-
|
121
|
-
def options
|
122
|
-
original_options = super
|
123
|
-
defaults = Sleet::OptionDefaults.new(Dir.pwd).defaults
|
124
|
-
Thor::CoreExt::HashWithIndifferentAccess.new(defaults.merge(original_options))
|
41
|
+
desc 'config', 'Print the config'
|
42
|
+
def config
|
43
|
+
Sleet::Config.new(cli_hash: options, dir: Dir.pwd).print!
|
125
44
|
end
|
126
45
|
end
|
127
46
|
end
|
data/lib/sleet/config.rb
ADDED
@@ -0,0 +1,107 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Sleet
|
4
|
+
class Config
|
5
|
+
OPTION_FILENAME = '.sleet.yml'
|
6
|
+
ConfigOption = Struct.new(:value, :source)
|
7
|
+
|
8
|
+
def initialize(dir:, cli_hash: {})
|
9
|
+
@dir = dir
|
10
|
+
@cli_hash = cli_hash
|
11
|
+
end
|
12
|
+
|
13
|
+
def source_dir
|
14
|
+
options_hash[:source_dir]
|
15
|
+
end
|
16
|
+
|
17
|
+
def input_file
|
18
|
+
options_hash[:input_file]
|
19
|
+
end
|
20
|
+
|
21
|
+
def output_file
|
22
|
+
options_hash[:output_file]
|
23
|
+
end
|
24
|
+
|
25
|
+
def workflows
|
26
|
+
options_hash[:workflows]
|
27
|
+
end
|
28
|
+
|
29
|
+
def print!
|
30
|
+
puts Terminal::Table.new headings: %w[Option Value Source], rows: table_rows
|
31
|
+
end
|
32
|
+
|
33
|
+
private
|
34
|
+
|
35
|
+
attr_reader :cli_hash, :dir
|
36
|
+
|
37
|
+
def options
|
38
|
+
@_options ||= default_options.merge(file_options).merge(cli_options)
|
39
|
+
end
|
40
|
+
|
41
|
+
def options_hash
|
42
|
+
@_options_hash ||= Thor::CoreExt::HashWithIndifferentAccess.new(options.map { |k, o| [k, o.value] }.to_h)
|
43
|
+
end
|
44
|
+
|
45
|
+
def table_rows
|
46
|
+
options.map do |key, option|
|
47
|
+
if key.to_sym == :workflows
|
48
|
+
[key, Terminal::Table.new(headings: ['Job Name', 'Output File'], rows: option.value.to_a), option.source]
|
49
|
+
else
|
50
|
+
[key, option.value, option.source]
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
def cli_options
|
56
|
+
build_option_hash('CLI', cli_hash)
|
57
|
+
end
|
58
|
+
|
59
|
+
def file_options
|
60
|
+
file_hashes.map do |file, options|
|
61
|
+
build_option_hash(file, options)
|
62
|
+
end.reduce({}, :merge)
|
63
|
+
end
|
64
|
+
|
65
|
+
def file_hashes
|
66
|
+
files.map { |f| [f, ::YAML.load_file(f) || {}] }
|
67
|
+
end
|
68
|
+
|
69
|
+
def files
|
70
|
+
paths_to_search.select { |f| File.file?(f) }
|
71
|
+
end
|
72
|
+
|
73
|
+
def paths_to_search
|
74
|
+
directories.each_index.map do |i|
|
75
|
+
(directories[0..i] + [OPTION_FILENAME]).join('/')
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
def directories
|
80
|
+
@_directories ||= dir.split('/')
|
81
|
+
end
|
82
|
+
|
83
|
+
def default_options
|
84
|
+
build_option_hash 'default', default_hash
|
85
|
+
end
|
86
|
+
|
87
|
+
def default_hash
|
88
|
+
{
|
89
|
+
'source_dir' => File.expand_path(default_dir),
|
90
|
+
'input_file' => '.rspec_example_statuses',
|
91
|
+
'output_file' => '.rspec_example_statuses'
|
92
|
+
}
|
93
|
+
end
|
94
|
+
|
95
|
+
def default_dir
|
96
|
+
Rugged::Repository.discover(Dir.pwd).path + '..'
|
97
|
+
rescue Rugged::RepositoryError
|
98
|
+
'.'
|
99
|
+
end
|
100
|
+
|
101
|
+
def build_option_hash(source, options)
|
102
|
+
options.map do |key, value|
|
103
|
+
[key, ConfigOption.new(value, source)]
|
104
|
+
end.to_h
|
105
|
+
end
|
106
|
+
end
|
107
|
+
end
|
data/lib/sleet/error.rb
CHANGED
@@ -0,0 +1,46 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Sleet
|
4
|
+
class FetchCommand
|
5
|
+
def initialize(config)
|
6
|
+
@config = config
|
7
|
+
end
|
8
|
+
|
9
|
+
def do!
|
10
|
+
repo.validate!
|
11
|
+
error_messages = []
|
12
|
+
fetchers.map do |fetcher|
|
13
|
+
begin
|
14
|
+
fetcher.do!
|
15
|
+
rescue Sleet::Error => e
|
16
|
+
error_messages << e.message
|
17
|
+
end
|
18
|
+
end
|
19
|
+
raise Thor::Error, error_messages.join("\n") unless error_messages.empty?
|
20
|
+
end
|
21
|
+
|
22
|
+
private
|
23
|
+
|
24
|
+
attr_reader :config
|
25
|
+
|
26
|
+
def fetchers
|
27
|
+
job_name_to_output_files.map do |job_name, output_filename|
|
28
|
+
Sleet::JobFetcher.new(
|
29
|
+
source_dir: config.source_dir,
|
30
|
+
input_filename: config.input_file,
|
31
|
+
output_filename: output_filename,
|
32
|
+
repo: repo,
|
33
|
+
job_name: job_name
|
34
|
+
)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
def job_name_to_output_files
|
39
|
+
config.workflows || { nil => config.output_file }
|
40
|
+
end
|
41
|
+
|
42
|
+
def repo
|
43
|
+
@_repo ||= Sleet::Repo.from_dir(config.source_dir)
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
@@ -0,0 +1,54 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Sleet
|
4
|
+
class JobFetcher
|
5
|
+
def initialize(source_dir:, input_filename:, output_filename:, job_name:, repo:)
|
6
|
+
@source_dir = source_dir
|
7
|
+
@input_filename = input_filename
|
8
|
+
@output_filename = output_filename
|
9
|
+
@job_name = job_name
|
10
|
+
@repo = repo
|
11
|
+
end
|
12
|
+
|
13
|
+
def do!
|
14
|
+
validate!
|
15
|
+
create_output_file!
|
16
|
+
end
|
17
|
+
|
18
|
+
private
|
19
|
+
|
20
|
+
attr_reader :input_filename, :output_filename, :job_name, :source_dir, :repo
|
21
|
+
|
22
|
+
def validate!
|
23
|
+
build_selector.validate!
|
24
|
+
end
|
25
|
+
|
26
|
+
def create_output_file!
|
27
|
+
File.write(File.join(source_dir, output_filename), combined_file)
|
28
|
+
puts "Created file (#{output_filename}) from build (##{build.build_num})".green
|
29
|
+
end
|
30
|
+
|
31
|
+
def combined_file
|
32
|
+
Sleet::RspecFileMerger.new(build_persistance_artifacts).output
|
33
|
+
end
|
34
|
+
|
35
|
+
def build_persistance_artifacts
|
36
|
+
@_build_persistance_artifacts ||= Sleet::ArtifactDownloader.new(
|
37
|
+
file_name: input_filename,
|
38
|
+
artifacts: build.artifacts
|
39
|
+
).files
|
40
|
+
end
|
41
|
+
|
42
|
+
def branch
|
43
|
+
repo.branch
|
44
|
+
end
|
45
|
+
|
46
|
+
def build
|
47
|
+
build_selector.build
|
48
|
+
end
|
49
|
+
|
50
|
+
def build_selector
|
51
|
+
@_build_selector ||= Sleet::BuildSelector.new(job_name: job_name, repo: repo)
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
data/lib/sleet/repo.rb
CHANGED
@@ -14,18 +14,32 @@ module Sleet
|
|
14
14
|
@repo = repo
|
15
15
|
end
|
16
16
|
|
17
|
-
def
|
18
|
-
!
|
17
|
+
def validate!
|
18
|
+
must_be_on_branch!
|
19
|
+
must_have_an_upstream_branch!
|
20
|
+
upstream_remote_must_be_github!
|
19
21
|
end
|
20
22
|
|
21
|
-
def
|
22
|
-
|
23
|
+
def branch
|
24
|
+
@_branch ||= Sleet::Branch.new(
|
25
|
+
github_user: github_user,
|
26
|
+
github_repo: github_repo,
|
27
|
+
branch: remote_branch
|
28
|
+
)
|
23
29
|
end
|
24
30
|
|
25
|
-
def
|
26
|
-
|
31
|
+
def build_for(build_num)
|
32
|
+
Sleet::Build.new(
|
33
|
+
github_user: github_user,
|
34
|
+
github_repo: github_repo,
|
35
|
+
build_num: build_num
|
36
|
+
)
|
27
37
|
end
|
28
38
|
|
39
|
+
private
|
40
|
+
|
41
|
+
attr_reader :repo
|
42
|
+
|
29
43
|
def remote_branch
|
30
44
|
current_branch.upstream.name.match(REMOTE_BRANCH_REGEX)[2]
|
31
45
|
end
|
@@ -42,10 +56,6 @@ module Sleet
|
|
42
56
|
repo.head.name.sub(CURRENT_BRANCH_REGEX, '')
|
43
57
|
end
|
44
58
|
|
45
|
-
private
|
46
|
-
|
47
|
-
attr_reader :repo
|
48
|
-
|
49
59
|
def current_branch
|
50
60
|
repo.branches[current_branch_name]
|
51
61
|
end
|
@@ -53,5 +63,20 @@ module Sleet
|
|
53
63
|
def github_match
|
54
64
|
@_github_match ||= GITHUB_MATCH_REGEX.match(current_branch.remote.url)
|
55
65
|
end
|
66
|
+
|
67
|
+
def must_be_on_branch!
|
68
|
+
!current_branch.nil? ||
|
69
|
+
raise(Error, 'Not on a branch')
|
70
|
+
end
|
71
|
+
|
72
|
+
def must_have_an_upstream_branch!
|
73
|
+
!current_branch.remote.nil? ||
|
74
|
+
raise(Error, "No upstream branch set for the current branch of #{repo.current_branch_name}")
|
75
|
+
end
|
76
|
+
|
77
|
+
def upstream_remote_must_be_github!
|
78
|
+
!github_match.nil? ||
|
79
|
+
raise(Error, 'Upstream remote is not GitHub')
|
80
|
+
end
|
56
81
|
end
|
57
82
|
end
|
data/lib/sleet/version.rb
CHANGED
data/lib/sleet.rb
CHANGED
@@ -2,24 +2,29 @@
|
|
2
2
|
|
3
3
|
require 'colorize'
|
4
4
|
require 'faraday'
|
5
|
+
require 'forwardable'
|
5
6
|
require 'json'
|
6
7
|
require 'rspec'
|
7
8
|
require 'rugged'
|
9
|
+
require 'terminal-table'
|
8
10
|
require 'thor'
|
9
11
|
require 'yaml'
|
10
12
|
|
11
13
|
# This is to load the classes that are defined in the same file as this one
|
14
|
+
# We are most definitely relying on Private API here
|
12
15
|
begin
|
13
16
|
RSpec::Core::ExampleStatusPersister
|
14
17
|
end
|
15
18
|
|
16
19
|
require 'sleet/artifact_downloader'
|
20
|
+
require 'sleet/branch'
|
21
|
+
require 'sleet/build'
|
22
|
+
require 'sleet/build_selector'
|
17
23
|
require 'sleet/circle_ci'
|
18
|
-
require 'sleet/
|
19
|
-
require 'sleet/circle_ci_build'
|
24
|
+
require 'sleet/config'
|
20
25
|
require 'sleet/error'
|
21
|
-
require 'sleet/
|
22
|
-
require 'sleet/
|
26
|
+
require 'sleet/fetch_command'
|
27
|
+
require 'sleet/job_fetcher'
|
23
28
|
require 'sleet/repo'
|
24
29
|
require 'sleet/rspec_file_merger'
|
25
30
|
require 'sleet/version'
|
data/sleet.gemspec
CHANGED
@@ -27,14 +27,16 @@ Gem::Specification.new do |spec|
|
|
27
27
|
spec.require_paths = ['lib']
|
28
28
|
|
29
29
|
spec.add_dependency 'colorize', '~> 0.8.1'
|
30
|
-
spec.add_dependency 'faraday', '
|
30
|
+
spec.add_dependency 'faraday', '>= 0.13.1', '< 0.15.0'
|
31
31
|
spec.add_dependency 'rspec', '~> 3.0'
|
32
32
|
spec.add_dependency 'rugged', '~> 0.26.0'
|
33
|
+
spec.add_dependency 'terminal-table', '~> 1.8'
|
33
34
|
spec.add_dependency 'thor', '~> 0.20.0'
|
34
35
|
|
35
36
|
spec.add_development_dependency 'bundler', '~> 1.13'
|
36
37
|
spec.add_development_dependency 'pry', '~> 0.10'
|
37
|
-
spec.add_development_dependency 'rake', '~>
|
38
|
+
spec.add_development_dependency 'rake', '~> 12.3'
|
38
39
|
spec.add_development_dependency 'rubocop', '~> 0.52.1'
|
40
|
+
spec.add_development_dependency 'rubocop-rspec', '~> 1.22'
|
39
41
|
spec.add_development_dependency 'webmock', '~> 3.3.0'
|
40
42
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sleet
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Corey Alexander
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-03-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: colorize
|
@@ -28,16 +28,22 @@ dependencies:
|
|
28
28
|
name: faraday
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- - "
|
31
|
+
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: 0.13.1
|
34
|
+
- - "<"
|
35
|
+
- !ruby/object:Gem::Version
|
36
|
+
version: 0.15.0
|
34
37
|
type: :runtime
|
35
38
|
prerelease: false
|
36
39
|
version_requirements: !ruby/object:Gem::Requirement
|
37
40
|
requirements:
|
38
|
-
- - "
|
41
|
+
- - ">="
|
39
42
|
- !ruby/object:Gem::Version
|
40
43
|
version: 0.13.1
|
44
|
+
- - "<"
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: 0.15.0
|
41
47
|
- !ruby/object:Gem::Dependency
|
42
48
|
name: rspec
|
43
49
|
requirement: !ruby/object:Gem::Requirement
|
@@ -66,6 +72,20 @@ dependencies:
|
|
66
72
|
- - "~>"
|
67
73
|
- !ruby/object:Gem::Version
|
68
74
|
version: 0.26.0
|
75
|
+
- !ruby/object:Gem::Dependency
|
76
|
+
name: terminal-table
|
77
|
+
requirement: !ruby/object:Gem::Requirement
|
78
|
+
requirements:
|
79
|
+
- - "~>"
|
80
|
+
- !ruby/object:Gem::Version
|
81
|
+
version: '1.8'
|
82
|
+
type: :runtime
|
83
|
+
prerelease: false
|
84
|
+
version_requirements: !ruby/object:Gem::Requirement
|
85
|
+
requirements:
|
86
|
+
- - "~>"
|
87
|
+
- !ruby/object:Gem::Version
|
88
|
+
version: '1.8'
|
69
89
|
- !ruby/object:Gem::Dependency
|
70
90
|
name: thor
|
71
91
|
requirement: !ruby/object:Gem::Requirement
|
@@ -114,14 +134,14 @@ dependencies:
|
|
114
134
|
requirements:
|
115
135
|
- - "~>"
|
116
136
|
- !ruby/object:Gem::Version
|
117
|
-
version: '
|
137
|
+
version: '12.3'
|
118
138
|
type: :development
|
119
139
|
prerelease: false
|
120
140
|
version_requirements: !ruby/object:Gem::Requirement
|
121
141
|
requirements:
|
122
142
|
- - "~>"
|
123
143
|
- !ruby/object:Gem::Version
|
124
|
-
version: '
|
144
|
+
version: '12.3'
|
125
145
|
- !ruby/object:Gem::Dependency
|
126
146
|
name: rubocop
|
127
147
|
requirement: !ruby/object:Gem::Requirement
|
@@ -136,6 +156,20 @@ dependencies:
|
|
136
156
|
- - "~>"
|
137
157
|
- !ruby/object:Gem::Version
|
138
158
|
version: 0.52.1
|
159
|
+
- !ruby/object:Gem::Dependency
|
160
|
+
name: rubocop-rspec
|
161
|
+
requirement: !ruby/object:Gem::Requirement
|
162
|
+
requirements:
|
163
|
+
- - "~>"
|
164
|
+
- !ruby/object:Gem::Version
|
165
|
+
version: '1.22'
|
166
|
+
type: :development
|
167
|
+
prerelease: false
|
168
|
+
version_requirements: !ruby/object:Gem::Requirement
|
169
|
+
requirements:
|
170
|
+
- - "~>"
|
171
|
+
- !ruby/object:Gem::Version
|
172
|
+
version: '1.22'
|
139
173
|
- !ruby/object:Gem::Dependency
|
140
174
|
name: webmock
|
141
175
|
requirement: !ruby/object:Gem::Requirement
|
@@ -178,13 +212,15 @@ files:
|
|
178
212
|
- exe/sleet
|
179
213
|
- lib/sleet.rb
|
180
214
|
- lib/sleet/artifact_downloader.rb
|
215
|
+
- lib/sleet/branch.rb
|
216
|
+
- lib/sleet/build.rb
|
217
|
+
- lib/sleet/build_selector.rb
|
181
218
|
- lib/sleet/circle_ci.rb
|
182
|
-
- lib/sleet/circle_ci_branch.rb
|
183
|
-
- lib/sleet/circle_ci_build.rb
|
184
219
|
- lib/sleet/cli.rb
|
220
|
+
- lib/sleet/config.rb
|
185
221
|
- lib/sleet/error.rb
|
186
|
-
- lib/sleet/
|
187
|
-
- lib/sleet/
|
222
|
+
- lib/sleet/fetch_command.rb
|
223
|
+
- lib/sleet/job_fetcher.rb
|
188
224
|
- lib/sleet/repo.rb
|
189
225
|
- lib/sleet/rspec_file_merger.rb
|
190
226
|
- lib/sleet/version.rb
|
data/lib/sleet/fetcher.rb
DELETED
@@ -1,81 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Sleet
|
4
|
-
class Fetcher
|
5
|
-
class Error < ::Sleet::Error; end
|
6
|
-
|
7
|
-
def initialize(source_dir:, circle_ci_branch:, input_filename:, output_filename:, github_user:, github_repo:, job_name: nil) # rubocop:disable Metrics/LineLength
|
8
|
-
@source_dir = source_dir
|
9
|
-
@circle_ci_branch = circle_ci_branch
|
10
|
-
@input_filename = input_filename
|
11
|
-
@output_filename = output_filename
|
12
|
-
@job_name = job_name
|
13
|
-
@github_user = github_user
|
14
|
-
@github_repo = github_repo
|
15
|
-
end
|
16
|
-
|
17
|
-
def do!
|
18
|
-
validate!
|
19
|
-
create_output_file!
|
20
|
-
end
|
21
|
-
|
22
|
-
def validate!
|
23
|
-
must_find_a_build_with_artifacts!
|
24
|
-
chosen_build_must_have_input_file!
|
25
|
-
true
|
26
|
-
end
|
27
|
-
|
28
|
-
def create_output_file!
|
29
|
-
Dir.chdir(source_dir) do
|
30
|
-
File.write(output_filename, combined_file)
|
31
|
-
end
|
32
|
-
puts "Created file (#{output_filename}) from build (##{circle_ci_build.build_num})".green
|
33
|
-
end
|
34
|
-
|
35
|
-
private
|
36
|
-
|
37
|
-
attr_reader :input_filename, :output_filename, :job_name, :circle_ci_branch, :github_user, :github_repo, :source_dir
|
38
|
-
|
39
|
-
def error(msg)
|
40
|
-
raise Error, msg
|
41
|
-
end
|
42
|
-
|
43
|
-
def combined_file
|
44
|
-
@_combined_file ||= Sleet::RspecFileMerger.new(build_persistance_artifacts).output
|
45
|
-
end
|
46
|
-
|
47
|
-
def build_persistance_artifacts
|
48
|
-
@_build_persistance_artifacts ||= Sleet::ArtifactDownloader.new(
|
49
|
-
file_name: input_filename,
|
50
|
-
artifacts: circle_ci_build.artifacts
|
51
|
-
).files
|
52
|
-
end
|
53
|
-
|
54
|
-
def circle_ci_build
|
55
|
-
@_circle_ci_build ||= Sleet::CircleCiBuild.new(
|
56
|
-
github_user: github_user,
|
57
|
-
github_repo: github_repo,
|
58
|
-
build_num: chosen_build_json['build_num']
|
59
|
-
)
|
60
|
-
end
|
61
|
-
|
62
|
-
def chosen_build_json
|
63
|
-
if job_name
|
64
|
-
circle_ci_branch.builds_with_artificats.find { |b| b.fetch('workflows', {})&.fetch('job_name', {}) == job_name }
|
65
|
-
else
|
66
|
-
circle_ci_branch.builds_with_artificats.first
|
67
|
-
end
|
68
|
-
end
|
69
|
-
|
70
|
-
|
71
|
-
def must_find_a_build_with_artifacts!
|
72
|
-
!chosen_build_json.nil? ||
|
73
|
-
error("No builds with artifcats found #{"for job name [#{job_name}]" if job_name}")
|
74
|
-
end
|
75
|
-
|
76
|
-
def chosen_build_must_have_input_file!
|
77
|
-
circle_ci_build.artifacts.any? ||
|
78
|
-
error("No Rspec example file found in the latest build (##{circle_ci_build.build_num}) with artifacts")
|
79
|
-
end
|
80
|
-
end
|
81
|
-
end
|
@@ -1,37 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Sleet
|
4
|
-
class OptionDefaults
|
5
|
-
OPTION_FILENAME = '.sleet.yml'
|
6
|
-
|
7
|
-
def initialize(dir)
|
8
|
-
@dir = dir
|
9
|
-
end
|
10
|
-
|
11
|
-
def defaults
|
12
|
-
defaults_hashes.reduce({}, :merge)
|
13
|
-
end
|
14
|
-
|
15
|
-
private
|
16
|
-
|
17
|
-
attr_reader :dir
|
18
|
-
|
19
|
-
def defaults_hashes
|
20
|
-
files.map { |f| ::YAML.load_file(f) || {} }
|
21
|
-
end
|
22
|
-
|
23
|
-
def files
|
24
|
-
files_to_search.select { |f| File.file?(f) }
|
25
|
-
end
|
26
|
-
|
27
|
-
def files_to_search
|
28
|
-
x.each_index.map do |i|
|
29
|
-
(x[0..i] + [OPTION_FILENAME]).join('/')
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
|
-
def x
|
34
|
-
@_x ||= dir.split('/')
|
35
|
-
end
|
36
|
-
end
|
37
|
-
end
|