shipit-engine 0.11.0 → 0.12.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/README.md +41 -37
- data/app/assets/javascripts/task/tty.js.coffee +40 -22
- data/app/assets/stylesheets/_pages/_deploy.scss +1 -0
- data/app/controllers/shipit/api/locks_controller.rb +3 -3
- data/app/controllers/shipit/api/stacks_controller.rb +14 -1
- data/app/controllers/shipit/commit_checks_controller.rb +9 -2
- data/app/controllers/shipit/shipit_controller.rb +1 -1
- data/app/controllers/shipit/stacks_controller.rb +11 -5
- data/app/controllers/shipit/status_controller.rb +1 -1
- data/app/controllers/shipit/webhooks_controller.rb +15 -5
- data/app/helpers/shipit/deploys_helper.rb +1 -1
- data/app/helpers/shipit/shipit_helper.rb +2 -0
- data/app/jobs/shipit/perform_commit_checks_job.rb +2 -0
- data/app/jobs/shipit/perform_task_job.rb +18 -8
- data/app/models/shipit/commit.rb +22 -12
- data/app/models/shipit/commit_checks.rb +20 -53
- data/app/models/shipit/deploy.rb +1 -1
- data/app/models/shipit/ephemeral_commit_checks.rb +76 -0
- data/app/models/shipit/stack.rb +40 -10
- data/app/models/shipit/status.rb +14 -8
- data/app/models/shipit/status_group.rb +1 -1
- data/app/models/shipit/task.rb +2 -0
- data/app/models/shipit/unknown_status.rb +4 -0
- data/app/models/shipit/user.rb +9 -1
- data/app/serializers/shipit/stack_serializer.rb +6 -1
- data/app/views/shipit/commit_checks/_checks.html.erb +13 -0
- data/app/views/shipit/commit_checks/show.html.erb +5 -0
- data/app/views/shipit/stacks/_header.html.erb +1 -1
- data/app/views/shipit/stacks/show.html.erb +15 -0
- data/config/routes.rb +2 -1
- data/db/migrate/20140226233935_create_baseline.rb +10 -10
- data/db/migrate/20160802092812_add_continuous_delivery_delayed_since_to_stacks.rb +5 -0
- data/db/migrate/20160822131405_add_locked_since_to_stacks.rb +5 -0
- data/lib/shipit.rb +4 -0
- data/lib/shipit/command.rb +1 -1
- data/lib/shipit/commands.rb +10 -7
- data/lib/shipit/csv_serializer.rb +1 -1
- data/lib/shipit/stack_commands.rb +17 -5
- data/lib/shipit/task_commands.rb +2 -2
- data/lib/shipit/version.rb +1 -1
- data/lib/snippets/push-to-heroku +20 -16
- data/test/controllers/api/deploys_controller_test.rb +8 -8
- data/test/controllers/api/hooks_controller_test.rb +11 -9
- data/test/controllers/api/locks_controller_test.rb +16 -6
- data/test/controllers/api/outputs_controller_test.rb +1 -1
- data/test/controllers/api/stacks_controller_test.rb +48 -3
- data/test/controllers/api/tasks_controller_test.rb +6 -6
- data/test/controllers/commit_checks_controller_test.rb +3 -3
- data/test/controllers/deploys_controller_test.rb +13 -13
- data/test/controllers/rollbacks_controller_test.rb +7 -7
- data/test/controllers/stacks_controller_test.rb +36 -29
- data/test/controllers/tasks_controller_test.rb +14 -14
- data/test/controllers/webhooks_controller_test.rb +16 -25
- data/test/dummy/config/application.rb +0 -3
- data/test/dummy/config/environments/test.rb +2 -2
- data/test/dummy/data/stacks/byroot/junk/production/git/bar.txt +2 -0
- data/test/dummy/data/stacks/byroot/junk/production/git/bin/slow +7 -0
- data/test/dummy/data/stacks/byroot/junk/production/git/bin/timeout +10 -0
- data/test/dummy/data/stacks/byroot/junk/production/git/dkfdsf +0 -0
- data/test/dummy/data/stacks/byroot/junk/production/git/dskjfsd +0 -0
- data/test/dummy/data/stacks/byroot/junk/production/git/dslkjfjsdf +0 -0
- data/test/dummy/data/stacks/byroot/junk/production/git/plopfizz +0 -0
- data/test/dummy/data/stacks/byroot/junk/production/git/sd +0 -0
- data/test/dummy/data/stacks/byroot/junk/production/git/sdkfjsdf +1 -0
- data/test/dummy/data/stacks/byroot/junk/production/git/sdlfjsdfdsfj +0 -0
- data/test/dummy/data/stacks/byroot/junk/production/git/sdlkfjsdlkfjsdlkfjdsfsdfksdfjsldkfjsdlkfjsdf +0 -0
- data/test/dummy/data/stacks/byroot/junk/production/git/shipit.yml +21 -0
- data/test/dummy/data/stacks/byroot/junk/production/git/toto.txt +2 -0
- data/test/dummy/db/development.sqlite3 +0 -0
- data/test/dummy/db/schema.rb +15 -13
- data/test/dummy/db/test.sqlite3 +0 -0
- data/test/fixtures/shipit/commit_deployments.yml +8 -8
- data/test/fixtures/shipit/output_chunks.yml +12 -12
- data/test/fixtures/shipit/tasks.yml +9 -1
- data/test/fixtures/shipit/users.yml +9 -2
- data/test/jobs/perform_task_job_test.rb +14 -11
- data/test/models/commits_test.rb +33 -14
- data/test/models/stacks_test.rb +78 -4
- data/test/models/users_test.rb +16 -0
- data/test/unit/commands_test.rb +4 -0
- data/test/unit/deploy_commands_test.rb +1 -1
- metadata +133 -34
- data/app/jobs/shipit/git_mirror_update_job.rb +0 -14
- data/app/views/shipit/deploys/_checks.html.erb +0 -11
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
@@ -0,0 +1 @@
|
|
1
|
+
dslkfnds
|
File without changes
|
data/test/dummy/data/stacks/byroot/junk/production/git/sdlkfjsdlkfjsdlkfjdsfsdfksdfjsldkfjsdlkfjsdf
ADDED
File without changes
|
@@ -0,0 +1,21 @@
|
|
1
|
+
review:
|
2
|
+
checklist:
|
3
|
+
- Blah Blah
|
4
|
+
checks:
|
5
|
+
- echo 42
|
6
|
+
|
7
|
+
deploy:
|
8
|
+
override:
|
9
|
+
- bin/slow
|
10
|
+
- bin/timeout: {timeout: 5}
|
11
|
+
|
12
|
+
rollback:
|
13
|
+
override:
|
14
|
+
- echo done
|
15
|
+
|
16
|
+
tasks:
|
17
|
+
restart:
|
18
|
+
action: Restart application
|
19
|
+
description: Trigger the restart of both app and jobs servers
|
20
|
+
steps:
|
21
|
+
- cap $ENVIRONMENT deploy:restart
|
Binary file
|
data/test/dummy/db/schema.rb
CHANGED
@@ -11,7 +11,7 @@
|
|
11
11
|
#
|
12
12
|
# It's strongly recommended that you check this file into your version control system.
|
13
13
|
|
14
|
-
ActiveRecord::Schema.define(version:
|
14
|
+
ActiveRecord::Schema.define(version: 20160822131405) do
|
15
15
|
|
16
16
|
create_table "api_clients", force: :cascade do |t|
|
17
17
|
t.text "permissions", limit: 65535
|
@@ -130,22 +130,24 @@ ActiveRecord::Schema.define(version: 20160526192650) do
|
|
130
130
|
add_index "output_chunks", ["task_id"], name: "index_output_chunks_on_task_id"
|
131
131
|
|
132
132
|
create_table "stacks", force: :cascade do |t|
|
133
|
-
t.string "repo_name",
|
134
|
-
t.string "repo_owner",
|
135
|
-
t.string "environment",
|
133
|
+
t.string "repo_name", limit: 100, null: false
|
134
|
+
t.string "repo_owner", limit: 39, null: false
|
135
|
+
t.string "environment", limit: 50, default: "production", null: false
|
136
136
|
t.datetime "created_at"
|
137
137
|
t.datetime "updated_at"
|
138
|
-
t.string "branch",
|
139
|
-
t.string "deploy_url",
|
140
|
-
t.string "lock_reason",
|
141
|
-
t.integer "tasks_count",
|
142
|
-
t.boolean "continuous_deployment",
|
143
|
-
t.integer "undeployed_commits_count",
|
144
|
-
t.text "cached_deploy_spec",
|
145
|
-
t.integer "lock_author_id",
|
138
|
+
t.string "branch", limit: 255, default: "master", null: false
|
139
|
+
t.string "deploy_url", limit: 255
|
140
|
+
t.string "lock_reason", limit: 4096
|
141
|
+
t.integer "tasks_count", limit: 4, default: 0, null: false
|
142
|
+
t.boolean "continuous_deployment", default: false, null: false
|
143
|
+
t.integer "undeployed_commits_count", limit: 4, default: 0, null: false
|
144
|
+
t.text "cached_deploy_spec", limit: 65535
|
145
|
+
t.integer "lock_author_id", limit: 4
|
146
146
|
t.boolean "ignore_ci"
|
147
147
|
t.datetime "inaccessible_since"
|
148
|
-
t.integer "estimated_deploy_duration",
|
148
|
+
t.integer "estimated_deploy_duration", default: 1, null: false
|
149
|
+
t.datetime "continuous_delivery_delayed_since"
|
150
|
+
t.datetime "locked_since"
|
149
151
|
end
|
150
152
|
|
151
153
|
add_index "stacks", ["repo_owner", "repo_name", "environment"], name: "stack_unicity", unique: true
|
data/test/dummy/db/test.sqlite3
CHANGED
Binary file
|
@@ -1,37 +1,37 @@
|
|
1
1
|
shipit_deploy_second:
|
2
2
|
commit_id: 2 # second
|
3
|
-
|
3
|
+
task_id: 1 # shipit
|
4
4
|
api_url: https://api.github.com/repos/shopify/shipit-engine/deployments/1
|
5
5
|
github_id: 1
|
6
6
|
|
7
7
|
shipit2_deploy_third:
|
8
8
|
commit_id: 3 # third
|
9
|
-
|
9
|
+
task_id: 2 # shipit2
|
10
10
|
api_url: https://api.github.com/repos/shopify/shipit-engine/deployments/2
|
11
11
|
github_id: 2
|
12
12
|
|
13
13
|
shipit_pending_third:
|
14
14
|
commit_id: 3 # third
|
15
|
-
|
15
|
+
task_id: 4 # shipit_pending
|
16
16
|
api_url: https://api.github.com/repos/shopify/shipit-engine/deployments/3
|
17
17
|
github_id: 3
|
18
18
|
|
19
19
|
shipit_pending_fourth:
|
20
20
|
commit_id: 4 # fourth
|
21
|
-
|
21
|
+
task_id: 4 # shipit_pending
|
22
22
|
|
23
23
|
shipit_running_fourth:
|
24
24
|
commit_id: 4 # fourth
|
25
|
-
|
25
|
+
task_id: 5 # shipit_running
|
26
26
|
|
27
27
|
shipit_complete_fourth:
|
28
28
|
commit_id: 4 # fourth
|
29
|
-
|
29
|
+
task_id: 6 # shipit_complete
|
30
30
|
|
31
31
|
shipit_aborted_fourth:
|
32
32
|
commit_id: 4 # fourth
|
33
|
-
|
33
|
+
task_id: 7 # shipit_aborted
|
34
34
|
|
35
35
|
shipit_rollback_fourth:
|
36
36
|
commit_id: 4 # fourth
|
37
|
-
|
37
|
+
task_id: 8 # shipit_rollback
|
@@ -1,47 +1,47 @@
|
|
1
1
|
shipit:
|
2
|
-
|
2
|
+
task_id: 1 # shipit
|
3
3
|
text: "deploy deploy deploy, faiiil"
|
4
4
|
|
5
5
|
shipit2:
|
6
|
-
|
6
|
+
task_id: 1 # shipit
|
7
7
|
text: "Migrating some stuff"
|
8
8
|
|
9
9
|
shipit3:
|
10
|
-
|
10
|
+
task_id: 1 # shipit
|
11
11
|
text: "Compiling all the sass"
|
12
12
|
|
13
13
|
shipit4:
|
14
|
-
|
14
|
+
task_id: 1 # shipit
|
15
15
|
text: "Making ops cry"
|
16
16
|
|
17
17
|
shipit5:
|
18
|
-
|
18
|
+
task_id: 1 # shipit
|
19
19
|
text: "sudo rm -rf /"
|
20
20
|
|
21
21
|
shipit6:
|
22
|
-
|
22
|
+
task_id: 1 # shipit
|
23
23
|
text: "sudo chmod -R 777 /"
|
24
24
|
|
25
25
|
shipit_running:
|
26
|
-
|
26
|
+
task_id: 5 # shipit_running
|
27
27
|
text: "deploy deploy deploy, faiiil"
|
28
28
|
|
29
29
|
shipit_running:
|
30
|
-
|
30
|
+
task_id: 5 # shipit_running
|
31
31
|
text: "Migrating some stuff"
|
32
32
|
|
33
33
|
shipit_running3:
|
34
|
-
|
34
|
+
task_id: 5 # shipit_running
|
35
35
|
text: "Compiling all the sass"
|
36
36
|
|
37
37
|
shipit_running4:
|
38
|
-
|
38
|
+
task_id: 5 # shipit_running
|
39
39
|
text: "Making ops cry"
|
40
40
|
|
41
41
|
shipit_running5:
|
42
|
-
|
42
|
+
task_id: 5 # shipit_running
|
43
43
|
text: "sudo rm -rf /"
|
44
44
|
|
45
45
|
shipit_running6:
|
46
|
-
|
46
|
+
task_id: 5 # shipit_running
|
47
47
|
text: "sudo chmod -R 777 /"
|
@@ -1,4 +1,5 @@
|
|
1
1
|
shipit:
|
2
|
+
id: 1
|
2
3
|
user: walrus
|
3
4
|
since_commit_id: 1 # first
|
4
5
|
until_commit_id: 2 # second
|
@@ -12,6 +13,7 @@ shipit:
|
|
12
13
|
ended_at: <%= (60 - 3).minutes.ago.to_s(:db) %>
|
13
14
|
|
14
15
|
shipit2:
|
16
|
+
id: 2
|
15
17
|
user: walrus
|
16
18
|
since_commit_id: 2 # second
|
17
19
|
until_commit_id: 3 # third
|
@@ -25,6 +27,7 @@ shipit2:
|
|
25
27
|
ended_at: <%= (60 - 4).minutes.ago.to_s(:db) %>
|
26
28
|
|
27
29
|
shipit_restart:
|
30
|
+
id: 3
|
28
31
|
user: walrus
|
29
32
|
since_commit_id: 2 # second
|
30
33
|
until_commit_id: 2 # second
|
@@ -49,6 +52,7 @@ shipit_restart:
|
|
49
52
|
ended_at: <%= (60 - 4).minutes.ago.to_s(:db) %>
|
50
53
|
|
51
54
|
shipit_pending:
|
55
|
+
id: 4
|
52
56
|
since_commit_id: 2 # second
|
53
57
|
until_commit_id: 4 # fourth
|
54
58
|
type: Shipit::Deploy
|
@@ -59,6 +63,7 @@ shipit_pending:
|
|
59
63
|
created_at: <%= (60 - 4).minutes.ago.to_s(:db) %>
|
60
64
|
|
61
65
|
shipit_running:
|
66
|
+
id: 5
|
62
67
|
user: walrus
|
63
68
|
since_commit_id: 3
|
64
69
|
until_commit_id: 4
|
@@ -71,6 +76,7 @@ shipit_running:
|
|
71
76
|
started_at: <%= (60 - 5).minutes.ago.to_s(:db) %>
|
72
77
|
|
73
78
|
shipit_complete:
|
79
|
+
id: 6
|
74
80
|
user: bob
|
75
81
|
since_commit_id: 3
|
76
82
|
until_commit_id: 4
|
@@ -84,6 +90,7 @@ shipit_complete:
|
|
84
90
|
ended_at: <%= (60 - 8).minutes.ago.to_s(:db) %>
|
85
91
|
|
86
92
|
shipit_aborted:
|
93
|
+
id: 7
|
87
94
|
user: bob
|
88
95
|
since_commit_id: 3
|
89
96
|
until_commit_id: 4
|
@@ -98,8 +105,9 @@ shipit_aborted:
|
|
98
105
|
ended_at: <%= (60 - 6).minutes.ago.to_s(:db) %>
|
99
106
|
|
100
107
|
shipit_rollback:
|
108
|
+
id: 8
|
101
109
|
user: bob
|
102
|
-
|
110
|
+
parent_id: 7 # shipit_aborted
|
103
111
|
since_commit_id: 3
|
104
112
|
until_commit_id: 4
|
105
113
|
type: Shipit::Rollback
|
@@ -2,8 +2,8 @@ walrus:
|
|
2
2
|
name: Lando Walrussian
|
3
3
|
email: walrus@shopify.com
|
4
4
|
login: walrus
|
5
|
-
encrypted_github_access_token:
|
6
|
-
encrypted_github_access_token_iv: "
|
5
|
+
encrypted_github_access_token: "ffHk4diyVKppJGfwfJefMizxF45H\n" # t0k3n
|
6
|
+
encrypted_github_access_token_iv: "gRSldoTZ+fmrIDoY\n"
|
7
7
|
|
8
8
|
bob:
|
9
9
|
name: Bob the Builder
|
@@ -20,3 +20,10 @@ shipit:
|
|
20
20
|
name: Shipit
|
21
21
|
email: shipit@example.com
|
22
22
|
login: shipit
|
23
|
+
|
24
|
+
legacy:
|
25
|
+
name: Legacy Walrussian
|
26
|
+
email: legacy@shopify.com
|
27
|
+
login: legacy
|
28
|
+
encrypted_github_access_token: FuQv9jpHmMZ8Px64xmqASJtKlefv # t0k3n
|
29
|
+
encrypted_github_access_token_iv: "QNS4smChXEXtOjxb\n"
|
@@ -9,10 +9,12 @@ module Shipit
|
|
9
9
|
end
|
10
10
|
|
11
11
|
test "#perform fetch commits from the API" do
|
12
|
+
@job.stubs(:capture!)
|
12
13
|
@job.stubs(:capture)
|
13
14
|
@commands = stub(:commands)
|
14
15
|
Commands.expects(:for).with(@deploy).returns(@commands)
|
15
16
|
|
17
|
+
@commands.expects(:fetched?).once.returns(false)
|
16
18
|
@commands.expects(:fetch).once
|
17
19
|
@commands.expects(:clone).once
|
18
20
|
@commands.expects(:checkout).with(@deploy.until_commit).once
|
@@ -27,7 +29,7 @@ module Shipit
|
|
27
29
|
test "#perform enqueues a FetchDeployedRevisionJob" do
|
28
30
|
Dir.stubs(:chdir).yields
|
29
31
|
DeployCommands.any_instance.expects(:perform).returns([])
|
30
|
-
@job.stubs(:capture)
|
32
|
+
@job.stubs(:capture!)
|
31
33
|
|
32
34
|
assert_enqueued_with(job: FetchDeployedRevisionJob, args: [@deploy.stack]) do
|
33
35
|
@job.perform(@deploy)
|
@@ -37,14 +39,14 @@ module Shipit
|
|
37
39
|
test "marks deploy as successful" do
|
38
40
|
Dir.stubs(:chdir).yields
|
39
41
|
DeployCommands.any_instance.expects(:perform).returns([])
|
40
|
-
@job.stubs(:capture)
|
42
|
+
@job.stubs(:capture!)
|
41
43
|
|
42
44
|
@job.perform(@deploy)
|
43
45
|
assert_equal 'success', @deploy.reload.status
|
44
46
|
end
|
45
47
|
|
46
48
|
test "marks deploy as `error` if any application error is raised" do
|
47
|
-
@job.expects(:capture).raises("some error")
|
49
|
+
@job.expects(:capture!).raises("some error")
|
48
50
|
assert_nothing_raised do
|
49
51
|
@job.perform(@deploy)
|
50
52
|
end
|
@@ -53,30 +55,31 @@ module Shipit
|
|
53
55
|
end
|
54
56
|
|
55
57
|
test "marks deploy as `failed` if a command exit with an error code" do
|
56
|
-
@job.expects(:capture).raises(Command::Error.new('something'))
|
58
|
+
@job.expects(:capture!).at_least_once.raises(Command::Error.new('something'))
|
57
59
|
@job.perform(@deploy)
|
58
60
|
assert_equal 'failed', @deploy.reload.status
|
59
61
|
end
|
60
62
|
|
61
63
|
test "bail out if deploy is not pending" do
|
62
64
|
@deploy.run!
|
63
|
-
@job.expects(:capture).never
|
65
|
+
@job.expects(:capture!).never
|
66
|
+
@job.expects(:capture!).never
|
64
67
|
@job.perform(@deploy)
|
65
68
|
end
|
66
69
|
|
67
70
|
test "mark deploy as error if a command timeout" do
|
68
|
-
Command.any_instance.expects(:
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
end
|
71
|
+
Command.any_instance.expects(:stream!).at_least_once.raises(Command::TimedOut)
|
72
|
+
|
73
|
+
@job.perform(@deploy)
|
74
|
+
|
73
75
|
assert_equal 'failed', @deploy.reload.status
|
74
76
|
assert_includes @deploy.chunk_output, 'TimedOut'
|
75
77
|
end
|
76
78
|
|
77
79
|
test "records stack support for rollbacks and fetching deployed revision" do
|
78
|
-
@job.stubs(:capture)
|
80
|
+
@job.stubs(:capture!)
|
79
81
|
@commands = stub(:commands)
|
82
|
+
@commands.stubs(:fetched?).returns([])
|
80
83
|
@commands.stubs(:fetch).returns([])
|
81
84
|
@commands.stubs(:clone).returns([])
|
82
85
|
@commands.stubs(:checkout).returns([])
|
data/test/models/commits_test.rb
CHANGED
@@ -157,8 +157,13 @@ module Shipit
|
|
157
157
|
end
|
158
158
|
|
159
159
|
test "refresh_statuses! pull state from github" do
|
160
|
-
|
161
|
-
|
160
|
+
status = mock(
|
161
|
+
state: 'success',
|
162
|
+
description: nil,
|
163
|
+
context: 'default',
|
164
|
+
target_url: 'http://example.com',
|
165
|
+
created_at: 1.day.ago,
|
166
|
+
)
|
162
167
|
Shipit.github_api.expects(:statuses).with(@stack.github_repo_name, @commit.sha).returns([status])
|
163
168
|
assert_difference '@commit.statuses.count', 1 do
|
164
169
|
@commit.refresh_statuses!
|
@@ -169,13 +174,14 @@ module Shipit
|
|
169
174
|
test "#creating a commit update the undeployed_commits_count" do
|
170
175
|
walrus = shipit_users(:walrus)
|
171
176
|
assert_equal 1, @stack.undeployed_commits_count
|
172
|
-
@stack.commits.create(
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
177
|
+
@stack.commits.create!(
|
178
|
+
author: walrus,
|
179
|
+
committer: walrus,
|
180
|
+
sha: "ab12",
|
181
|
+
authored_at: DateTime.now,
|
182
|
+
committed_at: DateTime.now,
|
183
|
+
message: "more fish!",
|
184
|
+
)
|
179
185
|
@stack.reload
|
180
186
|
assert_equal 2, @stack.undeployed_commits_count
|
181
187
|
end
|
@@ -292,6 +298,7 @@ module Shipit
|
|
292
298
|
end
|
293
299
|
|
294
300
|
expected_webhook_transitions = { # we expect deployable_status to fire on these transitions, and not on any others
|
301
|
+
'unknown' => %w(pending success failure error),
|
295
302
|
'pending' => %w(success failure error),
|
296
303
|
'success' => %w(failure error),
|
297
304
|
'failure' => %w(success),
|
@@ -299,7 +306,7 @@ module Shipit
|
|
299
306
|
}
|
300
307
|
expected_webhook_transitions.each do |initial_state, firing_states|
|
301
308
|
initial_status_attributes = {state: initial_state, description: 'abc', context: 'ci/travis'}
|
302
|
-
expected_webhook_transitions.keys.each do |new_state|
|
309
|
+
(expected_webhook_transitions.keys - %w(unknown)).each do |new_state|
|
303
310
|
should_fire = firing_states.include?(new_state)
|
304
311
|
action = should_fire ? 'fires' : 'does not fire'
|
305
312
|
test "#add_status #{action} for status from #{initial_state} to #{new_state}" do
|
@@ -308,11 +315,16 @@ module Shipit
|
|
308
315
|
refute commit.stack.ignore_ci
|
309
316
|
commit.statuses.destroy_all
|
310
317
|
commit.reload
|
311
|
-
|
318
|
+
unless initial_state == 'unknown'
|
319
|
+
commit.statuses.create!(initial_status_attributes.merge(created_at: 10.days.ago.to_s(:db)))
|
320
|
+
end
|
312
321
|
assert_equal initial_state, commit.state
|
313
322
|
|
314
323
|
expected_status_attributes = {state: new_state, description: initial_state, context: 'ci/travis'}
|
315
|
-
add_status =
|
324
|
+
add_status = lambda do
|
325
|
+
attrs = expected_status_attributes.merge(created_at: 1.day.ago.to_s(:db))
|
326
|
+
commit.create_status_from_github!(OpenStruct.new(attrs))
|
327
|
+
end
|
316
328
|
expect_hook_emit(commit, :commit_status, expected_status_attributes) do
|
317
329
|
if should_fire
|
318
330
|
expect_hook_emit(commit, :deployable_status, expected_status_attributes, &add_status)
|
@@ -329,7 +341,13 @@ module Shipit
|
|
329
341
|
assert commit.stack.hooks.where(events: ['commit_status']).size >= 1
|
330
342
|
|
331
343
|
expect_no_hook(:deployable_status) do
|
332
|
-
|
344
|
+
github_status = OpenStruct.new(
|
345
|
+
state: 'failure',
|
346
|
+
description: 'Sad',
|
347
|
+
context: 'ci/hidden',
|
348
|
+
created_at: 1.day.ago.to_s(:db),
|
349
|
+
)
|
350
|
+
commit.create_status_from_github!(github_status)
|
333
351
|
end
|
334
352
|
end
|
335
353
|
|
@@ -338,12 +356,13 @@ module Shipit
|
|
338
356
|
assert commit.stack.hooks.where(events: ['commit_status']).size >= 1
|
339
357
|
|
340
358
|
expect_no_hook(:deployable_status) do
|
341
|
-
|
359
|
+
github_status = OpenStruct.new(
|
342
360
|
state: 'failure',
|
343
361
|
description: 'Sad',
|
344
362
|
context: 'ci/ok_to_fail',
|
345
363
|
created_at: 1.day.ago.to_s(:db),
|
346
364
|
)
|
365
|
+
commit.create_status_from_github!(github_status)
|
347
366
|
end
|
348
367
|
end
|
349
368
|
|