knapsack_pro 8.0.0 → 8.0.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c531fc28ddde021a2417447b60d2feaec8924994bb5575cf1f3cd63484d2fa2b
4
- data.tar.gz: 28eb5e92aff6522f1dfb31b2c2c076bb54f6e50daec25985a09286fb337fec90
3
+ metadata.gz: 6135451be036cbd75b78cb5efd31498b91b08698771c78c69dfa7b2b1d218faa
4
+ data.tar.gz: bd73f2525bc9b89c5faca60bf95249d06e525fb533422b8e98399b03dcf732bf
5
5
  SHA512:
6
- metadata.gz: 5b66568ea07f6ab6ef881e61d3f3affa5d9ba0c0201c64c2292573fc11afc8e212e4d848e63c22b2596b9e4ea36780ad4f5b72a25f729370e463f865aed324c4
7
- data.tar.gz: '0021619b437b7815807667549ee8a49ffcfca23358b3456e3cbbc5331f2a03a535f271c9cdbf5c83db632709c47ec82e50f3806aab30a0660763011efe9e7800'
6
+ metadata.gz: 3cca977135a8795f725cd2ee73ae5c8af2df313db76892a9e29e283fc788f0c7479dff1e8aed532fb43a1ac56cb4582200dda0af1e953426c571fb177eb2ad2f
7
+ data.tar.gz: 00bb2a047303b2e11eb06f1f0f358dd209a1d98cb01657b4c8144a7f137efc5cb7aa44e736e6f4925642975afb83b576c2e9a0039233b389a196180ca0a194d3
data/CHANGELOG.md CHANGED
@@ -1,5 +1,32 @@
1
1
  # Changelog
2
2
 
3
+ ### Unreleased
4
+
5
+ ### 8.0.2
6
+
7
+ * (patch) Semaphore: Detect the correct branch name in the context of a PR
8
+ * (patch) Semaphore: Detect user seat (committer)
9
+
10
+ https://github.com/KnapsackPro/knapsack_pro-ruby/pull/294
11
+
12
+ * (patch) RSpec: Use the same regex when parsing file path and id path
13
+
14
+ https://github.com/KnapsackPro/knapsack_pro-ruby/pull/291
15
+
16
+ https://github.com/KnapsackPro/knapsack_pro-ruby/compare/v8.0.1...v8.0.2
17
+
18
+ ### 8.0.1
19
+
20
+ * Fix detection of id paths for Turnip, which resulted in sending to the API both file and id paths timings
21
+ * Example:
22
+ * turnip/acceptance/foo.feature[1:1:1] 0 seconds
23
+ * turnip/acceptance/foo.feature[1:1:2] 0 seconds
24
+ * turnip/acceptance/foo.feature 30 milliseconds (time recorded for [1:1:1] or [1:1:2])
25
+
26
+ https://github.com/KnapsackPro/knapsack_pro-ruby/pull/290
27
+
28
+ https://github.com/KnapsackPro/knapsack_pro-ruby/compare/v8.0.0...v8.0.1
29
+
3
30
  ### 8.0.0
4
31
 
