knapsack_pro 0.3.0 → 0.4.0

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
  SHA1:
3
- metadata.gz: 3332981f8b8f00fd4ae1746202ff4955a931db8e
4
- data.tar.gz: d58ddf37cbacdec16e88b70bff56c0da917da206
3
+ metadata.gz: a7107dbf41c676ee7c9e07f5aafdfa2a69deeccb
4
+ data.tar.gz: f5f8e62fe897d6c2308983e7c473e93fc63677c0
5
5
  SHA512:
6
- metadata.gz: 7aa19777190f729ab41ee527b17ce46547bcf45c8ef2aadfb8c962f3492f0b6915b10bada62b1673bf47c9286b55948dde63c6e2edf380746c96e5317f3f0f52
7
- data.tar.gz: eefb8f79a50289e91bbe662e1afae427d46a9ad492c21a76497c0fa7eb1d6d9fe9e69fd2bc89fb47b4c02771ce51792013a7ce47e6b3da08c05a1c3dba943ad9
6
+ metadata.gz: bb70ee375f3eab5daee242dddfc07de3ee6d559b12e547a7377384ae43da2ad46723506549ab1a12327f7f7387514a50eb447855dd37df6f9cf78fa287bc311f
7
+ data.tar.gz: 1fe863a20343585b52e717eb3a8bdb3e384fb713d7e744ae47d6fead141fb5f7c217d3b52e4d4048d510c39b2be54b02d3d7b2df65a4508ac884f5d9cd5424fa
data/CHANGELOG.md CHANGED
@@ -2,10 +2,18 @@
2
2
 
3
3
  * TODO
4
4
 
5
+ ### 0.4.0
6
+
7
+ * Add support for snap-ci.com
8
+
9
+ https://github.com/KnapsackPro/knapsack_pro-ruby/compare/v0.3.0...v0.4.0
10
+
5
11
  ### 0.3.0
6
12
 
7
13
  * Remove keyword arguments in order to add support for old ruby versions.
8
14
 
15
+ https://github.com/KnapsackPro/knapsack_pro-ruby/compare/v0.2.1...v0.3.0
16
+
9
17
  ### 0.2.1
10
18
 
11
19
  * TestFileFinder should find unique files without duplicates when using test file pattern supporting symlinks
