knapsack_pro 1.12.0 → 1.12.1

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
  SHA256:
3
- metadata.gz: e9136de69ec2946c504045fcc1d87f265d0a72813ca9b08005822a1a3d1204f0
4
- data.tar.gz: 84e21fb2cd6a32b8cbdd08f2ca47d8f97613783e6d4aa08fa821c96c98b63cc9
3
+ metadata.gz: 74b370cb50a79631e4168dfbc8303ac3efdd5cfb0c34758f6bea4845757dcdbf
4
+ data.tar.gz: 25cba47e95daef7952743d604b6f48388cb39368deff071d570ec8fe5272c312
5
5
  SHA512:
6
- metadata.gz: 0bc36feebf7c2e4548fdece973557f7babe6ac31b0faf504d1e80fa99a4b472c324eed71b90eb4c2619cc785aca9251fe1124cd179d50e578220778475e9b154
7
- data.tar.gz: ecb801b9ad989c9106ccbc74aa421ac4a2fbbc164188eb80bd3a82fc5fdc191ee20365707041c00ffefbe6a6ac6635d6c2e278c3fb10261daa4c8a7c156f32e5
6
+ metadata.gz: 74a62e6902ee09d62d5290e815e870dda6abbdd47e1bfdb21bf6a5b95d9dc0625e017ec24704ee71c6760f3762bcd3c6e41338a985919cd8ca32b315fff5757e
7
+ data.tar.gz: 72e4cd22c704ae1f088b631c7ba5bf1d3f78cc85b8f300daff9b9cb01b09bb3f923c871d88b3ac8c2d6a1d89ea64911288b40e396f3a191b24bb1fbb962cdf54
data/CHANGELOG.md CHANGED
@@ -1,5 +1,14 @@
1
1
  # Change Log
2
2
 
3
+ ### 1.12.1
4
+
5
+ * Use `CI_PIPELINE_ID` as build ID for GitLab CI because it is unique across parallel jobs
6
+ * Load GitLab CI first to avoid edge case with order of loading envs for `CI_NODE_INDEX`
7
+
8
+ https://github.com/KnapsackPro/knapsack_pro-ruby/pull/88
9
+
10
+ https://github.com/KnapsackPro/knapsack_pro-ruby/compare/v1.12.0...v1.12.1
11
+
3
12
  ### 1.12.0
4
13
 
5
14
  * Add Queue Mode for Cucumber
