shipit-engine 0.18.0 → 0.18.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/controllers/shipit/api/deploys_controller.rb +2 -1
- data/app/controllers/shipit/deploys_controller.rb +8 -3
- data/app/controllers/shipit/rollbacks_controller.rb +3 -2
- data/app/controllers/shipit/tasks_controller.rb +8 -3
- data/app/models/shipit/deploy.rb +4 -3
- data/app/models/shipit/stack.rb +8 -3
- data/app/models/shipit/task.rb +7 -0
- data/db/migrate/20140226233935_create_baseline.rb +1 -1
- data/db/migrate/20150515190352_add_output_column_to_tasks.rb +1 -1
- data/db/migrate/20150518214944_add_ignore_ci_to_stack.rb +1 -1
- data/db/migrate/20150630154640_add_inaccessible_since_to_stacks.rb +1 -1
- data/db/migrate/20150708143032_add_rollback_when_complete_on_task.rb +1 -1
- data/db/migrate/20150814182557_add_env_to_tasks.rb +1 -1
- data/db/migrate/20150918190012_add_confirmations_to_tasks.rb +1 -1
- data/db/migrate/20151102201634_schema_constraints_cleanup.rb +1 -1
- data/db/migrate/20151103144716_convert_stacks_lock_reason_to_text.rb +1 -1
- data/db/migrate/20151112152112_reduce_tasks_type_size.rb +1 -1
- data/db/migrate/20151112152113_reduce_tasks_stats_size.rb +1 -1
- data/db/migrate/20151113151323_improve_indexes_on_tasks.rb +1 -1
- data/db/migrate/20160104151742_increase_tasks_type_size_back.rb +1 -1
- data/db/migrate/20160104151833_convert_sti_columns.rb +1 -1
- data/db/migrate/20160122165559_rename_hooks_url_in_delivery_url.rb +1 -1
- data/db/migrate/20160210183823_add_allow_concurrency_to_tasks.rb +1 -1
- data/db/migrate/20160303163611_create_shipit_commit_deployments.rb +1 -1
- data/db/migrate/20160303170913_create_shipit_commit_deployment_statuses.rb +1 -1
- data/db/migrate/20160303203940_add_encrypted_token_to_users.rb +1 -1
- data/db/migrate/20160324155046_add_started_at_and_ended_at_on_tasks.rb +1 -1
- data/db/migrate/20160426155146_add_index_for_stack_active_task.rb +1 -1
- data/db/migrate/20160502150713_add_estimated_deploy_duration_to_stacks.rb +1 -1
- data/db/migrate/20160526192650_reorder_active_tasks_index.rb +1 -1
- data/db/migrate/20160802092812_add_continuous_delivery_delayed_since_to_stacks.rb +1 -1
- data/db/migrate/20160822131405_add_locked_since_to_stacks.rb +1 -1
- data/lib/shipit/command.rb +1 -1
- data/lib/shipit/version.rb +1 -1
- data/test/controllers/deploys_controller_test.rb +3 -3
- data/test/controllers/rollbacks_controller_test.rb +1 -1
- data/test/controllers/tasks_controller_test.rb +7 -3
- data/test/dummy/db/test.sqlite3 +0 -0
- data/test/fixtures/shipit/tasks.yml +2 -0
- metadata +3 -5
- data/test/dummy/db/test.sqlite3-journal +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 164e72e212fa74b62ae7adab49efea057f1d983a
|
4
|
+
data.tar.gz: c5fbe8b529b76c20298ea2394b79358cb3dd22be
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2929a4f676679ea715b527c0ab62c22d63222cab8902c005a507ddd1e30d32246532039e7784c674af9daaf52c6ccdbab02488ca22ea847b59c2514f943499a9
|
7
|
+
data.tar.gz: 16fc66870a734dd2e2be52e3868417d32302a4ffb817064ac4d54334e152533e1021ab6b50e20f7dbb700f368dbbf3573258706d9618c27a97584c9d18be37de
|
@@ -11,7 +11,8 @@ module Shipit
|
|
11
11
|
def create
|
12
12
|
commit = stack.commits.by_sha(params.sha) || param_error!(:sha, 'Unknown revision')
|
13
13
|
param_error!(:force, "Can't deploy a locked stack") if !params.force && stack.locked?
|
14
|
-
|
14
|
+
deploy = stack.trigger_deploy(commit, current_user, env: params.env, force: params.force)
|
15
|
+
render_resource deploy, status: :accepted
|
15
16
|
end
|
16
17
|
end
|
17
18
|
end
|
@@ -20,10 +20,15 @@ module Shipit
|
|
20
20
|
end
|
21
21
|
|
22
22
|
def create
|
23
|
-
|
24
|
-
|
25
|
-
|
23
|
+
@deploy = @stack.trigger_deploy(
|
24
|
+
@until_commit,
|
25
|
+
current_user,
|
26
|
+
env: deploy_params[:env],
|
27
|
+
force: params[:force].present?,
|
28
|
+
)
|
26
29
|
respond_with(@deploy.stack, @deploy)
|
30
|
+
rescue Task::ConcurrentTaskRunning
|
31
|
+
redirect_to new_stack_deploy_path(@stack, sha: @until_commit.sha)
|
27
32
|
end
|
28
33
|
|
29
34
|
def rollback
|
@@ -4,9 +4,10 @@ module Shipit
|
|
4
4
|
before_action :load_deploy
|
5
5
|
|
6
6
|
def create
|
7
|
-
|
8
|
-
@rollback = @deploy.trigger_rollback(current_user, env: rollback_params[:env])
|
7
|
+
@rollback = @deploy.trigger_rollback(current_user, env: rollback_params[:env], force: params[:force].present?)
|
9
8
|
redirect_to stack_deploy_path(@stack, @rollback)
|
9
|
+
rescue Task::ConcurrentTaskRunning
|
10
|
+
redirect_to rollback_stack_deploy_path(@stack, @deploy)
|
10
11
|
end
|
11
12
|
|
12
13
|
private
|
@@ -28,10 +28,15 @@ module Shipit
|
|
28
28
|
def create
|
29
29
|
@definition = stack.find_task_definition(params[:definition_id])
|
30
30
|
|
31
|
-
|
32
|
-
@task = stack.trigger_task(
|
31
|
+
begin
|
32
|
+
@task = stack.trigger_task(
|
33
|
+
params[:definition_id],
|
34
|
+
current_user,
|
35
|
+
env: task_params[:env],
|
36
|
+
force: params[:force].present?,
|
37
|
+
)
|
33
38
|
redirect_to [stack, @task]
|
34
|
-
|
39
|
+
rescue Task::ConcurrentTaskRunning
|
35
40
|
redirect_to new_stack_tasks_path(stack, @definition)
|
36
41
|
end
|
37
42
|
end
|
data/app/models/shipit/deploy.rb
CHANGED
@@ -37,7 +37,7 @@ module Shipit
|
|
37
37
|
|
38
38
|
delegate :broadcast_update, :filter_deploy_envs, to: :stack
|
39
39
|
|
40
|
-
def build_rollback(user = nil, env: nil)
|
40
|
+
def build_rollback(user = nil, env: nil, force: false)
|
41
41
|
Rollback.new(
|
42
42
|
user_id: user.try!(:id),
|
43
43
|
stack_id: stack_id,
|
@@ -45,12 +45,13 @@ module Shipit
|
|
45
45
|
since_commit: stack.last_deployed_commit,
|
46
46
|
until_commit: until_commit,
|
47
47
|
env: env.try!(:to_h) || {},
|
48
|
+
allow_concurrency: force,
|
48
49
|
)
|
49
50
|
end
|
50
51
|
|
51
52
|
# Rolls the stack back to this deploy
|
52
|
-
def trigger_rollback(user = AnonymousUser.new, env: nil)
|
53
|
-
rollback = build_rollback(user, env: env)
|
53
|
+
def trigger_rollback(user = AnonymousUser.new, env: nil, force: false)
|
54
|
+
rollback = build_rollback(user, env: env, force: force)
|
54
55
|
rollback.save!
|
55
56
|
rollback.enqueue
|
56
57
|
|
data/app/models/shipit/stack.rb
CHANGED
@@ -81,7 +81,7 @@ module Shipit
|
|
81
81
|
undeployed_commits_count > 0
|
82
82
|
end
|
83
83
|
|
84
|
-
def trigger_task(definition_id, user, env: nil)
|
84
|
+
def trigger_task(definition_id, user, env: nil, force: false)
|
85
85
|
definition = find_task_definition(definition_id)
|
86
86
|
env = env.try!(:to_h) || {}
|
87
87
|
|
@@ -96,18 +96,20 @@ module Shipit
|
|
96
96
|
until_commit_id: commit.id,
|
97
97
|
since_commit_id: commit.id,
|
98
98
|
env: definition.filter_envs(env),
|
99
|
+
allow_concurrency: definition.allow_concurrency? || force,
|
99
100
|
)
|
100
101
|
task.enqueue
|
101
102
|
task
|
102
103
|
end
|
103
104
|
|
104
|
-
def build_deploy(until_commit, user, env: nil)
|
105
|
+
def build_deploy(until_commit, user, env: nil, force: false)
|
105
106
|
since_commit = last_deployed_commit.presence || commits.first
|
106
107
|
deploys.build(
|
107
108
|
user_id: user.id,
|
108
109
|
until_commit: until_commit,
|
109
110
|
since_commit: since_commit,
|
110
111
|
env: filter_deploy_envs(env.try!(:to_h) || {}),
|
112
|
+
allow_concurrency: force,
|
111
113
|
)
|
112
114
|
end
|
113
115
|
|
@@ -144,7 +146,10 @@ module Shipit
|
|
144
146
|
return
|
145
147
|
end
|
146
148
|
|
147
|
-
|
149
|
+
begin
|
150
|
+
trigger_deploy(commit, Shipit.user, env: cached_deploy_spec.default_deploy_env)
|
151
|
+
rescue Task::ConcurrentTaskRunning
|
152
|
+
end
|
148
153
|
end
|
149
154
|
|
150
155
|
def schedule_merges
|
data/app/models/shipit/task.rb
CHANGED
@@ -2,6 +2,8 @@ module Shipit
|
|
2
2
|
class Task < ActiveRecord::Base
|
3
3
|
include DeferredTouch
|
4
4
|
|
5
|
+
ConcurrentTaskRunning = Class.new(StandardError)
|
6
|
+
|
5
7
|
PRESENCE_CHECK_TIMEOUT = 15
|
6
8
|
ACTIVE_STATUSES = %w(pending running aborting).freeze
|
7
9
|
COMPLETED_STATUSES = %w(success error failed flapping aborted).freeze
|
@@ -32,6 +34,7 @@ module Shipit
|
|
32
34
|
scope :due_for_rollup, -> { completed.where(rolled_up: false).where('created_at <= ?', 1.hour.ago) }
|
33
35
|
|
34
36
|
after_save :record_status_change
|
37
|
+
after_create :prevent_concurrency, unless: :allow_concurrency?
|
35
38
|
after_commit :emit_hooks
|
36
39
|
|
37
40
|
class << self
|
@@ -264,6 +267,10 @@ module Shipit
|
|
264
267
|
|
265
268
|
private
|
266
269
|
|
270
|
+
def prevent_concurrency
|
271
|
+
raise ConcurrentTaskRunning if stack.tasks.active.exclusive.count > 1
|
272
|
+
end
|
273
|
+
|
267
274
|
def status_key
|
268
275
|
"shipit:task:#{id}"
|
269
276
|
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
class SchemaConstraintsCleanup < ActiveRecord::Migration
|
1
|
+
class SchemaConstraintsCleanup < ActiveRecord::Migration[4.2]
|
2
2
|
# Set reasonable size limit to a bunch of indexed string columns. They were defaulted to 255
|
3
3
|
def change
|
4
4
|
change_column :github_hooks, :event, :string, limit: 50, null: false # The biggest existing event is 27
|
@@ -1,4 +1,4 @@
|
|
1
|
-
class ImproveIndexesOnTasks < ActiveRecord::Migration
|
1
|
+
class ImproveIndexesOnTasks < ActiveRecord::Migration[4.2]
|
2
2
|
def change
|
3
3
|
add_index :tasks, [:type, :stack_id, :status], name: :index_tasks_by_stack_and_status
|
4
4
|
add_index :tasks, [:type, :stack_id, :parent_id], name: :index_tasks_by_stack_and_parent
|
@@ -1,4 +1,4 @@
|
|
1
|
-
class CreateShipitCommitDeploymentStatuses < ActiveRecord::Migration
|
1
|
+
class CreateShipitCommitDeploymentStatuses < ActiveRecord::Migration[4.2]
|
2
2
|
def change
|
3
3
|
create_table :commit_deployment_statuses do |t|
|
4
4
|
t.references :commit_deployment, index: true, foreign_key: true
|
data/lib/shipit/command.rb
CHANGED
@@ -86,7 +86,7 @@ module Shipit
|
|
86
86
|
FileUtils.mkdir_p(@chdir)
|
87
87
|
with_full_path do
|
88
88
|
begin
|
89
|
-
@out, child_in, @pid = PTY.spawn(@env, *interpolated_arguments, chdir: @chdir)
|
89
|
+
@out, child_in, @pid = PTY.spawn(@env.stringify_keys, *interpolated_arguments, chdir: @chdir)
|
90
90
|
child_in.close
|
91
91
|
rescue Errno::ENOENT
|
92
92
|
raise NotFound, "#{Shellwords.split(interpolated_arguments.first).first}: command not found"
|
data/lib/shipit/version.rb
CHANGED
@@ -32,7 +32,7 @@ module Shipit
|
|
32
32
|
end
|
33
33
|
|
34
34
|
test ":new shows a warning if a deploy is already running" do
|
35
|
-
shipit_deploys(:shipit_running).
|
35
|
+
shipit_deploys(:shipit_running).update!(allow_concurrency: false, status: 'running')
|
36
36
|
|
37
37
|
get :new, params: {stack_id: @stack.to_param, sha: @commit.sha}
|
38
38
|
assert_response :success
|
@@ -70,7 +70,7 @@ module Shipit
|
|
70
70
|
end
|
71
71
|
|
72
72
|
test ":create redirect back to :new with a warning if there is an active deploy" do
|
73
|
-
shipit_deploys(:shipit_running).
|
73
|
+
shipit_deploys(:shipit_running).update!(allow_concurrency: false, status: 'running')
|
74
74
|
|
75
75
|
assert_no_difference '@stack.deploys.count' do
|
76
76
|
post :create, params: {stack_id: @stack.to_param, deploy: {until_commit_id: @commit.id}}
|
@@ -90,7 +90,7 @@ module Shipit
|
|
90
90
|
end
|
91
91
|
|
92
92
|
test ":rollback shows a warning if a deploy is already running" do
|
93
|
-
shipit_deploys(:shipit_running).
|
93
|
+
shipit_deploys(:shipit_running).update!(allow_concurrency: false, status: 'running')
|
94
94
|
|
95
95
|
get :rollback, params: {stack_id: @stack.to_param, id: @deploy.id}
|
96
96
|
assert_response :success
|
@@ -39,7 +39,7 @@ module Shipit
|
|
39
39
|
end
|
40
40
|
|
41
41
|
test ":create redirects back to the :new page if there is an active deploy" do
|
42
|
-
shipit_deploys(:shipit_running).
|
42
|
+
shipit_deploys(:shipit_running).update!(allow_concurrency: false, status: 'running')
|
43
43
|
assert_no_difference '@stack.deploys.count' do
|
44
44
|
post :create, params: {stack_id: @stack.to_param, rollback: {parent_id: @deploy.id}}
|
45
45
|
end
|
@@ -16,15 +16,19 @@ module Shipit
|
|
16
16
|
end
|
17
17
|
|
18
18
|
test "tasks defined in the shipit.yml can't be triggered if the stack is being deployed" do
|
19
|
-
|
19
|
+
shipit_deploys(:shipit_running).update!(allow_concurrency: false, status: 'running')
|
20
|
+
|
21
|
+
assert_predicate @stack, :active_task?
|
20
22
|
assert_no_difference -> { @stack.tasks.count } do
|
21
23
|
post :create, params: {stack_id: @stack, definition_id: @definition.id}
|
22
24
|
end
|
23
25
|
assert_redirected_to new_stack_tasks_path(@stack, @definition)
|
24
26
|
end
|
25
27
|
|
26
|
-
test "tasks defined in the shipit.yml can be triggered anyway if force
|
27
|
-
|
28
|
+
test "tasks defined in the shipit.yml can be triggered anyway if force param is present" do
|
29
|
+
shipit_deploys(:shipit_running).update!(allow_concurrency: false, status: 'running')
|
30
|
+
|
31
|
+
assert_predicate @stack, :active_task?
|
28
32
|
assert_difference -> { @stack.tasks.count } do
|
29
33
|
post :create, params: {stack_id: @stack, definition_id: @definition.id, force: 'true'}
|
30
34
|
end
|
data/test/dummy/db/test.sqlite3
CHANGED
Binary file
|
@@ -61,6 +61,7 @@ shipit_pending:
|
|
61
61
|
additions: 432
|
62
62
|
deletions: 406
|
63
63
|
created_at: <%= (60 - 4).minutes.ago.to_s(:db) %>
|
64
|
+
allow_concurrency: true
|
64
65
|
|
65
66
|
shipit_running:
|
66
67
|
id: 5
|
@@ -74,6 +75,7 @@ shipit_running:
|
|
74
75
|
deletions: 342
|
75
76
|
created_at: <%= (60 - 5).minutes.ago.to_s(:db) %>
|
76
77
|
started_at: <%= (60 - 5).minutes.ago.to_s(:db) %>
|
78
|
+
allow_concurrency: true
|
77
79
|
|
78
80
|
shipit_complete:
|
79
81
|
id: 6
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: shipit-engine
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.18.
|
4
|
+
version: 0.18.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jean Boussier
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-05-
|
11
|
+
date: 2017-05-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -776,7 +776,6 @@ files:
|
|
776
776
|
- test/dummy/db/schema.rb
|
777
777
|
- test/dummy/db/seeds.rb
|
778
778
|
- test/dummy/db/test.sqlite3
|
779
|
-
- test/dummy/db/test.sqlite3-journal
|
780
779
|
- test/dummy/public/404.html
|
781
780
|
- test/dummy/public/422.html
|
782
781
|
- test/dummy/public/500.html
|
@@ -879,7 +878,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
879
878
|
version: '0'
|
880
879
|
requirements: []
|
881
880
|
rubyforge_project:
|
882
|
-
rubygems_version: 2.
|
881
|
+
rubygems_version: 2.6.10
|
883
882
|
signing_key:
|
884
883
|
specification_version: 4
|
885
884
|
summary: Application deployment software
|
@@ -956,7 +955,6 @@ test_files:
|
|
956
955
|
- test/dummy/db/schema.rb
|
957
956
|
- test/dummy/db/seeds.rb
|
958
957
|
- test/dummy/db/test.sqlite3
|
959
|
-
- test/dummy/db/test.sqlite3-journal
|
960
958
|
- test/dummy/public/404.html
|
961
959
|
- test/dummy/public/422.html
|
962
960
|
- test/dummy/public/500.html
|
Binary file
|