knapsack_pro 3.10.0 → 4.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
 - data/CHANGELOG.md +16 -0
 - data/lib/knapsack_pro/client/api/v1/build_distributions.rb +1 -0
 - data/lib/knapsack_pro/client/api/v1/queues.rb +1 -0
 - data/lib/knapsack_pro/config/ci/base.rb +3 -0
 - data/lib/knapsack_pro/config/ci/buildkite.rb +4 -0
 - data/lib/knapsack_pro/config/ci/circle.rb +4 -0
 - data/lib/knapsack_pro/config/ci/github_actions.rb +4 -0
 - data/lib/knapsack_pro/config/ci/gitlab_ci.rb +6 -1
 - data/lib/knapsack_pro/config/env.rb +13 -2
 - data/lib/knapsack_pro/urls.rb +2 -0
 - data/lib/knapsack_pro/version.rb +1 -1
 - data/spec/integration/api/build_distributions_subset_spec.rb +1 -0
 - data/spec/knapsack_pro/client/api/v1/build_distributions_spec.rb +4 -0
 - data/spec/knapsack_pro/client/api/v1/queues_spec.rb +5 -0
 - data/spec/knapsack_pro/config/ci/base_spec.rb +1 -0
 - data/spec/knapsack_pro/config/ci/buildkite_spec.rb +37 -2
 - data/spec/knapsack_pro/config/ci/circle_spec.rb +37 -2
 - data/spec/knapsack_pro/config/ci/github_actions_spec.rb +16 -2
 - data/spec/knapsack_pro/config/ci/gitlab_ci_spec.rb +39 -4
 - data/spec/knapsack_pro/config/env_spec.rb +49 -2
 - metadata +3 -3
 
    
        checksums.yaml
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            ---
         
     | 
| 
       2 
2 
     | 
    
         
             
            SHA256:
         
     | 
| 
       3 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       4 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: 290f2d4d36346c2b4d87ccd475600a2fe68b61ed92f0f4c5e3d706321274482c
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: c363a381f9b18c4f8c8449cfe0477c7c6b987c6a356865d1fcdb34849168674b
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: cd0e5c7dbe72f032c6eaa0399bef86a944781adaacb894f3165f4b34720c2bf79cbf7f6f4b316c179ea91fd6f344a653e1441fd02d4e6d4d316e432c301374e9
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: 8f921a5501043c19f52069c4325062102dab01b0cd3ca89657093e4083fe736e6e1d2962fa6beb3c9d0f657d3d05873a7d261a706ad2531eff9edcb9c7163f00
         
     | 
    
        data/CHANGELOG.md
    CHANGED
    
    | 
         @@ -1,5 +1,21 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            # Change Log
         
     | 
| 
       2 
2 
     | 
    
         | 
| 
      
 3 
     | 
    
         
            +
            ### 4.0.0
         
     | 
| 
      
 4 
     | 
    
         
            +
             
     | 
| 
      
 5 
     | 
    
         
            +
            * Raise when `KNAPSACK_PRO_CI_NODE_BUILD_ID` is missing
         
     | 
| 
      
 6 
     | 
    
         
            +
             
     | 
| 
      
 7 
     | 
    
         
            +
                https://github.com/KnapsackPro/knapsack_pro-ruby/pull/195
         
     | 
| 
      
 8 
     | 
    
         
            +
             
     | 
| 
      
 9 
     | 
    
         
            +
            https://github.com/KnapsackPro/knapsack_pro-ruby/compare/v3.11.0...v4.0.0
         
     | 
| 
      
 10 
     | 
    
         
            +
             
     | 
| 
      
 11 
     | 
    
         
            +
            ### 3.11.0
         
     | 
| 
      
 12 
     | 
    
         
            +
             
     | 
| 
      
 13 
     | 
    
         
            +
            * Send distinguishable user seat info over to the API
         
     | 
| 
      
 14 
     | 
    
         
            +
             
     | 
| 
      
 15 
     | 
    
         
            +
                https://github.com/KnapsackPro/knapsack_pro-ruby/pull/192
         
     | 
| 
      
 16 
     | 
    
         
            +
             
     | 
| 
      
 17 
     | 
    
         
            +
            https://github.com/KnapsackPro/knapsack_pro-ruby/compare/v3.10.0...v3.11.0
         
     | 
| 
      
 18 
     | 
    
         
            +
             
     | 
| 
       3 
19 
     | 
    
         
             
            ### 3.10.0
         
     | 
| 
       4 
20 
     | 
    
         | 
| 
       5 
21 
     | 
    
         
             
            * Remove Solano CI and Snap CI support because they do not exist anymore
         
     | 
| 
         @@ -15,6 +15,7 @@ module KnapsackPro 
     | 
|
| 
       15 
15 
     | 
    
         
             
                            :node_total => args.fetch(:node_total),
         
     | 
| 
       16 
16 
     | 
    
         
             
                            :node_index => args.fetch(:node_index),
         
     | 
| 
       17 
17 
     | 
    
         
             
                            :ci_build_id => KnapsackPro::Config::Env.ci_node_build_id,
         
     | 
| 
      
 18 
     | 
    
         
            +
                            :user_seat => KnapsackPro::Config::Env.user_seat_hash,
         
     | 
| 
       18 
19 
     | 
    
         
             
                          }
         
     | 
| 
       19 
20 
     | 
    
         | 
| 
       20 
21 
     | 
    
         
             
                          unless request_hash[:cache_read_attempt]
         
     | 
| 
         @@ -16,6 +16,7 @@ module KnapsackPro 
     | 
|
| 
       16 
16 
     | 
    
         
             
                            :node_total => args.fetch(:node_total),
         
     | 
| 
       17 
17 
     | 
    
         
             
                            :node_index => args.fetch(:node_index),
         
     | 
