sleet 0.4.1 → 0.4.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 36ddaacead84e702849b36dd91308e7028782d3775e91937054e6d2d54632554
4
- data.tar.gz: ac73e5669a06f891cc250e3c2c67d27ce38c4d9d8b72b44233cec204c4086ef4
3
+ metadata.gz: 54355bc21cd53356e769f7bc10c5ac14ae2c0c332203e1194ee4588c40ebe475
4
+ data.tar.gz: b4d029da2f74a94712edcd0cde780f8e4029c844be8461a544d589c40072a6d9
5
5
  SHA512:
6
- metadata.gz: 24ae81f4d3265a67c3a7ee272ea5aefdb7df57fcd930e584aba4a34290c20ff16cc2fd779c5be25329e8f3cd9e2e4301cd209d478a0dd4900af9f946634b4d44
7
- data.tar.gz: eea0a055ba465999874d97ca5493b148c02039e6908d8eb75993cc7c9403afdaf5f65c2df099cf7e1ce0342c827f87b1616d39084449cff77fc385ab3a3c2a9e
6
+ metadata.gz: 7d9c5d7d4d8ac342de5a1abc280ed46da05cb72680f4973c9351eb277f87f89756a82bac6ff6c2fdfcd070f54ea39fc8b819f49946e13ea0f7592db8c2451fb9
7
+ data.tar.gz: '0190c0ffb1e5cc760fbe024920a1b892fc05185ab61a9633580829739c0308f217394a68509df8dd846474a5593ba51fd68d8e60b7c9879fb6f41c2873be891e'
data/.circleci/config.yml CHANGED
@@ -8,23 +8,8 @@ jobs:
8
8
  steps:
9
9
  - checkout
10
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
11
  # Install
22
12
  - run: bundle check --path vendor/bundle || 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
13
 
29
14
  - type: shell
30
15
  command: |
@@ -35,7 +20,7 @@ jobs:
35
20
  --out /tmp/test-results/rubocop.xml \
36
21
  --format progress \
37
22
  --force-exclusion \
38
- $(bundle exec rubocop --list-target-files | circleci tests split --split-by=filesize --show-counts)
23
+ $(circleci tests glob "**/*.rb" | circleci tests split --split-by=filesize --show-counts)
39
24
 
40
25
  # Run rspec in parallel
41
26
  - type: shell
data/.gitignore CHANGED
@@ -12,3 +12,5 @@
12
12
 
13
13
  # Ignore Rspec Example Status File
14
14
  spec/.rspec_example_statuses
15
+
16
+ .envrc
data/CHANGELOG.md CHANGED
@@ -1,5 +1,26 @@
1
1
  # Change Log
2
2
 
