knapsack_pro 1.12.1 → 1.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 +8 -0
- data/README.md +37 -10
- data/lib/knapsack_pro/config/ci/semaphore2.rb +3 -2
- data/lib/knapsack_pro/version.rb +1 -1
- data/spec/knapsack_pro/config/ci/semaphore2_spec.rb +16 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c6b31c406c88ef954bb9a6d72f9ee4ba3a4245a98fd4ba4421fd3d22808e573c
|
4
|
+
data.tar.gz: a0990305e67b692e88b3f3136399c41e8330732868628d69873504c7f4020ae2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 811f24df9900bc81b942d9aba6f112e4bb523f19aa9d717711b071239cf36751559b3f56eaf99e0b9e1575bafcf499d595936a22dcca2e567f1995c984c2039c
|
7
|
+
data.tar.gz: fa4e5826771f41d4ed1b907d2045a1aab3a9bd3414a68ab7adcbf19fe82917b36bbbcfefdeb4cafd1fe468041dd507127aa05d0a36e955d0db35706ffa48c3e5
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,13 @@
|
|
1
1
|
# Change Log
|
2
2
|
|
3
|
+
### 1.13.0
|
4
|
+
|
5
|
+
* Add support for job index and job count for parallelism in Semaphore 2.0
|
6
|
+
|
7
|
+
https://github.com/KnapsackPro/knapsack_pro-ruby/pull/89
|
8
|
+
|
9
|
+
https://github.com/KnapsackPro/knapsack_pro-ruby/compare/v1.12.1...v1.13.0
|
10
|
+
|
3
11
|
### 1.12.1
|
4
12
|
|
5
13
|
* Use `CI_PIPELINE_ID` as build ID for GitLab CI because it is unique across parallel jobs
|
data/README.md
CHANGED
@@ -127,6 +127,7 @@ You can see list of questions for common problems and tips in below [Table of Co
|
|
127
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)
|
128
128
|
- [Why when I use Queue Mode for RSpec then my rake tasks are run twice?](#why-when-i-use-queue-mode-for-rspec-then-my-rake-tasks-are-run-twice)
|
129
129
|
- [Why when I use Queue Mode for RSpec then I see error `superclass mismatch for class`?](#why-when-i-use-queue-mode-for-rspec-then-i-see-error-superclass-mismatch-for-class)
|
130
|
+
- [Why when I use Queue Mode for RSpec then `.rspec` config is ignored?](#why-when-i-use-queue-mode-for-rspec-then-rspec-config-is-ignored)
|
130
131
|
- [Why I don't see collected time execution data for my build in user dashboard?](#why-i-dont-see-collected-time-execution-data-for-my-build-in-user-dashboard)
|
131
132
|
- [Why all test files have 0.1s time execution for my CI build in user dashboard?](#why-all-test-files-have-01s-time-execution-for-my-ci-build-in-user-dashboard)
|
132
133
|
- [Why when I use Queue Mode for RSpec and test fails then I see multiple times info about failed test in RSpec result?](#why-when-i-use-queue-mode-for-rspec-and-test-fails-then-i-see-multiple-times-info-about-failed-test-in-rspec-result)
|
@@ -904,9 +905,7 @@ More info about global and matrix ENV configuration in [travis docs](https://doc
|
|
904
905
|
knapsack_pro gem supports environment variables provided by Semaphore CI 2.0 to run your tests. You will have to define a few things in `.semaphore/semaphore.yml` config file.
|
905
906
|
|
906
907
|
* You need to set `KNAPSACK_PRO_TEST_SUITE_TOKEN_RSPEC`. If you don't want to commit secrets in yml file then you can [follow this guide](https://docs.semaphoreci.com/article/66-environment-variables-and-secrets).
|
907
|
-
* You
|
908
|
-
* If you have 2 parallel jobs you need to set `KNAPSACK_PRO_CI_NODE_TOTAL=2` for each job.
|
909
|
-
* You need to set job index starting from 0 like `KNAPSACK_PRO_CI_NODE_INDEX=0` for Node 0.
|
908
|
+
* You should create as many parallel jobs as you need with `parallelism` property. If your test suite is long you should use more parallel jobs.
|
910
909
|
|
911
910
|
Below you can find full Semaphore CI 2.0 config for Rails project.
|
912
911
|
|
@@ -985,13 +984,10 @@ blocks:
|
|
985
984
|
- bundle exec rake db:setup
|
986
985
|
|
987
986
|
jobs:
|
988
|
-
- name:
|
987
|
+
- name: Run tests with Knapsack Pro
|
988
|
+
parallelism: 2
|
989
989
|
commands:
|
990
|
-
|
991
|
-
|
992
|
-
- name: Node 1 - Knapsack Pro
|
993
|
-
commands:
|
994
|
-
- KNAPSACK_PRO_CI_NODE_TOTAL=2 KNAPSACK_PRO_CI_NODE_INDEX=1 bundle exec rake knapsack_pro:queue:rspec
|
990
|
+
- bundle exec rake knapsack_pro:queue:rspec
|
995
991
|
```
|
996
992
|
|
997
993
|
##### Semaphore 1.0
|
@@ -1058,6 +1054,27 @@ Here you can find article [how to set up a new pipeline for your project in Buil
|
|
1058
1054
|
|
1059
1055
|
If you want to use Buildkite retry single agent feature to retry just failed tests on particular agent (CI node) then you should set [`KNAPSACK_PRO_FIXED_QUEUE_SPLIT=true`](#knapsack_pro_fixed_queue_split-remember-queue-split-on-retry-ci-node).
|
1060
1056
|
|
1057
|
+
When using the `docker-compose` plugin on Buildkite, you have to tell it which environment variables to pass to the docker container. Thanks to it knapsack_pro can detect info about CI build like commit, branch name, amount of parallel nodes.
|
1058
|
+
|
1059
|
+
```yaml
|
1060
|
+
steps:
|
1061
|
+
- label: "Test"
|
1062
|
+
parallelism: 2
|
1063
|
+
plugins:
|
1064
|
+
- docker-compose#3.0.3:
|
1065
|
+
run: app
|
1066
|
+
# use here proper knapsack_pro command for your test runner
|
1067
|
+
command: bundle exec rake knapsack_pro:queue:rspec
|
1068
|
+
config: docker-compose.test.yml
|
1069
|
+
env:
|
1070
|
+
- BUILDKITE_PARALLEL_JOB_COUNT
|
1071
|
+
- BUILDKITE_PARALLEL_JOB
|
1072
|
+
- BUILDKITE_BUILD_NUMBER
|
1073
|
+
- BUILDKITE_COMMIT
|
1074
|
+
- BUILDKITE_BRANCH
|
1075
|
+
- BUILDKITE_BUILD_CHECKOUT_PATH
|
1076
|
+
```
|
1077
|
+
|
1061
1078
|
#### Info for GitLab CI users
|
1062
1079
|
|
1063
1080
|
Remember to add API tokens like `KNAPSACK_PRO_TEST_SUITE_TOKEN_CUCUMBER` and `KNAPSACK_PRO_TEST_SUITE_TOKEN_RSPEC` to [Secret Variables](https://gitlab.com/help/ci/variables/README.md#secret-variables) in `GitLab CI Settings -> CI/CD Pipelines -> Secret Variables`.
|
@@ -1632,6 +1649,16 @@ end
|
|
1632
1649
|
|
1633
1650
|
Instead of mocking like shown above you could use [RSpec stub_const](https://relishapp.com/rspec/rspec-mocks/docs/mutating-constants) to solve error `superclass mismatch for class BatchClass`.
|
1634
1651
|
|
1652
|
+
##### Why when I use Queue Mode for RSpec then `.rspec` config is ignored?
|
1653
|
+
|
1654
|
+
The `.rspec` config file is ignored in Queue Mode because knapsack_pro has to pass explicitly arguments to `RSpec::Core::Runner` underhood. You can set your arguments from `.rspec` file in an inline way.
|
1655
|
+
|
1656
|
+
```
|
1657
|
+
bundle exec rake "knapsack_pro:queue:rspec[--format documentation --require rails_helper]"
|
1658
|
+
```
|
1659
|
+
|
1660
|
+
See [passing arguments to RSpec](#passing-arguments-to-rspec).
|
1661
|
+
|
1635
1662
|
##### Why I don't see collected time execution data for my build in user dashboard?
|
1636
1663
|
|
1637
1664
|
If you go to [user dashboard](https://knapsackpro.com/dashboard) and open `Build metrics` for your API token and you open build for your last git commit you should see there info about collected time execution data from all CI nodes. If you don't see collected time execution data for CI nodes then please ensure:
|
@@ -2691,7 +2718,7 @@ Regarding payments we use the BraintreePayments.com and they store credit cards
|
|
2691
2718
|
|
2692
2719
|
I’m the only admin so I can preview data in case you need help with debugging some problem etc. I’m not able to decrypt them without knowing the salt.
|
2693
2720
|
|
2694
|
-
When you sign in to your user dashboard then you can preview data for recent
|
2721
|
+
When you sign in to your user dashboard then you can preview data for recent CI builds. If the test file paths are encrypted then you only see hashes for test file paths.
|
2695
2722
|
You need to [decrypt](#how-to-debug-test-file-names) them locally on your machine to find out what each test file hash is.
|
2696
2723
|
|
2697
2724
|
## Gem tests
|
@@ -4,11 +4,12 @@ module KnapsackPro
|
|
4
4
|
module CI
|
5
5
|
class Semaphore2 < Base
|
6
6
|
def node_total
|
7
|
-
|
7
|
+
ENV['SEMAPHORE_JOB_COUNT']
|
8
8
|
end
|
9
9
|
|
10
10
|
def node_index
|
11
|
-
|
11
|
+
index = ENV['SEMAPHORE_JOB_INDEX']
|
12
|
+
index.to_i - 1 if index
|
12
13
|
end
|
13
14
|
|
14
15
|
def node_build_id
|
data/lib/knapsack_pro/version.rb
CHANGED
@@ -10,13 +10,27 @@ describe KnapsackPro::Config::CI::Semaphore2 do
|
|
10
10
|
describe '#node_total' do
|
11
11
|
subject { described_class.new.node_total }
|
12
12
|
|
13
|
-
|
13
|
+
context 'when environment exists' do
|
14
|
+
let(:env) { { 'SEMAPHORE_JOB_COUNT' => 4 } }
|
15
|
+
it { should eql 4 }
|
16
|
+
end
|
17
|
+
|
18
|
+
context "when environment doesn't exist" do
|
19
|
+
it { should be nil }
|
20
|
+
end
|
14
21
|
end
|
15
22
|
|
16
23
|
describe '#node_index' do
|
17
24
|
subject { described_class.new.node_index }
|
18
25
|
|
19
|
-
|
26
|
+
context 'when environment exists' do
|
27
|
+
let(:env) { { 'SEMAPHORE_JOB_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
|
20
34
|
end
|
21
35
|
|
22
36
|
describe '#node_build_id' 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.
|
4
|
+
version: 1.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: 2019-
|
11
|
+
date: 2019-08-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|