knapsack_pro 5.1.2 → 5.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/dependabot.yml +11 -0
- data/CHANGELOG.md +17 -0
- data/lib/knapsack_pro/client/api/v1/build_distributions.rb +2 -0
- data/lib/knapsack_pro/client/api/v1/queues.rb +2 -0
- data/lib/knapsack_pro/config/env.rb +6 -1
- data/lib/knapsack_pro/mask_string.rb +7 -0
- data/lib/knapsack_pro/repository_adapters/git_adapter.rb +36 -0
- data/lib/knapsack_pro/version.rb +1 -1
- data/lib/knapsack_pro.rb +1 -0
- data/spec/knapsack_pro/client/api/v1/build_distributions_spec.rb +17 -29
- data/spec/knapsack_pro/client/api/v1/queues_spec.rb +21 -46
- data/spec/knapsack_pro/config/env_spec.rb +14 -0
- data/spec/knapsack_pro/repository_adapters/git_adapter_spec.rb +72 -0
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ebf6661c02960aefdda92e8fd84ce692e22e59e9fb4d593f677577cda62acb57
|
4
|
+
data.tar.gz: c56e9069badb8ed6090e1b8afb6f2c7d5aebb52a8b7e484484399586b3b7f82c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: df2abe40a8b601acd3db8eedce7fc985273e4ff0100346300080ef0de7c8a3df96ecb98f7ab038f121f365d852da0ff877c579a57a652c1c5fb8318a72bc53a7
|
7
|
+
data.tar.gz: 032132b675a088531b3dd112f3258823ec4fd7b9beae8f982dbb3abc85508b4d4ccbd56112ab0e8f1faaf9b0af74edc98fd6896fb01d25ba77f20bef14f61273
|
@@ -0,0 +1,11 @@
|
|
1
|
+
# To get started with Dependabot version updates, you'll need to specify which
|
2
|
+
# package ecosystems to update and where the package manifests are located.
|
3
|
+
# Please see the documentation for all configuration options:
|
4
|
+
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
|
5
|
+
|
6
|
+
version: 2
|
7
|
+
updates:
|
8
|
+
- package-ecosystem: "bundler"
|
9
|
+
directory: "/"
|
10
|
+
schedule:
|
11
|
+
interval: "weekly"
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,22 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
### 5.2.1
|
4
|
+
|
5
|
+
* Shallow fetch the last month of commits only on CI
|
6
|
+
* Ensure input to `git shortlog`
|
7
|
+
|
8
|
+
https://github.com/KnapsackPro/knapsack_pro-ruby/pull/209
|
9
|
+
|
10
|
+
https://github.com/KnapsackPro/knapsack_pro-ruby/compare/v5.2.0...v5.2.1
|
11
|
+
|
12
|
+
### 5.2.0
|
13
|
+
|
14
|
+
* Send authors to the API
|
15
|
+
|
16
|
+
https://github.com/KnapsackPro/knapsack_pro-ruby/pull/208
|
17
|
+
|
18
|
+
https://github.com/KnapsackPro/knapsack_pro-ruby/compare/v5.1.2...v5.2.0
|
19
|
+
|
3
20
|
### 5.1.2
|
4
21
|
|
5
22
|
* Fix broken RSpec split by test examples feature when `SPEC_OPTS` is set in Queue Mode. Ignore `SPEC_OPTS` when generating test examples report for slow test files.
|
@@ -16,6 +16,8 @@ module KnapsackPro
|
|
16
16
|
:node_index => args.fetch(:node_index),
|
17
17
|
:ci_build_id => KnapsackPro::Config::Env.ci_node_build_id,
|
18
18
|
:user_seat => KnapsackPro::Config::Env.masked_user_seat,
|
19
|
+
:build_author => KnapsackPro::RepositoryAdapters::GitAdapter.new.build_author,
|
20
|
+
:commit_authors => KnapsackPro::RepositoryAdapters::GitAdapter.new.commit_authors,
|
19
21
|
}
|
20
22
|
|
21
23
|
unless request_hash[:cache_read_attempt]
|
@@ -17,6 +17,8 @@ module KnapsackPro
|
|
17
17
|
:node_index => args.fetch(:node_index),
|
18
18
|
:node_build_id => KnapsackPro::Config::Env.ci_node_build_id,
|
19
19
|
:user_seat => KnapsackPro::Config::Env.masked_user_seat,
|
20
|
+
:build_author => KnapsackPro::RepositoryAdapters::GitAdapter.new.build_author,
|
21
|
+
:commit_authors => KnapsackPro::RepositoryAdapters::GitAdapter.new.commit_authors,
|
20
22
|
}
|
21
23
|
|
22
24
|
if request_hash[:can_initialize_queue] && !request_hash[:attempt_connect_to_queue]
|
@@ -67,7 +67,7 @@ module KnapsackPro
|
|
67
67
|
def masked_user_seat
|
68
68
|
return unless user_seat
|
69
69
|
|
70
|
-
|
70
|
+
KnapsackPro::MaskString.call(user_seat)
|
71
71
|
end
|
72
72
|
|
73
73
|
def test_file_pattern
|
@@ -285,6 +285,11 @@ module KnapsackPro
|
|
285
285
|
ENV['KNAPSACK_PRO_TEST_RUNNER_ADAPTER'] = adapter_class.to_s.split('::').last
|
286
286
|
end
|
287
287
|
|
288
|
+
def ci?
|
289
|
+
ENV.fetch('CI', 'false').downcase == 'true' ||
|
290
|
+
detected_ci != KnapsackPro::Config::CI::Base
|
291
|
+
end
|
292
|
+
|
288
293
|
private
|
289
294
|
|
290
295
|
def required_env(env_name)
|
@@ -14,8 +14,44 @@ module KnapsackPro
|
|
14
14
|
str_branches.split("\n")
|
15
15
|
end
|
16
16
|
|
17
|
+
def commit_authors
|
18
|
+
authors = git_commit_authors
|
19
|
+
.split("\n")
|
20
|
+
.map { |line| line.strip }
|
21
|
+
.map { |line| line.split("\t") }
|
22
|
+
.map do |commits, author|
|
23
|
+
{ commits: commits.to_i, author: KnapsackPro::MaskString.call(author) }
|
24
|
+
end
|
25
|
+
|
26
|
+
raise if authors.empty?
|
27
|
+
|
28
|
+
authors
|
29
|
+
rescue Exception
|
30
|
+
[]
|
31
|
+
end
|
32
|
+
|
33
|
+
def build_author
|
34
|
+
author = KnapsackPro::MaskString.call(git_build_author.strip)
|
35
|
+
raise if author.empty?
|
36
|
+
author
|
37
|
+
rescue Exception
|
38
|
+
"no git <no.git@example.com>"
|
39
|
+
end
|
40
|
+
|
17
41
|
private
|
18
42
|
|
43
|
+
def git_commit_authors
|
44
|
+
if KnapsackPro::Config::Env.ci?
|
45
|
+
`git fetch --shallow-since "one month ago" --quiet`
|
46
|
+
end
|
47
|
+
|
48
|
+
`git log --since "one month ago" | git shortlog --summary --email`
|
49
|
+
end
|
50
|
+
|
51
|
+
def git_build_author
|
52
|
+
`git log --format="%aN <%aE>" -1`
|
53
|
+
end
|
54
|
+
|
19
55
|
def working_dir
|
20
56
|
dir = KnapsackPro::Config::Env.project_dir
|
21
57
|
File.expand_path(dir)
|
data/lib/knapsack_pro/version.rb
CHANGED
data/lib/knapsack_pro.rb
CHANGED
@@ -55,6 +55,7 @@ require_relative 'knapsack_pro/adapters/test_unit_adapter'
|
|
55
55
|
require_relative 'knapsack_pro/adapters/spinach_adapter'
|
56
56
|
require_relative 'knapsack_pro/allocator'
|
57
57
|
require_relative 'knapsack_pro/queue_allocator'
|
58
|
+
require_relative 'knapsack_pro/mask_string'
|
58
59
|
require_relative 'knapsack_pro/test_case_mergers/base_merger'
|
59
60
|
require_relative 'knapsack_pro/test_case_mergers/rspec_merger'
|
60
61
|
require_relative 'knapsack_pro/build_distribution_fetcher'
|
@@ -8,6 +8,7 @@ describe KnapsackPro::Client::API::V1::BuildDistributions do
|
|
8
8
|
let(:ci_build_id) { double }
|
9
9
|
let(:masked_user_seat) { double }
|
10
10
|
let(:test_files) { double }
|
11
|
+
let(:cache_read_attempt) { [false, true].sample }
|
11
12
|
|
12
13
|
subject do
|
13
14
|
described_class.subset(
|
@@ -31,20 +32,9 @@ describe KnapsackPro::Client::API::V1::BuildDistributions do
|
|
31
32
|
|
32
33
|
it 'does not send test_files among other params' do
|
33
34
|
action = double
|
34
|
-
expect(KnapsackPro::Client::API::Action).to receive(:new).with(
|
35
|
-
|
36
|
-
|
37
|
-
request_hash: {
|
38
|
-
fixed_test_suite_split: fixed_test_suite_split,
|
39
|
-
cache_read_attempt: cache_read_attempt,
|
40
|
-
commit_hash: commit_hash,
|
41
|
-
branch: branch,
|
42
|
-
node_total: node_total,
|
43
|
-
node_index: node_index,
|
44
|
-
ci_build_id: ci_build_id,
|
45
|
-
user_seat: masked_user_seat,
|
46
|
-
}
|
47
|
-
}).and_return(action)
|
35
|
+
expect(KnapsackPro::Client::API::Action).to receive(:new).with(
|
36
|
+
hash_including(request_hash: hash_excluding(:test_files))
|
37
|
+
).and_return(action)
|
48
38
|
expect(subject).to eq action
|
49
39
|
end
|
50
40
|
end
|
@@ -54,24 +44,22 @@ describe KnapsackPro::Client::API::V1::BuildDistributions do
|
|
54
44
|
|
55
45
|
it 'sends test_files among other params' do
|
56
46
|
action = double
|
57
|
-
expect(KnapsackPro::Client::API::Action).to receive(:new).with(
|
58
|
-
|
59
|
-
|
60
|
-
request_hash: {
|
61
|
-
fixed_test_suite_split: fixed_test_suite_split,
|
62
|
-
cache_read_attempt: cache_read_attempt,
|
63
|
-
commit_hash: commit_hash,
|
64
|
-
branch: branch,
|
65
|
-
node_total: node_total,
|
66
|
-
node_index: node_index,
|
67
|
-
ci_build_id: ci_build_id,
|
68
|
-
user_seat: masked_user_seat,
|
69
|
-
test_files: test_files
|
70
|
-
}
|
71
|
-
}).and_return(action)
|
47
|
+
expect(KnapsackPro::Client::API::Action).to receive(:new).with(
|
48
|
+
hash_including(request_hash: hash_including(test_files: test_files))
|
49
|
+
).and_return(action)
|
72
50
|
expect(subject).to eq action
|
73
51
|
end
|
74
52
|
end
|
53
|
+
|
54
|
+
it "sends authors" do
|
55
|
+
action = double
|
56
|
+
|
57
|
+
expect(KnapsackPro::Client::API::Action).to receive(:new).with(
|
58
|
+
hash_including(request_hash: hash_including(:build_author, :commit_authors))
|
59
|
+
).and_return(action)
|
60
|
+
|
61
|
+
expect(subject).to eq action
|
62
|
+
end
|
75
63
|
end
|
76
64
|
|
77
65
|
describe '.last' do
|
@@ -8,6 +8,8 @@ describe KnapsackPro::Client::API::V1::Queues do
|
|
8
8
|
let(:test_files) { double }
|
9
9
|
let(:node_build_id) { double }
|
10
10
|
let(:masked_user_seat) { double }
|
11
|
+
let(:can_initialize_queue) { [false, true].sample }
|
12
|
+
let(:attempt_connect_to_queue) { [false, true].sample }
|
11
13
|
|
12
14
|
subject do
|
13
15
|
described_class.queue(
|
@@ -33,21 +35,9 @@ describe KnapsackPro::Client::API::V1::Queues do
|
|
33
35
|
|
34
36
|
it 'does not send test_files among other params' do
|
35
37
|
action = double
|
36
|
-
expect(KnapsackPro::Client::API::Action).to receive(:new).with(
|
37
|
-
|
38
|
-
|
39
|
-
request_hash: {
|
40
|
-
fixed_queue_split: fixed_queue_split,
|
41
|
-
can_initialize_queue: can_initialize_queue,
|
42
|
-
attempt_connect_to_queue: attempt_connect_to_queue,
|
43
|
-
commit_hash: commit_hash,
|
44
|
-
branch: branch,
|
45
|
-
node_total: node_total,
|
46
|
-
node_index: node_index,
|
47
|
-
node_build_id: node_build_id,
|
48
|
-
user_seat: masked_user_seat,
|
49
|
-
}
|
50
|
-
}).and_return(action)
|
38
|
+
expect(KnapsackPro::Client::API::Action).to receive(:new).with(
|
39
|
+
hash_including(request_hash: hash_excluding(:test_files))
|
40
|
+
).and_return(action)
|
51
41
|
expect(subject).to eq action
|
52
42
|
end
|
53
43
|
end
|
@@ -58,22 +48,9 @@ describe KnapsackPro::Client::API::V1::Queues do
|
|
58
48
|
|
59
49
|
it 'sends test_files among other params' do
|
60
50
|
action = double
|
61
|
-
expect(KnapsackPro::Client::API::Action).to receive(:new).with(
|
62
|
-
|
63
|
-
|
64
|
-
request_hash: {
|
65
|
-
fixed_queue_split: fixed_queue_split,
|
66
|
-
can_initialize_queue: can_initialize_queue,
|
67
|
-
attempt_connect_to_queue: attempt_connect_to_queue,
|
68
|
-
commit_hash: commit_hash,
|
69
|
-
branch: branch,
|
70
|
-
node_total: node_total,
|
71
|
-
node_index: node_index,
|
72
|
-
node_build_id: node_build_id,
|
73
|
-
user_seat: masked_user_seat,
|
74
|
-
test_files: test_files
|
75
|
-
}
|
76
|
-
}).and_return(action)
|
51
|
+
expect(KnapsackPro::Client::API::Action).to receive(:new).with(
|
52
|
+
hash_including(request_hash: hash_including(test_files: test_files))
|
53
|
+
).and_return(action)
|
77
54
|
expect(subject).to eq action
|
78
55
|
end
|
79
56
|
end
|
@@ -84,23 +61,21 @@ describe KnapsackPro::Client::API::V1::Queues do
|
|
84
61
|
|
85
62
|
it 'does not send test_files among other params' do
|
86
63
|
action = double
|
87
|
-
expect(KnapsackPro::Client::API::Action).to receive(:new).with(
|
88
|
-
|
89
|
-
|
90
|
-
request_hash: {
|
91
|
-
fixed_queue_split: fixed_queue_split,
|
92
|
-
can_initialize_queue: can_initialize_queue,
|
93
|
-
attempt_connect_to_queue: attempt_connect_to_queue,
|
94
|
-
commit_hash: commit_hash,
|
95
|
-
branch: branch,
|
96
|
-
node_total: node_total,
|
97
|
-
node_index: node_index,
|
98
|
-
node_build_id: node_build_id,
|
99
|
-
user_seat: masked_user_seat,
|
100
|
-
}
|
101
|
-
}).and_return(action)
|
64
|
+
expect(KnapsackPro::Client::API::Action).to receive(:new).with(
|
65
|
+
hash_including(request_hash: hash_excluding(:test_files))
|
66
|
+
).and_return(action)
|
102
67
|
expect(subject).to eq action
|
103
68
|
end
|
104
69
|
end
|
70
|
+
|
71
|
+
it "sends authors" do
|
72
|
+
action = double
|
73
|
+
|
74
|
+
expect(KnapsackPro::Client::API::Action).to receive(:new).with(
|
75
|
+
hash_including(request_hash: hash_including(:build_author, :commit_authors))
|
76
|
+
).and_return(action)
|
77
|
+
|
78
|
+
expect(subject).to eq action
|
79
|
+
end
|
105
80
|
end
|
106
81
|
end
|
@@ -1041,4 +1041,18 @@ describe KnapsackPro::Config::Env do
|
|
1041
1041
|
end
|
1042
1042
|
end
|
1043
1043
|
end
|
1044
|
+
|
1045
|
+
describe '.ci?' do
|
1046
|
+
[
|
1047
|
+
['CI from env', { 'CI' => 'True' }, true],
|
1048
|
+
['Travis CI', { 'TRAVIS' => 'true' }, true],
|
1049
|
+
['Unsupported', {}, false],
|
1050
|
+
].each do |ci, env, expected|
|
1051
|
+
it "detects #{ci}" do
|
1052
|
+
stub_const("ENV", env)
|
1053
|
+
|
1054
|
+
expect(described_class.ci?).to eq(expected)
|
1055
|
+
end
|
1056
|
+
end
|
1057
|
+
end
|
1044
1058
|
end
|
@@ -31,4 +31,76 @@ describe KnapsackPro::RepositoryAdapters::GitAdapter do
|
|
31
31
|
it { expect(subject.include?('master')).to be true }
|
32
32
|
it { expect(subject.include?(circle_branch)).to be true } if ENV['CIRCLECI']
|
33
33
|
end
|
34
|
+
|
35
|
+
describe '#build_author' do
|
36
|
+
it "returns the masked build author" do
|
37
|
+
allow_any_instance_of(KnapsackPro::RepositoryAdapters::GitAdapter).to receive(:git_build_author).and_return(
|
38
|
+
"John Doe <john.doe@example.com>" + "\n"
|
39
|
+
)
|
40
|
+
|
41
|
+
subject = KnapsackPro::RepositoryAdapters::GitAdapter.new
|
42
|
+
|
43
|
+
expect(subject.build_author).to eq 'Jo** Do* <jo**.do*@ex*****.co*>'
|
44
|
+
end
|
45
|
+
|
46
|
+
context "when the command raises an exception" do
|
47
|
+
it "returns the no-git author" do
|
48
|
+
allow_any_instance_of(KnapsackPro::RepositoryAdapters::GitAdapter).to receive(:git_build_author).and_raise(Exception)
|
49
|
+
|
50
|
+
subject = KnapsackPro::RepositoryAdapters::GitAdapter.new
|
51
|
+
|
52
|
+
expect(subject.build_author).to eq "no git <no.git@example.com>"
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
context "when the command returns an empty string" do
|
57
|
+
it "returns the no-git author" do
|
58
|
+
allow_any_instance_of(KnapsackPro::RepositoryAdapters::GitAdapter).to receive(:git_build_author).and_return("")
|
59
|
+
|
60
|
+
subject = KnapsackPro::RepositoryAdapters::GitAdapter.new
|
61
|
+
|
62
|
+
expect(subject.build_author).to eq "no git <no.git@example.com>"
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
describe '#commit_authors' do
|
68
|
+
it "returns the masked commit authors" do
|
69
|
+
allow_any_instance_of(KnapsackPro::RepositoryAdapters::GitAdapter).to receive(:git_commit_authors).and_return([
|
70
|
+
" 5\t3v0k4 <riccardo@example.com>\n",
|
71
|
+
" 10\tArtur Nowak <artur@example.com>\n",
|
72
|
+
" 2\tRiccardo <riccardo@example.com>\n",
|
73
|
+
" 3 \tshadre <shadi@example.com>\n",
|
74
|
+
].join(""))
|
75
|
+
|
76
|
+
subject = KnapsackPro::RepositoryAdapters::GitAdapter.new
|
77
|
+
|
78
|
+
expect(subject.commit_authors).to eq([
|
79
|
+
{ commits: 5, author: "3v0*4 <ri******@ex*****.co*>" },
|
80
|
+
{ commits: 10, author: "Ar*** No*** <ar***@ex*****.co*>" },
|
81
|
+
{ commits: 2, author: "Ri****** <ri******@ex*****.co*>" },
|
82
|
+
{ commits: 3, author: "sh**** <sh***@ex*****.co*>" },
|
83
|
+
])
|
84
|
+
end
|
85
|
+
|
86
|
+
context "when the authors command raises an exception" do
|
87
|
+
it "returns []" do
|
88
|
+
allow_any_instance_of(KnapsackPro::RepositoryAdapters::GitAdapter).to receive(:git_commit_authors).and_raise(Exception)
|
89
|
+
|
90
|
+
subject = KnapsackPro::RepositoryAdapters::GitAdapter.new
|
91
|
+
|
92
|
+
expect(subject.commit_authors).to eq []
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
context "when the authors command returns an empty string" do
|
97
|
+
it "returns []" do
|
98
|
+
allow_any_instance_of(KnapsackPro::RepositoryAdapters::GitAdapter).to receive(:git_commit_authors).and_return("")
|
99
|
+
|
100
|
+
subject = KnapsackPro::RepositoryAdapters::GitAdapter.new
|
101
|
+
|
102
|
+
expect(subject.commit_authors).to eq []
|
103
|
+
end
|
104
|
+
end
|
105
|
+
end
|
34
106
|
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: 5.1
|
4
|
+
version: 5.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- ArturT
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-07-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -192,6 +192,7 @@ files:
|
|
192
192
|
- ".circleci/config.yml"
|
193
193
|
- ".github/assets/install-button.png"
|
194
194
|
- ".github/assets/knapsack-diamonds.png"
|
195
|
+
- ".github/dependabot.yml"
|
195
196
|
- ".gitignore"
|
196
197
|
- ".rspec"
|
197
198
|
- CHANGELOG.md
|
@@ -244,6 +245,7 @@ files:
|
|
244
245
|
- lib/knapsack_pro/formatters/rspec_queue_summary_formatter.rb
|
245
246
|
- lib/knapsack_pro/hooks/queue.rb
|
246
247
|
- lib/knapsack_pro/logger_wrapper.rb
|
248
|
+
- lib/knapsack_pro/mask_string.rb
|
247
249
|
- lib/knapsack_pro/presenter.rb
|
248
250
|
- lib/knapsack_pro/queue_allocator.rb
|
249
251
|
- lib/knapsack_pro/queue_allocator_builder.rb
|