knapsack_pro 0.0.1 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (100) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +3 -3
  3. data/CHANGELOG.md +4 -0
  4. data/README.md +368 -4
  5. data/bin/knapsack_pro +20 -0
  6. data/circle.yml +2 -0
  7. data/knapsack_pro.gemspec +6 -1
  8. data/lib/knapsack_pro.rb +74 -0
  9. data/lib/knapsack_pro/adapters/base_adapter.rb +30 -0
  10. data/lib/knapsack_pro/adapters/cucumber_adapter.rb +40 -0
  11. data/lib/knapsack_pro/adapters/minitest_adapter.rb +52 -0
  12. data/lib/knapsack_pro/adapters/rspec_adapter.rb +48 -0
  13. data/lib/knapsack_pro/allocator.rb +40 -0
  14. data/lib/knapsack_pro/allocator_builder.rb +40 -0
  15. data/lib/knapsack_pro/client/api/action.rb +17 -0
  16. data/lib/knapsack_pro/client/api/v1/base.rb +15 -0
  17. data/lib/knapsack_pro/client/api/v1/build_distributions.rb +29 -0
  18. data/lib/knapsack_pro/client/api/v1/build_subsets.rb +29 -0
  19. data/lib/knapsack_pro/client/connection.rb +94 -0
  20. data/lib/knapsack_pro/config/ci/base.rb +22 -0
  21. data/lib/knapsack_pro/config/ci/buildkite.rb +27 -0
  22. data/lib/knapsack_pro/config/ci/circle.rb +29 -0
  23. data/lib/knapsack_pro/config/ci/semaphore.rb +28 -0
  24. data/lib/knapsack_pro/config/env.rb +111 -0
  25. data/lib/knapsack_pro/logger_wrapper.rb +15 -0
  26. data/lib/knapsack_pro/presenter.rb +25 -0
  27. data/lib/knapsack_pro/report.rb +20 -0
  28. data/lib/knapsack_pro/repository_adapter_initiator.rb +12 -0
  29. data/lib/knapsack_pro/repository_adapters/base_adapter.rb +14 -0
  30. data/lib/knapsack_pro/repository_adapters/env_adapter.rb +13 -0
  31. data/lib/knapsack_pro/repository_adapters/git_adapter.rb +19 -0
  32. data/lib/knapsack_pro/runners/base_runner.rb +31 -0
  33. data/lib/knapsack_pro/runners/cucumber_runner.rb +16 -0
  34. data/lib/knapsack_pro/runners/minitest_runner.rb +26 -0
  35. data/lib/knapsack_pro/runners/rspec_runner.rb +16 -0
  36. data/lib/knapsack_pro/task_loader.rb +11 -0
  37. data/lib/knapsack_pro/test_file_cleaner.rb +7 -0
  38. data/lib/knapsack_pro/test_file_finder.rb +33 -0
  39. data/lib/knapsack_pro/test_file_pattern.rb +7 -0
  40. data/lib/knapsack_pro/test_file_presenter.rb +11 -0
  41. data/lib/knapsack_pro/test_flat_distributor.rb +84 -0
  42. data/lib/knapsack_pro/tracker.rb +64 -0
  43. data/lib/knapsack_pro/version.rb +1 -1
  44. data/lib/tasks/cucumber.rake +7 -0
  45. data/lib/tasks/minitest.rake +7 -0
  46. data/lib/tasks/rspec.rake +7 -0
  47. data/spec/fixtures/vcr_cassettes/api/v1/build_distributions/subset/invalid_test_suite_token.yml +50 -0
  48. data/spec/fixtures/vcr_cassettes/api/v1/build_distributions/subset/success.yml +52 -0
  49. data/spec/fixtures/vcr_cassettes/api/v1/build_subsets/create/invalid_test_suite_token.yml +50 -0
  50. data/spec/fixtures/vcr_cassettes/api/v1/build_subsets/create/success.yml +50 -0
  51. data/spec/integration/api/build_distributions_subset_spec.rb +74 -0
  52. data/spec/integration/api/build_subsets_create_spec.rb +76 -0
  53. data/spec/knapsack_pro/adapters/base_adapter_spec.rb +63 -0
  54. data/spec/knapsack_pro/adapters/cucumber_adapter_spec.rb +71 -0
  55. data/spec/knapsack_pro/adapters/minitest_adapter_spec.rb +107 -0
  56. data/spec/knapsack_pro/adapters/rspec_adapter_spec.rb +94 -0
  57. data/spec/knapsack_pro/allocator_builder_spec.rb +45 -0
  58. data/spec/knapsack_pro/allocator_spec.rb +80 -0
  59. data/spec/knapsack_pro/client/api/action_spec.rb +17 -0
  60. data/spec/knapsack_pro/client/api/v1/base_spec.rb +2 -0
  61. data/spec/knapsack_pro/client/api/v1/build_distributions_spec.rb +35 -0
  62. data/spec/knapsack_pro/client/api/v1/build_subsets_spec.rb +35 -0
  63. data/spec/knapsack_pro/client/connection_spec.rb +138 -0
  64. data/spec/knapsack_pro/config/ci/base_spec.rb +7 -0
  65. data/spec/knapsack_pro/config/ci/buildkite_spec.rb +74 -0
  66. data/spec/knapsack_pro/config/ci/circle_spec.rb +74 -0
  67. data/spec/knapsack_pro/config/ci/semaphore_spec.rb +74 -0
  68. data/spec/knapsack_pro/config/env_spec.rb +368 -0
  69. data/spec/knapsack_pro/logger_wrapper_spec.rb +15 -0
  70. data/spec/knapsack_pro/presenter_spec.rb +57 -0
  71. data/spec/knapsack_pro/report_spec.rb +68 -0
  72. data/spec/knapsack_pro/repository_adapter_initiator_spec.rb +21 -0
  73. data/spec/knapsack_pro/repository_adapters/base_adapter_spec.rb +13 -0
  74. data/spec/knapsack_pro/repository_adapters/env_adapter_spec.rb +27 -0
  75. data/spec/knapsack_pro/repository_adapters/git_adapter_spec.rb +27 -0
  76. data/spec/knapsack_pro/runners/base_runner_spec.rb +61 -0
  77. data/spec/knapsack_pro/runners/cucumber_runner_spec.rb +47 -0
  78. data/spec/knapsack_pro/runners/minitest_runner_spec.rb +34 -0
  79. data/spec/knapsack_pro/runners/rspec_runner_spec.rb +49 -0
  80. data/spec/knapsack_pro/task_loader_spec.rb +14 -0
  81. data/spec/knapsack_pro/test_file_cleaner_spec.rb +11 -0
  82. data/spec/knapsack_pro/test_file_finder_spec.rb +35 -0
  83. data/spec/knapsack_pro/test_file_pattern_spec.rb +23 -0
  84. data/spec/knapsack_pro/test_file_presenter_spec.rb +22 -0
  85. data/spec/knapsack_pro/test_flat_distributor_spec.rb +60 -0
  86. data/spec/knapsack_pro/tracker_spec.rb +102 -0
  87. data/spec/knapsack_pro_spec.rb +56 -0
  88. data/spec/spec_helper.rb +11 -1
  89. data/spec/support/fakes/cucumber.rb +12 -0
  90. data/spec/support/fakes/minitest.rb +12 -0
  91. data/spec/support/shared_examples/adapter.rb +17 -0
  92. data/spec_fake/controllers/users_controller_spec.rb +0 -0
  93. data/spec_fake/models/admin_spec.rb +0 -0
  94. data/spec_fake/models/user_spec.rb +0 -0
  95. data/spec_fake/spec_helper.rb +0 -0
  96. data/test_fake/a_test.rb +0 -0
  97. data/test_fake/b_test.rb +0 -0
  98. metadata +212 -12
  99. data/Gemfile.lock +0 -69
  100. data/spec/knapsack_spec.rb +0 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e868eb591c4891dbb94e7af8911d82108b7f6eb5