data/README.md CHANGED
@@ -71,6 +71,7 @@ For instance when you will run tests with rake knapsack_pro:rspec then:
71
71
  - [Info for Travis users](#info-for-travis-users)
72
72
  - [Info for semaphoreapp.com users](#info-for-semaphoreappcom-users)
73
73
  - [Info for buildkite.com users](#info-for-buildkitecom-users)
74
+ - [Info for snap-ci.com users](#info-for-snap-cicom-users)
74
75
  - [Gem tests](#gem-tests)
75
76
  - [Spec](#spec)
76
77
  - [Contributing](#contributing)
@@ -373,6 +374,21 @@ Knapsack Pro supports buildkite ENVs `BUILDKITE_PARALLEL_JOB_COUNT` and `BUILDKI
373
374
 
374
375
  Please remember to set up token like `KNAPSACK_PRO_TEST_SUITE_TOKEN_RSPEC` as global environment.
375
376
 
377
+ ### Info for snap-ci.com users
378
+
379
+ Knapsack Pro 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:
380
+
381
+ # Step for RSpec
382
+ bundle exec rake knapsack_pro:rspec
383
+
384
+ # Step for Cucumber
385
+ bundle exec rake knapsack_pro:cucumber
386
+
387
+ # Step for Minitest
388
+ bundle exec rake knapsack_pro:minitest
389
+
390
+ Please remember to set up token like `KNAPSACK_PRO_TEST_SUITE_TOKEN_RSPEC` as global environment.
391
+
376
392
  ## Gem tests
377
393
 
378
394
  ### Spec
@@ -0,0 +1,31 @@
1
+ module KnapsackPro
2
+ module Config
3
+ module CI
4
+ class SnapCI < Base
5
+ def node_total
6
+ ENV['SNAP_WORKER_TOTAL']
7
+ end
8
+
9
+ def node_index
10
+ index = ENV['SNAP_WORKER_INDEX']
11
+ index.to_i - 1 if index
12
+ end
13
+
14
+ def commit_hash
15
+ ENV['SNAP_COMMIT']
16
+ end
17
+
18
+ # https://docs.snap-ci.com/environment-variables/
19
+ # SNAP_BRANCH - the name of the git branch (not present on pull requests)
20
+ # SNAP_UPSTREAM_BRANCH - the upstream branch for which the pull request was opened
21
+ def branch
22
+ ENV['SNAP_BRANCH'] || ENV['SNAP_UPSTREAM_BRANCH']
23
+ end
24
+
25
+ def project_dir
26
+ ENV['SNAP_WORKING_DIR']
27
+ end
28
+ end
29
+ end
30
+ end
31
+ end
@@ -1,3 +1,3 @@
1
1
  module KnapsackPro
2
- VERSION = '0.3.0'
2
+ VERSION = '0.4.0'
3
3
  end
data/lib/knapsack_pro.rb CHANGED
@@ -13,6 +13,7 @@ require_relative 'knapsack_pro/config/ci/circle'
13
13
  require_relative 'knapsack_pro/config/ci/semaphore'
14
14
  require_relative 'knapsack_pro/config/ci/buildkite'
15
15
  require_relative 'knapsack_pro/config/ci/travis'
16
+ require_relative 'knapsack_pro/config/ci/snap_ci'
16
17
  require_relative 'knapsack_pro/config/env'
17
18
  require_relative 'knapsack_pro/client/api/action'
18
19
  require_relative 'knapsack_pro/client/api/v1/base'
@@ -0,0 +1,91 @@
1
+ describe KnapsackPro::Config::CI::SnapCI do
2
+ let(:env) { {} }
3
+
4
+ before do
5
+ stub_const('ENV', env)
6
+ end
7
+
8
+ it { should be_kind_of KnapsackPro::Config::CI::Base }
9
+
10
+ describe '#node_total' do
11
+ subject { described_class.new.node_total }
12
+
13
+ context 'when environment exists' do
14
+ let(:env) { { 'SNAP_WORKER_TOTAL' => 4 } }
15
+ it { should eql 4 }
16
+ end
17
+
18
+ context "when environment doesn't exist" do
19
+ it { should be nil }
20
+ end
21
+ end
22
+
23
+ describe '#node_index' do
24
+ subject { described_class.new.node_index }
25
+
26
+ context 'when environment exists' do
27
+ let(:env) { { 'SNAP_WORKER_INDEX' => 4 } }
28
+ it { should eql 3 }
29
+ end
30
+
31
+ context "when environment doesn't exist" do
32
+ it { should be nil }
33
+ end
34
+ end
35
+
36
+ describe '#commit_hash' do
37
+ subject { described_class.new.commit_hash }
38
+
39
+ context 'when environment exists' do
40
+ let(:env) { { 'SNAP_COMMIT' => '3fa64859337f6e56409d49f865d13fd7' } }
41
+ it { should eql '3fa64859337f6e56409d49f865d13fd7' }
42
+ end
43
+
44
+ context "when environment doesn't exist" do
45
+ it { should be nil }
46
+ end
47
+ end
48
+
49
+ describe '#branch' do
50
+ subject { described_class.new.branch }
51
+
52
+ context 'when environment exists' do
53
+ context 'when branch present' do
54
+ let(:env) { { 'SNAP_BRANCH' => 'master' } }
55
+ it { should eql 'master' }
56
+ end
57
+
58
+ context 'when pull request' do
59
+ let(:env) { { 'SNAP_UPSTREAM_BRANCH' => 'feature-branch' } }
60
+ it { should eql 'feature-branch' }
61
+ end
62
+
63
+ context 'branch has higher priority' do
64
+ let(:env) do
65
+ {
66
+ 'SNAP_BRANCH' => 'master',
67
+ 'SNAP_UPSTREAM_BRANCH' => 'feature-branch'
68
+ }
69
+ end
70
+ it { should eql 'master' }
71
+ end
72
+ end
73
+
74
+ context "when environment doesn't exist" do
75
+ it { should be nil }
76
+ end
77
+ end
78
+
79
+ describe '#project_dir' do
80
+ subject { described_class.new.project_dir }
81
+
82
+ context 'when environment exists' do
83
+ let(:env) { { 'SNAP_WORKING_DIR' => '/var/snap-ci/repo' } }
84
+ it { should eql '/var/snap-ci/repo' }
85
+ end
86
+
87
+ context "when environment doesn't exist" do
88
+ it { should be nil }
89
+ end
90
+ end
91
+ 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.3.0
4
+ version: 0.4.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-17 00:00:00.000000000 Z
11
+ date: 2015-11-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -219,6 +219,7 @@ files:
219
219
  - lib/knapsack_pro/config/ci/buildkite.rb
220
220
  - lib/knapsack_pro/config/ci/circle.rb
221
221
  - lib/knapsack_pro/config/ci/semaphore.rb
222
+ - lib/knapsack_pro/config/ci/snap_ci.rb
222
223
  - lib/knapsack_pro/config/ci/travis.rb
223
224
  - lib/knapsack_pro/config/env.rb
224
225
  - lib/knapsack_pro/logger_wrapper.rb
@@ -264,6 +265,7 @@ files:
264
265
  - spec/knapsack_pro/config/ci/buildkite_spec.rb
265
266
  - spec/knapsack_pro/config/ci/circle_spec.rb
266
267
  - spec/knapsack_pro/config/ci/semaphore_spec.rb
268
+ - spec/knapsack_pro/config/ci/snap_ci_spec.rb
267
269
  - spec/knapsack_pro/config/ci/travis_spec.rb
268
270
  - spec/knapsack_pro/config/env_spec.rb
269
271
  - spec/knapsack_pro/logger_wrapper_spec.rb
@@ -343,6 +345,7 @@ test_files:
343
345
  - spec/knapsack_pro/config/ci/buildkite_spec.rb
344
346
  - spec/knapsack_pro/config/ci/circle_spec.rb
345
347
  - spec/knapsack_pro/config/ci/semaphore_spec.rb
348
+ - spec/knapsack_pro/config/ci/snap_ci_spec.rb
346
349
  - spec/knapsack_pro/config/ci/travis_spec.rb
347
350
  - spec/knapsack_pro/config/env_spec.rb
348
351
  - spec/knapsack_pro/logger_wrapper_spec.rb