3
+ ## [v0.4.2](https://github.com/coreyja/sleet/tree/v0.4.2) (2019-05-26)
4
+ [Full Changelog](https://github.com/coreyja/sleet/compare/v0.4.1...v0.4.2)
5
+
6
+ **Closed issues:**
7
+
8
+ - Dependabot can't resolve your Ruby dependency files [\#51](https://github.com/coreyja/sleet/issues/51)
9
+ - Dependabot can't resolve your Ruby dependency files [\#50](https://github.com/coreyja/sleet/issues/50)
10
+ - Dependabot can't resolve your Ruby dependency files [\#48](https://github.com/coreyja/sleet/issues/48)
11
+ - Dependabot can't resolve your Ruby dependency files [\#49](https://github.com/coreyja/sleet/issues/49)
12
+
13
+ **Merged pull requests:**
14
+
15
+ - Fix CircleCI Builds [\#59](https://github.com/coreyja/sleet/pull/59) ([coreyja](https://github.com/coreyja))
16
+ - Add a Gitter chat badge to README.md [\#58](https://github.com/coreyja/sleet/pull/58) ([gitter-badger](https://github.com/gitter-badger))
17
+ - Symlink to docs README.md from top level [\#57](https://github.com/coreyja/sleet/pull/57) ([coreyja](https://github.com/coreyja))
18
+ - Docs site fixes [\#56](https://github.com/coreyja/sleet/pull/56) ([coreyja](https://github.com/coreyja))
19
+ - Setup Github Pages [\#54](https://github.com/coreyja/sleet/pull/54) ([coreyja](https://github.com/coreyja))
20
+ - Update rugged requirement from \>= 0.26, \< 0.28 to \>= 0.26, \< 0.29 [\#53](https://github.com/coreyja/sleet/pull/53) ([dependabot-preview[bot]](https://github.com/apps/dependabot-preview))
21
+ - Remove direct dependency on Bundler [\#52](https://github.com/coreyja/sleet/pull/52) ([dependabot-preview[bot]](https://github.com/apps/dependabot-preview))
22
+ - Update webmock requirement from ~\> 3.4.0 to ~\> 3.5.1 [\#47](https://github.com/coreyja/sleet/pull/47) ([dependabot-preview[bot]](https://github.com/apps/dependabot-preview))
23
+
3
24
  ## [v0.4.1](https://github.com/coreyja/sleet/tree/v0.4.1) (2018-11-24)
4
25
  [Full Changelog](https://github.com/coreyja/sleet/compare/v0.4.0...v0.4.1)
5
26
 
@@ -7,12 +28,12 @@
7
28
 
8
29
  - chore: Set up Rubocop-Coreyja gem [\#45](https://github.com/coreyja/sleet/pull/45) ([coreyja](https://github.com/coreyja))
9
30
  - Update README.md [\#40](https://github.com/coreyja/sleet/pull/40) ([coreyja](https://github.com/coreyja))
10
- - Update gem-release requirement to = 2.0.1 [\#33](https://github.com/coreyja/sleet/pull/33) ([dependabot[bot]](https://github.com/apps/dependabot))
11
- - Update webmock requirement to ~\> 3.4.0 [\#28](https://github.com/coreyja/sleet/pull/28) ([dependabot[bot]](https://github.com/apps/dependabot))
12
- - Update faraday requirement to \>= 0.13.1, \< 0.16.0 [\#27](https://github.com/coreyja/sleet/pull/27) ([dependabot[bot]](https://github.com/apps/dependabot))
13
- - Update rubocop requirement to ~\> 0.55.0 [\#26](https://github.com/coreyja/sleet/pull/26) ([dependabot[bot]](https://github.com/apps/dependabot))
14
- - Update gem-release requirement to = 2.0.0.rc.3 [\#25](https://github.com/coreyja/sleet/pull/25) ([dependabot[bot]](https://github.com/apps/dependabot))
15
- - Update rugged requirement to \>= 0.26, \< 0.28 [\#24](https://github.com/coreyja/sleet/pull/24) ([dependabot[bot]](https://github.com/apps/dependabot))
31
+ - Update gem-release requirement to = 2.0.1 [\#33](https://github.com/coreyja/sleet/pull/33) ([dependabot-preview[bot]](https://github.com/apps/dependabot-preview))
32
+ - Update webmock requirement to ~\> 3.4.0 [\#28](https://github.com/coreyja/sleet/pull/28) ([dependabot-preview[bot]](https://github.com/apps/dependabot-preview))
33
+ - Update faraday requirement to \>= 0.13.1, \< 0.16.0 [\#27](https://github.com/coreyja/sleet/pull/27) ([dependabot-preview[bot]](https://github.com/apps/dependabot-preview))
34
+ - Update rubocop requirement to ~\> 0.55.0 [\#26](https://github.com/coreyja/sleet/pull/26) ([dependabot-preview[bot]](https://github.com/apps/dependabot-preview))
35
+ - Update gem-release requirement to = 2.0.0.rc.3 [\#25](https://github.com/coreyja/sleet/pull/25) ([dependabot-preview[bot]](https://github.com/apps/dependabot-preview))
36
+ - Update rugged requirement to \>= 0.26, \< 0.28 [\#24](https://github.com/coreyja/sleet/pull/24) ([dependabot-preview[bot]](https://github.com/apps/dependabot-preview))
16
37
 
17
38
  ## [v0.4.0](https://github.com/coreyja/sleet/tree/v0.4.0) (2018-03-08)
18
39
  [Full Changelog](https://github.com/coreyja/sleet/compare/v0.3.10...v0.4.0)
@@ -31,7 +52,7 @@
31
52
  **Merged pull requests:**
32
53
 
33
54
  - Base Version Option [\#20](https://github.com/coreyja/sleet/pull/20) ([coreyja](https://github.com/coreyja))
34
- - Update rubocop requirement to ~\> 0.53.0 [\#19](https://github.com/coreyja/sleet/pull/19) ([dependabot[bot]](https://github.com/apps/dependabot))
55
+ - Update rubocop requirement to ~\> 0.53.0 [\#19](https://github.com/coreyja/sleet/pull/19) ([dependabot-preview[bot]](https://github.com/apps/dependabot-preview))
35
56
 
36
57
  ## [v0.3.9](https://github.com/coreyja/sleet/tree/v0.3.9) (2018-03-04)
37
58
  [Full Changelog](https://github.com/coreyja/sleet/compare/v0.3.8...v0.3.9)
@@ -43,8 +64,8 @@
43
64
  **Merged pull requests:**
44
65
 
45
66
  - Refactor [\#18](https://github.com/coreyja/sleet/pull/18) ([coreyja](https://github.com/coreyja))
46
- - Update rake requirement to ~\> 12.3 [\#17](https://github.com/coreyja/sleet/pull/17) ([dependabot[bot]](https://github.com/apps/dependabot))
47
- - 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))
67
+ - Update rake requirement to ~\> 12.3 [\#17](https://github.com/coreyja/sleet/pull/17) ([dependabot-preview[bot]](https://github.com/apps/dependabot-preview))
68
+ - Update faraday requirement to \>= 0.13.1, \< 0.15.0 [\#16](https://github.com/coreyja/sleet/pull/16) ([dependabot-preview[bot]](https://github.com/apps/dependabot-preview))
48
69
 
49
70
  ## [v0.3.8](https://github.com/coreyja/sleet/tree/v0.3.8) (2018-02-25)
50
71
  [Full Changelog](https://github.com/coreyja/sleet/compare/v0.3.7...v0.3.8)
data/README.md ADDED
@@ -0,0 +1 @@
1
+ ./docs/README.md
data/docs/CNAME ADDED
@@ -0,0 +1 @@
1
+ sleet.dev
data/docs/README.md ADDED
@@ -0,0 +1,143 @@
1
+ # Sleet ☁️ ❄️
2
+
3
+ [![Gem Version](https://badge.fury.io/rb/sleet.svg)](https://badge.fury.io/rb/sleet)
4
+ [![Maintainability](https://api.codeclimate.com/v1/badges/7f346b368d72b53ef630/maintainability)](https://codeclimate.com/github/coreyja/sleet/maintainability)
5
+ [![CircleCI](https://circleci.com/gh/coreyja/sleet.svg?style=svg)](https://circleci.com/gh/coreyja/sleet)
6
+ [![Join the chat at https://gitter.im/rspec-sleet/community](https://badges.gitter.im/rspec-sleet/community.svg)](https://gitter.im/rspec-sleet/community?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
7
+
8
+ ## Background and Problem
9
+
10
+ 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.
11
+
12
+ 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.
13
+ 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.
14
+ This is where `Sleet` comes in!
15
+
16
+ ## Purpose
17
+
18
+ This tool does two things:
19
+ 1. It downloads all of the `.rspec_failed_examples` files that were uploaded to CircleCI for the most recent build of the current branch
20
+ 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)
21
+
22
+ ## Getting Started
23
+
24
+ ### 1. Configure RSpec to Create and Use an example persistance file
25
+
26
+ 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).
27
+
28
+ 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. The actual location and file name are up to you, this is just an example. (Though using this name will require less configuration later.)
29
+
30
+ ```
31
+ RSpec.configure do |c|
32
+ c.example_status_persistence_file_path = ".rspec_example_statuses"
33
+ end
34
+ ```
35
+
36
+ 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.
37
+
38
+ ```
39
+ --require spec_helper
40
+ ```
41
+
42
+ Again there are other ways to load your `spec_helper.rb` file, including requiring it from each spec. Pick one that works for you.
43
+
44
+ ### 2. Collect the example persistance files in CircleCI
45
+
46
+ 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.
47
+
48
+ ```
49
+ - store_artifacts:
50
+ path: .rspec_example_statuses
51
+
52
+ ```
53
+
54
+ ### 3. Save a CircleCI Token locally (to access private builds)
55
+
56
+ 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.
57
+ The recommended approach is to create a yml file in your home directory which contains your the key `circle_ci_token`
58
+
59
+ ```
60
+ circle_ci_token: PLACE_TOKEN_HERE
61
+ ```
62
+
63
+ An API token can be generated here: [https://circleci.com/account/api](https://circleci.com/account/api)
64
+
65
+ ### 4. Run this tool from your project
66
+
67
+ ```
68
+ sleet
69
+ ```
70
+
71
+ 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.
72
+
73
+ ### 5. Run RSpec with `--only-failures`
74
+
75
+ ```
76
+ bundle exec rspec --only-failures
77
+ ```
78
+
79
+ This will run only the examples that failed in CircleCI!
80
+
81
+ ## Configuration
82
+
83
+ If you are using Worklfows in your CircleCI builds, or you are working with a different persistance file name, you may need to configure Sleet beyond the defaults.
84
+
85
+ Sleet currently supports two ways to input configurations:
86
+
87
+ 1. Through YML files
88
+ - `Sleet` will search 'up' from where the command was run and look for `.sleet.yml` files. It will combine all the files it finds, such that 'deeper' files take presedence. This allows you to have a user-level config at `~/.sleet.yml` and have project specific files which take presendence over the user level config (ex: `~/Projects/foo/.sleet.yml`)
89
+ 2. Through the CLI
90
+ - These always take presendece the options provided in the YML files
91
+
92
+ 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.
93
+
94
+ ### Options
95
+
96
+ These are the options that are currently supported
97
+
98
+ #### `source_dir`
99
+
100
+ Alias: s
101
+
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
+
104
+ #### `input_file`
105
+
106
+ Alias: i
107
+
108
+ This is the name of the Rspec Circle Persistance File in CircleCI. The default is `.rspec_example_statuses`
109
+
110
+ This will match if the full path on CircleCI ends in the given name.
111
+
112
+ #### `output_file`
113
+
114
+ Alias: o
115
+
116
+ This is the name for the output file, on your local system. It is relative to the `source_dir`.
117
+
118
+ Will be IGNORED if `workflows` is provided.
119
+
120
+ #### `workflows`
121
+
122
+ Alias: w
123
+
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
+ 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.
126
+
127
+ Build-Test-Deploy Demo:
128
+
129
+ For this example you have three jobs in your CircleCI Workflow, `build`, `test` and `deploy`, but only 1 (the `test` build) generate an Rspec persistance file
130
+
131
+ This command will pick the `test` build and save it's artificats to the `.rspec_example_statuses` file
132
+
133
+ ```
134
+ sleet fetch --workflows test:.rspec_example_statuses
135
+ ```
136
+
137
+ MonoRepo Demo:
138
+
139
+ 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.
140
+
141
+ ```
142
+ sleet fetch --workflows foo-test:foo/.rpsec_example_statuses bar-test:bar/.rspec_example_statuses baz-specs:baz/spec/examples.txt
143
+ ```
data/docs/_config.yml ADDED
@@ -0,0 +1 @@
1
+ theme: jekyll-theme-slate
data/lib/sleet/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Sleet
4
- VERSION = '0.4.1'
4
+ VERSION = '0.4.2'
5
5
  end
data/sleet.gemspec CHANGED
@@ -28,15 +28,14 @@ Gem::Specification.new do |spec|
28
28
  spec.add_dependency 'colorize', '~> 0.8.1'
29
29
  spec.add_dependency 'faraday', '>= 0.13.1', '< 0.16.0'
30
30
  spec.add_dependency 'rspec', '~> 3.0'
31
- spec.add_dependency 'rugged', '>= 0.26', '< 0.28'
31
+ spec.add_dependency 'rugged', '>= 0.26', '< 0.29'
32
32
  spec.add_dependency 'terminal-table', '~> 1.8'
33
33
  spec.add_dependency 'thor', '~> 0.20.0'
34
34
 
35
- spec.add_development_dependency 'bundler', '~> 1.13'
36
35
  spec.add_development_dependency 'gem-release', '= 2.0.1'
37
36
  spec.add_development_dependency 'github_changelog_generator', '~> 1.14'
38
37
  spec.add_development_dependency 'pry', '~> 0.10'
39
38
  spec.add_development_dependency 'rake', '~> 12.3'
40
- spec.add_development_dependency 'rubocop-coreyja', '0.3.0'
41
- spec.add_development_dependency 'webmock', '~> 3.4.0'
39
+ spec.add_development_dependency 'rubocop-coreyja', '0.4.0'
40
+ spec.add_development_dependency 'webmock', '~> 3.5.1'
42
41
  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.4.1
4
+ version: 0.4.2
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-24 00:00:00.000000000 Z
11
+ date: 2019-05-27 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.28'
70
+ version: '0.29'
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.28'
80
+ version: '0.29'
81
81
  - !ruby/object:Gem::Dependency
82
82
  name: terminal-table
83
83
  requirement: !ruby/object:Gem::Requirement
@@ -106,20 +106,6 @@ dependencies:
106
106
  - - "~>"
107
107
  - !ruby/object:Gem::Version
108
108
  version: 0.20.0
109
- - !ruby/object:Gem::Dependency
110
- name: bundler
111
- requirement: !ruby/object:Gem::Requirement
112
- requirements:
113
- - - "~>"
114
- - !ruby/object:Gem::Version
115
- version: '1.13'
116
- type: :development
117
- prerelease: false
118
- version_requirements: !ruby/object:Gem::Requirement
119
- requirements:
120
- - - "~>"
121
- - !ruby/object:Gem::Version
122
- version: '1.13'
123
109
  - !ruby/object:Gem::Dependency
124
110
  name: gem-release
125
111
  requirement: !ruby/object:Gem::Requirement
@@ -182,28 +168,28 @@ dependencies:
182
168
  requirements:
183
169
  - - '='
184
170
  - !ruby/object:Gem::Version
185
- version: 0.3.0
171
+ version: 0.4.0
186
172
  type: :development
187
173
  prerelease: false
188
174
  version_requirements: !ruby/object:Gem::Requirement
189
175
  requirements:
190
176
  - - '='
191
177
  - !ruby/object:Gem::Version
192
- version: 0.3.0
178
+ version: 0.4.0
193
179
  - !ruby/object:Gem::Dependency
194
180
  name: webmock
195
181
  requirement: !ruby/object:Gem::Requirement
196
182
  requirements:
197
183
  - - "~>"
198
184
  - !ruby/object:Gem::Version
199
- version: 3.4.0
185
+ version: 3.5.1
200
186
  type: :development
201
187
  prerelease: false
202
188
  version_requirements: !ruby/object:Gem::Requirement
203
189
  requirements:
204
190
  - - "~>"
205
191
  - !ruby/object:Gem::Version
206
- version: 3.4.0
192
+ version: 3.5.1
207
193
  description: |
208
194
  Sleet provides an easy way to grab the most recent Rspec persistance files from CircleCI.
209
195
  It also aggregates the artificats from CircleCI, since you will have 1 per build container.
@@ -230,6 +216,9 @@ files:
230
216
  - bin/console
231
217
  - bin/release
232
218
  - bin/setup
219
+ - docs/CNAME
220
+ - docs/README.md
221
+ - docs/_config.yml
233
222
  - exe/sleet
234
223
  - lib/sleet.rb
235
224
  - lib/sleet/artifact_downloader.rb
@@ -265,8 +254,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
265
254
  - !ruby/object:Gem::Version
266
255
  version: '0'
267
256
  requirements: []
268
- rubyforge_project:
269
- rubygems_version: 2.7.6
257
+ rubygems_version: 3.0.1
270
258
  signing_key:
271
259
  specification_version: 4
272
260
  summary: CircleCI RSpec Status Persistance File Aggregator
data/README.md DELETED
@@ -1,142 +0,0 @@
1
- # Sleet ☁️ ❄️
2
-
3
- [![Gem Version](https://badge.fury.io/rb/sleet.svg)](https://badge.fury.io/rb/sleet)
4
- [![Maintainability](https://api.codeclimate.com/v1/badges/7f346b368d72b53ef630/maintainability)](https://codeclimate.com/github/coreyja/sleet/maintainability)
5
- [![CircleCI](https://circleci.com/gh/coreyja/sleet.svg?style=svg)](https://circleci.com/gh/coreyja/sleet)
6
-
7
- ## Background and Problem
8
-
9
- 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.
10
-
11
- 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.
12
- 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.
13
- This is where `Sleet` comes in!
14
-
15
- ## Purpose
16
-
17
- This tool does two things:
18
- 1. It downloads all of the `.rspec_failed_examples` files that were uploaded to CircleCI for the most recent build of the current branch
19
- 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)
20
-
21
- ## Getting Started
22
-
23
- ### 1. Configure RSpec to Create and Use an example persistance file
24
-
25
- 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).
26
-
27
- 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. The actual location and file name are up to you, this is just an example. (Though using this name will require less configuration later.)
28
-
29
- ```
30
- RSpec.configure do |c|
31
- c.example_status_persistence_file_path = ".rspec_example_statuses"
32
- end
33
- ```
34
-
35
- 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.
36
-
37
- ```
38
- --require spec_helper
39
- ```
40
-
41
- Again there are other ways to load your `spec_helper.rb` file, including requiring it from each spec. Pick one that works for you.
42
-
43
- ### 2. Collect the example persistance files in CircleCI
44
-
45
- 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.
46
-
47
- ```
48
- - store_artifacts:
49
- path: .rspec_example_statuses
50
-
51
- ```
52
-
53
- ### 3. Save a CircleCI Token locally (to access private builds)
54
-
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
- ```
61
-
62
- An API token can be generated here: [https://circleci.com/account/api](https://circleci.com/account/api)
63
-
64
- ### 4. Run this tool from your project
65
-
66
- ```
67
- sleet
68
- ```
69
-
70
- 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.
71
-
72
- ### 5. Run RSpec with `--only-failures`
73
-
74
- ```
75
- bundle exec rspec --only-failures
76
- ```
77
-
78
- This will run only the examples that failed in CircleCI!
79
-
80
- ## Configuration
81
-
82
- If you are using Worklfows in your CircleCI builds, or you are working with a different persistance file name, you may need to configure Sleet beyond the defaults.
83
-
84
- Sleet currently supports two ways to input configurations:
85
-
86
- 1. Through YML files
87
- - `Sleet` will search 'up' from where the command was run and look for `.sleet.yml` files. It will combine all the files it finds, such that 'deeper' files take presedence. This allows you to have a user-level config at `~/.sleet.yml` and have project specific files which take presendence over the user level config (ex: `~/Projects/foo/.sleet.yml`)
88
- 2. Through the CLI
89
- - These always take presendece the options provided in the YML files
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
-
93
- ### Options
94
-
95
- These are the options that are currently supported
96
-
97
- #### `source_dir`
98
-
99
- Alias: s
100
-
101
- 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.
102
-
103
- #### `input_file`
104
-
105
- Alias: i
106
-
107
- This is the name of the Rspec Circle Persistance File in CircleCI. The default is `.rspec_example_statuses`
108
-
109
- This will match if the full path on CircleCI ends in the given name.
110
-
111
- #### `output_file`
112
-
113
- Alias: o
114
-
115
- This is the name for the output file, on your local system. It is relative to the `source_dir`.
116
-
117
- Will be IGNORED if `workflows` is provided.
118
-
119
- #### `workflows`
120
-
121
- Alias: w
122
-
123
- 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.
124
- 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.
125
-
126
- Build-Test-Deploy Demo:
127
-
128
- For this example you have three jobs in your CircleCI Workflow, `build`, `test` and `deploy`, but only 1 (the `test` build) generate an Rspec persistance file
129
-
130
- This command will pick the `test` build and save it's artificats to the `.rspec_example_statuses` file
131
-
132
- ```
133
- sleet fetch --workflows test:.rspec_example_statuses
134
- ```
135
-
136
- MonoRepo Demo:
137
-
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.
139
-
140
- ```
141
- sleet fetch --workflows foo-test:foo/.rpsec_example_statuses bar-test:bar/.rspec_example_statuses baz-specs:baz/spec/examples.txt
142
- ```