sleet 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.circleci/config.yml +55 -0
- data/.editorconfig +7 -0
- data/.gitignore +14 -0
- data/.rspec +2 -0
- data/.rubocop.yml +31 -0
- data/.rubocop_todo.yml +16 -0
- data/.sleet.yml +1 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +10 -0
- data/LICENSE +21 -0
- data/README.md +63 -0
- data/Rakefile +8 -0
- data/bin/console +12 -0
- data/bin/setup +8 -0
- data/exe/sleet +6 -0
- data/lib/sleet/artifact_downloader.rb +28 -0
- data/lib/sleet/circle_ci.rb +21 -0
- data/lib/sleet/circle_ci_branch.rb +27 -0
- data/lib/sleet/circle_ci_build.rb +23 -0
- data/lib/sleet/cli.rb +50 -0
- data/lib/sleet/current_branch_github.rb +46 -0
- data/lib/sleet/option_defaults.rb +37 -0
- data/lib/sleet/rspec_file_merger.rb +27 -0
- data/lib/sleet/version.rb +5 -0
- data/lib/sleet.rb +25 -0
- data/sleet.gemspec +38 -0
- metadata +185 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 933041f7651895c7bab30f37d49946f5ce0a0ceeb481d3bb82651fe065301d73
|
4
|
+
data.tar.gz: e1552d7eb0e635beb108c6d45313c814f8c67aa38efe49902c1ce7e94ba33750
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 60a77f2b55d572b2bfa89a2c5c05d9c5f77e8bcf2078f7d7f7dc3fe4f01e05e21114a2b7f85bed0fd1f36ff127d7bfc92b4be8af5ecd7e041ec0d92c0e35ac49
|
7
|
+
data.tar.gz: 8d178fe995d03c2840c7b4704b0afa3e640c9aa4cddef877f58d1c5cb0dade06bf28b882862d5bb918c421bad88205143df67e9d4cf1057ce42584d988fcf856
|
@@ -0,0 +1,55 @@
|
|
1
|
+
version: 2
|
2
|
+
jobs:
|
3
|
+
build:
|
4
|
+
parallelism: 1
|
5
|
+
docker:
|
6
|
+
- image: circleci/ruby:latest
|
7
|
+
|
8
|
+
steps:
|
9
|
+
- checkout
|
10
|
+
|
11
|
+
- run: date +%U-%Y > 'date-cache-key.txt'
|
12
|
+
- run: ruby -v > 'ruby-version.txt'
|
13
|
+
|
14
|
+
## Bundler
|
15
|
+
# Restore Cache
|
16
|
+
- restore_cache:
|
17
|
+
keys:
|
18
|
+
- gem-cache-{{ checksum "ruby-version.txt" }}-{{ checksum "sleet.gemspec" }}-
|
19
|
+
- gem-cache-{{ checksum "ruby-version.txt" }}-
|
20
|
+
- gem-cache-
|
21
|
+
# Install
|
22
|
+
- run: bundle check || sudo apt-get install cmake && bundle install --path vendor/bundle
|
23
|
+
# Store Cache
|
24
|
+
- save_cache:
|
25
|
+
key: gem-cache-{{ checksum "ruby-version.txt" }}-{{ checksum "sleet.gemspec" }}-{{ checksum "date-cache-key.txt" }}
|
26
|
+
paths:
|
27
|
+
- vendor/bundle
|
28
|
+
|
29
|
+
- type: shell
|
30
|
+
command: |
|
31
|
+
bundle exec rubocop \
|
32
|
+
--config .rubocop.yml \
|
33
|
+
-r $(bundle show rubocop-junit-formatter)/lib/rubocop/formatter/junit_formatter.rb \
|
34
|
+
--format RuboCop::Formatter::JUnitFormatter \
|
35
|
+
--out /tmp/test-results/rubocop.xml \
|
36
|
+
--format progress \
|
37
|
+
--force-exclusion \
|
38
|
+
$(bundle exec rubocop --list-target-files | circleci tests split --split-by=filesize --show-counts)
|
39
|
+
|
40
|
+
# Run rspec in parallel
|
41
|
+
- type: shell
|
42
|
+
command: |
|
43
|
+
bundle exec rspec --profile 10 \
|
44
|
+
--format RspecJunitFormatter \
|
45
|
+
--out /tmp/test-results/rspec.xml \
|
46
|
+
--format progress \
|
47
|
+
$(circleci tests glob "spec/**/*_spec.rb" | circleci tests split --split-by=timings --show-counts)
|
48
|
+
|
49
|
+
# Save artifacts
|
50
|
+
- type: store_test_results
|
51
|
+
path: /tmp/test-results
|
52
|
+
|
53
|
+
- store_artifacts:
|
54
|
+
path: spec/.rspec_example_statuses
|
55
|
+
|
data/.editorconfig
ADDED
data/.gitignore
ADDED
data/.rspec
ADDED
data/.rubocop.yml
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
inherit_from: .rubocop_todo.yml
|
2
|
+
|
3
|
+
AllCops:
|
4
|
+
TargetRubyVersion: 2.4
|
5
|
+
Exclude:
|
6
|
+
- 'vendor/**/*'
|
7
|
+
|
8
|
+
Metrics/LineLength:
|
9
|
+
Max: 120
|
10
|
+
Exclude:
|
11
|
+
- 'spec/**/*'
|
12
|
+
|
13
|
+
Metrics/ClassLength:
|
14
|
+
Exclude:
|
15
|
+
- 'spec/**/*'
|
16
|
+
|
17
|
+
Metrics/BlockLength:
|
18
|
+
Exclude:
|
19
|
+
- 'spec/**/*'
|
20
|
+
|
21
|
+
Documentation:
|
22
|
+
Enabled: false
|
23
|
+
|
24
|
+
Style/StringLiterals:
|
25
|
+
Description: Checks if uses of quotes match the configured preference.
|
26
|
+
StyleGuide: https://github.com/bbatsov/ruby-style-guide#consistent-string-literals
|
27
|
+
Enabled: true
|
28
|
+
EnforcedStyle: single_quotes
|
29
|
+
SupportedStyles:
|
30
|
+
- single_quotes
|
31
|
+
- double_quotes
|
data/.rubocop_todo.yml
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
# This configuration was generated by
|
2
|
+
# `rubocop --auto-gen-config`
|
3
|
+
# on 2018-01-14 18:15:04 -0500 using RuboCop version 0.52.1.
|
4
|
+
# The point is for the user to remove these configuration records
|
5
|
+
# one by one as the offenses are removed from the code base.
|
6
|
+
# Note that changes in the inspected code, or installation of new
|
7
|
+
# versions of RuboCop, may require this file to be generated again.
|
8
|
+
|
9
|
+
# Offense count: 1
|
10
|
+
Metrics/AbcSize:
|
11
|
+
Max: 27
|
12
|
+
|
13
|
+
# Offense count: 1
|
14
|
+
# Configuration parameters: CountComments.
|
15
|
+
Metrics/MethodLength:
|
16
|
+
Max: 19
|
data/.sleet.yml
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
output_file: 'spec/.rspec_example_statuses'
|
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
2
|
+
|
3
|
+
## Our Pledge
|
4
|
+
|
5
|
+
In the interest of fostering an open and welcoming environment, we as
|
6
|
+
contributors and maintainers pledge to making participation in our project and
|
7
|
+
our community a harassment-free experience for everyone, regardless of age, body
|
8
|
+
size, disability, ethnicity, gender identity and expression, level of experience,
|
9
|
+
nationality, personal appearance, race, religion, or sexual identity and
|
10
|
+
orientation.
|
11
|
+
|
12
|
+
## Our Standards
|
13
|
+
|
14
|
+
Examples of behavior that contributes to creating a positive environment
|
15
|
+
include:
|
16
|
+
|
17
|
+
* Using welcoming and inclusive language
|
18
|
+
* Being respectful of differing viewpoints and experiences
|
19
|
+
* Gracefully accepting constructive criticism
|
20
|
+
* Focusing on what is best for the community
|
21
|
+
* Showing empathy towards other community members
|
22
|
+
|
23
|
+
Examples of unacceptable behavior by participants include:
|
24
|
+
|
25
|
+
* The use of sexualized language or imagery and unwelcome sexual attention or
|
26
|
+
advances
|
27
|
+
* Trolling, insulting/derogatory comments, and personal or political attacks
|
28
|
+
* Public or private harassment
|
29
|
+
* Publishing others' private information, such as a physical or electronic
|
30
|
+
address, without explicit permission
|
31
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
32
|
+
professional setting
|
33
|
+
|
34
|
+
## Our Responsibilities
|
35
|
+
|
36
|
+
Project maintainers are responsible for clarifying the standards of acceptable
|
37
|
+
behavior and are expected to take appropriate and fair corrective action in
|
38
|
+
response to any instances of unacceptable behavior.
|
39
|
+
|
40
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
41
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
42
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
43
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
44
|
+
threatening, offensive, or harmful.
|
45
|
+
|
46
|
+
## Scope
|
47
|
+
|
48
|
+
This Code of Conduct applies both within project spaces and in public spaces
|
49
|
+
when an individual is representing the project or its community. Examples of
|
50
|
+
representing a project or community include using an official project e-mail
|
51
|
+
address, posting via an official social media account, or acting as an appointed
|
52
|
+
representative at an online or offline event. Representation of a project may be
|
53
|
+
further defined and clarified by project maintainers.
|
54
|
+
|
55
|
+
## Enforcement
|
56
|
+
|
57
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
58
|
+
reported by contacting the project team at coreyja@gmail.com. All
|
59
|
+
complaints will be reviewed and investigated and will result in a response that
|
60
|
+
is deemed necessary and appropriate to the circumstances. The project team is
|
61
|
+
obligated to maintain confidentiality with regard to the reporter of an incident.
|
62
|
+
Further details of specific enforcement policies may be posted separately.
|
63
|
+
|
64
|
+
Project maintainers who do not follow or enforce the Code of Conduct in good
|
65
|
+
faith may face temporary or permanent repercussions as determined by other
|
66
|
+
members of the project's leadership.
|
67
|
+
|
68
|
+
## Attribution
|
69
|
+
|
70
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
71
|
+
available at [http://contributor-covenant.org/version/1/4][version]
|
72
|
+
|
73
|
+
[homepage]: http://contributor-covenant.org
|
74
|
+
[version]: http://contributor-covenant.org/version/1/4/
|
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2017 Corey Alexander
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,63 @@
|
|
1
|
+
# CircleCI RSpec Status Persistance File Aggregator
|
2
|
+
|
3
|
+
## Background and Problem
|
4
|
+
|
5
|
+
RSpec has a [feature](https://relishapp.com/rspec/rspec-core/v/3-7/docs/command-line/only-failures) that I find very useful which is the `--only-failures` option. This will re-run only that examples that failed the previous run.
|
6
|
+
|
7
|
+
CircleCI has support for [uploading artifcats](https://circleci.com/docs/2.0/artifacts/) with your builds, which allows us to store the persistance file that powers the RSpec only failures option.
|
8
|
+
However! CircleCI also supports and encourages parallelizing your build, which means even if you upload your rspec persistance file, you actually have a number of them each containing a subset of your test suite.
|
9
|
+
This is where this tool comes in!
|
10
|
+
|
11
|
+
## Purpose
|
12
|
+
|
13
|
+
This tool does two things:
|
14
|
+
1. It downloads all of the `.rspec_failed_examples` files that were uploaded to CircleCI for the most recent build of the current branch
|
15
|
+
2. It combines the multiple files into a single sorted `.rspec_failed_examples` file, and moves it to the [current directory](https://github.com/coreyja/CRSPFA/issues/1)
|
16
|
+
|
17
|
+
## Getting Started
|
18
|
+
|
19
|
+
### 1. Configure RSpec to Create and Use an example persistance file
|
20
|
+
|
21
|
+
A current limitation is that the RSpec Persistance file must be named `.rspec_example_statuses`.
|
22
|
+
|
23
|
+
We need to set the `example_status_persistence_file_path` config in RSpec. Here are the relevant [RSpec docs](https://relishapp.com/rspec/rspec-core/v/3-7/docs/command-line/only-failures#background).
|
24
|
+
|
25
|
+
The first step is to create(/or add to) your `spec/spec_helper.rb` file. We want to include the following configuration, which tells RSpec where to store the status persistance file.
|
26
|
+
|
27
|
+
```
|
28
|
+
RSpec.configure do |c|
|
29
|
+
c.example_status_persistence_file_path = ".rspec_example_statuses"
|
30
|
+
end
|
31
|
+
```
|
32
|
+
|
33
|
+
if you just created the `spec_helper.rb` file then you will need to create a `.rspec` file containing the following to load your new helper file
|
34
|
+
|
35
|
+
```
|
36
|
+
--require spec_helper
|
37
|
+
```
|
38
|
+
|
39
|
+
### 2. Collect the example persistance files in CircleCI
|
40
|
+
|
41
|
+
To do this we need to create a step which [saves](https://circleci.com/docs/2.0/artifacts/) the `.rspec_example_statuses` as artifacts of the build. The following is an example of such a step in CircleCI. This must happen after rspec has run or else the persistance file will not exist.
|
42
|
+
|
43
|
+
```
|
44
|
+
- store_artifacts:
|
45
|
+
path: ~/PROJECT_NAME/.rspec_example_statuses
|
46
|
+
|
47
|
+
```
|
48
|
+
|
49
|
+
### 3. Run this tool in the root of your project
|
50
|
+
|
51
|
+
```
|
52
|
+
sleet
|
53
|
+
```
|
54
|
+
|
55
|
+
This will look up the latest completed build in CircleCI for this branch, and download all the relevant `.rspec_example_statuses` files. It then combines and sorts them and saves the result to the `.rspec_example_statuses` file locally.
|
56
|
+
|
57
|
+
### 4. Run RSpec with `--only-failures`
|
58
|
+
|
59
|
+
```
|
60
|
+
bundle exec rspec --only-failures
|
61
|
+
```
|
62
|
+
|
63
|
+
This will run only the examples that failed in CircleCI!
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
require 'bundler/setup'
|
5
|
+
require 'sleet'
|
6
|
+
|
7
|
+
require 'pry'
|
8
|
+
|
9
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
10
|
+
# with your gem easier. You can also use a different console, if you like.
|
11
|
+
|
12
|
+
Pry.start
|
data/bin/setup
ADDED
data/exe/sleet
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Sleet
|
4
|
+
class ArtifactDownloader
|
5
|
+
def initialize(artifacts:, file_name:)
|
6
|
+
@artifacts = artifacts
|
7
|
+
@file_name = file_name
|
8
|
+
end
|
9
|
+
|
10
|
+
def files
|
11
|
+
@_files ||= urls.map do |url|
|
12
|
+
Sleet::CircleCi.get(url)
|
13
|
+
end.map(&:body)
|
14
|
+
end
|
15
|
+
|
16
|
+
private
|
17
|
+
|
18
|
+
attr_reader :artifacts, :file_name
|
19
|
+
|
20
|
+
def urls
|
21
|
+
rspec_artifacts.map { |x| x['url'] }
|
22
|
+
end
|
23
|
+
|
24
|
+
def rspec_artifacts
|
25
|
+
artifacts.select { |x| x['path'].end_with?(file_name) }
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'singleton'
|
4
|
+
|
5
|
+
module Sleet
|
6
|
+
class CircleCi
|
7
|
+
include Singleton
|
8
|
+
|
9
|
+
def token
|
10
|
+
@_token ||= File.read("#{Dir.home}/.circleci.token").strip
|
11
|
+
end
|
12
|
+
|
13
|
+
def get(url)
|
14
|
+
Faraday.get(url, circleci_token: token)
|
15
|
+
end
|
16
|
+
|
17
|
+
def self.get(url)
|
18
|
+
instance.get(url)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Sleet
|
4
|
+
class CircleCiBranch
|
5
|
+
def initialize(github_user:, github_repo:, branch:)
|
6
|
+
@github_user = github_user
|
7
|
+
@github_repo = github_repo
|
8
|
+
@branch = branch
|
9
|
+
end
|
10
|
+
|
11
|
+
def builds
|
12
|
+
@_builds ||= JSON.parse(Sleet::CircleCi.get(url).body)
|
13
|
+
end
|
14
|
+
|
15
|
+
def builds_with_artificats
|
16
|
+
builds.select { |b| b['has_artifacts'] }
|
17
|
+
end
|
18
|
+
|
19
|
+
private
|
20
|
+
|
21
|
+
attr_reader :github_user, :github_repo, :branch
|
22
|
+
|
23
|
+
def url
|
24
|
+
"https://circleci.com/api/v1.1/project/github/#{github_user}/#{github_repo}/tree/#{branch}"
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Sleet
|
4
|
+
class CircleCiBuild
|
5
|
+
def initialize(github_user:, github_repo:, build_num:)
|
6
|
+
@github_user = github_user
|
7
|
+
@github_repo = github_repo
|
8
|
+
@build_num = build_num
|
9
|
+
end
|
10
|
+
|
11
|
+
def artifacts
|
12
|
+
@_artifacts ||= JSON.parse(Sleet::CircleCi.get(url).body)
|
13
|
+
end
|
14
|
+
|
15
|
+
private
|
16
|
+
|
17
|
+
attr_reader :github_user, :github_repo, :build_num
|
18
|
+
|
19
|
+
def url
|
20
|
+
"https://circleci.com/api/v1.1/project/github/#{github_user}/#{github_repo}/#{build_num}/artifacts"
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
data/lib/sleet/cli.rb
ADDED
@@ -0,0 +1,50 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Sleet
|
4
|
+
class Cli < Thor
|
5
|
+
default_task :fetch
|
6
|
+
|
7
|
+
desc 'Fetch Rspec Status File from CircleCI', 'fetch'
|
8
|
+
option :source_dir, type: :string, aliases: [:s]
|
9
|
+
option :input_file, type: :string, aliases: [:i]
|
10
|
+
option :output_file, type: :string, aliases: [:o]
|
11
|
+
def fetch
|
12
|
+
source_dir = options.fetch(:source_dir, default_dir)
|
13
|
+
file_name = options.fetch(:input_file, '.rspec_example_statuses')
|
14
|
+
output_file = options.fetch(:output_file, '.rspec_example_statuses')
|
15
|
+
|
16
|
+
current_branch = Sleet::CurrentBranchGithub.from_dir(source_dir)
|
17
|
+
|
18
|
+
branch = Sleet::CircleCiBranch.new(
|
19
|
+
github_user: current_branch.github_user,
|
20
|
+
github_repo: current_branch.github_repo,
|
21
|
+
branch: current_branch.remote_branch
|
22
|
+
)
|
23
|
+
|
24
|
+
build = branch.builds_with_artificats.first
|
25
|
+
|
26
|
+
build = Sleet::CircleCiBuild.new(
|
27
|
+
github_user: current_branch.github_user,
|
28
|
+
github_repo: current_branch.github_repo,
|
29
|
+
build_num: build['build_num']
|
30
|
+
)
|
31
|
+
|
32
|
+
files = Sleet::ArtifactDownloader.new(file_name: file_name, artifacts: build.artifacts).files
|
33
|
+
Dir.chdir(source_dir) do
|
34
|
+
File.write(output_file, Sleet::RspecFileMerger.new(files).output)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
private
|
39
|
+
|
40
|
+
def default_dir
|
41
|
+
Rugged::Repository.discover(Dir.pwd).path + '..'
|
42
|
+
end
|
43
|
+
|
44
|
+
def options
|
45
|
+
original_options = super
|
46
|
+
defaults = Sleet::OptionDefaults.new(Dir.pwd).defaults
|
47
|
+
Thor::CoreExt::HashWithIndifferentAccess.new(defaults.merge(original_options))
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Sleet
|
4
|
+
class CurrentBranchGithub
|
5
|
+
REMOTE_BRANCH_REGEX = %r{^([^\/.]+)\/(.+)}
|
6
|
+
CURRENT_BRANCH_REGEX = %r{^refs\/heads\/}
|
7
|
+
GITHUB_MATCH_REGEX = %r{github.com[:\/](.+)\/(.+)\.git}
|
8
|
+
|
9
|
+
def self.from_dir(dir)
|
10
|
+
new(repo: Rugged::Repository.new(dir))
|
11
|
+
end
|
12
|
+
|
13
|
+
def initialize(repo:)
|
14
|
+
@repo = repo
|
15
|
+
raise 'NOT GITHUB' unless github_match
|
16
|
+
end
|
17
|
+
|
18
|
+
def remote_branch
|
19
|
+
current_branch.upstream.name.match(REMOTE_BRANCH_REGEX)[2]
|
20
|
+
end
|
21
|
+
|
22
|
+
def github_user
|
23
|
+
github_match[1]
|
24
|
+
end
|
25
|
+
|
26
|
+
def github_repo
|
27
|
+
github_match[2]
|
28
|
+
end
|
29
|
+
|
30
|
+
private
|
31
|
+
|
32
|
+
attr_reader :repo
|
33
|
+
|
34
|
+
def current_branch
|
35
|
+
repo.branches[current_branch_name]
|
36
|
+
end
|
37
|
+
|
38
|
+
def current_branch_name
|
39
|
+
repo.head.name.sub(CURRENT_BRANCH_REGEX, '')
|
40
|
+
end
|
41
|
+
|
42
|
+
def github_match
|
43
|
+
@_github_match ||= GITHUB_MATCH_REGEX.match(current_branch.remote.url)
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
@@ -0,0 +1,37 @@
|
|
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
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Sleet
|
4
|
+
class RspecFileMerger
|
5
|
+
def initialize(files)
|
6
|
+
@files = files
|
7
|
+
end
|
8
|
+
|
9
|
+
def output
|
10
|
+
RSpec::Core::ExampleStatusDumper.dump(sorted_examples)
|
11
|
+
end
|
12
|
+
|
13
|
+
private
|
14
|
+
|
15
|
+
attr_reader :files
|
16
|
+
|
17
|
+
def sorted_examples
|
18
|
+
examples.sort_by { |hash| hash[:example_id] }
|
19
|
+
end
|
20
|
+
|
21
|
+
def examples
|
22
|
+
files.flat_map do |file|
|
23
|
+
RSpec::Core::ExampleStatusParser.parse(file)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
data/lib/sleet.rb
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'thor'
|
4
|
+
require 'json'
|
5
|
+
require 'rugged'
|
6
|
+
require 'faraday'
|
7
|
+
require 'rspec'
|
8
|
+
require 'yaml'
|
9
|
+
begin
|
10
|
+
RSpec::Core::ExampleStatusPersister
|
11
|
+
end
|
12
|
+
|
13
|
+
require 'sleet/artifact_downloader'
|
14
|
+
require 'sleet/circle_ci'
|
15
|
+
require 'sleet/circle_ci_branch'
|
16
|
+
require 'sleet/circle_ci_build'
|
17
|
+
require 'sleet/current_branch_github'
|
18
|
+
require 'sleet/option_defaults'
|
19
|
+
require 'sleet/rspec_file_merger'
|
20
|
+
require 'sleet/version'
|
21
|
+
|
22
|
+
require 'sleet/cli'
|
23
|
+
|
24
|
+
module Sleet
|
25
|
+
end
|
data/sleet.gemspec
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
lib = File.expand_path('../lib', __FILE__)
|
5
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
6
|
+
require 'sleet/version'
|
7
|
+
|
8
|
+
Gem::Specification.new do |spec|
|
9
|
+
spec.name = 'sleet'
|
10
|
+
spec.version = Sleet::VERSION
|
11
|
+
spec.authors = ['Corey Alexander']
|
12
|
+
spec.email = ['coreyja@gmail.com']
|
13
|
+
|
14
|
+
spec.summary = 'CircleCI RSpec Status Persistance File Aggregator'
|
15
|
+
spec.description = <<~DOC
|
16
|
+
Sleet provides an easy way to grab the most recent Rspec persistance files from CircleCI.
|
17
|
+
It also aggregates the artificats from CircleCI, since you will have 1 per build container.
|
18
|
+
DOC
|
19
|
+
spec.homepage = 'https://github.com/coreyja/sleet'
|
20
|
+
spec.license = 'MIT'
|
21
|
+
|
22
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
23
|
+
f.match(%r{^(test|spec|features)/})
|
24
|
+
end
|
25
|
+
spec.bindir = 'exe'
|
26
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
27
|
+
spec.require_paths = ['lib']
|
28
|
+
|
29
|
+
spec.add_dependency 'faraday'
|
30
|
+
spec.add_dependency 'rspec', '~> 3.0'
|
31
|
+
spec.add_dependency 'rugged'
|
32
|
+
spec.add_dependency 'thor'
|
33
|
+
|
34
|
+
spec.add_development_dependency 'bundler', '~> 1.13'
|
35
|
+
spec.add_development_dependency 'pry'
|
36
|
+
spec.add_development_dependency 'rake', '~> 10.0'
|
37
|
+
spec.add_development_dependency 'rubocop', '~> 0.52.1'
|
38
|
+
end
|
metadata
ADDED
@@ -0,0 +1,185 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: sleet
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.2.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Corey Alexander
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2018-01-14 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: faraday
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rspec
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '3.0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '3.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rugged
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: thor
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: bundler
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '1.13'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '1.13'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: pry
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: rake
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - "~>"
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '10.0'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - "~>"
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '10.0'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: rubocop
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - "~>"
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: 0.52.1
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - "~>"
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: 0.52.1
|
125
|
+
description: |
|
126
|
+
Sleet provides an easy way to grab the most recent Rspec persistance files from CircleCI.
|
127
|
+
It also aggregates the artificats from CircleCI, since you will have 1 per build container.
|
128
|
+
email:
|
129
|
+
- coreyja@gmail.com
|
130
|
+
executables:
|
131
|
+
- sleet
|
132
|
+
extensions: []
|
133
|
+
extra_rdoc_files: []
|
134
|
+
files:
|
135
|
+
- ".circleci/config.yml"
|
136
|
+
- ".editorconfig"
|
137
|
+
- ".gitignore"
|
138
|
+
- ".rspec"
|
139
|
+
- ".rubocop.yml"
|
140
|
+
- ".rubocop_todo.yml"
|
141
|
+
- ".sleet.yml"
|
142
|
+
- CODE_OF_CONDUCT.md
|
143
|
+
- Gemfile
|
144
|
+
- LICENSE
|
145
|
+
- README.md
|
146
|
+
- Rakefile
|
147
|
+
- bin/console
|
148
|
+
- bin/setup
|
149
|
+
- exe/sleet
|
150
|
+
- lib/sleet.rb
|
151
|
+
- lib/sleet/artifact_downloader.rb
|
152
|
+
- lib/sleet/circle_ci.rb
|
153
|
+
- lib/sleet/circle_ci_branch.rb
|
154
|
+
- lib/sleet/circle_ci_build.rb
|
155
|
+
- lib/sleet/cli.rb
|
156
|
+
- lib/sleet/current_branch_github.rb
|
157
|
+
- lib/sleet/option_defaults.rb
|
158
|
+
- lib/sleet/rspec_file_merger.rb
|
159
|
+
- lib/sleet/version.rb
|
160
|
+
- sleet.gemspec
|
161
|
+
homepage: https://github.com/coreyja/sleet
|
162
|
+
licenses:
|
163
|
+
- MIT
|
164
|
+
metadata: {}
|
165
|
+
post_install_message:
|
166
|
+
rdoc_options: []
|
167
|
+
require_paths:
|
168
|
+
- lib
|
169
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
170
|
+
requirements:
|
171
|
+
- - ">="
|
172
|
+
- !ruby/object:Gem::Version
|
173
|
+
version: '0'
|
174
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
175
|
+
requirements:
|
176
|
+
- - ">="
|
177
|
+
- !ruby/object:Gem::Version
|
178
|
+
version: '0'
|
179
|
+
requirements: []
|
180
|
+
rubyforge_project:
|
181
|
+
rubygems_version: 2.7.4
|
182
|
+
signing_key:
|
183
|
+
specification_version: 4
|
184
|
+
summary: CircleCI RSpec Status Persistance File Aggregator
|
185
|
+
test_files: []
|