data/README.md CHANGED
@@ -121,6 +121,7 @@ You can see list of questions for common problems and tips in below [Table of Co
121
121
  - [Why Capybara feature tests randomly fail when using CI parallelisation?](#why-capybara-feature-tests-randomly-fail-when-using-ci-parallelisation)
122
122
  - [Why knapsack_pro freezes / hangs my CI (for instance Travis)?](#why-knapsack_pro-freezes--hangs-my-ci-for-instance-travis)
123
123
  - [Why tests hitting external API fail?](#why-tests-hitting-external-api-fail)
124
+ - [Why green test suite for Cucumber 2.99 tests always fails with `invalid option: --require`?](#why-green-test-suite-for-cucumber-299-tests-always-fails-with-invalid-option---require)
124
125
  - [Queue Mode problems](#queue-mode-problems)
125
126
  - [Why when I use Queue Mode for RSpec then my tests fail?](#why-when-i-use-queue-mode-for-rspec-then-my-tests-fail)
126
127
  - [Why when I use Queue Mode for RSpec then FactoryBot/FactoryGirl tests fail?](#why-when-i-use-queue-mode-for-rspec-then-factorybotfactorygirl-tests-fail)
@@ -1459,6 +1460,48 @@ To fix that you can think of:
1459
1460
  * using [VCR](https://github.com/vcr/vcr) gem to record HTTP requests and then instead of doing real HTTP requests just reply recorded requests.
1460
1461
  * maybe you could write your tests in a way when you generate some fake customers or subscriptions with fake id and each test has different customer id so there will be no conflict when 2 tests are run at the same time.
1461
1462
 
1463
+ #### Why green test suite for Cucumber 2.99 tests always fails with `invalid option: --require`?
1464
+
1465
+ If you use old Cucumber version 2.99 and `cucumber-rails` gem you could notice bug that knapsack_pro for Cucumber fails with `1` exit status. Error you may see:
1466
+
1467
+ ```
1468
+ invalid option: --require
1469
+
1470
+ minitest options:
1471
+ -h, --help Display this help.
1472
+ --no-plugins Bypass minitest plugin auto-loading (or set $MT_NO_PLUGINS).
1473
+ -s, --seed SEED Sets random seed. Also via env. Eg: SEED=n rake
1474
+ -v, --verbose Verbose. Show progress processing files.
1475
+ -n, --name PATTERN Filter run on /regexp/ or string.
1476
+ --exclude PATTERN Exclude /regexp/ or string from run.
1477
+
1478
+ Known extensions: rails, pride
1479
+ -w, --warnings Run with Ruby warnings enabled
1480
+ -e, --environment ENV Run tests in the ENV environment
1481
+ -b, --backtrace Show the complete backtrace
1482
+ -d, --defer-output Output test failures and errors after the test run
1483
+ -f, --fail-fast Abort test run on first failure or error
1484
+ -c, --[no-]color Enable color in the output
1485
+ -p, --pride Pride. Show your testing pride!
1486
+
1487
+ # exit status is 1 - which means failed tests
1488
+ > echo $?
1489
+ 1
1490
+ ```
1491
+
1492
+ The root problem is that Rails add `minitest` gem and it is started when `cucumber/rails` is loaded. It should not be. You can fix it by adding below in file `features/support/env.rb`:
1493
+
1494
+ ```ruby
1495
+ # features/support/env.rb
1496
+ require 'cucumber/rails'
1497
+
1498
+ # this must be after we require cucumber/rails
1499
+ require 'multi_test'
1500
+ MultiTest.disable_autorun
1501
+ ```
1502
+
1503
+ The solution comes from: [cucumber/multi_test](https://github.com/cucumber/multi_test/pull/2#issuecomment-21863459)
1504
+
1462
1505
  #### Queue Mode problems
1463
1506
 
1464
1507
  ##### Why when I use Queue Mode for RSpec then my tests fail?
@@ -1601,8 +1644,8 @@ If you go to [user dashboard](https://knapsackpro.com/dashboard) and open `Build
1601
1644
 
1602
1645
  If you go to [user dashboard](https://knapsackpro.com/dashboard) and open `Build metrics` for your API token and you open CI build for your last git commit you should see there info about collected time execution data from all CI nodes. If you see all test files have 0.1s time execution then please ensure:
1603
1646
 
1604
- * you don't clean up `tmp` directory in your tests (for instance in RSpec hooks like `before` or `after`) so knapsack_pro can publish measured time execution data to Knapsack Pro API server. knapsack_pro Queue Mode saves temporary files with collected time execution data in `your_rails_project/tmp/knapsack_pro/queue/`.
1605
- * please ensure you have in your `rails_helper.rb` or `spec_helper.rb` line:
1647
+ * you should not clean up `tmp` directory in your tests (for instance in RSpec hooks like `before` or `after`) so knapsack_pro can publish measured time execution data to Knapsack Pro API server. knapsack_pro Queue Mode saves temporary files with collected time execution data in `your_rails_project/tmp/knapsack_pro/queue/`.
1648
+ * please ensure you have in your `rails_helper.rb` or `spec_helper.rb` line that allows to measure tests:
1606
1649
 
1607
1650
  ```ruby
1608
1651
  require 'knapsack_pro'
@@ -2547,6 +2590,30 @@ On the 3rd CI node, you can run other things like linters etc.
2547
2590
  If you would like to check what is the CI node total ENV variable name exposed by your CI provider you can check that in your CI provider environment variables docs
2548
2591
  or preview the [ENV variables that knapsack_pro can read](https://github.com/KnapsackPro/knapsack_pro-ruby/tree/master/lib/knapsack_pro/config/ci) for supported CI providers.
2549
2592
 
2593
+ If you use for instance Heroku CI that allows you to provide only one test command you can make a bash script to control what's executed on particular CI node:
2594
+
2595
+ ```bash
2596
+ #!/bin/bash
2597
+ # add this file in bin/knapsack_pro_rspec_and_npm_test and change chmod
2598
+ # $ chmod a+x bin/knapsack_pro_rspec_and_npm_test
2599
+
2600
+ # 15 is last CI node (index starts from 0, so in total we have 16 parallel Heroku dynos)
2601
+ if [ "$CI_NODE_TOTAL" == "15" ]; then
2602
+ # run npm tests on the last CI node
2603
+ npm test
2604
+ else
2605
+ KNAPSACK_PRO_CI_NODE_TOTAL=$((CI_NODE_TOTAL-1)) bundle exec rake knapsack_pro:queue:rspec
2606
+ fi
2607
+ ```
2608
+
2609
+ then in your Heroku CI config `app.json` set:
2610
+
2611
+ ```
2612
+ "scripts": {
2613
+ "test": "bin/knapsack_pro_rspec_and_npm_test"
2614
+ }
2615
+ ```
2616
+
2550
2617
  #### How to use CodeClimate with knapsack_pro?
2551
2618
 
2552
2619
  You can check articles about CodeClimate configuration with knapsack_pro gem:
data/knapsack_pro.gemspec CHANGED
@@ -27,7 +27,7 @@ Gem::Specification.new do |spec|
27
27
 
28
28
  spec.add_dependency 'rake', '>= 0'
29
29
 
30
- spec.add_development_dependency 'bundler', '~> 1.6'
30
+ spec.add_development_dependency 'bundler', '>= 1.6'
31
31
  spec.add_development_dependency 'rspec', '~> 3.0', '>= 2.10.0'
32
32
  spec.add_development_dependency 'rspec-its', '~> 1.2'
33
33
  spec.add_development_dependency 'cucumber', '>= 0'
@@ -15,7 +15,7 @@ module KnapsackPro
15
15
  end
16
16
 
17
17
  def node_build_id
18
- ENV['CI_JOB_ID'] || # Gitlab Release 9.0+
18
+ ENV['CI_PIPELINE_ID'] || # Gitlab Release 9.0+
19
19
  ENV['CI_BUILD_ID'] # Gitlab Release 8.x
20
20
  end
21
21
 
@@ -177,7 +177,9 @@ module KnapsackPro
177
177
 
178
178
  def ci_env_for(env_name)
179
179
  value = nil
180
- ci_list = KnapsackPro::Config::CI.constants - [:Base]
180
+ ci_list = KnapsackPro::Config::CI.constants - [:Base, :GitlabCI]
181
+ # load GitLab CI first to avoid edge case with order of loading envs for CI_NODE_INDEX
182
+ ci_list = [:GitlabCI] + ci_list
181
183
  ci_list.each do |ci_name|
182
184
  ci_class = Object.const_get("KnapsackPro::Config::CI::#{ci_name}")
183
185
  ci = ci_class.new
@@ -1,3 +1,3 @@
1
1
  module KnapsackPro
2
- VERSION = '1.12.0'
2
+ VERSION = '1.12.1'
3
3
  end
@@ -37,7 +37,7 @@ describe KnapsackPro::Config::CI::GitlabCI do
37
37
  subject { described_class.new.node_build_id }
38
38
 
39
39
  context 'when Gitlab Release 9.0+ and environment exists' do
40
- let(:env) { { 'CI_JOB_ID' => 7046507 } }
40
+ let(:env) { { 'CI_PIPELINE_ID' => 7046507 } }
41
41
  it { should eql 7046507 }
42
42
  end
43
43
 
@@ -40,6 +40,13 @@ describe KnapsackPro::Config::Env do
40
40
 
41
41
  it { should eq 2 }
42
42
  end
43
+
44
+ context 'when order of loading envs does matter' do
45
+ context 'when GitLab CI' do
46
+ before { stub_const("ENV", { 'CI_NODE_INDEX' => '2', 'GITLAB_CI' => 'true' }) }
47
+ it { should eq 1 }
48
+ end
49
+ end
43
50
  end
44
51
 
45
52
  context "when ENV doesn't exist" do
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: 1.12.0
4
+ version: 1.12.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - ArturT
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-06-07 00:00:00.000000000 Z
11
+ date: 2019-07-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -28,14 +28,14 @@ dependencies:
28
28
  name: bundler
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - "~>"
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
33
  version: '1.6'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - "~>"
38
+ - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: '1.6'
41
41
  - !ruby/object:Gem::Dependency