| 
       18 
18 
     | 
    
         
             
                            :node_build_id => KnapsackPro::Config::Env.ci_node_build_id,
         
     | 
| 
      
 19 
     | 
    
         
            +
                            :user_seat => KnapsackPro::Config::Env.user_seat_hash,
         
     | 
| 
       19 
20 
     | 
    
         
             
                          }
         
     | 
| 
       20 
21 
     | 
    
         | 
| 
       21 
22 
     | 
    
         
             
                          if request_hash[:can_initialize_queue] && !request_hash[:attempt_connect_to_queue]
         
     | 
| 
         @@ -16,7 +16,7 @@ module KnapsackPro 
     | 
|
| 
       16 
16 
     | 
    
         | 
| 
       17 
17 
     | 
    
         
             
                    def node_build_id
         
     | 
| 
       18 
18 
     | 
    
         
             
                      ENV['CI_PIPELINE_ID'] || # Gitlab Release 9.0+
         
     | 
| 
       19 
     | 
    
         
            -
                      ENV['CI_BUILD_ID'] 
     | 
| 
      
 19 
     | 
    
         
            +
                      ENV['CI_BUILD_ID'] # Gitlab Release 8.x
         
     | 
| 
       20 
20 
     | 
    
         
             
                    end
         
     | 
| 
       21 
21 
     | 
    
         | 
| 
       22 
22 
     | 
    
         
             
                    def commit_hash
         
     | 
| 
         @@ -32,6 +32,11 @@ module KnapsackPro 
     | 
|
| 
       32 
32 
     | 
    
         
             
                    def project_dir
         
     | 
| 
       33 
33 
     | 
    
         
             
                      ENV['CI_PROJECT_DIR']
         
     | 
| 
       34 
34 
     | 
    
         
             
                    end
         
     | 
| 
      
 35 
     | 
    
         
            +
             
     | 
| 
      
 36 
     | 
    
         
            +
                    def user_seat
         
     | 
| 
      
 37 
     | 
    
         
            +
                      ENV['GITLAB_USER_NAME'] || # Gitlab Release 10.0
         
     | 
| 
      
 38 
     | 
    
         
            +
                      ENV['GITLAB_USER_EMAIL'] # Gitlab Release 8.12
         
     | 
| 
      
 39 
     | 
    
         
            +
                    end
         
     | 
| 
       35 
40 
     | 
    
         
             
                  end
         
     | 
| 
       36 
41 
     | 
    
         
             
                end
         
     | 
| 
       37 
42 
     | 
    
         
             
              end
         
     | 
| 
         @@ -23,9 +23,10 @@ module KnapsackPro 
     | 
|
| 
       23 
23 
     | 
    
         
             
                    end
         
     | 
| 
       24 
24 
     | 
    
         | 
| 
       25 
25 
     | 
    
         
             
                    def ci_node_build_id
         
     | 
| 
       26 
     | 
    
         
            -
                       
     | 
| 
      
 26 
     | 
    
         
            +
                      env_name = 'KNAPSACK_PRO_CI_NODE_BUILD_ID'
         
     | 
| 
      
 27 
     | 
    
         
            +
                      ENV[env_name] ||
         
     | 
| 
       27 
28 
     | 
    
         
             
                        ci_env_for(:node_build_id) ||
         
     | 
| 
       28 
     | 
    
         
            -
                         
     | 
| 
      
 29 
     | 
    
         
            +
                        raise("Missing environment variable #{env_name}. Read more at #{KnapsackPro::Urls::KNAPSACK_PRO_CI_NODE_BUILD_ID}")
         
     | 
| 
       29 
30 
     | 
    
         
             
                    end
         
     | 
| 
       30 
31 
     | 
    
         | 
| 
       31 
32 
     | 
    
         
             
                    def ci_node_retry_count
         
     | 
| 
         @@ -58,6 +59,16 @@ module KnapsackPro 
     | 
|
| 
       58 
59 
     | 
    
         
             
                        ci_env_for(:project_dir)
         
     | 
| 
       59 
60 
     | 
    
         
             
                    end
         
     | 
| 
       60 
61 
     | 
    
         | 
| 
      
 62 
     | 
    
         
            +
                    def user_seat
         
     | 
| 
      
 63 
     | 
    
         
            +
                      ENV['KNAPSACK_PRO_USER_SEAT'] ||
         
     | 
| 
      
 64 
     | 
    
         
            +
                        ci_env_for(:user_seat)
         
     | 
| 
      
 65 
     | 
    
         
            +
                    end
         
     | 
| 
      
 66 
     | 
    
         
            +
             
     | 
| 
      
 67 
     | 
    
         
            +
                    def user_seat_hash
         
     | 
| 
      
 68 
     | 
    
         
            +
                      return unless user_seat
         
     | 
| 
      
 69 
     | 
    
         
            +
                      Digest::SHA2.hexdigest(user_seat)
         
     | 
| 
      
 70 
     | 
    
         
            +
                    end
         
     | 
| 
      
 71 
     | 
    
         
            +
             
     | 
| 
       61 
72 
     | 
    
         
             
                    def test_file_pattern
         
     | 
| 
       62 
73 
     | 
    
         
             
                      ENV['KNAPSACK_PRO_TEST_FILE_PATTERN']
         
     | 
| 
       63 
74 
     | 
    
         
             
                    end
         
     | 
    
        data/lib/knapsack_pro/urls.rb
    CHANGED
    
    | 
         @@ -18,6 +18,8 @@ module KnapsackPro 
     | 
|
| 
       18 
18 
     | 
    
         | 
| 
       19 
19 
     | 
    
         
             
                INSTALLATION_GUIDE = "#{HOST}/perma/ruby/installation-guide"
         
     | 
| 
       20 