5
32
  * Enable [`KNAPSACK_PRO_RSPEC_SPLIT_BY_TEST_EXAMPLES`](https://docs.knapsackpro.com/ruby/split-by-test-examples/) by default
@@ -6,7 +6,8 @@ module KnapsackPro
6
6
  module Adapters
7
7
  class RSpecAdapter < BaseAdapter
8
8
  TEST_DIR_PATTERN = 'spec/**{,/*/**}/*_spec.rb'
9
- ID_PATH_REGEX = /.+_spec\.rb\[.+\]$/
9
+ # https://github.com/rspec/rspec/blob/86b5e4218eece4c1913fe9aad24c0a96d8bc9f40/rspec-core/lib/rspec/core/example.rb#L122
10
+ REGEX = /\A(.*?)(?:\[([\d\s:,]+)\])?\z/.freeze
10
11
 
11
12
  def self.split_by_test_cases_enabled?
12
13
  return false unless KnapsackPro::Config::Env.rspec_split_by_test_examples?
@@ -75,13 +76,14 @@ module KnapsackPro
75
76
  return ''
76
77
  end
77
78
 
78
- def self.parse_file_path(id)
79
- # https://github.com/rspec/rspec-core/blob/1eeadce5aa7137ead054783c31ff35cbfe9d07cc/lib/rspec/core/example.rb#L122
80
- id.match(/\A(.*?)(?:\[([\d\s:,]+)\])?\z/).captures.first
79
+ def self.parse_file_path(path)
80
+ file, _id = path.match(REGEX).captures
81
+ file
81
82
  end
82
83
 
83
84
  def self.id_path?(path)
84
- ID_PATH_REGEX.match?(path)
85
+ _file, id = path.match(REGEX).captures
86
+ !id.nil?
85
87
  end
86
88
 
87
89
  def self.rails_helper_exists?(test_dir)
@@ -23,7 +23,8 @@ module KnapsackPro
23
23
  end
24
24
 
25
25
  def branch
26
- ENV['SEMAPHORE_GIT_BRANCH']
26
+ ENV['SEMAPHORE_GIT_WORKING_BRANCH'] || # nil when workflow is triggered by pushing a Git tag
27
+ ENV['SEMAPHORE_GIT_BRANCH']
27
28
  end
28
29
 
29
30
  def project_dir
@@ -33,7 +34,7 @@ module KnapsackPro
33
34
  end
34
35
 
35
36
  def user_seat
36
- # not provided
37
+ ENV['SEMAPHORE_GIT_COMMITTER']
37
38
  end
38
39
 
39
40
  def detected
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module KnapsackPro
4
- VERSION = '8.0.0'
4
+ VERSION = '8.0.2'
5
5
  end
@@ -148,23 +148,41 @@ describe KnapsackPro::Adapters::RSpecAdapter do
148
148
  describe '.id_path?' do
149
149
  subject { described_class.id_path?(path) }
150
150
 
151
- context 'when the path resembles the RSpec path with id' do
151
+ context 'when the path is an RSpec path with id' do
152
152
  let(:path) { 'spec/features/a_spec.rb[1:1:7:1]' }
153
153
 
154
154
  it { is_expected.to be true }
155
155
  end
156
156
 
157
- context 'when the path resembles the RSpec path with multiple ids' do
157
+ context 'when the path is an RSpec path with multiple ids' do
158
158
  let(:path) { 'spec/features/a_spec.rb[1:1:7:1, 1:2]' }
159
159
 
160
160
  it { is_expected.to be true }
161
161
  end
162
162
 
163
- context "when the path doesn't resemble the RSpec path with id" do
163
+ context 'when the path is an RSpec path with no id' do
164
164
  let(:path) { 'spec/features/a_spec.rb' }
165
165
 
166
166
  it { is_expected.to be false }
167
167
  end
168
+
169
+ context 'when the path is a Turnip path with id' do
170
+ let(:path) { 'spec/acceptance/a.feature[1:1:7:1]' }
171
+
172
+ it { is_expected.to be true }
173
+ end
174
+
175
+ context 'when the path is a Turnip path with multiple ids' do
176
+ let(:path) { 'spec/acceptance/a.feature[1:1:7:1,1:2]' }
177
+
178
+ it { is_expected.to be true }
179
+ end
180
+
181
+ context 'when the path is a Turnip path with no id' do
182
+ let(:path) { 'spec/acceptance/a.feature' }
183
+
184
+ it { is_expected.to be false }
185
+ end
168
186
  end
169
187
 
170
188
  describe '.rails_helper_exists?' do
@@ -62,12 +62,22 @@ describe KnapsackPro::Config::CI::Semaphore2 do
62
62
  describe '#branch' do
63
63
  subject { described_class.new.branch }
64
64
 
65
- context 'when the environment exists' do
65
+ context 'when SEMAPHORE_GIT_WORKING_BRANCH is set' do
66
+ let(:env) { { 'SEMAPHORE_GIT_WORKING_BRANCH' => 'feature' } }
67
+ it { should eql 'feature' }
68
+ end
69
+
70
+ context 'when both SEMAPHORE_GIT_WORKING_BRANCH and SEMAPHORE_GIT_BRANCH are set' do
71
+ let(:env) { { 'SEMAPHORE_GIT_WORKING_BRANCH' => 'feature', 'SEMAPHORE_GIT_BRANCH' => 'master' } }
72
+ it { should eql 'feature' }
73
+ end
74
+
75
+ context 'when SEMAPHORE_GIT_BRANCH is set' do
66
76
  let(:env) { { 'SEMAPHORE_GIT_BRANCH' => 'master' } }
67
77
  it { should eql 'master' }
68
78
  end
69
79
 
70
- context "when the environment doesn't exist" do
80
+ context "when no ENVs are set" do
71
81
  it { should be nil }
72
82
  end
73
83
  end
@@ -107,4 +117,17 @@ describe KnapsackPro::Config::CI::Semaphore2 do
107
117
  it { should be nil }
108
118
  end
109
119
  end
120
+
121
+ describe '#user_seat' do
122
+ subject { described_class.new.user_seat }
123
+
124
+ context 'when SEMAPHORE_GIT_COMMITTER is set' do
125
+ let(:env) { { 'SEMAPHORE_GIT_COMMITTER' => 'jane_doe' } }
126
+ it { should eql 'jane_doe' }
127
+ end
128
+
129
+ context "when no ENVs are set" do
130
+ it { should be nil }
131
+ end
132
+ end
110
133
  end
metadata CHANGED
@@ -1,14 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: knapsack_pro
3
3
  version: !ruby/object:Gem::Version
4
- version: 8.0.0
4
+ version: 8.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - ArturT
8
- autorequire:
9
8
  bindir: bin
10
9
  cert_chain: []
11
- date: 2025-02-25 00:00:00.000000000 Z
10
+ date: 2025-03-25 00:00:00.000000000 Z
12
11
  dependencies:
13
12
  - !ruby/object:Gem::Dependency
14
13
  name: rake
@@ -418,7 +417,6 @@ metadata:
418
417
  documentation_uri: https://docs.knapsackpro.com/knapsack_pro-ruby/guide/
419
418
  homepage_uri: https://knapsackpro.com
420
419
  source_code_uri: https://github.com/KnapsackPro/knapsack_pro-ruby
421
- post_install_message:
422
420
  rdoc_options: []
423
421
  require_paths:
424
422
  - lib
@@ -433,8 +431,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
433
431
  - !ruby/object:Gem::Version
434
432
  version: '0'
435
433
  requirements: []
436
- rubygems_version: 3.5.22
437
- signing_key:
434
+ rubygems_version: 3.6.2
438
435
  specification_version: 4
439
436
  summary: Knapsack Pro splits tests across parallel CI nodes and ensures each parallel
440
437
  job finish work at a similar time.