knapsack 1.4.1 → 1.5.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 +39 -6
- data/lib/knapsack/config/env.rb +11 -4
- data/lib/knapsack/version.rb +1 -1
- data/spec/knapsack/config/env_spec.rb +10 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8e9917104f810c3361175811b6bb1b82ebfd8503
|
4
|
+
data.tar.gz: 3b07a94beca2e14f4cb98bcd1f00808edb2c294f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c00e5c1c442e0c2a45f206b254de22d480a2d3ef7b3abec902878defd98857a669c2e05630b54b22226dc0511cdb779904f8965495248a84e2301ea621168076
|
7
|
+
data.tar.gz: 85fbaab6ff333b3197546f8ec5808f7c16d5cbd7f408a6a0b5dd2fb36c6bcc91362fc38d7edb2943165c50e4343138db5b6ea8464dc6ce4dd492201e40df2087
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -64,6 +64,9 @@ Presentations about gem:
|
|
64
64
|
- [Info for buildkite.com users](#info-for-buildkitecom-users)
|
65
65
|
- [Step 1](#step-1-3)
|
66
66
|
- [Step 2](#step-2-3)
|
67
|
+
- [Info for snap-ci.com users](#info-for-snap-cicom-users)
|
68
|
+
- [Step 1](#step-1-4)
|
69
|
+
- [Step 2](#step-2-4)
|
67
70
|
- [Gem tests](#gem-tests)
|
68
71
|
- [Spec](#spec)
|
69
72
|
- [Spec examples](#spec-examples)
|
@@ -92,6 +95,12 @@ And then execute:
|
|
92
95
|
|
93
96
|
$ bundle
|
94
97
|
|
98
|
+
Add this line at the bottom of `Rakefile`:
|
99
|
+
|
100
|
+
```ruby
|
101
|
+
Knapsack.load_tasks if defined?(Knapsack)
|
102
|
+
```
|
103
|
+
|
95
104
|
## Usage
|
96
105
|
|
97
106
|
You can find here example of rails app with already configured knapsack.
|
@@ -158,12 +167,6 @@ Knapsack.logger.level = Logger::INFO
|
|
158
167
|
|
159
168
|
### Common step
|
160
169
|
|
161
|
-
Add this line at the bottom of `Rakefile`:
|
162
|
-
|
163
|
-
```ruby
|
164
|
-
Knapsack.load_tasks if defined?(Knapsack)
|
165
|
-
```
|
166
|
-
|
167
170
|
Generate time execution report for your test files. Run below command on one of your CI nodes.
|
168
171
|
|
169
172
|
# Step for RSpec
|
@@ -456,6 +459,36 @@ Knapsack supports buildkite ENVs `BUILDKITE_PARALLEL_JOB_COUNT` and `BUILDKITE_P
|
|
456
459
|
# Step for Minitest
|
457
460
|
bundle exec rake knapsack:minitest
|
458
461
|
|
462
|
+
### Info for snap-ci.com users
|
463
|
+
|
464
|
+
#### Step 1
|
465
|
+
|
466
|
+
For the first time run all tests at once with enabled report generator. Run the following commands locally:
|
467
|
+
|
468
|
+
# Step for RSpec
|
469
|
+
KNAPSACK_GENERATE_REPORT=true bundle exec rspec spec
|
470
|
+
|
471
|
+
# Step for Cucumber
|
472
|
+
KNAPSACK_GENERATE_REPORT=true bundle exec cucumber features
|
473
|
+
|
474
|
+
# Step for Minitest
|
475
|
+
KNAPSACK_GENERATE_REPORT=true bundle exec rake test
|
476
|
+
|
477
|
+
After tests pass your should copy knapsack json report which is rendered at the end of rspec/cucumber/minitest results. Save it into your repository as `knapsack_rspec_report.json`, `knapsack_cucumber_report.json` or `knapsack_minitest_report.json` file and commit.
|
478
|
+
|
479
|
+
#### Step 2
|
480
|
+
|
481
|
+
Knapsack supports snap-ci.com ENVs `SNAP_WORKER_TOTAL` and `SNAP_WORKER_INDEX`. The only thing you need to do is to configure number of workers for your project in configuration settings in order to enable parallelism. Next thing is to set below commands to be executed in your stage:
|
482
|
+
|
483
|
+
# Step for RSpec
|
484
|
+
bundle exec rake knapsack:rspec
|
485
|
+
|
486
|
+
# Step for Cucumber
|
487
|
+
bundle exec rake knapsack:cucumber
|
488
|
+
|
489
|
+
# Step for Minitest
|
490
|
+
bundle exec rake knapsack:minitest
|
491
|
+
|
459
492
|
## Gem tests
|
460
493
|
|
461
494
|
### Spec
|
data/lib/knapsack/config/env.rb
CHANGED
@@ -7,11 +7,11 @@ module Knapsack
|
|
7
7
|
end
|
8
8
|
|
9
9
|
def ci_node_total
|
10
|
-
ENV['CI_NODE_TOTAL'] || ENV['CIRCLE_NODE_TOTAL'] || ENV['SEMAPHORE_THREAD_COUNT'] || ENV['BUILDKITE_PARALLEL_JOB_COUNT'] || 1
|
10
|
+
ENV['CI_NODE_TOTAL'] || ENV['CIRCLE_NODE_TOTAL'] || ENV['SEMAPHORE_THREAD_COUNT'] || ENV['BUILDKITE_PARALLEL_JOB_COUNT'] || ENV['SNAP_WORKER_TOTAL'] || 1
|
11
11
|
end
|
12
12
|
|
13
13
|
def ci_node_index
|
14
|
-
ENV['CI_NODE_INDEX'] || ENV['CIRCLE_NODE_INDEX'] || semaphore_current_thread || ENV['BUILDKITE_PARALLEL_JOB'] || 0
|
14
|
+
ENV['CI_NODE_INDEX'] || ENV['CIRCLE_NODE_INDEX'] || semaphore_current_thread || ENV['BUILDKITE_PARALLEL_JOB'] || snap_ci_worker_index || 0
|
15
15
|
end
|
16
16
|
|
17
17
|
def test_file_pattern
|
@@ -20,10 +20,17 @@ module Knapsack
|
|
20
20
|
|
21
21
|
private
|
22
22
|
|
23
|
-
def
|
24
|
-
index = ENV['SEMAPHORE_CURRENT_THREAD']
|
23
|
+
def index_starting_from_one(index)
|
25
24
|
index.to_i - 1 if index
|
26
25
|
end
|
26
|
+
|
27
|
+
def semaphore_current_thread
|
28
|
+
index_starting_from_one(ENV['SEMAPHORE_CURRENT_THREAD'])
|
29
|
+
end
|
30
|
+
|
31
|
+
def snap_ci_worker_index
|
32
|
+
index_starting_from_one(ENV['SNAP_WORKER_INDEX'])
|
33
|
+
end
|
27
34
|
end
|
28
35
|
end
|
29
36
|
end
|
data/lib/knapsack/version.rb
CHANGED
@@ -36,6 +36,11 @@ describe Knapsack::Config::Env do
|
|
36
36
|
before { stub_const("ENV", { 'BUILDKITE_PARALLEL_JOB_COUNT' => 4 }) }
|
37
37
|
it { should eql 4 }
|
38
38
|
end
|
39
|
+
|
40
|
+
context 'when SNAP_WORKER_TOTAL has value' do
|
41
|
+
before { stub_const("ENV", { 'SNAP_WORKER_TOTAL' => 6 }) }
|
42
|
+
it { should eql 6 }
|
43
|
+
end
|
39
44
|
end
|
40
45
|
|
41
46
|
context "when ENV doesn't exist" do
|
@@ -66,6 +71,11 @@ describe Knapsack::Config::Env do
|
|
66
71
|
before { stub_const("ENV", { 'BUILDKITE_PARALLEL_JOB' => 2 }) }
|
67
72
|
it { should eql 2 }
|
68
73
|
end
|
74
|
+
|
75
|
+
context 'when SNAP_WORKER_INDEX has value' do
|
76
|
+
before { stub_const("ENV", { 'SNAP_WORKER_INDEX' => 4 }) }
|
77
|
+
it { should eql 3 }
|
78
|
+
end
|
69
79
|
end
|
70
80
|
|
71
81
|
context "when ENV doesn't exist" do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: knapsack
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- ArturT
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-11-
|
11
|
+
date: 2015-11-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|