20 
     | 
    
         | 
| 
      
 21 
     | 
    
         
            +
                KNAPSACK_PRO_CI_NODE_BUILD_ID= "#{HOST}/perma/ruby/knapsack-pro-ci-node-build-id"
         
     | 
| 
      
 22 
     | 
    
         
            +
             
     | 
| 
       21 
23 
     | 
    
         
             
                QUEUE_MODE__CONNECTION_ERROR_WITH_FALLBACK_ENABLED_FALSE = "#{HOST}/perma/ruby/queue-mode-connection-error-with-fallback-enabled-false"
         
     | 
| 
       22 
24 
     | 
    
         | 
| 
       23 
25 
     | 
    
         
             
                QUEUE_MODE__CONNECTION_ERROR_WITH_FALLBACK_ENABLED_TRUE_AND_POSITIVE_RETRY_COUNT = "#{HOST}/perma/ruby/queue-mode-connection-error-with-fallback-enabled-true-and-positive-retry-count"
         
     | 
    
        data/lib/knapsack_pro/version.rb
    CHANGED
    
    
| 
         @@ -6,6 +6,7 @@ describe KnapsackPro::Client::API::V1::BuildDistributions do 
     | 
|
| 
       6 
6 
     | 
    
         
             
                let(:node_total) { double }
         
     | 
| 
       7 
7 
     | 
    
         
             
                let(:node_index) { double }
         
     | 
| 
       8 
8 
     | 
    
         
             
                let(:ci_build_id) { double }
         
     | 
| 
      
 9 
     | 
    
         
            +
                let(:user_seat_hash) { double }
         
     | 
| 
       9 
10 
     | 
    
         
             
                let(:test_files) { double }
         
     | 
| 
       10 
11 
     | 
    
         | 
| 
       11 
12 
     | 
    
         
             
                subject do
         
     | 
| 
         @@ -22,6 +23,7 @@ describe KnapsackPro::Client::API::V1::BuildDistributions do 
     | 
|
| 
       22 
23 
     | 
    
         
             
                before do
         
     | 
| 
       23 
24 
     | 
    
         
             
                  expect(KnapsackPro::Config::Env).to receive(:fixed_test_suite_split).and_return(fixed_test_suite_split)
         
     | 
| 
       24 
25 
     | 
    
         
             
                  expect(KnapsackPro::Config::Env).to receive(:ci_node_build_id).and_return(ci_build_id)
         
     | 
| 
      
 26 
     | 
    
         
            +
                  expect(KnapsackPro::Config::Env).to receive(:user_seat_hash).and_return(user_seat_hash)
         
     | 
| 
       25 
27 
     | 
    
         
             
                end
         
     | 
| 
       26 
28 
     | 
    
         | 
| 
       27 
29 
     | 
    
         
             
                context 'when cache_read_attempt=true' do
         
     | 
| 
         @@ -40,6 +42,7 @@ describe KnapsackPro::Client::API::V1::BuildDistributions do 
     | 
|
| 
       40 
42 
     | 
    
         
             
                        node_total: node_total,
         
     | 
| 
       41 
43 
     | 
    
         
             
                        node_index: node_index,
         
     | 
| 
       42 
44 
     | 
    
         
             
                        ci_build_id: ci_build_id,
         
     | 
| 
      
 45 
     | 
    
         
            +
                        user_seat: user_seat_hash,
         
     | 
| 
       43 
46 
     | 
    
         
             
                      }
         
     | 
| 
       44 
47 
     | 
    
         
             
                    }).and_return(action)
         
     | 
| 
       45 
48 
     | 
    
         
             
                    expect(subject).to eq action
         
     | 
| 
         @@ -62,6 +65,7 @@ describe KnapsackPro::Client::API::V1::BuildDistributions do 
     | 
|
| 
       62 
65 
     | 
    
         
             
                        node_total: node_total,
         
     | 
| 
       63 
66 
     | 
    
         
             
                        node_index: node_index,
         
     | 
| 
       64 
67 
     | 
    
         
             
                        ci_build_id: ci_build_id,
         
     | 
| 
      
 68 
     | 
    
         
            +
                        user_seat: user_seat_hash,
         
     | 
| 
       65 
69 
     | 
    
         
             
                        test_files: test_files
         
     | 
| 
       66 
70 
     | 
    
         
             
                      }
         
     | 
| 
       67 
71 
     | 
    
         
             
                    }).and_return(action)
         
     | 
| 
         @@ -7,6 +7,7 @@ describe KnapsackPro::Client::API::V1::Queues do 
     | 
|
| 
       7 
7 
     | 
    
         
             
                let(:node_index) { double }
         
     | 
| 
       8 
8 
     | 
    
         
             
                let(:test_files) { double }
         
     | 
| 
       9 
9 
     | 
    
         
             
                let(:node_build_id) { double }
         
     | 
| 
      
 10 
     | 
    
         
            +
                let(:user_seat_hash) { double }
         
     | 
| 
       10 
11 
     | 
    
         | 
| 
       11 
12 
     | 
    
         
             
                subject do
         
     | 
| 
       12 