4
- data.tar.gz: 9bfad8c2e053b0e663a28d98be2e9f85becdbb69
3
+ metadata.gz: 298cd101879e3a4da08f66de0b2ccfe6fd4be478
4
+ data.tar.gz: a393fbb53dff07029ffcc4ffde88b7a99150f9aa
5
5
  SHA512:
6
- metadata.gz: e9839f1c256278b9b55312ea428ec59465e9548686f69b2ff37a689ac9b787601179ad01a19b74e102704d39b929605d700eef0f941d5def183796605727d8d8
7
- data.tar.gz: 4e78f4f8bb6ed5f944d53dd10e29425361c97875ae57b9a49f03982780733570113c5fdd748dedf57805e31e2c1478ec5ad9387ca06cdd68d1ff6ded7b4dca2e
6
+ metadata.gz: 67bb457b7c35e6c1135f197d34a67e0b4e222e9a8be9dd24a093b2761fdf497349c2b2cd95d5636333f6bb9aadb980ab56374b2b3d914e3457422be86cd5fe2d
7
+ data.tar.gz: 4bcc5069b5aa69d8be4f1477a332c0318a97f4d122493cd6c393196ea672831e921093ad402542a99018928f83d1dc5d59cd038b8dadf66ba2859c72c75effc2
data/.gitignore CHANGED
@@ -27,9 +27,9 @@ build/
27
27
 
