shipit-engine 0.42.0 → 0.43.1
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/app/models/shipit/commit.rb +7 -9
- data/app/models/shipit/deploy_spec/bundler_discovery.rb +19 -7
- data/lib/shipit/commands.rb +12 -5
- data/lib/shipit/version.rb +1 -1
- data/lib/shipit.rb +6 -1
- data/test/dummy/config/environments/development.rb +3 -0
- data/test/dummy/config/environments/production.rb +3 -0
- data/test/dummy/config/environments/test.rb +3 -0
- data/test/dummy/db/seeds.rb +1 -1
- data/test/models/commits_test.rb +69 -0
- data/test/models/deploy_spec_test.rb +9 -10
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: a115bf18d2ceef6d9174c41bf746c8c0e7481b9967f546ee26ff9dfad8cde608
|
|
4
|
+
data.tar.gz: 5e3856d83fdd58ec6f169ce4a01e2782606cddeda43b24705075e62237c79709
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: b1763e4292845af68b81ff1e60dc34377a962834a797975293429726371b9a8868be7a47193a777e3e10bcfb171dc429d09b86aaf83f202e065716245c650214
|
|
7
|
+
data.tar.gz: 9a6f799a3d538f45c781443798f7076a52e98499d6e56cc477b250ca5a390759b3344c6d5a1809cc894bb88ad456d64b6d3910ab3322b371b88ed314dd83b538
|
data/app/models/shipit/commit.rb
CHANGED
|
@@ -173,23 +173,21 @@ module Shipit
|
|
|
173
173
|
stack.github_api.check_runs(github_repo_name, sha, per_page: 100)
|
|
174
174
|
end
|
|
175
175
|
|
|
176
|
-
|
|
176
|
+
yield response.check_runs
|
|
177
177
|
|
|
178
|
-
|
|
178
|
+
until stack.github_api.last_response.rels[:next].nil?
|
|
179
179
|
page = stack.handle_github_redirections do
|
|
180
180
|
stack.github_api.get(stack.github_api.last_response.rels[:next].href)
|
|
181
181
|
end
|
|
182
|
-
|
|
183
|
-
break if stack.github_api.last_response.rels[:next].nil?
|
|
182
|
+
yield page.check_runs
|
|
184
183
|
end
|
|
185
|
-
|
|
186
|
-
response
|
|
187
184
|
end
|
|
188
185
|
|
|
189
186
|
def refresh_check_runs!
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
187
|
+
paginated_check_runs do |check_runs|
|
|
188
|
+
check_runs.each do |check_run|
|
|
189
|
+
create_or_update_check_run_from_github!(check_run)
|
|
190
|
+
end
|
|
193
191
|
end
|
|
194
192
|
end
|
|
195
193
|
|
|
@@ -26,9 +26,18 @@ module Shipit
|
|
|
26
26
|
end
|
|
27
27
|
|
|
28
28
|
def bundle_install
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
[
|
|
29
|
+
install_command = %(bundle install --jobs 4 --retry 2)
|
|
30
|
+
install_command += " --without=#{bundler_without.join(':')}" unless bundler_without.empty?
|
|
31
|
+
[
|
|
32
|
+
remove_ruby_version_from_gemfile,
|
|
33
|
+
(bundle_config_frozen if frozen_mode?),
|
|
34
|
+
bundle_config_path,
|
|
35
|
+
install_command
|
|
36
|
+
].compact
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
def bundle_config_path
|
|
40
|
+
"bundle config set --local path #{bundle_path}"
|
|
32
41
|
end
|
|
33
42
|
|
|
34
43
|
def remove_ruby_version_from_gemfile
|
|
@@ -41,11 +50,14 @@ module Shipit
|
|
|
41
50
|
end
|
|
42
51
|
end
|
|
43
52
|
|
|
44
|
-
def
|
|
45
|
-
|
|
46
|
-
|
|
53
|
+
def bundle_config_frozen
|
|
54
|
+
'bundle config set --local frozen true'
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
def frozen_mode?
|
|
58
|
+
return false unless gemfile_lock_exists?
|
|
47
59
|
|
|
48
|
-
'
|
|
60
|
+
config('dependencies', 'bundler', 'frozen') != false
|
|
49
61
|
end
|
|
50
62
|
|
|
51
63
|
def bundler_without
|
data/lib/shipit/commands.rb
CHANGED
|
@@ -35,11 +35,18 @@ module Shipit
|
|
|
35
35
|
private
|
|
36
36
|
|
|
37
37
|
def base_env
|
|
38
|
-
@base_env ||=
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
38
|
+
@base_env ||= begin
|
|
39
|
+
env = Shipit.env.merge(
|
|
40
|
+
'GITHUB_DOMAIN' => github.domain,
|
|
41
|
+
'GITHUB_TOKEN' => github.token
|
|
42
|
+
)
|
|
43
|
+
|
|
44
|
+
if Shipit.use_git_askpass?
|
|
45
|
+
env['GIT_ASKPASS'] = Shipit::Engine.root.join('lib', 'snippets', 'git-askpass').realpath.to_s
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
env
|
|
49
|
+
end
|
|
43
50
|
end
|
|
44
51
|
|
|
45
52
|
def github
|
data/lib/shipit/version.rb
CHANGED
data/lib/shipit.rb
CHANGED
|
@@ -71,7 +71,8 @@ module Shipit
|
|
|
71
71
|
:internal_hook_receivers,
|
|
72
72
|
:preferred_org_emails,
|
|
73
73
|
:task_execution_strategy,
|
|
74
|
-
:task_logger
|
|
74
|
+
:task_logger,
|
|
75
|
+
:use_git_askpass
|
|
75
76
|
)
|
|
76
77
|
|
|
77
78
|
def task_execution_strategy
|
|
@@ -297,6 +298,10 @@ module Shipit
|
|
|
297
298
|
@task_logger ||= Logger.new(nil)
|
|
298
299
|
end
|
|
299
300
|
|
|
301
|
+
def use_git_askpass?
|
|
302
|
+
@use_git_askpass.nil? ? true : @use_git_askpass
|
|
303
|
+
end
|
|
304
|
+
|
|
300
305
|
protected
|
|
301
306
|
|
|
302
307
|
def revision_file
|
|
@@ -48,6 +48,9 @@ Rails.application.configure do
|
|
|
48
48
|
# Raises helpful error messages.
|
|
49
49
|
config.assets.raise_runtime_errors = true
|
|
50
50
|
|
|
51
|
+
# Disable git askpass in development
|
|
52
|
+
Shipit.use_git_askpass = false
|
|
53
|
+
|
|
51
54
|
# Raises error for missing translations
|
|
52
55
|
# config.action_view.raise_on_missing_translations = true
|
|
53
56
|
if Rails.application.config_for(:database)&.dig('adapter') == 'sqlite3'
|
|
@@ -32,6 +32,9 @@ Rails.application.configure do
|
|
|
32
32
|
# Print deprecation notices to the stderr.
|
|
33
33
|
config.active_support.deprecation = :stderr
|
|
34
34
|
|
|
35
|
+
# Disable git askpass in test
|
|
36
|
+
Shipit.use_git_askpass = false
|
|
37
|
+
|
|
35
38
|
# Raises error for missing translations
|
|
36
39
|
# config.action_view.raise_on_missing_translations = true
|
|
37
40
|
|
data/test/dummy/db/seeds.rb
CHANGED
|
@@ -53,7 +53,7 @@ module Shipit
|
|
|
53
53
|
]
|
|
54
54
|
},
|
|
55
55
|
"override": [
|
|
56
|
-
"bundle
|
|
56
|
+
"bundle config set path /tmp/bundler && (bundle check || bundle install --frozen --retry=2 --without=default:production:development:test:staging:benchmark:debug)"
|
|
57
57
|
]
|
|
58
58
|
},
|
|
59
59
|
"fetch": [
|
data/test/models/commits_test.rb
CHANGED
|
@@ -367,6 +367,75 @@ module Shipit
|
|
|
367
367
|
assert_equal 'success', @commit.check_runs.first.state
|
|
368
368
|
end
|
|
369
369
|
|
|
370
|
+
test "refresh_check_runs! handles paginated responses from github" do
|
|
371
|
+
# First page check runs
|
|
372
|
+
check_run1 = mock(
|
|
373
|
+
id: 111_111_111_111_111,
|
|
374
|
+
name: 'Test suite 1',
|
|
375
|
+
conclusion: 'success',
|
|
376
|
+
details_url: 'https://example.com/details/1',
|
|
377
|
+
html_url: 'https://example.com/run/1',
|
|
378
|
+
output: mock(
|
|
379
|
+
title: 'Tests build 1 ran successfully'
|
|
380
|
+
),
|
|
381
|
+
completed_at: Time.now,
|
|
382
|
+
started_at: Time.now - 1.minute
|
|
383
|
+
)
|
|
384
|
+
check_run2 = mock(
|
|
385
|
+
id: 222_222_222_222_222,
|
|
386
|
+
name: 'Test suite 2',
|
|
387
|
+
conclusion: 'failure',
|
|
388
|
+
details_url: 'https://example.com/details/2',
|
|
389
|
+
html_url: 'https://example.com/run/2',
|
|
390
|
+
output: mock(
|
|
391
|
+
title: 'Tests build 2 failed'
|
|
392
|
+
),
|
|
393
|
+
completed_at: Time.now,
|
|
394
|
+
started_at: Time.now - 2.minutes
|
|
395
|
+
)
|
|
396
|
+
|
|
397
|
+
# Second page check runs
|
|
398
|
+
check_run3 = mock(
|
|
399
|
+
id: 333_333_333_333_333,
|
|
400
|
+
name: 'Test suite 3',
|
|
401
|
+
conclusion: 'success',
|
|
402
|
+
details_url: 'https://example.com/details/3',
|
|
403
|
+
html_url: 'https://example.com/run/3',
|
|
404
|
+
output: mock(
|
|
405
|
+
title: 'Tests build 3 skipped'
|
|
406
|
+
),
|
|
407
|
+
completed_at: Time.now,
|
|
408
|
+
started_at: Time.now - 3.minutes
|
|
409
|
+
)
|
|
410
|
+
|
|
411
|
+
next_link = stub(href: 'https://api.github.com/repos/test/repo/check-runs?page=2')
|
|
412
|
+
first_response = stub(rels: { next: next_link }, data: mock(check_runs: [check_run1, check_run2]))
|
|
413
|
+
second_response = stub(rels: {}, data: mock(check_runs: [check_run3]))
|
|
414
|
+
|
|
415
|
+
call_sequence = sequence('api_calls')
|
|
416
|
+
Shipit.github.api.expects(:check_runs).with(@stack.github_repo_name, @commit.sha, per_page: 100).returns(first_response.data).in_sequence(call_sequence)
|
|
417
|
+
Shipit.github.api.expects(:last_response).returns(first_response).in_sequence(call_sequence)
|
|
418
|
+
Shipit.github.api.expects(:last_response).returns(first_response).in_sequence(call_sequence)
|
|
419
|
+
Shipit.github.api.expects(:get).with(next_link.href).returns(second_response.data).in_sequence(call_sequence)
|
|
420
|
+
Shipit.github.api.expects(:last_response).returns(second_response).in_sequence(call_sequence)
|
|
421
|
+
|
|
422
|
+
assert_difference -> { @commit.check_runs.count }, 3 do
|
|
423
|
+
@commit.refresh_check_runs!
|
|
424
|
+
end
|
|
425
|
+
|
|
426
|
+
check1 = @commit.check_runs.find_by(github_id: 111_111_111_111_111)
|
|
427
|
+
assert_not_nil check1
|
|
428
|
+
assert_equal 'success', check1.state
|
|
429
|
+
|
|
430
|
+
check2 = @commit.check_runs.find_by(github_id: 222_222_222_222_222)
|
|
431
|
+
assert_not_nil check2
|
|
432
|
+
assert_equal 'failure', check2.state
|
|
433
|
+
|
|
434
|
+
check3 = @commit.check_runs.find_by(github_id: 333_333_333_333_333)
|
|
435
|
+
assert_not_nil check3
|
|
436
|
+
assert_equal 'success', check3.state
|
|
437
|
+
end
|
|
438
|
+
|
|
370
439
|
test "#creating a commit update the undeployed_commits_count" do
|
|
371
440
|
walrus = shipit_users(:walrus)
|
|
372
441
|
assert_equal 2, @stack.undeployed_commits_count
|
|
@@ -67,13 +67,14 @@ module Shipit
|
|
|
67
67
|
@spec.stubs(:gemfile_lock_exists?).returns(true)
|
|
68
68
|
command = %(
|
|
69
69
|
bundle install
|
|
70
|
-
--frozen
|
|
71
70
|
--jobs 4
|
|
72
|
-
--path #{DeploySpec.bundle_path}
|
|
73
71
|
--retry 2
|
|
74
72
|
--without=default:production:development:test:staging:benchmark:debug
|
|
75
73
|
).gsub(/\s+/, ' ').strip
|
|
74
|
+
config_command = "bundle config set --local path #{@spec.bundle_path}"
|
|
75
|
+
|
|
76
76
|
assert_equal command, @spec.bundle_install.last
|
|
77
|
+
assert @spec.bundle_install.include?(config_command)
|
|
77
78
|
end
|
|
78
79
|
|
|
79
80
|
test '#bundle_install use `dependencies.bundler.without` if present to build the --without argument' do
|
|
@@ -81,31 +82,29 @@ module Shipit
|
|
|
81
82
|
@spec.stubs(:load_config).returns('dependencies' => { 'bundler' => { 'without' => %w[some custom groups] } })
|
|
82
83
|
command = %(
|
|
83
84
|
bundle install
|
|
84
|
-
--frozen
|
|
85
85
|
--jobs 4
|
|
86
|
-
--path #{DeploySpec.bundle_path}
|
|
87
86
|
--retry 2
|
|
88
87
|
--without=some:custom:groups
|
|
89
88
|
).gsub(/\s+/, ' ').strip
|
|
90
89
|
assert_equal command, @spec.bundle_install.last
|
|
91
90
|
end
|
|
92
91
|
|
|
93
|
-
test '#bundle_install
|
|
92
|
+
test '#bundle_install configures frozen mode if Gemfile.lock is present' do
|
|
94
93
|
@spec.stubs(:load_config).returns('dependencies' => { 'bundler' => { 'without' => %w[some custom groups] } })
|
|
95
94
|
@spec.stubs(:gemfile_lock_exists?).returns(true)
|
|
96
|
-
assert @spec.bundle_install.
|
|
95
|
+
assert @spec.bundle_install.include?('bundle config set --local frozen true')
|
|
97
96
|
end
|
|
98
97
|
|
|
99
|
-
test '#bundle_install does not
|
|
98
|
+
test '#bundle_install does not configure frozen mode if Gemfile.lock is not present' do
|
|
100
99
|
@spec.stubs(:load_config).returns('dependencies' => { 'bundler' => { 'without' => %w[some custom groups] } })
|
|
101
100
|
@spec.stubs(:gemfile_lock_exists?).returns(false)
|
|
102
|
-
refute @spec.bundle_install.
|
|
101
|
+
refute @spec.bundle_install.include?('bundle config set --local frozen true')
|
|
103
102
|
end
|
|
104
103
|
|
|
105
|
-
test '#bundle_install does not
|
|
104
|
+
test '#bundle_install does not configure frozen mode if overridden in shipit.yml' do
|
|
106
105
|
@spec.stubs(:load_config).returns('dependencies' => { 'bundler' => { 'frozen' => false } })
|
|
107
106
|
@spec.stubs(:gemfile_lock_exists?).returns(true)
|
|
108
|
-
refute @spec.bundle_install.
|
|
107
|
+
refute @spec.bundle_install.include?('bundle config set --local frozen true')
|
|
109
108
|
end
|
|
110
109
|
|
|
111
110
|
test "#provisioning_handler returns `provision.handler` if present" do
|