13 
     | 
    
         
             
                  described_class.queue(
         
     | 
| 
         @@ -23,6 +24,7 @@ describe KnapsackPro::Client::API::V1::Queues do 
     | 
|
| 
       23 
24 
     | 
    
         
             
                before do
         
     | 
| 
       24 
25 
     | 
    
         
             
                  expect(KnapsackPro::Config::Env).to receive(:fixed_queue_split).and_return(fixed_queue_split)
         
     | 
| 
       25 
26 
     | 
    
         
             
                  expect(KnapsackPro::Config::Env).to receive(:ci_node_build_id).and_return(node_build_id)
         
     | 
| 
      
 27 
     | 
    
         
            +
                  expect(KnapsackPro::Config::Env).to receive(:user_seat_hash).and_return(user_seat_hash)
         
     | 
| 
       26 
28 
     | 
    
         
             
                end
         
     | 
| 
       27 
29 
     | 
    
         | 
| 
       28 
30 
     | 
    
         
             
                context 'when can_initialize_queue=true and attempt_connect_to_queue=true' do
         
     | 
| 
         @@ -43,6 +45,7 @@ describe KnapsackPro::Client::API::V1::Queues do 
     | 
|
| 
       43 
45 
     | 
    
         
             
                        node_total: node_total,
         
     | 
| 
       44 
46 
     | 
    
         
             
                        node_index: node_index,
         
     | 
| 
       45 
47 
     | 
    
         
             
                        node_build_id: node_build_id,
         
     | 
| 
      
 48 
     | 
    
         
            +
                        user_seat: user_seat_hash,
         
     | 
| 
       46 
49 
     | 
    
         
             
                      }
         
     | 
| 
       47 
50 
     | 
    
         
             
                    }).and_return(action)
         
     | 
| 
       48 
51 
     | 
    
         
             
                    expect(subject).to eq action
         
     | 
| 
         @@ -67,6 +70,7 @@ describe KnapsackPro::Client::API::V1::Queues do 
     | 
|
| 
       67 
70 
     | 
    
         
             
                        node_total: node_total,
         
     | 
| 
       68 
71 
     | 
    
         
             
                        node_index: node_index,
         
     | 
| 
       69 
72 
     | 
    
         
             
                        node_build_id: node_build_id,
         
     | 
| 
      
 73 
     | 
    
         
            +
                        user_seat: user_seat_hash,
         
     | 
| 
       70 
74 
     | 
    
         
             
                        test_files: test_files
         
     | 
| 
       71 
75 
     | 
    
         
             
                      }
         
     | 
| 
       72 
76 
     | 
    
         
             
                    }).and_return(action)
         
     | 
| 
         @@ -92,6 +96,7 @@ describe KnapsackPro::Client::API::V1::Queues do 
     | 
|
| 
       92 
96 
     | 
    
         
             
                        node_total: node_total,
         
     | 
| 
       93 
97 
     | 
    
         
             
                        node_index: node_index,
         
     | 
| 
       94 
98 
     | 
    
         
             
                        node_build_id: node_build_id,
         
     | 
| 
      
 99 
     | 
    
         
            +
                        user_seat: user_seat_hash,
         
     | 
| 
       95 
100 
     | 
    
         
             
                      }
         
     | 
| 
       96 
101 
     | 
    
         
             
                    }).and_return(action)
         
     | 
| 
       97 
102 
     | 
    
         
             
                    expect(subject).to eq action
         
     | 
| 
         @@ -76,8 +76,8 @@ describe KnapsackPro::Config::CI::Buildkite do 
     | 
|
| 
       76 
76 
     | 
    
         
             
                subject { described_class.new.branch }
         
     | 
| 
       77 
77 
     | 
    
         | 
| 
       78 
78 
     | 
    
         
             
                context 'when environment exists' do
         
     | 