28
28
  # for a library or gem, you might want to ignore these files since the code is
29
29
  # intended to run in multiple environments; otherwise, check them in:
30
- # Gemfile.lock
31
- # .ruby-version
32
- # .ruby-gemset
30
+ Gemfile.lock
31
+ .ruby-version
32
+ .ruby-gemset
33
33
 
34
34
  # unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
35
35
  .rvmrc
data/CHANGELOG.md CHANGED
@@ -2,6 +2,10 @@
2
2
 
3
3
  * TODO
4
4
 
5
+ ### 0.1.0
6
+
7
+ First working release on rubygems.org.
8
+
5
9
  ### 0.0.1
6
10
 
7
11
  Init repository.
data/README.md CHANGED
@@ -5,15 +5,379 @@
5
5
  [![Code Climate](https://codeclimate.com/github/KnapsackPro/knapsack_pro-ruby/badges/gpa.svg)](https://codeclimate.com/github/KnapsackPro/knapsack_pro-ruby)
6
6
  [![Test Coverage](https://codeclimate.com/github/KnapsackPro/knapsack_pro-ruby/badges/coverage.svg)](https://codeclimate.com/github/KnapsackPro/knapsack_pro-ruby)
7
7
 
8
- Knapsack Pro gem splits tests across CI nodes and makes sure that tests will run comparable time on each node. It uses KnapsackPro.com API.
8
+ Knapsack Pro gem splits tests across CI nodes and makes sure that tests will run comparable time on each node. It uses [KnapsackPro.com API](http://docs.knapsackpro.com). Original idea came from [knapsack](https://github.com/ArturT/knapsack) gem.
9
9
 
10
- The gem supports:
10
+ The knapsack_pro gem supports:
11
11
 
12
12
  * [RSpec](http://rspec.info)
13
13
  * [Cucumber](https://cucumber.io)
14
14
  * [Minitest](http://docs.seattlerb.org/minitest/)
15
15
  * [Turnip](https://github.com/jnicklas/turnip)
16
16
 
17
- # Basic info
17
+ __Would you like to try knapsack_pro gem?__ Drop me an [email](https://github.com/KnapsackPro/knapsack_pro-ruby/blob/master/knapsack_pro.gemspec#L10) so I will generate API keys for you.
18
18
 
19
- knapsack_pro gem is not ready yet. Please see https://github.com/ArturT/knapsack - it's working version you can use in your project for now.
19
+ # How knapsack_pro works?
20
+
21
+ ## Basics
22
+
23
+ Basically it will track your branches, commits and on how many CI nodes you are running tests.
24
+ Collected data about test time execution will be send to API where test suite split is done.
25
+ Next time when you will run tests you will get proper test files for each CI node in order to achieve comparable time execution on each CI node.
26
+
27
+ ## Details
28
+
29
+ For instance when you will run tests with rake knapsack_pro:rspec then:
30
+
31
+ * information about all your existing test files are sent to API http://docs.knapsackpro.com/api/v1/#build_distributions_subset_post
32
+ * API returns which files should be executed on particular CI node (example KNAPSACK_PRO_CI_NODE_INDEX=0)
33
+ * when API server has info about previous tests runs then it will use it to return more accurate test split results, in other case API returns simple split based on directory names
34
+ * knapsack_pro will run test files which got from API
35
+ * after tests finished knapsack_pro will send information about time execution of each file to API http://docs.knapsackpro.com/api/v1/#build_subsets_post so data can be used for future test runs
36
+
37
+ # Requirements
38
+
39
+ * >= Ruby 2.0
40
+
41
+ # Table of Contents
42
+
43
+ <!-- START doctoc generated TOC please keep comment here to allow auto update -->
44
+ <!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
45
+ **Table of Contents** *generated with [DocToc](https://github.com/thlorenz/doctoc)*
46
+
47
+ - [Update gem](#update-gem)
48
+ - [Installation](#installation)
49
+ - [Usage](#usage)
50
+ - [Step for RSpec](#step-for-rspec)
51
+ - [Step for Cucumber](#step-for-cucumber)
52
+ - [Step for Minitest](#step-for-minitest)
53
+ - [Custom configuration](#custom-configuration)
54
+ - [Setup your CI server](#setup-your-ci-server)
55
+ - [Set API key token](#set-api-key-token)
56
+ - [Set knapsack_pro command to execute tests](#set-knapsack_pro-command-to-execute-tests)
57
+ - [Extra configuration for CI server](#extra-configuration-for-ci-server)
58
+ - [Info about ENV variables](#info-about-env-variables)
59
+ - [Repository adapter](#repository-adapter)
60
+ - [Environment variables for debugging gem](#environment-variables-for-debugging-gem)
61
+ - [Passing arguments to rake task](#passing-arguments-to-rake-task)
62
+ - [Passing arguments to rspec](#passing-arguments-to-rspec)
63
+ - [Passing arguments to cucumber](#passing-arguments-to-cucumber)
64
+ - [Passing arguments to minitest](#passing-arguments-to-minitest)
65
+ - [Knapsack Pro binary](#knapsack-pro-binary)
66
+ - [Supported CI providers](#supported-ci-providers)
67
+ - [Info for CircleCI users](#info-for-circleci-users)
68
+ - [Info for Travis users](#info-for-travis-users)
69
+ - [Info for semaphoreapp.com users](#info-for-semaphoreappcom-users)
70
+ - [Info for buildkite.com users](#info-for-buildkitecom-users)
71
+ - [Gem tests](#gem-tests)
72
+ - [Spec](#spec)
73
+ - [Contributing](#contributing)
74
+
75
+ <!-- END doctoc generated TOC please keep comment here to allow auto update -->
76
+
77
+ ## Update gem
78
+
79
+ Please check [changelog](CHANGELOG.md) before update gem. Knapsack Pro follows [semantic versioning](http://semver.org).
80
+
81
+ ## Installation
82
+
83
+ Add those lines to your application's Gemfile:
84
+
85
+ ```ruby
86
+ group :test, :development do
87
+ gem 'knapsack_pro'
88
+ end
89
+ ```
90
+
91
+ And then execute:
92
+
93
+ $ bundle
94
+
95
+
96
+ Add this line at the bottom of `Rakefile` if your project has it:
97
+
98
+ ```ruby
99
+ KnapsackPro.load_tasks if defined?(KnapsackPro)
100
+ ```
101
+
102
+ ## Usage
103
+
104
+ You can find here example of rails app with already configured knapsack_pro.
105
+
106
+ https://github.com/KnapsackPro/rails-app-with-knapsack_pro
107
+
108
+ ### Step for RSpec
109
+
110
+ Add at the beginning of your `spec_helper.rb`:
111
+
112
+ ```ruby
113
+ require 'knapsack_pro'
114
+
115
+ # CUSTOM_CONFIG_GOES_HERE
116
+
117
+ KnapsackPro::Adapters::RSpecAdapter.bind
118
+ ```
119
+
120
+ ### Step for Cucumber
121
+
122
+ Create file `features/support/knapsack_pro.rb` and add there:
123
+
124
+ ```ruby
125
+ require 'knapsack_pro'
126
+
127
+ # CUSTOM_CONFIG_GOES_HERE
128
+
129
+ KnapsackPro::Adapters::CucumberAdapter.bind
130
+ ```
131
+
132
+ ### Step for Minitest
133
+
134
+ Add at the beginning of your `test_helper.rb`:
135
+
136
+ ```ruby
137
+ require 'knapsack_pro'
138
+
139
+ # CUSTOM_CONFIG_GOES_HERE
140
+
141
+ knapsack_pro_adapter = KnapsackPro::Adapters::MinitestAdapter.bind
142
+ knapsack_pro_adapter.set_test_helper_path(__FILE__)
143
+ ```
144
+
145
+ ### Custom configuration
146
+
147
+ You can change default Knapsack Pro configuration for RSpec, Cucumber or Minitest tests. Here are examples what you can do. Put below configuration instead of `CUSTOM_CONFIG_GOES_HERE`.
148
+
149
+ ```ruby
150
+ # you can use your own logger
151
+ require 'logger'
152
+ KnapsackPro.logger = Logger.new(STDOUT)
153
+ KnapsackPro.logger.level = Logger::INFO
154
+ ```
155
+
156
+ ## Setup your CI server
157
+
158
+ ### Set API key token
159
+
160
+ Set one or a few tokens depend on how many test suites you run on CI server.
161
+
162
+ * `KNAPSACK_PRO_TEST_SUITE_TOKEN_RSPEC` - as value set token for rspec test suite. Token can be generated when you sign in to [knapsackpro.com](http://www.knapsackpro.com).
163
+ * `KNAPSACK_PRO_TEST_SUITE_TOKEN_CUCUMBER` - token for cucumber test suite.
164
+ * `KNAPSACK_PRO_TEST_SUITE_TOKEN_MINITEST` - token for minitest test suite.
165
+
166
+ __Tip:__ In case you have for instance multiple rspec test suites then prepend each of knapsack_pro command which executes tests with `KNAPSACK_PRO_TEST_SUITE_TOKEN_RSPEC` variable.
167
+
168
+ ### Set knapsack_pro command to execute tests
169
+
170
+ On your CI server run this command for the first CI node. Update `KNAPSACK_PRO_CI_NODE_INDEX` for the next one.
171
+
172
+ # Step for RSpec
173
+ $ KNAPSACK_PRO_CI_NODE_TOTAL=2 KNAPSACK_PRO_CI_NODE_INDEX=0 bundle exec rake knapsack_pro:rspec
174
+
175
+ # Step for Cucumber
176
+ $ KNAPSACK_PRO_CI_NODE_TOTAL=2 KNAPSACK_PRO_CI_NODE_INDEX=0 bundle exec rake knapsack_pro:cucumber
177
+
178
+ # Step for Minitest
179
+ $ KNAPSACK_PRO_CI_NODE_TOTAL=2 KNAPSACK_PRO_CI_NODE_INDEX=0 bundle exec rake knapsack_pro:minitest
180
+
181
+ You can add `KNAPSACK_PRO_TEST_FILE_PATTERN` if your tests are not in default directory. For instance:
182
+
183
+ # Step for RSpec
184
+ $ KNAPSACK_PRO_TEST_FILE_PATTERN="directory_with_specs/**/*_spec.rb" KNAPSACK_PRO_CI_NODE_TOTAL=2 KNAPSACK_PRO_CI_NODE_INDEX=0 bundle exec rake knapsack_pro:rspec
185
+
186
+ # Step for Cucumber
187
+ $ KNAPSACK_PRO_TEST_FILE_PATTERN="directory_with_features/**/*.feature" KNAPSACK_PRO_CI_NODE_TOTAL=2 KNAPSACK_PRO_CI_NODE_INDEX=0 bundle exec rake knapsack_pro:cucumber
188
+
189
+ # Step for Minitest
190
+ $ KNAPSACK_PRO_TEST_FILE_PATTERN="directory_with_tests/**/*_test.rb" KNAPSACK_PRO_CI_NODE_TOTAL=2 KNAPSACK_PRO_CI_NODE_INDEX=0 bundle exec rake knapsack_pro:minitest
191
+
192
+ ## Extra configuration for CI server
193
+
194
+ ### Info about ENV variables
195
+
196
+ By default knapsack_pro gem [supports a few CI providers](#supported-ci-providers) so you don't need to set environment variables.
197
+ In case when you use other CI provider for instance [Jenkins](https://jenkins-ci.org) etc then you need to provide configuration via below environment variables.
198
+
199
+ `KNAPSACK_PRO_CI_NODE_TOTAL` - total number CI nodes you have.
200
+
201
+ `KNAPSACK_PRO_CI_NODE_INDEX` - index of current CI node starts from 0. Second CI node should have `KNAPSACK_PRO_CI_NODE_INDEX=1`.
202
+
203
+ #### Repository adapter
204
+
205
+ `KNAPSACK_PRO_REPOSITORY_ADAPTER` - When it has value `git` then your local version of git on CI server will be used to get info about branch name, commit hash and project directory path.
206
+ By default this variable has no value so knapsack_pro will try to get those info from [supported CI](#supported-ci-providers) (CI providers have branch, commit, project directory stored as environment variables). In case when you use other CI provider like Jenkins then please set below variables on your own.
207
+
208
+ `KNAPSACK_PRO_BRANCH` - It's branch name. You run tests on this branch.
209
+
210
+ `KNAPSACK_PRO_COMMIT_HASH` - Commit hash. You run tests for this commit.
211
+
212
+ `KNAPSACK_PRO_PROJECT_DIR` - Path to the project on CI node for instance `/home/ubuntu/my-app-repository`. It should be main directory of your repository.
213
+
214
+ #### Environment variables for debugging gem
215
+
216
+ `KNAPSACK_PRO_ENDPOINT` - Default value is `http://api.knapsackpro.com` which is endpoint for [Knapsack Pro API](http://docs.knapsackpro.com).
217
+
218
+ `KNAPSACK_PRO_MODE` - Default value is `production`. When mode is `development` then endpoint is `http://api.knapsackpro.dev:3000`. When mode is `test` then endpoint is `http://api-staging.knapsackpro.com`.
219
+
220
+ ### Passing arguments to rake task
221
+
222
+ #### Passing arguments to rspec
223
+
224
+ Knapsack Pro allows you to pass arguments through to rspec. For example if you want to run only specs that have the tag `focus`. If you do this with rspec directly it would look like:
225
+
226
+ $ bundle exec rake rspec --tag focus
227
+
228
+ To do this with Knapsack Pro you simply add your rspec arguments as parameters to the knapsack_pro rake task.
229
+
230
+ $ bundle exec rake "knapsack_pro:rspec[--tag focus]"
231
+
232
+ #### Passing arguments to cucumber
233
+
234
+ Add arguments to knapsack_pro cucumber task like this:
235
+
236
+ $ bundle exec rake "knapsack_pro:cucumber[--name feature]"
237
+
238
+ #### Passing arguments to minitest
239
+
240
+ Add arguments to knapsack_pro minitest task like this:
241
+
242
+ $ bundle exec rake "knapsack_pro:minitest[--arg_name value]"
243
+
244
+ For instance to run verbose tests:
245
+
246
+ $ bundle exec rake "knapsack_pro:minitest[--verbose]"
247
+
248
+ ### Knapsack Pro binary
249
+
250
+ You can install knapsack_pro globally and use binary. For instance:
251
+
252
+ $ knapsack_pro rspec "--tag custom_tag_name --profile"
253
+ $ knapsack_pro cucumber "--name feature"
254
+ $ knapsack_pro minitest "--verbose --pride"
255
+
256
+ This is optional way of using knapsack_pro when you don't want to add it to `Gemfile`.
257
+
258
+ ### Supported CI providers
259
+
260
+ #### Info for CircleCI users
261
+
262
+ If you are using circleci.com you can omit `KNAPSACK_PRO_CI_NODE_TOTAL` and `KNAPSACK_PRO_CI_NODE_INDEX`. Knapsack Pro will use `KNAPSACK_PRO_CIRCLE_NODE_TOTAL` and `KNAPSACK_PRO_CIRCLE_NODE_INDEX` provided by CircleCI.
263
+
264
+ Here is an example for test configuration in your `circleci.yml` file.
265
+
266
+ ```yaml
267
+ test:
268
+ override:
269
+ # Step for RSpec
270
+ - bundle exec rake knapsack_pro:rspec:
271
+ parallel: true # Caution: there are 8 spaces indentation!
272
+
273
+ # Step for Cucumber
274
+ - bundle exec rake knapsack_pro:cucumber:
275
+ parallel: true # Caution: there are 8 spaces indentation!
276
+
277
+ # Step for Minitest
278
+ - bundle exec rake knapsack_pro:minitest:
279
+ parallel: true # Caution: there are 8 spaces indentation!
280
+ ```
281
+
282
+ Please remember to add additional containers for your project in CircleCI settings.
283
+
284
+ #### Info for Travis users
285
+
286
+ You can parallel your builds across virtual machines with [travis matrix feature](http://docs.travis-ci.com/user/speeding-up-the-build/#Parallelizing-your-builds-across-virtual-machines). Edit `.travis.yml`
287
+
288
+ ```yaml
289
+ script:
290
+ # Step for RSpec
291
+ - "bundle exec rake knapsack_pro:rspec"
292
+
293
+ # Step for Cucumber
294
+ - "bundle exec rake knapsack_pro:cucumber"
295
+
296
+ # Step for Minitest
297
+ - "bundle exec rake knapsack_pro:minitest"
298
+
299
+ env:
300
+ - KNAPSACK_PRO_CI_NODE_TOTAL=2 KNAPSACK_PRO_CI_NODE_INDEX=0
301
+ - KNAPSACK_PRO_CI_NODE_TOTAL=2 KNAPSACK_PRO_CI_NODE_INDEX=1
302
+ ```
303
+
304
+ If you want to have some global ENVs and matrix of ENVs then do it like this:
305
+
306
+ ```yaml
307
+ script:
308
+ # Step for RSpec
309
+ - "bundle exec rake knapsack_pro:rspec"
310
+
311
+ # Step for Cucumber
312
+ - "bundle exec rake knapsack_pro:cucumber"
313
+
314
+ # Step for Minitest
315
+ - "bundle exec rake knapsack_pro:minitest"
316
+
317
+ env:
318
+ global:
319
+ - RAILS_ENV=test
320
+ - MY_GLOBAL_VAR=123
321
+ - KNAPSACK_PRO_CI_NODE_TOTAL=2
322
+ matrix:
323
+ - KNAPSACK_PRO_CI_NODE_INDEX=0
324
+ - KNAPSACK_PRO_CI_NODE_INDEX=1
325
+ ```
326
+
327
+ Such configuration will generate matrix with 2 following ENV rows:
328
+
329
+ KNAPSACK_PRO_CI_NODE_TOTAL=2 KNAPSACK_PRO_CI_NODE_INDEX=0 RAILS_ENV=test MY_GLOBAL_VAR=123
330
+ KNAPSACK_PRO_CI_NODE_TOTAL=2 KNAPSACK_PRO_CI_NODE_INDEX=1 RAILS_ENV=test MY_GLOBAL_VAR=123
331
+
332
+ More info about global and matrix ENV configuration in [travis docs](http://docs.travis-ci.com/user/build-configuration/#Environment-variables).
333
+
334
+ #### Info for semaphoreapp.com users
335
+
336
+ Knapsack Pro supports semaphoreapp ENVs `SEMAPHORE_THREAD_COUNT` and `SEMAPHORE_CURRENT_THREAD`. The only thing you need to do is set up knapsack_pro rspec/cucumber/minitest command for as many threads as you need. Here is an example:
337
+
338
+ # Thread 1
339
+ ## Step for RSpec
340
+ bundle exec rake knapsack_pro:rspec
341
+ ## Step for Cucumber
342
+ bundle exec rake knapsack_pro:cucumber
343
+ ## Step for Minitest
344
+ bundle exec rake knapsack_pro:minitest
345
+
346
+ # Thread 2
347
+ ## Step for RSpec
348
+ bundle exec rake knapsack_pro:rspec
349
+ ## Step for Cucumber
350
+ bundle exec rake knapsack_pro:cucumber
351
+ ## Step for Minitest
352
+ bundle exec rake knapsack_pro:minitest
353
+
354
+ Tests will be split across threads.
355
+
356
+ #### Info for buildkite.com users
357
+
358
+ Knapsack Pro supports buildkite ENVs `BUILDKITE_PARALLEL_JOB_COUNT` and `BUILDKITE_PARALLEL_JOB`. The only thing you need to do is to configure the parallelism parameter in your build step and run the appropiate command in your build
359
+
360
+ # Step for RSpec
361
+ bundle exec rake knapsack_pro:rspec
362
+
363
+ # Step for Cucumber
364
+ bundle exec rake knapsack_pro:cucumber
365
+
366
+ # Step for Minitest
367
+ bundle exec rake knapsack_pro:minitest
368
+
369
+ ## Gem tests
370
+
371
+ ### Spec
372
+
373
+ To run specs for Knapsack Pro gem type:
374
+
375
+ $ bundle exec rspec spec
376
+
377
+ ## Contributing
378
+
379
+ 1. Fork it ( https://github.com/ArturT/knapsack/fork )
380
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
381
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
382
+ 4. Push to the branch (`git push origin my-new-feature`)
383
+ 5. Create a new Pull Request
data/bin/knapsack_pro ADDED
@@ -0,0 +1,20 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require_relative '../lib/knapsack_pro'
4
+
5
+ runner = ARGV[0]
6
+ arguments = ARGV[1]
7
+
8
+ MAP = {
9
+ 'rspec' => KnapsackPro::Runners::RSpecRunner,
10
+ 'cucumber' => KnapsackPro::Runners::CucumberRunner,
11
+ 'minitest' => KnapsackPro::Runners::MinitestRunner,
12
+ }
13
+
14
+ runner_class = MAP[runner]
15
+
16
+ if runner_class
17
+ runner_class.run(arguments)
18
+ else
19
+ raise 'Undefined runner. Please provide runner name and optional arguments, for instance: knapsack_pro rspec "--color --profile"'
20
+ end
data/circle.yml CHANGED
@@ -1,3 +1,5 @@
1
1
  machine:
2
+ ruby:
3
+ version: 2.2.3
2
4
  environment:
3
5
  CODECLIMATE_REPO_TOKEN: b6626e682a8e97e0c5978febc92c3526792a2d018b41b8e1b52689da37fb7d92