knapsack_pro 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +8 -0
- data/README.md +30 -28
- data/lib/knapsack_pro.rb +1 -0
- data/lib/knapsack_pro/config/ci/travis.rb +19 -0
- data/lib/knapsack_pro/version.rb +1 -1
- data/spec/knapsack_pro/config/ci/travis_spec.rb +60 -0
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b300b67986e3d1f899db86baa3c750e3c1984b6e
|
4
|
+
data.tar.gz: 537267adfaaeacf16890fb3ef30bde398aa82d04
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 111b2b41ddec465bec5a5769427f3dacd8deb6309c9efc32e5ee43dd567e582824d78095832befcb0e73dcd4466d11a5a50fc20261f4e45c6055b1ee03ecc3b3
|
7
|
+
data.tar.gz: f43acacaca9c57986df0b64cdd2ad5995ad362f5ceeeab160224969ce9a8a3175c7c2457d39d49a58f3ede018d1e3e37e6143b2f0b1ceab75e3073d874e2001f
|
data/CHANGELOG.md
CHANGED
@@ -2,6 +2,14 @@
|
|
2
2
|
|
3
3
|
* TODO
|
4
4
|
|
5
|
+
### 0.1.2
|
6
|
+
|
7
|
+
* Fix Travis CI environment variables support
|
8
|
+
|
9
|
+
https://github.com/KnapsackPro/knapsack_pro-ruby/pull/1
|
10
|
+
|
11
|
+
https://github.com/KnapsackPro/knapsack_pro-ruby/compare/v0.1.1...v0.1.2
|
12
|
+
|
5
13
|
### 0.1.1
|
6
14
|
|
7
15
|
* Make knapsack_pro backwards compatible with earlier version of minitest
|
data/README.md
CHANGED
@@ -36,7 +36,7 @@ For instance when you will run tests with rake knapsack_pro:rspec then:
|
|
36
36
|
|
37
37
|
# Requirements
|
38
38
|
|
39
|
-
* >= Ruby 2.
|
39
|
+
* >= Ruby 2.1 (because gem uses required keyword arguments in ruby)
|
40
40
|
|
41
41
|
# Table of Contents
|
42
42
|
|
@@ -57,6 +57,8 @@ For instance when you will run tests with rake knapsack_pro:rspec then:
|
|
57
57
|
- [Extra configuration for CI server](#extra-configuration-for-ci-server)
|
58
58
|
- [Info about ENV variables](#info-about-env-variables)
|
59
59
|
- [Repository adapter](#repository-adapter)
|
60
|
+
- [When you set global variable `KNAPSACK_PRO_REPOSITORY_ADAPTER=git` (optional)](#when-you-set-global-variable-knapsack_pro_repository_adaptergit-optional)
|
61
|
+
- [When you NOT set global variable `KNAPSACK_PRO_REPOSITORY_ADAPTER` (default)](#when-you-not-set-global-variable-knapsack_pro_repository_adapter-default)
|
60
62
|
- [Environment variables for debugging gem](#environment-variables-for-debugging-gem)
|
61
63
|
- [Passing arguments to rake task](#passing-arguments-to-rake-task)
|
62
64
|
- [Passing arguments to rspec](#passing-arguments-to-rspec)
|
@@ -202,15 +204,20 @@ In case when you use other CI provider for instance [Jenkins](https://jenkins-ci
|
|
202
204
|
|
203
205
|
#### Repository adapter
|
204
206
|
|
205
|
-
|
206
|
-
|
207
|
+
##### When you set global variable `KNAPSACK_PRO_REPOSITORY_ADAPTER=git` (optional)
|
208
|
+
|
209
|
+
`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 and commit hash. You need to set also `KNAPSACK_PRO_PROJECT_DIR` with project directory path.
|
210
|
+
|
211
|
+
`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.
|
212
|
+
|
213
|
+
##### When you NOT set global variable `KNAPSACK_PRO_REPOSITORY_ADAPTER` (default)
|
214
|
+
|
215
|
+
By default `KNAPSACK_PRO_REPOSITORY_ADAPTER` variable has no value so knapsack_pro will try to get info about branch name and commit hash 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
216
|
|
208
217
|
`KNAPSACK_PRO_BRANCH` - It's branch name. You run tests on this branch.
|
209
218
|
|
210
219
|
`KNAPSACK_PRO_COMMIT_HASH` - Commit hash. You run tests for this commit.
|
211
220
|
|
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
221
|
#### Environment variables for debugging gem
|
215
222
|
|
216
223
|
`KNAPSACK_PRO_ENDPOINT` - Default value is `http://api.knapsackpro.com` which is endpoint for [Knapsack Pro API](http://docs.knapsackpro.com).
|
@@ -259,11 +266,17 @@ This is optional way of using knapsack_pro when you don't want to add it to `Gem
|
|
259
266
|
|
260
267
|
#### Info for CircleCI users
|
261
268
|
|
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 `
|
269
|
+
If you are using circleci.com you can omit `KNAPSACK_PRO_CI_NODE_TOTAL` and `KNAPSACK_PRO_CI_NODE_INDEX`. Knapsack Pro will use `CIRCLE_NODE_TOTAL` and `CIRCLE_NODE_INDEX` provided by CircleCI.
|
263
270
|
|
264
271
|
Here is an example for test configuration in your `circleci.yml` file.
|
265
272
|
|
266
273
|
```yaml
|
274
|
+
machine:
|
275
|
+
environment:
|
276
|
+
# Tokens should be set in CircleCI settings to avoid expose tokens in build logs
|
277
|
+
# KNAPSACK_PRO_TEST_SUITE_TOKEN_RSPEC: rspec-token
|
278
|
+
# KNAPSACK_PRO_TEST_SUITE_TOKEN_CUCUMBER: cucumber-token
|
279
|
+
# KNAPSACK_PRO_TEST_SUITE_TOKEN_MINITEST: minitest-token
|
267
280
|
test:
|
268
281
|
override:
|
269
282
|
# Step for RSpec
|
@@ -285,24 +298,6 @@ Please remember to add additional containers for your project in CircleCI settin
|
|
285
298
|
|
286
299
|
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
300
|
|
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
301
|
```yaml
|
307
302
|
script:
|
308
303
|
# Step for RSpec
|
@@ -316,8 +311,11 @@ script:
|
|
316
311
|
|
317
312
|
env:
|
318
313
|
global:
|
319
|
-
|
320
|
-
-
|
314
|
+
# tokens should be set in travis settings in web interface to avoid expose tokens in build logs
|
315
|
+
- KNAPSACK_PRO_TEST_SUITE_TOKEN_RSPEC=rspec-token
|
316
|
+
- KNAPSACK_PRO_TEST_SUITE_TOKEN_CUCUMBER=cucumber-token
|
317
|
+
- KNAPSACK_PRO_TEST_SUITE_TOKEN_MINITEST=minitest-token
|
318
|
+
|
321
319
|
- KNAPSACK_PRO_CI_NODE_TOTAL=2
|
322
320
|
matrix:
|
323
321
|
- KNAPSACK_PRO_CI_NODE_INDEX=0
|
@@ -326,8 +324,8 @@ env:
|
|
326
324
|
|
327
325
|
Such configuration will generate matrix with 2 following ENV rows:
|
328
326
|
|
329
|
-
KNAPSACK_PRO_CI_NODE_TOTAL=2 KNAPSACK_PRO_CI_NODE_INDEX=0
|
330
|
-
KNAPSACK_PRO_CI_NODE_TOTAL=2 KNAPSACK_PRO_CI_NODE_INDEX=1
|
327
|
+
KNAPSACK_PRO_CI_NODE_TOTAL=2 KNAPSACK_PRO_CI_NODE_INDEX=0 KNAPSACK_PRO_TEST_SUITE_TOKEN_RSPEC=rspec-token KNAPSACK_PRO_TEST_SUITE_TOKEN_CUCUMBER=cucumber-token KNAPSACK_PRO_TEST_SUITE_TOKEN_MINITEST=minitest-token
|
328
|
+
KNAPSACK_PRO_CI_NODE_TOTAL=2 KNAPSACK_PRO_CI_NODE_INDEX=1 KNAPSACK_PRO_TEST_SUITE_TOKEN_RSPEC=rspec-token KNAPSACK_PRO_TEST_SUITE_TOKEN_CUCUMBER=cucumber-token KNAPSACK_PRO_TEST_SUITE_TOKEN_MINITEST=minitest-token
|
331
329
|
|
332
330
|
More info about global and matrix ENV configuration in [travis docs](http://docs.travis-ci.com/user/build-configuration/#Environment-variables).
|
333
331
|
|
@@ -353,6 +351,8 @@ Knapsack Pro supports semaphoreapp ENVs `SEMAPHORE_THREAD_COUNT` and `SEMAPHORE_
|
|
353
351
|
|
354
352
|
Tests will be split across threads.
|
355
353
|
|
354
|
+
Please remember to set up token like `KNAPSACK_PRO_TEST_SUITE_TOKEN_RSPEC` as global environment.
|
355
|
+
|
356
356
|
#### Info for buildkite.com users
|
357
357
|
|
358
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
|
@@ -366,6 +366,8 @@ Knapsack Pro supports buildkite ENVs `BUILDKITE_PARALLEL_JOB_COUNT` and `BUILDKI
|
|
366
366
|
# Step for Minitest
|
367
367
|
bundle exec rake knapsack_pro:minitest
|
368
368
|
|
369
|
+
Please remember to set up token like `KNAPSACK_PRO_TEST_SUITE_TOKEN_RSPEC` as global environment.
|
370
|
+
|
369
371
|
## Gem tests
|
370
372
|
|
371
373
|
### Spec
|
data/lib/knapsack_pro.rb
CHANGED
@@ -12,6 +12,7 @@ require_relative 'knapsack_pro/config/ci/base'
|
|
12
12
|
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
|
+
require_relative 'knapsack_pro/config/ci/travis'
|
15
16
|
require_relative 'knapsack_pro/config/env'
|
16
17
|
require_relative 'knapsack_pro/client/api/action'
|
17
18
|
require_relative 'knapsack_pro/client/api/v1/base'
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module KnapsackPro
|
2
|
+
module Config
|
3
|
+
module CI
|
4
|
+
class Travis < Base
|
5
|
+
def commit_hash
|
6
|
+
ENV['TRAVIS_COMMIT']
|
7
|
+
end
|
8
|
+
|
9
|
+
def branch
|
10
|
+
ENV['TRAVIS_BRANCH']
|
11
|
+
end
|
12
|
+
|
13
|
+
def project_dir
|
14
|
+
ENV['TRAVIS_BUILD_DIR']
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
data/lib/knapsack_pro/version.rb
CHANGED
@@ -0,0 +1,60 @@
|
|
1
|
+
describe KnapsackPro::Config::CI::Travis 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
|
+
it { should be nil }
|
14
|
+
end
|
15
|
+
|
16
|
+
describe '#node_index' do
|
17
|
+
subject { described_class.new.node_index }
|
18
|
+
|
19
|
+
it { should be nil }
|
20
|
+
end
|
21
|
+
|
22
|
+
describe '#commit_hash' do
|
23
|
+
subject { described_class.new.commit_hash }
|
24
|
+
|
25
|
+
context 'when environment exists' do
|
26
|
+
let(:env) { { 'TRAVIS_COMMIT' => '3fa64859337f6e56409d49f865d13fd7' } }
|
27
|
+
it { should eql '3fa64859337f6e56409d49f865d13fd7' }
|
28
|
+
end
|
29
|
+
|
30
|
+
context "when environment doesn't exist" do
|
31
|
+
it { should be nil }
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
describe '#branch' do
|
36
|
+
subject { described_class.new.branch }
|
37
|
+
|
38
|
+
context 'when environment exists' do
|
39
|
+
let(:env) { { 'TRAVIS_BRANCH' => 'master' } }
|
40
|
+
it { should eql 'master' }
|
41
|
+
end
|
42
|
+
|
43
|
+
context "when environment doesn't exist" do
|
44
|
+
it { should be nil }
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
describe '#project_dir' do
|
49
|
+
subject { described_class.new.project_dir }
|
50
|
+
|
51
|
+
context 'when environment exists' do
|
52
|
+
let(:env) { { 'TRAVIS_BUILD_DIR' => '/home/travis/build/KnapsackPro/rails-app-with-knapsack_pro' } }
|
53
|
+
it { should eql '/home/travis/build/KnapsackPro/rails-app-with-knapsack_pro' }
|
54
|
+
end
|
55
|
+
|
56
|
+
context "when environment doesn't exist" do
|
57
|
+
it { should be nil }
|
58
|
+
end
|
59
|
+
end
|
60
|
+
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.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- ArturT
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-10-
|
11
|
+
date: 2015-10-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/travis.rb
|
222
223
|
- lib/knapsack_pro/config/env.rb
|
223
224
|
- lib/knapsack_pro/logger_wrapper.rb
|
224
225
|
- lib/knapsack_pro/presenter.rb
|
@@ -263,6 +264,7 @@ files:
|
|
263
264
|
- spec/knapsack_pro/config/ci/buildkite_spec.rb
|
264
265
|
- spec/knapsack_pro/config/ci/circle_spec.rb
|
265
266
|
- spec/knapsack_pro/config/ci/semaphore_spec.rb
|
267
|
+
- spec/knapsack_pro/config/ci/travis_spec.rb
|
266
268
|
- spec/knapsack_pro/config/env_spec.rb
|
267
269
|
- spec/knapsack_pro/logger_wrapper_spec.rb
|
268
270
|
- spec/knapsack_pro/presenter_spec.rb
|
@@ -341,6 +343,7 @@ test_files:
|
|
341
343
|
- spec/knapsack_pro/config/ci/buildkite_spec.rb
|
342
344
|
- spec/knapsack_pro/config/ci/circle_spec.rb
|
343
345
|
- spec/knapsack_pro/config/ci/semaphore_spec.rb
|
346
|
+
- spec/knapsack_pro/config/ci/travis_spec.rb
|
344
347
|
- spec/knapsack_pro/config/env_spec.rb
|
345
348
|
- spec/knapsack_pro/logger_wrapper_spec.rb
|
346
349
|
- spec/knapsack_pro/presenter_spec.rb
|