| 
       79 
     | 
    
         
            -
                  let(:env) { { 'BUILDKITE_BRANCH' => ' 
     | 
| 
       80 
     | 
    
         
            -
                  it { should eql ' 
     | 
| 
      
 79 
     | 
    
         
            +
                  let(:env) { { 'BUILDKITE_BRANCH' => 'main' } }
         
     | 
| 
      
 80 
     | 
    
         
            +
                  it { should eql 'main' }
         
     | 
| 
       81 
81 
     | 
    
         
             
                end
         
     | 
| 
       82 
82 
     | 
    
         | 
| 
       83 
83 
     | 
    
         
             
                context "when environment doesn't exist" do
         
     | 
| 
         @@ -97,4 +97,39 @@ describe KnapsackPro::Config::CI::Buildkite do 
     | 
|
| 
       97 
97 
     | 
    
         
             
                  it { should be nil }
         
     | 
| 
       98 
98 
     | 
    
         
             
                end
         
     | 
| 
       99 
99 
     | 
    
         
             
              end
         
     | 
| 
      
 100 
     | 
    
         
            +
             
     | 
| 
      
 101 
     | 
    
         
            +
              describe '#user_seat' do
         
     | 
| 
      
 102 
     | 
    
         
            +
                subject { described_class.new.user_seat }
         
     | 
| 
      
 103 
     | 
    
         
            +
             
     | 
| 
      
 104 
     | 
    
         
            +
                context 'when the BUILDKITE_BUILD_AUTHOR env var exists' do
         
     | 
| 
      
 105 
     | 
    
         
            +
                  let(:env) do
         
     | 
| 
      
 106 
     | 
    
         
            +
                    { 'BUILDKITE_BUILD_AUTHOR' => 'Jane Doe',
         
     | 
| 
      
 107 
     | 
    
         
            +
                      'BUILDKITE_BUILD_CREATOR' => nil }
         
     | 
| 
      
 108 
     | 
    
         
            +
                  end
         
     | 
| 
      
 109 
     | 
    
         
            +
             
     | 
| 
      
 110 
     | 
    
         
            +
                  it { should eql 'Jane Doe' }
         
     | 
| 
      
 111 
     | 
    
         
            +
                end
         
     | 
| 
      
 112 
     | 
    
         
            +
             
     | 
| 
      
 113 
     | 
    
         
            +
                context 'when the BUILDKITE_BUILD_CREATOR env var exists' do
         
     | 
| 
      
 114 
     | 
    
         
            +
                  let(:env) do
         
     | 
| 
      
 115 
     | 
    
         
            +
                    { 'BUILDKITE_BUILD_AUTHOR' => nil,
         
     | 
| 
      
 116 
     | 
    
         
            +
                      'BUILDKITE_BUILD_CREATOR' => 'John Doe' }
         
     | 
| 
      
 117 
     | 
    
         
            +
                  end
         
     | 
| 
      
 118 
     | 
    
         
            +
             
     | 
| 
      
 119 
     | 
    
         
            +
                  it { should eql 'John Doe' }
         
     | 
| 
      
 120 
     | 
    
         
            +
                end
         
     | 
| 
      
 121 
     | 
    
         
            +
             
     | 
| 
      
 122 
     | 
    
         
            +
                context 'when both BUILDKITE_BUILD_AUTHOR and BUILDKITE_BUILD_CREATOR env vars exist' do
         
     | 
| 
      
 123 
     | 
    
         
            +
                  let(:env) do
         
     | 
| 
      
 124 
     | 
    
         
            +
                    { 'BUILDKITE_BUILD_AUTHOR' => 'Jane Doe',
         
     | 
| 
      
 125 
     | 
    
         
            +
                      'BUILDKITE_BUILD_CREATOR' => 'John Doe' }
         
     | 
| 
      
 126 
     | 
    
         
            +
                  end
         
     | 
| 
      
 127 
     | 
    
         
            +
             
     | 
| 
      
 128 
     | 
    
         
            +
                  it { should eql 'Jane Doe' }
         
     | 
| 
      
 129 
     | 
    
         
            +
                end
         
     | 
| 
      
 130 
     | 
    
         
            +
             
     | 
| 
      
 131 
     | 
    
         
            +
                context "when neither env var exists" do
         
     | 
| 
      
 132 
     | 
    
         
            +
                  it { should be nil }
         
     | 
| 
      
 133 
     | 
    
         
            +
                end
         
     | 
| 
      
 134 
     | 
    
         
            +
              end
         
     | 
| 
       100 
135 
     | 
    
         
             
            end
         
     | 
| 
         @@ -63,8 +63,8 @@ describe KnapsackPro::Config::CI::Circle do 
     | 
|
| 
       63 
63 
     | 
    
         
             
                subject { described_class.new.branch }
         
     | 
| 
       64 
64 
     | 
    
         | 
| 
       65 
65 
     | 
    
         
             
                context 'when environment exists' do
         
     | 
| 
       66 
     | 
    
         
            -
                  let(:env) { { 'CIRCLE_BRANCH' => ' 
     | 
| 
       67 
     | 
    
         
            -
                  it { should eql ' 
     | 
| 
      
 66 
     | 
    
         
            +
                  let(:env) { { 'CIRCLE_BRANCH' => 'main' } }
         
     | 
| 
      
 67 
     | 
    
         
            +
                  it { should eql 'main' }
         
     | 
| 
       68 
68 
     | 
    
         
             
                end
         
     | 
| 
       69 
69 
     | 
    
         | 
| 
       70 
70 
     | 
    
         
             
                context "when environment doesn't exist" do
         
     | 
| 
         @@ -84,4 +84,39 @@ describe KnapsackPro::Config::CI::Circle do 
     | 
|
| 
       84 
84 
     | 
    
         
             
                  it { should be nil }
         
     | 
| 
       85 
85 
     | 
    
         
             
                end
         
     | 
| 
       86 
86 
     | 
    
         
             
              end
         
     | 
| 
      
 87 
     | 
    
         
            +
             
     | 
| 
      
 88 
     | 
    
         
            +
              describe '#user_seat' do
         
     | 
| 
      
 89 
     | 
    
         
            +
                subject { described_class.new.user_seat }
         
     | 
| 
      
 90 
     | 
    
         
            +
             
     | 
| 
      
 91 
     | 
    
         
            +
                context 'when the CIRCLE_USERNAME env var exists' do
         
     | 
| 
      
 92 
     | 
    
         
            +
                  let(:env) do
         
     | 
| 
      
 93 
     | 
    
         
            +
                    { 'CIRCLE_USERNAME' => 'Jane Doe',
         
     | 
| 
      
 94 
     | 
    
         
            +
                      'CIRCLE_PR_USERNAME' => nil }
         
     | 
| 
      
 95 
     | 
    
         
            +
                  end
         
     | 
| 
      
 96 
     | 
    
         
            +
             
     | 
| 
      
 97 
     | 
    
         
            +
                  it { should eql 'Jane Doe' }
         
     | 
| 
      
 98 
     | 
    
         
            +
                end
         
     | 
| 
      
 99 
     | 
    
         
            +
             
     | 
| 
      
 100 
     | 
    
         
            +
                context 'when the CIRCLE_PR_USERNAME env var exists' do
         
     | 
| 
      
 101 
     | 
    
         
            +
                  let(:env) do
         
     | 
| 
      
 102 
     | 
    
         
            +
                    { 'CIRCLE_USERNAME' => nil,
         
     | 
| 
      
 103 
     | 
    
         
            +
                      'CIRCLE_PR_USERNAME' => 'John Doe' }
         
     | 
| 
      
 104 
     | 
    
         
            +
                  end
         
     | 
| 
      
 105 
     | 
    
         
            +
             
     | 
| 
      
 106 
     | 
    
         
            +
                  it { should eql 'John Doe' }
         
     | 
| 
      
 107 
     | 
    
         
            +
                end
         
     | 
| 
      
 108 
     | 
    
         
            +
             
     | 
| 
      
 109 
     | 
    
         
            +
                context 'when both CIRCLE_USERNAME and CIRCLE_PR_USERNAME env vars exist' do
         
     | 
| 
      
 110 
     | 
    
         
            +
                  let(:env) do
         
     | 
| 
      
 111 
     | 
    
         
            +
                    { 'CIRCLE_USERNAME' => 'Jane Doe',
         
     | 
| 
      
 112 
     | 
    
         
            +
                      'CIRCLE_PR_USERNAME' => 'John Doe' }
         
     | 
| 
      
 113 
     | 
    
         
            +
                  end
         
     | 
| 
      
 114 
     | 
    
         
            +
             
     | 
| 
      
 115 
     | 
    
         
            +
                  it { should eql 'Jane Doe' }
         
     | 
| 
      
 116 
     | 
    
         
            +
                end
         
     | 
| 
      
 117 
     | 
    
         
            +
             
     | 
| 
      
 118 
     | 
    
         
            +
                context "when neither env var exists" do
         
     | 
| 
      
 119 
     | 
    
         
            +
                  it { should be nil }
         
     | 
| 
      
 120 
     | 
    
         
            +
                end
         
     | 
| 
      
 121 
     | 
    
         
            +
              end
         
     | 
| 
       87 
122 
     | 
    
         
             
            end
         
     | 
| 
         @@ -52,12 +52,12 @@ describe KnapsackPro::Config::CI::GithubActions do 
     | 
|
| 
       52 
52 
     | 
    
         
             
                  context 'when GITHUB_REF has value' do
         
     | 
| 
       53 
53 
     | 
    
         
             
                    let(:env) do
         
     | 
| 
       54 
54 
     | 
    
         
             
                      {
         
     | 
| 
       55 
     | 
    
         
            -
                        'GITHUB_REF' => ' 
     | 
| 
      
 55 
     | 
    
         
            +
                        'GITHUB_REF' => 'main',
         
     | 
| 
       56 
56 
     | 
    
         
             
                        'GITHUB_SHA' => '2e13512fc230d6f9ebf4923352718e4d',
         
     | 
| 
       57 
57 
     | 
    
         
             
                      }
         
     | 
| 
       58 
58 
     | 
    
         
             
                    end
         
     | 
| 
       59 
59 
     | 
    
         | 
| 
       60 
     | 
    
         
            -
                    it { should eql ' 
     | 
| 
      
 60 
     | 
    
         
            +
                    it { should eql 'main' }
         
     | 
| 
       61 
61 
     | 
    
         
             
                  end
         
     | 
| 
       62 
62 
     | 
    
         | 
| 
       63 
63 
     | 
    
         
             
                  context 'when GITHUB_REF is not set' do
         
     | 
| 
         @@ -88,4 +88,18 @@ describe KnapsackPro::Config::CI::GithubActions do 
     | 
|
| 
       88 
88 
     | 
    
         
             
                  it { should be nil }
         
     | 
| 
       89 
89 
     | 
    
         
             
                end
         
     | 
| 
       90 
90 
     | 
    
         
             
              end
         
     | 
| 
      
 91 
     | 
    
         
            +
             
     | 
| 
      
 92 
     | 
    
         
            +
              describe '#user_seat' do
         
     | 
| 
      
 93 
     | 
    
         
            +
                subject { described_class.new.user_seat }
         
     | 
| 
      
 94 
     | 
    
         
            +
             
     | 
| 
      
 95 
     | 
    
         
            +
                context 'when the GITHUB_ACTOR environment variable exists' do
         
     | 
| 
      
 96 
     | 
    
         
            +
                  let(:env) { { 'GITHUB_ACTOR' => 'jane_doe' } }
         
     | 
| 
      
 97 
     | 
    
         
            +
             
     | 
| 
      
 98 
     | 
    
         
            +
                  it { should eql 'jane_doe' }
         
     | 
| 
      
 99 
     | 
    
         
            +
                end
         
     | 
| 
      
 100 
     | 
    
         
            +
             
     | 
| 
      
 101 
     | 
    
         
            +
                context "when the GITHUB_ACTOR environment variable doesn't exist" do
         
     | 
| 
      
 102 
     | 
    
         
            +
                  it { should be nil }
         
     | 
| 
      
 103 
     | 
    
         
            +
                end
         
     | 
| 
      
 104 
     | 
    
         
            +
              end
         
     | 
| 
       91 
105 
     | 
    
         
             
            end
         
     | 
| 
         @@ -73,13 +73,13 @@ describe KnapsackPro::Config::CI::GitlabCI do 
     | 
|
| 
       73 
73 
     | 
    
         
             
                subject { described_class.new.branch }
         
     | 
| 
       74 
74 
     | 
    
         | 
| 
       75 
75 
     | 
    
         
             
                context 'when Gitlab Release 9.0+ and environment exists' do
         
     | 
| 
       76 
     | 
    
         
            -
                  let(:env) { { 'CI_COMMIT_REF_NAME' => ' 
     | 
| 
       77 
     | 
    
         
            -
                  it { should eql ' 
     | 
| 
      
 76 
     | 
    
         
            +
                  let(:env) { { 'CI_COMMIT_REF_NAME' => 'main' } }
         
     | 
| 
      
 77 
     | 
    
         
            +
                  it { should eql 'main' }
         
     | 
| 
       78 
78 
     | 
    
         
             
                end
         
     | 
| 
       79 
79 
     | 
    
         | 
| 
       80 
80 
     | 
    
         
             
                context 'when Gitlab Release 8.x and environment exists' do
         
     | 
| 
       81 
     | 
    
         
            -
                  let(:env) { { 'CI_BUILD_REF_NAME' => ' 
     | 
| 
       82 
     | 
    
         
            -
                  it { should eql ' 
     | 
| 
      
 81 
     | 
    
         
            +
                  let(:env) { { 'CI_BUILD_REF_NAME' => 'main' } }
         
     | 
| 
      
 82 
     | 
    
         
            +
                  it { should eql 'main' }
         
     | 
| 
       83 
83 
     | 
    
         
             
                end
         
     | 
| 
       84 
84 
     | 
    
         | 
| 
       85 
85 
     | 
    
         
             
                context "when environment doesn't exist" do
         
     | 
| 
         @@ -99,4 +99,39 @@ describe KnapsackPro::Config::CI::GitlabCI do 
     | 
|
| 
       99 
99 
     | 
    
         
             
                  it { should be nil }
         
     | 
| 
       100 
100 
     | 
    
         
             
                end
         
     | 
| 
       101 
101 
     | 
    
         
             
              end
         
     | 
| 
      
 102 
     | 
    
         
            +
             
     | 
| 
      
 103 
     | 
    
         
            +
              describe '#user_seat' do
         
     | 
| 
      
 104 
     | 
    
         
            +
                subject { described_class.new.user_seat }
         
     | 
| 
      
 105 
     | 
    
         
            +
             
     | 
| 
      
 106 
     | 
    
         
            +
                context 'when the GITLAB_USER_NAME env var exists' do
         
     | 
| 
      
 107 
     | 
    
         
            +
                  let(:env) do
         
     | 
| 
      
 108 
     | 
    
         
            +
                    { 'GITLAB_USER_NAME' => 'Jane Doe',
         
     | 
| 
      
 109 
     | 
    
         
            +
                      'GITLAB_USER_EMAIL' => nil }
         
     | 
| 
      
 110 
     | 
    
         
            +
                  end
         
     | 
| 
      
 111 
     | 
    
         
            +
             
     | 
| 
      
 112 
     | 
    
         
            +
                  it { should eql 'Jane Doe' }
         
     | 
| 
      
 113 
     | 
    
         
            +
                end
         
     | 
| 
      
 114 
     | 
    
         
            +
             
     | 
| 
      
 115 
     | 
    
         
            +
                context 'when the GITLAB_USER_EMAIL env var exists' do
         
     | 
| 
      
 116 
     | 
    
         
            +
                  let(:env) do
         
     | 
| 
      
 117 
     | 
    
         
            +
                    { 'GITLAB_USER_NAME' => nil,
         
     | 
| 
      
 118 
     | 
    
         
            +
                      'GITLAB_USER_EMAIL' => 'janed@example.com' }
         
     | 
| 
      
 119 
     | 
    
         
            +
                  end
         
     | 
| 
      
 120 
     | 
    
         
            +
             
     | 
| 
      
 121 
     | 
    
         
            +
                  it { should eql 'janed@example.com' }
         
     | 
| 
      
 122 
     | 
    
         
            +
                end
         
     | 
| 
      
 123 
     | 
    
         
            +
             
     | 
| 
      
 124 
     | 
    
         
            +
                context 'when both GITLAB_USER_NAME and GITLAB_USER_EMAIL env vars exist' do
         
     | 
| 
      
 125 
     | 
    
         
            +
                  let(:env) do
         
     | 
| 
      
 126 
     | 
    
         
            +
                    { 'GITLAB_USER_NAME' => 'Jane Doe',
         
     | 
| 
      
 127 
     | 
    
         
            +
                      'GITLAB_USER_EMAIL' => 'janed@example.com' }
         
     | 
| 
      
 128 
     | 
    
         
            +
                  end
         
     | 
| 
      
 129 
     | 
    
         
            +
             
     | 
| 
      
 130 
     | 
    
         
            +
                  it { should eql 'Jane Doe' }
         
     | 
| 
      
 131 
     | 
    
         
            +
                end
         
     | 
| 
      
 132 
     | 
    
         
            +
             
     | 
| 
      
 133 
     | 
    
         
            +
                context "when neither env var exists" do
         
     | 
| 
      
 134 
     | 
    
         
            +
                  it { should be nil }
         
     | 
| 
      
 135 
     | 
    
         
            +
                end
         
     | 
| 
      
 136 
     | 
    
         
            +
              end
         
     | 
| 
       102 
137 
     | 
    
         
             
            end
         
     | 
| 
         @@ -72,8 +72,10 @@ describe KnapsackPro::Config::Env do 
     | 
|
| 
       72 
72 
     | 
    
         
             
                  end
         
     | 
| 
       73 
73 
     | 
    
         
             
                end
         
     | 
| 
       74 
74 
     | 
    
         | 
| 
       75 
     | 
    
         
            -
                context "when ENV  
     | 
| 
       76 
     | 
    
         
            -
                  it  
     | 
| 
      
 75 
     | 
    
         
            +
                context "when ENV does not exist" do
         
     | 
| 
      
 76 
     | 
    
         
            +
                  it 'raises' do
         
     | 
| 
      
 77 
     | 
    
         
            +
                    expect { subject }.to raise_error(/Missing environment variable KNAPSACK_PRO_CI_NODE_BUILD_ID/)
         
     | 
| 
      
 78 
     | 
    
         
            +
                  end
         
     | 
| 
       77 
79 
     | 
    
         
             
                end
         
     | 
| 
       78 
80 
     | 
    
         
             
              end
         
     | 
| 
       79 
81 
     | 
    
         | 
| 
         @@ -182,6 +184,51 @@ describe KnapsackPro::Config::Env do 
     | 
|
| 
       182 
184 
     | 
    
         
             
                end
         
     | 
| 
       183 
185 
     | 
    
         
             
              end
         
     | 
| 
       184 
186 
     | 
    
         | 
| 
      
 187 
     | 
    
         
            +
              describe '.user_seat' do
         
     | 
| 
      
 188 
     | 
    
         
            +
                subject { described_class.user_seat }
         
     | 
| 
      
 189 
     | 
    
         
            +
             
     | 
| 
      
 190 
     | 
    
         
            +
                context 'when ENV exists' do
         
     | 
| 
      
 191 
     | 
    
         
            +
                  context 'when KNAPSACK_PRO_USER_SEAT has value' do
         
     | 
| 
      
 192 
     | 
    
         
            +
                    before { stub_const("ENV", { 'KNAPSACK_PRO_USER_SEAT' => 'John Doe' }) }
         
     | 
| 
      
 193 
     | 
    
         
            +
                    it { should eq 'John Doe' }
         
     | 
| 
      
 194 
     | 
    
         
            +
                  end
         
     | 
| 
      
 195 
     | 
    
         
            +
             
     | 
| 
      
 196 
     | 
    
         
            +
                  context 'when CI environment has value' do
         
     | 
| 
      
 197 
     | 
    
         
            +
                    before do
         
     | 
| 
      
 198 
     | 
    
         
            +
                      expect(described_class).to receive(:ci_env_for).with(:user_seat).and_return('Jane Doe')
         
     | 
| 
      
 199 
     | 
    
         
            +
                    end
         
     | 
| 
      
 200 
     | 
    
         
            +
             
     | 
| 
      
 201 
     | 
    
         
            +
                    it { should eq 'Jane Doe' }
         
     | 
| 
      
 202 
     | 
    
         
            +
                  end
         
     | 
| 
      
 203 
     | 
    
         
            +
                end
         
     | 
| 
      
 204 
     | 
    
         
            +
             
     | 
| 
      
 205 
     | 
    
         
            +
                context "when ENV doesn't exist" do
         
     | 
| 
      
 206 
     | 
    
         
            +
                  it { should be nil }
         
     | 
| 
      
 207 
     | 
    
         
            +
                end
         
     | 
| 
      
 208 
     | 
    
         
            +
              end
         
     | 
| 
      
 209 
     | 
    
         
            +
             
     | 
| 
      
 210 
     | 
    
         
            +
              describe '.user_seat_hash' do
         
     | 
| 
      
 211 
     | 
    
         
            +
                subject { described_class.user_seat_hash }
         
     | 
| 
      
 212 
     | 
    
         
            +
             
     | 
| 
      
 213 
     | 
    
         
            +
                before do
         
     | 
| 
      
 214 
     | 
    
         
            +
                  expect(described_class).to receive(:user_seat).at_least(1).and_return(user_seat)
         
     | 
| 
      
 215 
     | 
    
         
            +
                end
         
     | 
| 
      
 216 
     | 
    
         
            +
             
     | 
| 
      
 217 
     | 
    
         
            +
                context 'when the user seat has a value' do
         
     | 
| 
      
 218 
     | 
    
         
            +
                  let(:user_seat) { 'John Doe' }
         
     | 
| 
      
 219 
     | 
    
         
            +
             
     | 
| 
      
 220 
     | 
    
         
            +
                  it 'returns a SHA256 hash for the user seat' do
         
     | 
| 
      
 221 
     | 
    
         
            +
                    expect(subject).to eq '6cea57c2fb6cbc2a40411135005760f241fffc3e5e67ab99882726431037f908'
         
     | 
| 
      
 222 
     | 
    
         
            +
                  end
         
     | 
| 
      
 223 
     | 
    
         
            +
                end
         
     | 
| 
      
 224 
     | 
    
         
            +
             
     | 
| 
      
 225 
     | 
    
         
            +
                context 'when the user seat has no value' do
         
     | 
| 
      
 226 
     | 
    
         
            +
                  let(:user_seat) { nil }
         
     | 
| 
      
 227 
     | 
    
         
            +
             
     | 
| 
      
 228 
     | 
    
         
            +
                  it { expect(subject).to be_nil }
         
     | 
| 
      
 229 
     | 
    
         
            +
                end
         
     | 
| 
      
 230 
     | 
    
         
            +
              end
         
     | 
| 
      
 231 
     | 
    
         
            +
             
     | 
| 
       185 
232 
     | 
    
         
             
              describe '.test_file_pattern' do
         
     | 
| 
       186 
233 
     | 
    
         
             
                subject { described_class.test_file_pattern }
         
     | 
| 
       187 
234 
     | 
    
         | 
    
        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:  
     | 
| 
      
 4 
     | 
    
         
            +
              version: 4.0.0
         
     | 
| 
       5 
5 
     | 
    
         
             
            platform: ruby
         
     | 
| 
       6 
6 
     | 
    
         
             
            authors:
         
     | 
| 
       7 
7 
     | 
    
         
             
            - ArturT
         
     | 
| 
       8 
8 
     | 
    
         
             
            autorequire:
         
     | 
| 
       9 
9 
     | 
    
         
             
            bindir: bin
         
     | 
| 
       10 
10 
     | 
    
         
             
            cert_chain: []
         
     | 
| 
       11 
     | 
    
         
            -
            date: 2023-05- 
     | 
| 
      
 11 
     | 
    
         
            +
            date: 2023-05-22 00:00:00.000000000 Z
         
     | 
| 
       12 
12 
     | 
    
         
             
            dependencies:
         
     | 
| 
       13 
13 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       14 
14 
     | 
    
         
             
              name: rake
         
     | 
| 
         @@ -404,7 +404,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement 
     | 
|
| 
       404 
404 
     | 
    
         
             
                - !ruby/object:Gem::Version
         
     | 
| 
       405 
405 
     | 
    
         
             
                  version: '0'
         
     | 
| 
       406 
406 
     | 
    
         
             
            requirements: []
         
     | 
| 
       407 
     | 
    
         
            -
            rubygems_version: 3.4. 
     | 
| 
      
 407 
     | 
    
         
            +
            rubygems_version: 3.4.8
         
     | 
| 
       408 
408 
     | 
    
         
             
            signing_key:
         
     | 
| 
       409 
409 
     | 
    
         
             
            specification_version: 4
         
     | 
| 
       410 
410 
     | 
    
         
             
            summary: Knapsack Pro splits tests across parallel CI nodes and ensures each parallel
         
     |