sleet 0.4.3 → 0.5.0

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
  SHA256:
3
- metadata.gz: d8eb6437ac9bdfb783a8d168289c197d3dbc7626e2f3e68a1484d6c538f1106b
4
- data.tar.gz: 695273c145d440bc2ab46a9ba3238641b04fb8d655135ad3f6a281f44e414deb
3
+ metadata.gz: 8805bb18d2e088cf5f63494b42e29e4e05afcd187917c8260823911242d5910b
4
+ data.tar.gz: 3611f50834801d5c2330a1f30a249faf89985bc0675a1d4b00911c25405565ae
5
5
  SHA512:
6
- metadata.gz: 88eee7ed041b3fdf4c886fd7bebe2f0e8ca4df3d68623d40f0c2647b8a9f6b0cbc752e25d73a9b40373682b5628267e8fc12755e23bb9c8519c9b557a975495b
7
- data.tar.gz: fe6e5e4a5eab4eef4cf992e35fb1ad2e2040873986509141082fd75a42f543dfc4c46acdc12ad470c093ebe39db03b33b6d60223df3d0bb15ae76d532b0f85d8
6
+ metadata.gz: 92c65ac25258e338d9e86af77142a172621af44ea3ab9aad61bf91924c2e4a3f8fe15c0428c5acce1c80412e20789c8a8aadfe9e02644aeccaa54888b829038d
7
+ data.tar.gz: eaf9852bceea8250b85a499af61dda56463aeb6fd85ea1b49c0566b0b99c65ff09ba9ea02a9e0200b13a268960c211402892b2b88d38ce70d06f6db324334ca1
@@ -1,6 +1,21 @@
1
1
  # Changelog
2
2
 
