sleet 0.3.10 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.circleci/config.yml +1 -1
- data/.rubocop_todo.yml +5 -1
- data/CHANGELOG.md +12 -1
- data/README.md +9 -2
- data/lib/sleet/artifact_downloader.rb +4 -3
- data/lib/sleet/branch.rb +4 -3
- data/lib/sleet/build.rb +4 -3
- data/lib/sleet/circle_ci.rb +1 -15
- data/lib/sleet/cli.rb +3 -1
- data/lib/sleet/config.rb +17 -2
- data/lib/sleet/fetch_command.rb +2 -3
- data/lib/sleet/job_fetcher.rb +7 -5
- data/lib/sleet/repo.rb +10 -4
- data/lib/sleet/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 022c2a45bc1d863b22fd82ab7af14dbc67ba5aef247b5dae0769ac980ce9a2a2
|
4
|
+
data.tar.gz: c4fe3d8aa029508432ac6fce6215cb7c81782e12bc9a458adfe80540f9aae669
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8bf1267eec2081f51b2afadce3da9e66f42d04ea190a7ac3c7788d39db47f0dc9d524bd1bb0109fbd009540b0392cc2f8430bd7425a4d2b51352fbc17f0bc06d
|
7
|
+
data.tar.gz: 7b735f0733806f08f66fe9357bf4bfd44d46b3dc3f402eb232cabde4dffd7397d691117360913dd00a147270d65f9e7be3459ec83bfb5cc69ff6f375ee815c37
|
data/.circleci/config.yml
CHANGED
data/.rubocop_todo.yml
CHANGED
@@ -1,11 +1,15 @@
|
|
1
1
|
# This configuration was generated by
|
2
2
|
# `rubocop --auto-gen-config`
|
3
|
-
# on 2018-03-
|
3
|
+
# on 2018-03-08 00:46:21 -0500 using RuboCop version 0.53.0.
|
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
|
+
# Offense count: 1
|
10
|
+
Metrics/AbcSize:
|
11
|
+
Max: 18
|
12
|
+
|
9
13
|
# Offense count: 1
|
10
14
|
# Configuration parameters: Max.
|
11
15
|
RSpec/NestedGroups:
|
data/CHANGELOG.md
CHANGED
@@ -1,6 +1,17 @@
|
|
1
1
|
# Change Log
|
2
2
|
|
3
|
-
## [v0.
|
3
|
+
## [v0.4.0](https://github.com/coreyja/sleet/tree/v0.4.0) (2018-03-08)
|
4
|
+
[Full Changelog](https://github.com/coreyja/sleet/compare/v0.3.10...v0.4.0)
|
5
|
+
|
6
|
+
**Closed issues:**
|
7
|
+
|
8
|
+
- Allow Specifying Token from Config Files [\#9](https://github.com/coreyja/sleet/issues/9)
|
9
|
+
|
10
|
+
**Merged pull requests:**
|
11
|
+
|
12
|
+
- Get Token From Config File [\#21](https://github.com/coreyja/sleet/pull/21) ([coreyja](https://github.com/coreyja))
|
13
|
+
|
14
|
+
## [v0.3.10](https://github.com/coreyja/sleet/tree/v0.3.10) (2018-03-08)
|
4
15
|
[Full Changelog](https://github.com/coreyja/sleet/compare/v0.3.9...v0.3.10)
|
5
16
|
|
6
17
|
**Merged pull requests:**
|
data/README.md
CHANGED
@@ -52,11 +52,16 @@ To do this we need to create a step which [saves](https://circleci.com/docs/2.0/
|
|
52
52
|
|
53
53
|
### 3. Save a CircleCI Token locally (to access private builds)
|
54
54
|
|
55
|
-
In order to see private builds/repos in CircleCI you will need to get a CircleCI token and save it to
|
55
|
+
In order to see private builds/repos in CircleCI you will need to get a CircleCI token and save it locally to a Sleet Configuration file.
|
56
|
+
The recommended approach is to create a yml file in your home directory which contains your the key `circle_ci_token`
|
57
|
+
|
58
|
+
```
|
59
|
+
circle_ci_token: PLACE_TOKEN_HERE
|
60
|
+
```
|
56
61
|
|
57
62
|
An API token can be generated here: [https://circleci.com/account/api](https://circleci.com/account/api)
|
58
63
|
|
59
|
-
### 4. Run this tool
|
64
|
+
### 4. Run this tool from your project
|
60
65
|
|
61
66
|
```
|
62
67
|
sleet
|
@@ -83,6 +88,8 @@ Sleet currently supports two ways to input configurations:
|
|
83
88
|
2. Through the CLI
|
84
89
|
- These always take presendece the options provided in the YML files
|
85
90
|
|
91
|
+
To view your current configuration use the `sleet config` command which will give you a table of the current configuration. You can also use the `--print-config` flag with the `fetch` command to print out the config, including any other CLI options. This can be useful for bebugging as the output also tells you where each option came from.
|
92
|
+
|
86
93
|
### Options
|
87
94
|
|
88
95
|
These are the options that are currently supported
|
@@ -2,20 +2,21 @@
|
|
2
2
|
|
3
3
|
module Sleet
|
4
4
|
class ArtifactDownloader
|
5
|
-
def initialize(artifacts:, file_name:)
|
5
|
+
def initialize(circle_ci_token:, artifacts:, file_name:)
|
6
|
+
@circle_ci_token = circle_ci_token
|
6
7
|
@artifacts = artifacts
|
7
8
|
@file_name = file_name
|
8
9
|
end
|
9
10
|
|
10
11
|
def files
|
11
12
|
@files ||= urls.map do |url|
|
12
|
-
Sleet::CircleCi.get(url)
|
13
|
+
Sleet::CircleCi.get(url, circle_ci_token)
|
13
14
|
end.map(&:body)
|
14
15
|
end
|
15
16
|
|
16
17
|
private
|
17
18
|
|
18
|
-
attr_reader :artifacts, :file_name
|
19
|
+
attr_reader :artifacts, :file_name, :circle_ci_token
|
19
20
|
|
20
21
|
def urls
|
21
22
|
rspec_artifacts.map { |x| x['url'] }
|
data/lib/sleet/branch.rb
CHANGED
@@ -2,14 +2,15 @@
|
|
2
2
|
|
3
3
|
module Sleet
|
4
4
|
class Branch
|
5
|
-
def initialize(github_user:, github_repo:, branch:)
|
5
|
+
def initialize(circle_ci_token:, github_user:, github_repo:, branch:)
|
6
|
+
@circle_ci_token = circle_ci_token
|
6
7
|
@github_user = github_user
|
7
8
|
@github_repo = github_repo
|
8
9
|
@branch = branch
|
9
10
|
end
|
10
11
|
|
11
12
|
def builds
|
12
|
-
@builds ||= JSON.parse(Sleet::CircleCi.get(url).body)
|
13
|
+
@builds ||= JSON.parse(Sleet::CircleCi.get(url, circle_ci_token).body)
|
13
14
|
end
|
14
15
|
|
15
16
|
def builds_with_artificats
|
@@ -18,7 +19,7 @@ module Sleet
|
|
18
19
|
|
19
20
|
private
|
20
21
|
|
21
|
-
attr_reader :github_user, :github_repo, :branch
|
22
|
+
attr_reader :github_user, :github_repo, :branch, :circle_ci_token
|
22
23
|
|
23
24
|
def url
|
24
25
|
"https://circleci.com/api/v1.1/project/github/#{github_user}/#{github_repo}/tree/#{branch}?filter=completed"
|
data/lib/sleet/build.rb
CHANGED
@@ -4,19 +4,20 @@ module Sleet
|
|
4
4
|
class Build
|
5
5
|
attr_reader :build_num
|
6
6
|
|
7
|
-
def initialize(github_user:, github_repo:, build_num:)
|
7
|
+
def initialize(circle_ci_token:, github_user:, github_repo:, build_num:)
|
8
|
+
@circle_ci_token = circle_ci_token
|
8
9
|
@github_user = github_user
|
9
10
|
@github_repo = github_repo
|
10
11
|
@build_num = build_num
|
11
12
|
end
|
12
13
|
|
13
14
|
def artifacts
|
14
|
-
@artifacts ||= JSON.parse(Sleet::CircleCi.get(url).body)
|
15
|
+
@artifacts ||= JSON.parse(Sleet::CircleCi.get(url, circle_ci_token).body)
|
15
16
|
end
|
16
17
|
|
17
18
|
private
|
18
19
|
|
19
|
-
attr_reader :github_user, :github_repo
|
20
|
+
attr_reader :github_user, :github_repo, :circle_ci_token
|
20
21
|
|
21
22
|
def url
|
22
23
|
"https://circleci.com/api/v1.1/project/github/#{github_user}/#{github_repo}/#{build_num}/artifacts" # rubocop:disable Metrics/LineLength
|
data/lib/sleet/circle_ci.rb
CHANGED
@@ -4,22 +4,8 @@ require 'singleton'
|
|
4
4
|
|
5
5
|
module Sleet
|
6
6
|
class CircleCi
|
7
|
-
|
8
|
-
|
9
|
-
def token
|
10
|
-
@token ||= File.read("#{Dir.home}/.circleci.token").strip
|
11
|
-
end
|
12
|
-
|
13
|
-
def get(url)
|
7
|
+
def self.get(url, token)
|
14
8
|
Faraday.get(url, 'circle-token' => token)
|
15
9
|
end
|
16
|
-
|
17
|
-
def reset!
|
18
|
-
@token = nil
|
19
|
-
end
|
20
|
-
|
21
|
-
def self.get(url)
|
22
|
-
instance.get(url)
|
23
|
-
end
|
24
10
|
end
|
25
11
|
end
|
data/lib/sleet/cli.rb
CHANGED
@@ -23,13 +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
|
26
|
+
option :print_config, type: :boolean
|
27
27
|
def fetch
|
28
28
|
sleet_config = Sleet::Config.new(cli_hash: options, dir: Dir.pwd)
|
29
29
|
if options[:print_config]
|
30
30
|
sleet_config.print!
|
31
31
|
exit
|
32
32
|
end
|
33
|
+
raise Sleet::Error, 'circle_ci_token required and not provided' unless sleet_config.circle_ci_token
|
33
34
|
Sleet::FetchCommand.new(sleet_config).do!
|
34
35
|
end
|
35
36
|
|
@@ -44,6 +45,7 @@ module Sleet
|
|
44
45
|
end
|
45
46
|
|
46
47
|
desc 'config', 'Print the config'
|
48
|
+
option :show_sensitive, type: :boolean
|
47
49
|
def config
|
48
50
|
Sleet::Config.new(cli_hash: options, dir: Dir.pwd).print!
|
49
51
|
end
|
data/lib/sleet/config.rb
CHANGED
@@ -3,6 +3,7 @@
|
|
3
3
|
module Sleet
|
4
4
|
class Config
|
5
5
|
OPTION_FILENAME = '.sleet.yml'
|
6
|
+
HIDDEN_UNLESS_IN_CLI_OPTIONS = %w[show_sensitive print_config].freeze
|
6
7
|
ConfigOption = Struct.new(:value, :source)
|
7
8
|
|
8
9
|
def initialize(dir:, cli_hash: {})
|
@@ -26,6 +27,10 @@ module Sleet
|
|
26
27
|
options_hash[:workflows]
|
27
28
|
end
|
28
29
|
|
30
|
+
def circle_ci_token
|
31
|
+
options_hash[:circle_ci_token]
|
32
|
+
end
|
33
|
+
|
29
34
|
def print!
|
30
35
|
puts Terminal::Table.new headings: %w[Option Value Source], rows: table_rows
|
31
36
|
end
|
@@ -43,15 +48,23 @@ module Sleet
|
|
43
48
|
end
|
44
49
|
|
45
50
|
def table_rows
|
46
|
-
|
51
|
+
table_options.map do |key, option|
|
47
52
|
if key.to_sym == :workflows
|
48
53
|
[key, Terminal::Table.new(headings: ['Job Name', 'Output File'], rows: option.value.to_a), option.source]
|
54
|
+
elsif key.to_sym == :circle_ci_token && !options['show_sensitive'].value
|
55
|
+
[key, '**REDACTED**', option.source]
|
49
56
|
else
|
50
57
|
[key, option.value, option.source]
|
51
58
|
end
|
52
59
|
end
|
53
60
|
end
|
54
61
|
|
62
|
+
def table_options
|
63
|
+
options.reject do |key, _option|
|
64
|
+
HIDDEN_UNLESS_IN_CLI_OPTIONS.include?(key) && !cli_hash.key?(key)
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
55
68
|
def cli_options
|
56
69
|
build_option_hash('CLI', cli_hash)
|
57
70
|
end
|
@@ -88,7 +101,9 @@ module Sleet
|
|
88
101
|
{
|
89
102
|
'source_dir' => File.expand_path(default_dir),
|
90
103
|
'input_file' => '.rspec_example_statuses',
|
91
|
-
'output_file' => '.rspec_example_statuses'
|
104
|
+
'output_file' => '.rspec_example_statuses',
|
105
|
+
'show_sensitive' => false,
|
106
|
+
'print_config' => true
|
92
107
|
}
|
93
108
|
end
|
94
109
|
|
data/lib/sleet/fetch_command.rb
CHANGED
@@ -26,8 +26,7 @@ module Sleet
|
|
26
26
|
def fetchers
|
27
27
|
job_name_to_output_files.map do |job_name, output_filename|
|
28
28
|
Sleet::JobFetcher.new(
|
29
|
-
|
30
|
-
input_filename: config.input_file,
|
29
|
+
config: config,
|
31
30
|
output_filename: output_filename,
|
32
31
|
repo: repo,
|
33
32
|
job_name: job_name
|
@@ -40,7 +39,7 @@ module Sleet
|
|
40
39
|
end
|
41
40
|
|
42
41
|
def repo
|
43
|
-
@repo ||= Sleet::Repo.
|
42
|
+
@repo ||= Sleet::Repo.from_config(config)
|
44
43
|
end
|
45
44
|
end
|
46
45
|
end
|
data/lib/sleet/job_fetcher.rb
CHANGED
@@ -2,9 +2,10 @@
|
|
2
2
|
|
3
3
|
module Sleet
|
4
4
|
class JobFetcher
|
5
|
-
def initialize(
|
6
|
-
@
|
7
|
-
@
|
5
|
+
def initialize(config:, output_filename:, job_name:, repo:)
|
6
|
+
@circle_ci_token = config.circle_ci_token
|
7
|
+
@source_dir = config.source_dir
|
8
|
+
@input_filename = config.input_file
|
8
9
|
@output_filename = output_filename
|
9
10
|
@job_name = job_name
|
10
11
|
@repo = repo
|
@@ -17,7 +18,7 @@ module Sleet
|
|
17
18
|
|
18
19
|
private
|
19
20
|
|
20
|
-
attr_reader :input_filename, :output_filename, :job_name, :source_dir, :repo
|
21
|
+
attr_reader :input_filename, :output_filename, :job_name, :source_dir, :repo, :circle_ci_token
|
21
22
|
|
22
23
|
def validate!
|
23
24
|
build_selector.validate!
|
@@ -35,7 +36,8 @@ module Sleet
|
|
35
36
|
def build_persistance_artifacts
|
36
37
|
@build_persistance_artifacts ||= Sleet::ArtifactDownloader.new(
|
37
38
|
file_name: input_filename,
|
38
|
-
artifacts: build.artifacts
|
39
|
+
artifacts: build.artifacts,
|
40
|
+
circle_ci_token: circle_ci_token
|
39
41
|
).files
|
40
42
|
end
|
41
43
|
|
data/lib/sleet/repo.rb
CHANGED
@@ -6,12 +6,16 @@ module Sleet
|
|
6
6
|
CURRENT_BRANCH_REGEX = %r{^refs\/heads\/}
|
7
7
|
GITHUB_MATCH_REGEX = %r{github.com[:\/](.+)\/(.+)\.git}
|
8
8
|
|
9
|
-
def self.
|
10
|
-
new(
|
9
|
+
def self.from_config(config)
|
10
|
+
new(
|
11
|
+
repo: Rugged::Repository.new(config.source_dir),
|
12
|
+
circle_ci_token: config.circle_ci_token
|
13
|
+
)
|
11
14
|
end
|
12
15
|
|
13
|
-
def initialize(repo:)
|
16
|
+
def initialize(repo:, circle_ci_token:)
|
14
17
|
@repo = repo
|
18
|
+
@circle_ci_token = circle_ci_token
|
15
19
|
end
|
16
20
|
|
17
21
|
def validate!
|
@@ -22,6 +26,7 @@ module Sleet
|
|
22
26
|
|
23
27
|
def branch
|
24
28
|
@branch ||= Sleet::Branch.new(
|
29
|
+
circle_ci_token: circle_ci_token,
|
25
30
|
github_user: github_user,
|
26
31
|
github_repo: github_repo,
|
27
32
|
branch: remote_branch
|
@@ -30,6 +35,7 @@ module Sleet
|
|
30
35
|
|
31
36
|
def build_for(build_num)
|
32
37
|
Sleet::Build.new(
|
38
|
+
circle_ci_token: circle_ci_token,
|
33
39
|
github_user: github_user,
|
34
40
|
github_repo: github_repo,
|
35
41
|
build_num: build_num
|
@@ -38,7 +44,7 @@ module Sleet
|
|
38
44
|
|
39
45
|
private
|
40
46
|
|
41
|
-
attr_reader :repo
|
47
|
+
attr_reader :repo, :circle_ci_token
|
42
48
|
|
43
49
|
def remote_branch
|
44
50
|
current_branch.upstream.name.match(REMOTE_BRANCH_REGEX)[2]
|
data/lib/sleet/version.rb
CHANGED