knapsack_pro 0.12.0 → 0.13.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +6 -0
- data/README.md +13 -7
- data/knapsack_pro.gemspec +1 -0
- data/lib/knapsack_pro/version.rb +1 -1
- data/lib/tasks/install.rake +302 -0
- metadata +17 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 331541f2ecd345ac6c68562799b8b00d774a82ee
|
4
|
+
data.tar.gz: 6f2c4dc59a7283f77351fd640dc2632c57db07e1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ceaace21c1274a31e97c0ce6e6d7addb1c99b834242c45dc558f783845b03dc1720eabcf2b1d36325da61f8f96955b35574fd64d64453e5cde9e1b5d131aee59
|
7
|
+
data.tar.gz: b966ee4bb2bc7f7938bbaec8a4db8e850618645177ed36e88fcac5430d11be66eaacf26037955601ff03cac61235ddb5126d22b024a361640c0e28d02dc3f9cc
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -15,7 +15,7 @@ The knapsack_pro gem supports:
|
|
15
15
|
* [Spinach](https://github.com/codegram/spinach)
|
16
16
|
* [Turnip](https://github.com/jnicklas/turnip)
|
17
17
|
|
18
|
-
__Would you like to try knapsack_pro gem?__ You can [get API token here](http://knapsackpro.com).
|
18
|
+
__Would you like to try knapsack_pro gem?__ You can [get API token here](http://knapsackpro.com?utm_source=github&utm_medium=readme&utm_campaign=knapsack_pro-ruby_gem&utm_content=get_api_token).
|
19
19
|
|
20
20
|
## Is knapsack_pro gem free?
|
21
21
|
|
@@ -109,7 +109,7 @@ end
|
|
109
109
|
|
110
110
|
And then execute:
|
111
111
|
|
112
|
-
$ bundle
|
112
|
+
$ bundle install
|
113
113
|
|
114
114
|
|
115
115
|
Add this lines at the bottom of `Rakefile` if your project has it:
|
@@ -118,6 +118,14 @@ Add this lines at the bottom of `Rakefile` if your project has it:
|
|
118
118
|
KnapsackPro.load_tasks if defined?(KnapsackPro)
|
119
119
|
```
|
120
120
|
|
121
|
+
Run installer to get started. It will ask you a few questions and generate instruction steps for your project.
|
122
|
+
|
123
|
+
$ bundle exec rake knapsack_pro:install
|
124
|
+
|
125
|
+
You can read next section only if you want to better understand optional gem configuration and features.
|
126
|
+
|
127
|
+
## How to set up
|
128
|
+
|
121
129
|
If you are using [VCR gem](https://github.com/vcr/vcr) then add Knapsack Pro API subdomain to [ignore hosts](https://www.relishapp.com/vcr/vcr/v/2-9-3/docs/configuration/ignore-request):
|
122
130
|
|
123
131
|
```ruby
|
@@ -130,8 +138,6 @@ end
|
|
130
138
|
WebMock.disable_net_connect!(:allow => 'api.knapsackpro.com') if defined?(WebMock)
|
131
139
|
```
|
132
140
|
|
133
|
-
## How to set up
|
134
|
-
|
135
141
|
### Usage (How to set up 1 of 3)
|
136
142
|
|
137
143
|
__Tip:__ You can find here example of rails app with already configured knapsack_pro.
|
@@ -184,7 +190,7 @@ require 'knapsack_pro'
|
|
184
190
|
|
185
191
|
# CUSTOM_CONFIG_GOES_HERE
|
186
192
|
|
187
|
-
KnapsackPro::Adapters::
|
193
|
+
KnapsackPro::Adapters::SpinachAdapter.bind
|
188
194
|
```
|
189
195
|
|
190
196
|
#### Custom configuration
|
@@ -427,7 +433,7 @@ Please remember to add additional containers for your project in CircleCI settin
|
|
427
433
|
|
428
434
|
#### Info for Travis users
|
429
435
|
|
430
|
-
You can
|
436
|
+
You can parallelize 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`
|
431
437
|
|
432
438
|
```yaml
|
433
439
|
script:
|
@@ -554,7 +560,7 @@ To run specs for Knapsack Pro gem type:
|
|
554
560
|
|
555
561
|
## Contributing
|
556
562
|
|
557
|
-
1. Fork it ( https://github.com/
|
563
|
+
1. Fork it ( https://github.com/KnapsackPro/knapsack_pro-ruby )
|
558
564
|
2. Create your feature branch (`git checkout -b my-new-feature`)
|
559
565
|
3. Commit your changes (`git commit -am 'Add some feature'`)
|
560
566
|
4. Push to the branch (`git push origin my-new-feature`)
|
data/knapsack_pro.gemspec
CHANGED
@@ -20,6 +20,7 @@ Gem::Specification.new do |spec|
|
|
20
20
|
|
21
21
|
spec.add_dependency 'rake', '>= 0'
|
22
22
|
spec.add_dependency 'timecop', '>= 0.1.0'
|
23
|
+
spec.add_dependency 'tty-prompt', '~> 0.7'
|
23
24
|
|
24
25
|
spec.add_development_dependency 'bundler', '~> 1.6'
|
25
26
|
spec.add_development_dependency 'rspec', '~> 3.0', '>= 2.0.0'
|
data/lib/knapsack_pro/version.rb
CHANGED
@@ -0,0 +1,302 @@
|
|
1
|
+
require 'knapsack_pro'
|
2
|
+
require 'tty-prompt'
|
3
|
+
|
4
|
+
def step_for_rspec(prompt)
|
5
|
+
prompt.say "Step for RSpec", color: :yellow
|
6
|
+
prompt.say "Add at the beginning of your spec/spec_helper.rb:"
|
7
|
+
|
8
|
+
prompt.say %{
|
9
|
+
require 'knapsack_pro'
|
10
|
+
KnapsackPro::Adapters::RSpecAdapter.bind
|
11
|
+
}, color: :cyan
|
12
|
+
end
|
13
|
+
|
14
|
+
def step_for_minitest(prompt)
|
15
|
+
prompt.say "Step for Minitest", color: :yellow
|
16
|
+
prompt.say "Add at the beginning of your test/test_helper.rb:"
|
17
|
+
|
18
|
+
prompt.say %{
|
19
|
+
require 'knapsack_pro'
|
20
|
+
knapsack_pro_adapter = KnapsackPro::Adapters::MinitestAdapter.bind
|
21
|
+
knapsack_pro_adapter.set_test_helper_path(__FILE__)
|
22
|
+
}, color: :cyan
|
23
|
+
end
|
24
|
+
|
25
|
+
def step_for_cucumber(prompt)
|
26
|
+
prompt.say "Step for Cucumber", color: :yellow
|
27
|
+
prompt.say "Create file features/support/knapsack_pro.rb and add there:"
|
28
|
+
|
29
|
+
prompt.say %{
|
30
|
+
require 'knapsack_pro'
|
31
|
+
KnapsackPro::Adapters::CucumberAdapter.bind
|
32
|
+
}, color: :cyan
|
33
|
+
end
|
34
|
+
|
35
|
+
def step_for_spinach(prompt)
|
36
|
+
prompt.say "Step for Spinach", color: :yellow
|
37
|
+
prompt.say "Create file features/support/knapsack_pro.rb and add there:"
|
38
|
+
|
39
|
+
prompt.say %{
|
40
|
+
require 'knapsack_pro'
|
41
|
+
KnapsackPro::Adapters::SpinachAdapter.bind
|
42
|
+
}, color: :cyan
|
43
|
+
end
|
44
|
+
|
45
|
+
def step_for_vcr(prompt)
|
46
|
+
prompt.say "Step for VCR gem", color: :yellow
|
47
|
+
prompt.say "Add Knapsack Pro API subdomain to ignore hosts"
|
48
|
+
prompt.say "in spec/spec_helper.rb or wherever is your VCR configuration"
|
49
|
+
|
50
|
+
prompt.say %{
|
51
|
+
VCR.configure do |config|
|
52
|
+
config.ignore_hosts 'localhost', '127.0.0.1', '0.0.0.0', 'api.knapsackpro.com'
|
53
|
+
end
|
54
|
+
|
55
|
+
WebMock.disable_net_connect!(:allow => 'api.knapsackpro.com') if defined?(WebMock)
|
56
|
+
}, color: :cyan
|
57
|
+
end
|
58
|
+
|
59
|
+
def step_for_ci_circle(prompt, answers)
|
60
|
+
prompt.say "Step for https://circleci.com", color: :yellow
|
61
|
+
prompt.say "Update circle.yml in your project:"
|
62
|
+
|
63
|
+
str = ''
|
64
|
+
answers[:testing_tools].each do |tool|
|
65
|
+
str << %{
|
66
|
+
# Step for #{tool}
|
67
|
+
- bundle exec rake knapsack_pro:#{tool}:
|
68
|
+
parallel: true # Caution: there are 8 spaces indentation!
|
69
|
+
}
|
70
|
+
end
|
71
|
+
|
72
|
+
prompt.say((%{
|
73
|
+
test:
|
74
|
+
override:} + str), color: :cyan)
|
75
|
+
|
76
|
+
puts
|
77
|
+
set_api_tokens_on_ci(prompt, answers)
|
78
|
+
end
|
79
|
+
|
80
|
+
def step_for_ci_travis(prompt, answers)
|
81
|
+
prompt.say "Step for https://travis-ci.org", color: :yellow
|
82
|
+
prompt.say "You can parallelize your builds across virtual machines with travis matrix feature."
|
83
|
+
prompt.say "https://docs.travis-ci.com/user/speeding-up-the-build/#Parallelizing-your-builds-across-virtual-machines"
|
84
|
+
puts
|
85
|
+
prompt.say "Update .travis.yml"
|
86
|
+
|
87
|
+
prompt.say %{
|
88
|
+
script:
|
89
|
+
}, color: :cyan
|
90
|
+
|
91
|
+
answers[:testing_tools].each do |tool|
|
92
|
+
prompt.say %{
|
93
|
+
# Step for #{tool}
|
94
|
+
- "bundle exec rake knapsack_pro:#{tool}"
|
95
|
+
}, color: :cyan
|
96
|
+
end
|
97
|
+
|
98
|
+
prompt.say %{
|
99
|
+
env:
|
100
|
+
global:
|
101
|
+
- KNAPSACK_PRO_CI_NODE_TOTAL=2
|
102
|
+
}, color: :cyan
|
103
|
+
|
104
|
+
prompt.say %{
|
105
|
+
matrix:
|
106
|
+
- KNAPSACK_PRO_CI_NODE_INDEX=0
|
107
|
+
- KNAPSACK_PRO_CI_NODE_INDEX=1
|
108
|
+
}, color: :cyan
|
109
|
+
|
110
|
+
puts
|
111
|
+
prompt.say "If you want more parallel jobs then update accordingly:"
|
112
|
+
tip_ci_node_total_and_index(prompt)
|
113
|
+
|
114
|
+
puts
|
115
|
+
prompt.say "Open travis settings in web interface to add there Knapsack Pro API token."
|
116
|
+
puts
|
117
|
+
set_api_tokens_on_ci(prompt, answers)
|
118
|
+
end
|
119
|
+
|
120
|
+
def step_for_ci_buildkite(prompt, answers)
|
121
|
+
prompt.say "Step for https://buildkite.com", color: :yellow
|
122
|
+
prompt.say "Please configure the parallelism parameter in your build step and run the appropiate command in your build:"
|
123
|
+
|
124
|
+
answers[:testing_tools].each do |tool|
|
125
|
+
prompt.say %{
|
126
|
+
# Step for #{tool}
|
127
|
+
bundle exec rake knapsack_pro:#{tool}
|
128
|
+
}, color: :cyan
|
129
|
+
end
|
130
|
+
|
131
|
+
puts
|
132
|
+
set_api_tokens_on_ci(prompt, answers)
|
133
|
+
end
|
134
|
+
|
135
|
+
def step_for_ci_semaphore(prompt, answers)
|
136
|
+
prompt.say "Step for https://semaphoreci.com", color: :yellow
|
137
|
+
prompt.say "Set knapsack pro command for each parallel thread. Here is example:"
|
138
|
+
|
139
|
+
answers[:testing_tools].each do |tool|
|
140
|
+
puts
|
141
|
+
prompt.say "Step for #{tool}"
|
142
|
+
prompt.say %{
|
143
|
+
# Thread 1
|
144
|
+
bundle exec rake knapsack_pro:#{tool}
|
145
|
+
|
146
|
+
# Thread 2
|
147
|
+
bundle exec rake knapsack_pro:#{tool}
|
148
|
+
}, color: :cyan
|
149
|
+
end
|
150
|
+
|
151
|
+
puts
|
152
|
+
set_api_tokens_on_ci(prompt, answers)
|
153
|
+
end
|
154
|
+
|
155
|
+
def step_for_ci_snap_ci(prompt, answers)
|
156
|
+
prompt.say "Step for https://snap-ci.com", color: :yellow
|
157
|
+
prompt.say "Please configure number of workers for your project in configuration settings in order to enable parallelism."
|
158
|
+
prompt.say "Next thing is to set below commands to be executed in your stage:"
|
159
|
+
|
160
|
+
answers[:testing_tools].each do |tool|
|
161
|
+
prompt.say %{
|
162
|
+
# Step for #{tool}
|
163
|
+
bundle exec rake knapsack_pro:#{tool}
|
164
|
+
}, color: :cyan
|
165
|
+
end
|
166
|
+
|
167
|
+
puts
|
168
|
+
set_api_tokens_on_ci(prompt, answers)
|
169
|
+
end
|
170
|
+
|
171
|
+
def step_for_ci_other(prompt, answers)
|
172
|
+
prompt.say "Step for other CI provider", color: :yellow
|
173
|
+
prompt.say "Set below global variables on your CI server."
|
174
|
+
puts
|
175
|
+
|
176
|
+
prompt.say "Git installed on the CI server will be used to determine branch name and current commit hash."
|
177
|
+
|
178
|
+
prompt.say %{
|
179
|
+
KNAPSACK_PRO_REPOSITORY_ADAPTER=git
|
180
|
+
}, color: :cyan
|
181
|
+
puts
|
182
|
+
|
183
|
+
prompt.say "Path to the project repository on CI server, for instance:"
|
184
|
+
prompt.say %{
|
185
|
+
KNAPSACK_PRO_PROJECT_DIR=/home/ubuntu/my-app-repository
|
186
|
+
}, color: :cyan
|
187
|
+
puts
|
188
|
+
|
189
|
+
prompt.say "You can learn more about those variables here:"
|
190
|
+
prompt.say "https://github.com/KnapsackPro/knapsack_pro-ruby#when-you-set-global-variable-knapsack_pro_repository_adaptergit-required-when-ci-provider-is-not-supported"
|
191
|
+
puts
|
192
|
+
|
193
|
+
set_api_tokens_on_ci(prompt, answers)
|
194
|
+
|
195
|
+
# set test run command on CI server
|
196
|
+
prompt.say "Set test run command on CI server", color: :yellow
|
197
|
+
prompt.say "You must set command responsible for running tests for each CI node."
|
198
|
+
prompt.say "Let's assume you have 2 CI nodes. Here are commands you need to run for each CI node."
|
199
|
+
|
200
|
+
answers[:testing_tools].each do |tool|
|
201
|
+
puts
|
202
|
+
prompt.say "Step for #{tool}"
|
203
|
+
prompt.say %{
|
204
|
+
# Command for first CI node
|
205
|
+
$ KNAPSACK_PRO_CI_NODE_TOTAL=2 KNAPSACK_PRO_CI_NODE_INDEX=0 bundle exec rake knapsack_pro:#{tool}
|
206
|
+
|
207
|
+
# Command for second CI node
|
208
|
+
$ KNAPSACK_PRO_CI_NODE_TOTAL=2 KNAPSACK_PRO_CI_NODE_INDEX=1 bundle exec rake knapsack_pro:#{tool}
|
209
|
+
}, color: :cyan
|
210
|
+
end
|
211
|
+
puts
|
212
|
+
prompt.say "If you have more CI nodes then update accordingly:"
|
213
|
+
tip_ci_node_total_and_index(prompt)
|
214
|
+
puts
|
215
|
+
end
|
216
|
+
|
217
|
+
def tip_ci_node_total_and_index(prompt)
|
218
|
+
prompt.say %{
|
219
|
+
KNAPSACK_PRO_CI_NODE_TOTAL - total number of your CI nodes
|
220
|
+
KNAPSACK_PRO_CI_NODE_INDEX - starts from 0, it's index of each CI node
|
221
|
+
}, color: :cyan
|
222
|
+
end
|
223
|
+
|
224
|
+
def set_api_tokens_on_ci(prompt, answers)
|
225
|
+
prompt.say "Set API token", color: :yellow
|
226
|
+
prompt.say "You must set different API token on your CI server for each test suite you have:"
|
227
|
+
puts
|
228
|
+
|
229
|
+
str = ''
|
230
|
+
answers[:testing_tools].each do |tool|
|
231
|
+
str << "KNAPSACK_PRO_TEST_SUITE_TOKEN_#{tool.upcase}\n"
|
232
|
+
end
|
233
|
+
prompt.say str, color: :cyan
|
234
|
+
|
235
|
+
prompt.say "You can generate more API tokens after sign in on https://knapsackpro.com"
|
236
|
+
puts
|
237
|
+
end
|
238
|
+
|
239
|
+
namespace :knapsack_pro do
|
240
|
+
task :install do
|
241
|
+
prompt = TTY::Prompt.new
|
242
|
+
answers = {}
|
243
|
+
|
244
|
+
puts
|
245
|
+
prompt.say "Welcome to knapsack_pro gem installer."
|
246
|
+
puts
|
247
|
+
|
248
|
+
TESTING_TOOLS_CHOICES = {
|
249
|
+
'RSpec' => :rspec,
|
250
|
+
'Minitest' => :minitest,
|
251
|
+
'Cucumber' => :cucumber,
|
252
|
+
'Spinach' => :spinach,
|
253
|
+
}
|
254
|
+
answers[:testing_tools] = []
|
255
|
+
while answers[:testing_tools].empty?
|
256
|
+
answers[:testing_tools] = prompt.multi_select("Choose your testing tools:", TESTING_TOOLS_CHOICES)
|
257
|
+
end
|
258
|
+
|
259
|
+
answers[:has_vcr] = prompt.yes?('Do you use VCR gem?')
|
260
|
+
|
261
|
+
CI_PROVIDER_CHOICES = {
|
262
|
+
'https://circleci.com' => :circle,
|
263
|
+
'https://travis-ci.org' => :travis,
|
264
|
+
'https://buildkite.com' => :buildkite,
|
265
|
+
'https://semaphoreci.com' => :semaphore,
|
266
|
+
'https://snap-ci.com' => :snap_ci,
|
267
|
+
'other' => :other,
|
268
|
+
}
|
269
|
+
answers[:ci] = prompt.select("What is your CI provider?", CI_PROVIDER_CHOICES)
|
270
|
+
|
271
|
+
puts
|
272
|
+
|
273
|
+
# Instructions how to set up the gem
|
274
|
+
puts
|
275
|
+
puts
|
276
|
+
prompt.say "###### Please follow below instructions to finish configuration ######", color: :green
|
277
|
+
puts
|
278
|
+
|
279
|
+
answers[:testing_tools].each do |tool|
|
280
|
+
send("step_for_#{tool}", prompt)
|
281
|
+
puts
|
282
|
+
end
|
283
|
+
|
284
|
+
if answers[:has_vcr]
|
285
|
+
step_for_vcr(prompt)
|
286
|
+
puts
|
287
|
+
end
|
288
|
+
|
289
|
+
send("step_for_ci_#{answers[:ci]}", prompt, answers)
|
290
|
+
|
291
|
+
prompt.say "Now you are ready to use the gem!"
|
292
|
+
prompt.say "Please push a new commit to repository so knapsack_pro gem will record time execution of your test suite."
|
293
|
+
prompt.say "Your second tests run on CI will be parallelized with optimal test suite split."
|
294
|
+
puts
|
295
|
+
puts
|
296
|
+
prompt.say "You can learn more about custom configuration and other features:"
|
297
|
+
prompt.say "https://knapsackpro.com/features"
|
298
|
+
prompt.say "https://github.com/KnapsackPro/knapsack_pro-ruby#table-of-contents"
|
299
|
+
puts
|
300
|
+
prompt.say "###### Please follow above instructions to finish configuration ######", color: :green
|
301
|
+
end
|
302
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: knapsack_pro
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.13.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- ArturT
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-09-
|
11
|
+
date: 2016-09-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -38,6 +38,20 @@ dependencies:
|
|
38
38
|
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: 0.1.0
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: tty-prompt
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0.7'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0.7'
|
41
55
|
- !ruby/object:Gem::Dependency
|
42
56
|
name: bundler
|
43
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -249,6 +263,7 @@ files:
|
|
249
263
|
- lib/knapsack_pro/version.rb
|
250
264
|
- lib/tasks/cucumber.rake
|
251
265
|
- lib/tasks/encrypted_test_file_names.rake
|
266
|
+
- lib/tasks/install.rake
|
252
267
|
- lib/tasks/minitest.rake
|
253
268
|
- lib/tasks/rspec.rake
|
254
269
|
- lib/tasks/salt.rake
|