3
- ## [v0.4.3](https://github.com/coreyja/sleet/tree/v0.4.3) (2020-03-06)
3
+ ## [v0.5.0](https://github.com/coreyja/sleet/tree/v0.5.0) (2020-06-13)
4
+
5
+ [Full Changelog](https://github.com/coreyja/sleet/compare/v0.4.3...v0.5.0)
6
+
7
+ **Closed issues:**
8
+
9
+ - Add Support for Forked Repos in Github [\#41](https://github.com/coreyja/sleet/issues/41)
10
+
11
+ **Merged pull requests:**
12
+
13
+ - Support PR builds from forked repos!!! ✨ [\#77](https://github.com/coreyja/sleet/pull/77) ([smudge](https://github.com/smudge))
14
+ - Update rugged requirement from \>= 0.26, \< 0.100 to \>= 0.26, \< 1.1 [\#76](https://github.com/coreyja/sleet/pull/76) ([dependabot-preview[bot]](https://github.com/apps/dependabot-preview))
15
+ - Update rugged requirement from \>= 0.26, \< 0.29 to \>= 0.26, \< 0.100 [\#75](https://github.com/coreyja/sleet/pull/75) ([dependabot-preview[bot]](https://github.com/apps/dependabot-preview))
16
+ - Update thor requirement from ~\> 0.20.0 to \>= 0.20, \< 1.1 [\#70](https://github.com/coreyja/sleet/pull/70) ([dependabot-preview[bot]](https://github.com/apps/dependabot-preview))
17
+
18
+ ## [v0.4.3](https://github.com/coreyja/sleet/tree/v0.4.3) (2020-03-07)
4
19
 
5
20
  [Full Changelog](https://github.com/coreyja/sleet/compare/v0.4.2...v0.4.3)
6
21
 
@@ -95,31 +95,31 @@ To view your current configuration use the `sleet config` command which will giv
95
95
 
96
96
  These are the options that are currently supported
97
97
 
98
- #### `source_dir`
98
+ #### `--source_dir`
99
99
 
100
- Alias: s
100
+ Alias: `s`
101
101
 
102
102
  This is the directory of the source git repo. If a `source_dir` is NOT given we look up from the current directory for the nearest git repo.
103
103
 
104
- #### `input_file`
104
+ #### `--input_file`
105
105
 
106
- Alias: i
106
+ Alias: `i`
107
107
 
108
108
  This is the name of the Rspec Circle Persistance File in CircleCI. The default is `.rspec_example_statuses`
109
109
 
110
110
  This will match if the full path on CircleCI ends in the given name.
111
111
 
112
- #### `output_file`
112
+ #### `--output_file`
113
113
 
114
- Alias: o
114
+ Alias: `o`
115
115
 
116
116
  This is the name for the output file, on your local system. It is relative to the `source_dir`.
117
117
 
118
118
  Will be IGNORED if `workflows` is provided.
119
119
 
120
- #### `workflows`
120
+ #### `--workflows`
121
121
 
122
- Alias: w
122
+ Alias: `w`
123
123
 
124
124
  If you are using workflows in CircleCI, then this is for you! You need to tell `Sleet` which build(s) to look in, and where each output should be saved.
125
125
  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.
@@ -133,7 +133,6 @@ This command will pick the `test` build and save its artifacts to the `.rspec_ex
133
133
  ```
134
134
  sleet fetch --workflows test:.rspec_example_statuses
135
135
  ```
136
-
137
136
  MonoRepo Demo:
138
137
 
139
138
  If you have a mono-repo that contains 3 sub-dirs. `foo`, `bar` and `baz`. And each one has an accompanying build. We can process all these sub-dirs at once with the following workflow command.
@@ -141,3 +140,21 @@ If you have a mono-repo that contains 3 sub-dirs. `foo`, `bar` and `baz`. And ea
141
140
  ```
142
141
  sleet fetch --workflows foo-test:foo/.rpsec_example_statuses bar-test:bar/.rspec_example_statuses baz-specs:baz/spec/examples.txt
143
142
  ```
143
+
144
+ #### `--username`
145
+
146
+ Alias: `u`
147
+
148
+ This is the GitHub username that is referenced by the CircleCI build. By default, Sleet will base this on your upstream git remote.
149
+
150
+ #### `--project`
151
+
152
+ Alias: `p`
153
+
154
+ This is the GitHub project that is referenced by the CircleCI build. By default, Sleet will base this on your upstream git remote.
155
+
156
+ #### `--branch`
157
+
158
+ Alias: `b`
159
+
160
+ This is the remote branch that is referenced by the CircleCI build. Sleet will attempt to guess this by default, but if you are pushing to a forked repo, you may need to specify a different branch name (e.g. "pull/1234").
@@ -25,6 +25,7 @@ require 'sleet/config'
25
25
  require 'sleet/error'
26
26
  require 'sleet/fetch_command'
27
27
  require 'sleet/job_fetcher'
28
+ require 'sleet/local_repo'
28
29
  require 'sleet/repo'
29
30
  require 'sleet/rspec_file_merger'
30
31
  require 'sleet/version'
@@ -6,7 +6,7 @@ module Sleet
6
6
  @circle_ci_token = circle_ci_token
7
7
  @github_user = github_user
8
8
  @github_repo = github_repo
9
- @branch = branch
9
+ @branch = CGI.escape(branch)
10
10
  end
11
11
 
12
12
  def builds
@@ -4,6 +4,10 @@ module Sleet
4
4
  class Cli < Thor
5
5
  default_task :fetch
6
6
 
7
+ def self.exit_on_failure?
8
+ true
9
+ end
10
+
7
11
  desc 'fetch', 'Fetch and Aggregate RSpec Persistance Files from CircleCI'
8
12
  long_desc <<~LONGDESC
9
13
  `sleet fetch` will find build(s) in CircleCI for the current branch, and
@@ -20,6 +24,15 @@ module Sleet
20
24
  option :output_file, type: :string, aliases: [:o], desc: <<~DESC
21
25
  This is the name for the output file, on your local system. It is relative to the source_dir. Will be IGNORED if workflows is provided.
22
26
  DESC
27
+ option :username, type: :string, aliases: [:u], desc: <<~DESC
28
+ This is the GitHub username that is referenced by the CircleCI build. By default, Sleet will base this on your upstream git remote.
29
+ DESC
30
+ option :project, type: :string, aliases: [:p], desc: <<~DESC
31
+ This is the GitHub project that is referenced by the CircleCI build. By default, Sleet will base this on your upstream git remote.
32
+ DESC
33
+ option :branch, type: :string, aliases: [:b], desc: <<~DESC
34
+ This is the remote branch that is referenced by the CircleCI build. Sleet will attempt to guess this by default, but if you are pushing to a forked repo, you may need to specify a different branch name (e.g. "pull/1234").
35
+ DESC
23
36
  option :workflows, type: :hash, aliases: [:w], desc: <<~DESC
24
37
  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
38
  DESC
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Sleet
4
- class Config
4
+ class Config # rubocop:disable Metrics/ClassLength
5
5
  OPTION_FILENAME = '.sleet.yml'
6
6
  HIDDEN_UNLESS_IN_CLI_OPTIONS = %w[show_sensitive print_config].freeze
7
7
  ConfigOption = Struct.new(:value, :source)
@@ -23,6 +23,18 @@ module Sleet
23
23
  options_hash[:output_file]
24
24
  end
25
25
 
26
+ def username
27
+ options_hash[:username]
28
+ end
29
+
30
+ def project
31
+ options_hash[:project]
32
+ end
33
+
34
+ def branch
35
+ options_hash[:branch]
36
+ end
37
+
26
38
  def workflows
27
39
  options_hash[:workflows]
28
40
  end
@@ -7,7 +7,6 @@ module Sleet
7
7
  end
8
8
 
9
9
  def do!
10
- repo.validate!
11
10
  error_messages = []
12
11
  fetchers.map do |fetcher|
13
12
  begin
@@ -41,10 +41,6 @@ module Sleet
41
41
  ).files
42
42
  end
43
43
 
44
- def branch
45
- repo.branch
46
- end
47
-
48
44
  def build
49
45
  build_selector.build
50
46
  end
@@ -0,0 +1,75 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Sleet
4
+ class LocalRepo
5
+ REMOTE_BRANCH_REGEX = %r{^([^\/.]+)\/(.+)}.freeze
6
+ CURRENT_BRANCH_REGEX = %r{^refs\/heads\/}.freeze
7
+ GITHUB_MATCH_REGEX = %r{github.com[:\/](.+)\/(.+)\.git}.freeze
8
+
9
+ def initialize(source_dir:)
10
+ @source_dir = source_dir
11
+ end
12
+
13
+ def username
14
+ validate!
15
+
16
+ github_match[1]
17
+ end
18
+
19
+ def project
20
+ validate!
21
+
22
+ github_match[2]
23
+ end
24
+
25
+ def branch_name
26
+ validate!
27
+
28
+ current_branch.upstream.name.match(REMOTE_BRANCH_REGEX)[2]
29
+ end
30
+
31
+ private
32
+
33
+ attr_reader :source_dir
34
+
35
+ def current_branch_name
36
+ @current_branch_name ||= repo.head.name.sub(CURRENT_BRANCH_REGEX, '')
37
+ end
38
+
39
+ def current_branch
40
+ @current_branch ||= repo.branches[current_branch_name]
41
+ end
42
+
43
+ def github_match
44
+ @github_match ||= GITHUB_MATCH_REGEX.match(current_branch.remote.url)
45
+ end
46
+
47
+ def repo
48
+ @repo ||= Rugged::Repository.new(source_dir)
49
+ end
50
+
51
+ def validate!
52
+ return if @validated
53
+
54
+ must_be_on_branch!
55
+ must_have_an_upstream_branch!
56
+ upstream_remote_must_be_github!
57
+ @validated = true
58
+ end
59
+
60
+ def must_be_on_branch!
61
+ !current_branch.nil? ||
62
+ raise(Error, 'Not on a branch')
63
+ end
64
+
65
+ def must_have_an_upstream_branch!
66
+ !current_branch.remote.nil? ||
67
+ raise(Error, "No upstream branch set for the current branch of #{repo.current_branch_name}")
68
+ end
69
+
70
+ def upstream_remote_must_be_github!
71
+ !github_match.nil? ||
72
+ raise(Error, 'Upstream remote is not GitHub')
73
+ end
74
+ end
75
+ end
@@ -2,87 +2,44 @@
2
2
 
3
3
  module Sleet
4
4
  class Repo
5
- REMOTE_BRANCH_REGEX = %r{^([^\/.]+)\/(.+)}.freeze
6
- CURRENT_BRANCH_REGEX = %r{^refs\/heads\/}.freeze
7
- GITHUB_MATCH_REGEX = %r{github.com[:\/](.+)\/(.+)\.git}.freeze
8
-
9
5
  def self.from_config(config)
6
+ local_repo = Sleet::LocalRepo.new(source_dir: config.source_dir)
7
+
10
8
  new(
11
- repo: Rugged::Repository.new(config.source_dir),
12
- circle_ci_token: config.circle_ci_token
9
+ circle_ci_token: config.circle_ci_token,
10
+ username: config.username || local_repo.username,
11
+ project: config.project || local_repo.project,
12
+ branch_name: config.branch || local_repo.branch_name
13
13
  )
14
14
  end
15
15
 
16
- def initialize(repo:, circle_ci_token:)
17
- @repo = repo
16
+ def initialize(circle_ci_token:, username:, project:, branch_name:)
18
17
  @circle_ci_token = circle_ci_token
18
+ @github_user = username
19
+ @github_repo = project
20
+ @branch_name = branch_name
19
21
  end
20
22
 
21
- def validate!
22
- must_be_on_branch!
23
- must_have_an_upstream_branch!
24
- upstream_remote_must_be_github!
25
- end
26
-
27
- def branch
28
- @branch ||= Sleet::Branch.new(
23
+ def build_for(build_num)
24
+ Sleet::Build.new(
29
25
  circle_ci_token: circle_ci_token,
30
26
  github_user: github_user,
31
27
  github_repo: github_repo,
32
- branch: remote_branch
28
+ build_num: build_num
33
29
  )
34
30
  end
35
31
 
36
- def build_for(build_num)
37
- Sleet::Build.new(
32
+ def branch
33
+ @branch ||= Sleet::Branch.new(
38
34
  circle_ci_token: circle_ci_token,
39
35
  github_user: github_user,
40
36
  github_repo: github_repo,
41
- build_num: build_num
37
+ branch: branch_name
42
38
  )
43
39
  end
44
40
 
45
41
  private
46
42
 
47
- attr_reader :repo, :circle_ci_token
48
-
49
- def remote_branch
50
- current_branch.upstream.name.match(REMOTE_BRANCH_REGEX)[2]
51
- end
52
-
53
- def github_user
54
- github_match[1]
55
- end
56
-
57
- def github_repo
58
- github_match[2]
59
- end
60
-
61
- def current_branch_name
62
- repo.head.name.sub(CURRENT_BRANCH_REGEX, '')
63
- end
64
-
65
- def current_branch
66
- repo.branches[current_branch_name]
67
- end
68
-
69
- def github_match
70
- @github_match ||= GITHUB_MATCH_REGEX.match(current_branch.remote.url)
71
- end
72
-
73
- def must_be_on_branch!
74
- !current_branch.nil? ||
75
- raise(Error, 'Not on a branch')
76
- end
77
-
78
- def must_have_an_upstream_branch!
79
- !current_branch.remote.nil? ||
80
- raise(Error, "No upstream branch set for the current branch of #{repo.current_branch_name}")
81
- end
82
-
83
- def upstream_remote_must_be_github!
84
- !github_match.nil? ||
85
- raise(Error, 'Upstream remote is not GitHub')
86
- end
43
+ attr_reader :circle_ci_token, :github_user, :github_repo, :branch_name
87
44
  end
88
45
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Sleet
4
- VERSION = '0.4.3'
4
+ VERSION = '0.5.0'
5
5
  end
@@ -28,9 +28,9 @@ Gem::Specification.new do |spec|
28
28
  spec.add_dependency 'colorize', '~> 0.8.1'
29
29
  spec.add_dependency 'faraday', '>= 0.13.1', '< 1.1.0'
30
30
  spec.add_dependency 'rspec', '~> 3.0'
31
- spec.add_dependency 'rugged', '>= 0.26', '< 0.29'
31
+ spec.add_dependency 'rugged', '>= 0.26', '< 1.1'
32
32
  spec.add_dependency 'terminal-table', '~> 1.8'
33
- spec.add_dependency 'thor', '~> 0.20.0'
33
+ spec.add_dependency 'thor', '>= 0.20', '< 1.1'
34
34
 
35
35
  spec.add_development_dependency 'gem-release', '= 2.1.1'
36
36
  spec.add_development_dependency 'github_changelog_generator', '~> 1.14'
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.4.3
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Corey Alexander
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-03-07 00:00:00.000000000 Z
11
+ date: 2020-06-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: colorize
@@ -67,7 +67,7 @@ dependencies:
67
67
  version: '0.26'
68
68
  - - "<"
69
69
  - !ruby/object:Gem::Version
70
- version: '0.29'
70
+ version: '1.1'
71
71
  type: :runtime
72
72
  prerelease: false
73
73
  version_requirements: !ruby/object:Gem::Requirement
@@ -77,7 +77,7 @@ dependencies:
77
77
  version: '0.26'
78
78
  - - "<"
79
79
  - !ruby/object:Gem::Version
80
- version: '0.29'
80
+ version: '1.1'
81
81
  - !ruby/object:Gem::Dependency
82
82
  name: terminal-table
83
83
  requirement: !ruby/object:Gem::Requirement
@@ -96,16 +96,22 @@ dependencies:
96
96
  name: thor
97
97
  requirement: !ruby/object:Gem::Requirement
98
98
  requirements:
99
- - - "~>"
99
+ - - ">="
100
+ - !ruby/object:Gem::Version
101
+ version: '0.20'
102
+ - - "<"
100
103
  - !ruby/object:Gem::Version
101
- version: 0.20.0
104
+ version: '1.1'
102
105
  type: :runtime
103
106
  prerelease: false
104
107
  version_requirements: !ruby/object:Gem::Requirement
105
108
  requirements:
106
- - - "~>"
109
+ - - ">="
110
+ - !ruby/object:Gem::Version
111
+ version: '0.20'
112
+ - - "<"
107
113
  - !ruby/object:Gem::Version
108
- version: 0.20.0
114
+ version: '1.1'
109
115
  - !ruby/object:Gem::Dependency
110
116
  name: gem-release
111
117
  requirement: !ruby/object:Gem::Requirement
@@ -231,6 +237,7 @@ files:
231
237
  - lib/sleet/error.rb
232
238
  - lib/sleet/fetch_command.rb
233
239
  - lib/sleet/job_fetcher.rb
240
+ - lib/sleet/local_repo.rb
234
241
  - lib/sleet/repo.rb
235
242
  - lib/sleet/rspec_file_merger.rb
236
243
  - lib/sleet/version.rb