shipit-engine 0.29.0 → 0.30.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +37 -2
- data/app/assets/images/archive-solid.svg +1 -0
- data/app/assets/stylesheets/_pages/_stacks.scss +76 -0
- data/app/controllers/shipit/api/stacks_controller.rb +20 -1
- data/app/controllers/shipit/api_clients_controller.rb +49 -0
- data/app/controllers/shipit/merge_status_controller.rb +8 -4
- data/app/controllers/shipit/stacks_controller.rb +58 -9
- data/app/controllers/shipit/webhooks_controller.rb +2 -130
- data/app/helpers/shipit/stacks_helper.rb +4 -0
- data/app/jobs/shipit/background_job/unique.rb +3 -1
- data/app/jobs/shipit/continuous_delivery_job.rb +1 -0
- data/app/jobs/shipit/destroy_stack_job.rb +2 -2
- data/app/models/shipit/commit.rb +21 -9
- data/app/models/shipit/commit_deployment.rb +15 -11
- data/app/models/shipit/commit_deployment_status.rb +6 -2
- data/app/models/shipit/deploy.rb +48 -7
- data/app/models/shipit/deploy_stats.rb +57 -0
- data/app/models/shipit/repository.rb +38 -0
- data/app/models/shipit/stack.rb +41 -34
- data/app/models/shipit/task.rb +26 -4
- data/app/models/shipit/webhooks.rb +32 -0
- data/app/models/shipit/webhooks/handlers/check_suite_handler.rb +19 -0
- data/app/models/shipit/webhooks/handlers/handler.rb +40 -0
- data/app/models/shipit/webhooks/handlers/membership_handler.rb +45 -0
- data/app/models/shipit/webhooks/handlers/push_handler.rb +20 -0
- data/app/models/shipit/webhooks/handlers/status_handler.rb +26 -0
- data/app/serializers/shipit/stack_serializer.rb +6 -1
- data/app/validators/ascii_only_validator.rb +3 -3
- data/app/views/layouts/_head.html.erb +0 -0
- data/app/views/layouts/shipit.html.erb +4 -2
- data/app/views/shipit/api_clients/index.html.erb +36 -0
- data/app/views/shipit/api_clients/new.html.erb +33 -0
- data/app/views/shipit/api_clients/show.html.erb +35 -0
- data/app/views/shipit/merge_status/logged_out.erb +1 -1
- data/app/views/shipit/stacks/_header.html.erb +12 -7
- data/app/views/shipit/stacks/_links.html.erb +1 -0
- data/app/views/shipit/stacks/index.html.erb +7 -2
- data/app/views/shipit/stacks/settings.html.erb +19 -0
- data/app/views/shipit/stacks/statistics.html.erb +82 -0
- data/config/locales/en.yml +14 -2
- data/config/routes.rb +4 -0
- data/db/migrate/20191209231045_create_shipit_repositories.rb +12 -0
- data/db/migrate/20191209231307_add_repository_reference_to_stacks.rb +15 -0
- data/db/migrate/20191216162728_backfill_repository_data.rb +22 -0
- data/db/migrate/20191216163010_remove_repository_information_from_stacks.rb +20 -0
- data/db/migrate/20191219205202_add_archived_since_to_stacks.rb +6 -0
- data/db/migrate/20200102175621_optional_task_commits.rb +6 -0
- data/db/migrate/20200109132519_add_sha_to_commit_deployments.rb +5 -0
- data/lib/shipit/github_app.rb +32 -3
- data/lib/shipit/task_commands.rb +10 -2
- data/lib/shipit/version.rb +1 -1
- data/test/controllers/api/ccmenu_controller_test.rb +1 -1
- data/test/controllers/api/stacks_controller_test.rb +14 -6
- data/test/controllers/api_clients_controller_test.rb +103 -0
- data/test/controllers/merge_status_controller_test.rb +21 -4
- data/test/controllers/stacks_controller_test.rb +35 -0
- data/test/controllers/webhooks_controller_test.rb +26 -0
- data/test/dummy/config/environments/development.rb +22 -4
- data/test/dummy/db/schema.rb +17 -6
- data/test/dummy/db/seeds.rb +20 -6
- data/test/fixtures/shipit/commit_deployment_statuses.yml +4 -4
- data/test/fixtures/shipit/commit_deployments.yml +8 -8
- data/test/fixtures/shipit/commits.yml +23 -0
- data/test/fixtures/shipit/repositories.yml +23 -0
- data/test/fixtures/shipit/stacks.yml +100 -16
- data/test/fixtures/shipit/tasks.yml +66 -3
- data/test/jobs/destroy_stack_job_test.rb +9 -0
- data/test/models/commit_deployment_status_test.rb +33 -4
- data/test/models/commit_deployment_test.rb +8 -11
- data/test/models/commits_test.rb +22 -2
- data/test/models/deploy_stats_test.rb +112 -0
- data/test/models/deploys_test.rb +55 -17
- data/test/models/pull_request_test.rb +1 -1
- data/test/models/shipit/repository_test.rb +76 -0
- data/test/models/shipit/wehbooks/handlers_test.rb +26 -0
- data/test/models/stacks_test.rb +44 -51
- data/test/models/undeployed_commits_test.rb +13 -0
- data/test/test_helper.rb +3 -1
- data/test/unit/deploy_commands_test.rb +9 -0
- data/test/unit/github_app_test.rb +136 -0
- metadata +161 -128
@@ -10,6 +10,7 @@ first:
|
|
10
10
|
additions: 42
|
11
11
|
deletions: 24
|
12
12
|
updated_at: <%= 8.days.ago.to_s(:db) %>
|
13
|
+
created_at: <%= 1.day.ago.to_s(:db) %>
|
13
14
|
|
14
15
|
second:
|
15
16
|
id: 2
|
@@ -23,6 +24,7 @@ second:
|
|
23
24
|
additions: 1
|
24
25
|
deletions: 1
|
25
26
|
updated_at: <%= 8.days.ago.to_s(:db) %>
|
27
|
+
created_at: <%= 1.day.ago.to_s(:db) %>
|
26
28
|
|
27
29
|
third:
|
28
30
|
id: 3
|
@@ -36,6 +38,7 @@ third:
|
|
36
38
|
additions: 12
|
37
39
|
deletions: 64
|
38
40
|
updated_at: <%= 8.days.ago.to_s(:db) %>
|
41
|
+
created_at: <%= 1.day.ago.to_s(:db) %>
|
39
42
|
|
40
43
|
fourth:
|
41
44
|
id: 4
|
@@ -49,6 +52,7 @@ fourth:
|
|
49
52
|
additions: 420
|
50
53
|
deletions: 342
|
51
54
|
updated_at: <%= 8.days.ago.to_s(:db) %>
|
55
|
+
created_at: <%= 1.day.ago.to_s(:db) %>
|
52
56
|
|
53
57
|
fifth:
|
54
58
|
id: 5
|
@@ -62,6 +66,7 @@ fifth:
|
|
62
66
|
additions: 1
|
63
67
|
deletions: 24
|
64
68
|
updated_at: <%= 8.days.ago.to_s(:db) %>
|
69
|
+
created_at: <%= 1.day.ago.to_s(:db) %>
|
65
70
|
|
66
71
|
cyclimse_first:
|
67
72
|
id: 6
|
@@ -194,6 +199,7 @@ canaries_first:
|
|
194
199
|
additions: 42
|
195
200
|
deletions: 24
|
196
201
|
updated_at: <%= 8.days.ago.to_s(:db) %>
|
202
|
+
created_at: <%= 1.day.ago.to_s(:db) %>
|
197
203
|
|
198
204
|
canaries_second:
|
199
205
|
id: 302
|
@@ -207,6 +213,7 @@ canaries_second:
|
|
207
213
|
additions: 1
|
208
214
|
deletions: 1
|
209
215
|
updated_at: <%= 8.days.ago.to_s(:db) %>
|
216
|
+
created_at: <%= 1.day.ago.to_s(:db) %>
|
210
217
|
|
211
218
|
canaries_third:
|
212
219
|
id: 303
|
@@ -220,6 +227,7 @@ canaries_third:
|
|
220
227
|
additions: 12
|
221
228
|
deletions: 64
|
222
229
|
updated_at: <%= 8.days.ago.to_s(:db) %>
|
230
|
+
created_at: <%= 1.day.ago.to_s(:db) %>
|
223
231
|
|
224
232
|
canaries_fourth:
|
225
233
|
id: 304
|
@@ -233,6 +241,7 @@ canaries_fourth:
|
|
233
241
|
additions: 420
|
234
242
|
deletions: 342
|
235
243
|
updated_at: <%= 8.days.ago.to_s(:db) %>
|
244
|
+
created_at: <%= 1.day.ago.to_s(:db) %>
|
236
245
|
|
237
246
|
canaries_fifth:
|
238
247
|
id: 305
|
@@ -246,6 +255,7 @@ canaries_fifth:
|
|
246
255
|
additions: 1
|
247
256
|
deletions: 24
|
248
257
|
updated_at: <%= 8.days.ago.to_s(:db) %>
|
258
|
+
created_at: <%= 1.day.ago.to_s(:db) %>
|
249
259
|
|
250
260
|
undeployed_1:
|
251
261
|
id: 401
|
@@ -350,3 +360,16 @@ single:
|
|
350
360
|
additions: 420
|
351
361
|
deletions: 342
|
352
362
|
updated_at: <%= 8.days.ago.to_s(:db) %>
|
363
|
+
|
364
|
+
task_no_commits:
|
365
|
+
id: 601
|
366
|
+
sha: 547578b362bf2b4df5903e1c7960929361c3435a
|
367
|
+
message: "first commit"
|
368
|
+
stack: shipit_task_no_commits
|
369
|
+
author: walrus
|
370
|
+
committer: walrus
|
371
|
+
authored_at: <%= 4.days.ago.to_s(:db) %>
|
372
|
+
committed_at: <%= 3.days.ago.to_s(:db) %>
|
373
|
+
additions: 420
|
374
|
+
deletions: 342
|
375
|
+
updated_at: <%= 8.days.ago.to_s(:db) %>
|
@@ -0,0 +1,23 @@
|
|
1
|
+
shipit:
|
2
|
+
owner: shopify
|
3
|
+
name: shipit-engine
|
4
|
+
|
5
|
+
cyclimse:
|
6
|
+
owner: george
|
7
|
+
name: cyclimse
|
8
|
+
|
9
|
+
foo-bar:
|
10
|
+
owner: shopify
|
11
|
+
name: foo-bar
|
12
|
+
|
13
|
+
soc:
|
14
|
+
owner: "shopify"
|
15
|
+
name: "soc"
|
16
|
+
|
17
|
+
check_runs:
|
18
|
+
owner: shopify
|
19
|
+
name: check_runs
|
20
|
+
|
21
|
+
rails:
|
22
|
+
owner: rails
|
23
|
+
name: rails
|
@@ -1,8 +1,8 @@
|
|
1
1
|
shipit:
|
2
|
-
|
3
|
-
repo_name: "shipit-engine"
|
2
|
+
repository: shipit
|
4
3
|
environment: "production"
|
5
4
|
branch: master
|
5
|
+
deploy_url: https://shipit.shopify.com
|
6
6
|
ignore_ci: false
|
7
7
|
merge_queue_enabled: true
|
8
8
|
tasks_count: 8
|
@@ -54,8 +54,7 @@ shipit:
|
|
54
54
|
updated_at: <%= 8.days.ago.to_s(:db) %>
|
55
55
|
|
56
56
|
shipit_canaries:
|
57
|
-
|
58
|
-
repo_name: "shipit-engine"
|
57
|
+
repository: shipit
|
59
58
|
environment: "canaries"
|
60
59
|
branch: master
|
61
60
|
ignore_ci: false
|
@@ -114,8 +113,7 @@ shipit_canaries:
|
|
114
113
|
updated_at: <%= 8.days.ago.to_s(:db) %>
|
115
114
|
|
116
115
|
cyclimse:
|
117
|
-
|
118
|
-
repo_name: cyclimse
|
116
|
+
repository: cyclimse
|
119
117
|
environment: production
|
120
118
|
branch: master
|
121
119
|
ignore_ci: false
|
@@ -148,8 +146,7 @@ cyclimse:
|
|
148
146
|
updated_at: <%= 8.days.ago.to_s(:db) %>
|
149
147
|
|
150
148
|
undeployed_stack:
|
151
|
-
|
152
|
-
repo_name: "foo-bar"
|
149
|
+
repository: foo-bar
|
153
150
|
environment: "production"
|
154
151
|
branch: master
|
155
152
|
ignore_ci: true
|
@@ -185,8 +182,7 @@ undeployed_stack:
|
|
185
182
|
updated_at: <%= 8.days.ago.to_s(:db) %>
|
186
183
|
|
187
184
|
soc:
|
188
|
-
|
189
|
-
repo_name: "soc"
|
185
|
+
repository: soc
|
190
186
|
environment: "production"
|
191
187
|
branch: master
|
192
188
|
tasks_count: 0
|
@@ -220,16 +216,14 @@ soc:
|
|
220
216
|
updated_at: <%= 8.days.ago.to_s(:db) %>
|
221
217
|
|
222
218
|
check_runs:
|
223
|
-
|
224
|
-
repo_name: check_runs
|
219
|
+
repository: check_runs
|
225
220
|
environment: production
|
226
221
|
branch: master
|
227
222
|
tasks_count: 0
|
228
223
|
undeployed_commits_count: 1
|
229
224
|
|
230
225
|
shipit_undeployed:
|
231
|
-
|
232
|
-
repo_name: "shipit-engine"
|
226
|
+
repository: shipit
|
233
227
|
environment: "undeployed"
|
234
228
|
branch: master
|
235
229
|
ignore_ci: true
|
@@ -284,8 +278,7 @@ shipit_undeployed:
|
|
284
278
|
updated_at: <%= 8.days.ago.to_s(:db) %>
|
285
279
|
|
286
280
|
shipit_single:
|
287
|
-
|
288
|
-
repo_name: "shipit-engine"
|
281
|
+
repository: shipit
|
289
282
|
environment: "single"
|
290
283
|
branch: master
|
291
284
|
ignore_ci: false
|
@@ -320,3 +313,94 @@ shipit_single:
|
|
320
313
|
}
|
321
314
|
updated_at: <%= 8.days.ago.to_s(:db) %>
|
322
315
|
last_deployed_at: <%= 8.days.ago.to_s(:db) %>
|
316
|
+
|
317
|
+
shipit_stats:
|
318
|
+
repository: shipit
|
319
|
+
environment: "stats"
|
320
|
+
branch: master
|
321
|
+
ignore_ci: false
|
322
|
+
merge_queue_enabled: true
|
323
|
+
tasks_count: 4
|
324
|
+
undeployed_commits_count: 1
|
325
|
+
cached_deploy_spec: >
|
326
|
+
{
|
327
|
+
"machine": {"environment": {}},
|
328
|
+
"review": {
|
329
|
+
"checklist": ["foo", "bar", "baz"],
|
330
|
+
"monitoring": [
|
331
|
+
{"image": "https://example.com/monitor.png", "width": 200, "height": 300}
|
332
|
+
]
|
333
|
+
},
|
334
|
+
"dependencies": {"override": []},
|
335
|
+
"deploy": {"override": null},
|
336
|
+
"rollback": {"override": ["echo 'Rollback!'"]},
|
337
|
+
"fetch": ["echo '42'"],
|
338
|
+
"tasks": {
|
339
|
+
"restart": {
|
340
|
+
"action": "Restart application",
|
341
|
+
"description": "Restart app and job servers",
|
342
|
+
"steps": [
|
343
|
+
"cap $ENVIRONMENT deploy:restart"
|
344
|
+
]
|
345
|
+
}
|
346
|
+
},
|
347
|
+
"ci": {
|
348
|
+
"blocking": ["soc/compliance"]
|
349
|
+
}
|
350
|
+
}
|
351
|
+
updated_at: <%= 8.days.ago.to_s(:db) %>
|
352
|
+
last_deployed_at: <%= 8.days.ago.to_s(:db) %>
|
353
|
+
|
354
|
+
shipit_task_no_commits:
|
355
|
+
repository: shipit
|
356
|
+
environment: "task_no_commits"
|
357
|
+
branch: master
|
358
|
+
ignore_ci: true
|
359
|
+
merge_queue_enabled: true
|
360
|
+
tasks_count: 1
|
361
|
+
undeployed_commits_count: 1
|
362
|
+
continuous_deployment: true
|
363
|
+
cached_deploy_spec: >
|
364
|
+
{
|
365
|
+
"machine": {"environment": {}},
|
366
|
+
"review": {
|
367
|
+
"checklist": ["foo", "bar", "baz"],
|
368
|
+
"monitoring": [
|
369
|
+
{"image": "https://example.com/monitor.png", "width": 200, "height": 300}
|
370
|
+
]
|
371
|
+
},
|
372
|
+
"dependencies": {"override": []},
|
373
|
+
"deploy": {"override": null, "interval": 60, "max_commits": 3, "variables": [{"name": "SAFETY_DISABLED", "title": "Set to 1 to do dangerous things", "default": 0}]},
|
374
|
+
"rollback": {"override": ["echo 'Rollback!'"]},
|
375
|
+
"fetch": ["echo '42'"],
|
376
|
+
"tasks": {
|
377
|
+
"restart": {
|
378
|
+
"action": "Restart application",
|
379
|
+
"description": "Restart app and job servers",
|
380
|
+
"variables": [
|
381
|
+
{"name": "FOO", "title": "Set to 0 to foo", "default": 1},
|
382
|
+
{"name": "BAR", "title": "Set to 1 to bar", "default": 0},
|
383
|
+
{"name": "WALRUS", "title": "Walrus without a default value"}
|
384
|
+
],
|
385
|
+
"steps": [
|
386
|
+
"cap $ENVIRONMENT deploy:restart"
|
387
|
+
]
|
388
|
+
},
|
389
|
+
"flush_cache": {
|
390
|
+
"action": "Flush cache",
|
391
|
+
"description": "Flush the application cache",
|
392
|
+
"steps": [
|
393
|
+
"cap $ENVIRONMENT cache:flush"
|
394
|
+
],
|
395
|
+
"allow_concurrency": true
|
396
|
+
}
|
397
|
+
},
|
398
|
+
"merge": {
|
399
|
+
"revalidate_after": 900
|
400
|
+
},
|
401
|
+
"ci": {
|
402
|
+
"hide": ["ci/hidden"],
|
403
|
+
"allow_failures": ["ci/ok_to_fail"]
|
404
|
+
}
|
405
|
+
}
|
406
|
+
updated_at: <%= 8.days.ago.to_s(:db) %>
|
@@ -10,7 +10,7 @@ shipit:
|
|
10
10
|
deletions: 1
|
11
11
|
created_at: <%= (60 - 1).minutes.ago.to_s(:db) %>
|
12
12
|
started_at: <%= (60 - 1).minutes.ago.to_s(:db) %>
|
13
|
-
ended_at: <%= (60 -
|
13
|
+
ended_at: <%= (60 - 6).minutes.ago.to_s(:db) %>
|
14
14
|
|
15
15
|
shipit2:
|
16
16
|
id: 2
|
@@ -29,8 +29,6 @@ shipit2:
|
|
29
29
|
shipit_restart:
|
30
30
|
id: 3
|
31
31
|
user: walrus
|
32
|
-
since_commit_id: 2 # second
|
33
|
-
until_commit_id: 2 # second
|
34
32
|
type: Shipit::Task
|
35
33
|
stack: shipit
|
36
34
|
status: success
|
@@ -278,3 +276,68 @@ shipit_single:
|
|
278
276
|
created_at: <%= (60 - 2).minutes.ago.to_s(:db) %>
|
279
277
|
started_at: <%= (60 - 2).minutes.ago.to_s(:db) %>
|
280
278
|
ended_at: <%= (60 - 4).minutes.ago.to_s(:db) %>
|
279
|
+
|
280
|
+
shipit_stats:
|
281
|
+
id: 401
|
282
|
+
user: walrus
|
283
|
+
since_commit_id: 601
|
284
|
+
until_commit_id: 601
|
285
|
+
type: Shipit::Deploy
|
286
|
+
stack: shipit_stats
|
287
|
+
status: success
|
288
|
+
additions: 12
|
289
|
+
deletions: 64
|
290
|
+
created_at: <%= 60.minutes.ago.to_s(:db) %>
|
291
|
+
started_at: <%= 60.minutes.ago.to_s(:db) %>
|
292
|
+
ended_at: <%= (60 - 4).minutes.ago.to_s(:db) %>
|
293
|
+
|
294
|
+
shipit_stats_2:
|
295
|
+
id: 402
|
296
|
+
user: walrus
|
297
|
+
since_commit_id: 602
|
298
|
+
until_commit_id: 603
|
299
|
+
type: Shipit::Deploy
|
300
|
+
stack: shipit_stats
|
301
|
+
status: failed
|
302
|
+
additions: 12
|
303
|
+
deletions: 64
|
304
|
+
created_at: <%= (60 - 5).minutes.ago.to_s(:db) %>
|
305
|
+
started_at: <%= (60 - 5).minutes.ago.to_s(:db) %>
|
306
|
+
ended_at: <%= (60 - 11).minutes.ago.to_s(:db) %>
|
307
|
+
|
308
|
+
shipit_stats_3:
|
309
|
+
id: 403
|
310
|
+
user: walrus
|
311
|
+
since_commit_id: 604
|
312
|
+
until_commit_id: 605
|
313
|
+
type: Shipit::Deploy
|
314
|
+
stack: shipit_stats
|
315
|
+
status: success
|
316
|
+
additions: 12
|
317
|
+
deletions: 64
|
318
|
+
created_at: <%= (60 - 10).minutes.ago.to_s(:db) %>
|
319
|
+
started_at: <%= (60 - 12).minutes.ago.to_s(:db) %>
|
320
|
+
ended_at: <%= (60 - 15).minutes.ago.to_s(:db) %>
|
321
|
+
|
322
|
+
shipit_stats_4:
|
323
|
+
id: 404
|
324
|
+
user: walrus
|
325
|
+
since_commit_id: 606
|
326
|
+
until_commit_id: 608
|
327
|
+
type: Shipit::Deploy
|
328
|
+
stack: shipit_stats
|
329
|
+
status: success
|
330
|
+
additions: 12
|
331
|
+
deletions: 64
|
332
|
+
created_at: <%= (30 - 15).minutes.ago.to_s(:db) %>
|
333
|
+
started_at: <%= (30 - 15).minutes.ago.to_s(:db) %>
|
334
|
+
ended_at: <%= (30 - 17).minutes.ago.to_s(:db) %>
|
335
|
+
|
336
|
+
shipit_nocommit_task:
|
337
|
+
id: 501
|
338
|
+
user: walrus
|
339
|
+
type: Shipit::Task
|
340
|
+
stack: shipit_task_no_commits
|
341
|
+
status: pending
|
342
|
+
created_at: <%= (60 - 2).minutes.ago.to_s(:db) %>
|
343
|
+
started_at: <%= (60 - 2).minutes.ago.to_s(:db) %>
|
@@ -14,5 +14,14 @@ module Shipit
|
|
14
14
|
@job.perform(@stack)
|
15
15
|
end
|
16
16
|
end
|
17
|
+
|
18
|
+
test "perform destroys the CommitDeployments of the received stack" do
|
19
|
+
stack = shipit_stacks(:shipit)
|
20
|
+
Shipit.legacy_github_api.stubs(:remove_hook)
|
21
|
+
|
22
|
+
assert_changes -> { CommitDeployment.count }, 'CommitDeployments not deleted' do
|
23
|
+
@job.perform(stack)
|
24
|
+
end
|
25
|
+
end
|
17
26
|
end
|
18
27
|
end
|
@@ -3,10 +3,9 @@ require 'test_helper'
|
|
3
3
|
module Shipit
|
4
4
|
class CommitDeploymentStatusTest < ActiveSupport::TestCase
|
5
5
|
setup do
|
6
|
-
@status = shipit_commit_deployment_statuses(:
|
6
|
+
@status = shipit_commit_deployment_statuses(:shipit2_deploy_third_in_progress)
|
7
7
|
@deployment = @status.commit_deployment
|
8
8
|
@task = @deployment.task
|
9
|
-
@commit = @deployment.commit
|
10
9
|
@author = @deployment.author
|
11
10
|
end
|
12
11
|
|
@@ -14,14 +13,44 @@ module Shipit
|
|
14
13
|
response = stub(id: 44, url: 'https://example.com')
|
15
14
|
@author.github_api.expects(:create_deployment_status).with(
|
16
15
|
@deployment.api_url,
|
17
|
-
'
|
16
|
+
'in_progress',
|
17
|
+
accept: "application/vnd.github.flash-preview+json",
|
18
18
|
target_url: "http://shipit.com/shopify/shipit-engine/production/deploys/#{@task.id}",
|
19
|
-
description: "walrus triggered the deploy of shopify/shipit-engine/production to #{@
|
19
|
+
description: "walrus triggered the deploy of shopify/shipit-engine/production to #{@deployment.short_sha}",
|
20
|
+
environment_url: "https://shipit.shopify.com",
|
20
21
|
).returns(response)
|
21
22
|
|
22
23
|
@status.create_on_github!
|
23
24
|
assert_equal response.id, @status.github_id
|
24
25
|
assert_equal response.url, @status.api_url
|
25
26
|
end
|
27
|
+
|
28
|
+
test 'description is truncated to character limit' do
|
29
|
+
limit = CommitDeploymentStatus::DESCRIPTION_CHARACTER_LIMIT_ON_GITHUB
|
30
|
+
deployment = shipit_commit_deployments(:shipit_deploy_second)
|
31
|
+
|
32
|
+
status = deployment.statuses.create!(status: 'success')
|
33
|
+
status.stubs(:description).returns('desc' * limit)
|
34
|
+
create_status_response = stub(id: 'abcd', url: 'https://github.com/status/abcd')
|
35
|
+
status.author.github_api.expects(:create_deployment_status).with do |*_args, **kwargs|
|
36
|
+
kwargs[:description].size <= limit
|
37
|
+
end.returns(create_status_response)
|
38
|
+
|
39
|
+
status.create_on_github!
|
40
|
+
end
|
41
|
+
|
42
|
+
test 'includes deployment url when the deployment succeeds' do
|
43
|
+
deployment = shipit_commit_deployments(:shipit_deploy_second)
|
44
|
+
|
45
|
+
status = deployment.statuses.create!(status: 'success')
|
46
|
+
stack = status.stack
|
47
|
+
stack.deploy_url = "stack-deploy-url"
|
48
|
+
create_status_response = stub(id: 'abcd', url: 'https://github.com/status/abcd')
|
49
|
+
status.author.github_api.expects(:create_deployment_status).with do |*_args, **kwargs|
|
50
|
+
kwargs[:environment_url] == 'stack-deploy-url'
|
51
|
+
end.returns(create_status_response)
|
52
|
+
|
53
|
+
status.create_on_github!
|
54
|
+
end
|
26
55
|
end
|
27
56
|
end
|
@@ -4,30 +4,27 @@ module Shipit
|
|
4
4
|
class CommitDeploymentTest < ActiveSupport::TestCase
|
5
5
|
setup do
|
6
6
|
@deployment = shipit_commit_deployments(:shipit_pending_fourth)
|
7
|
-
@commit = @deployment.commit
|
8
7
|
@task = @deployment.task
|
9
8
|
@stack = @task.stack
|
10
9
|
@author = @deployment.author
|
11
10
|
end
|
12
11
|
|
13
|
-
test "there can only be one record per deploy and commit pair" do
|
14
|
-
assert_raises ActiveRecord::RecordNotUnique do
|
15
|
-
CommitDeployment.create!(task: @deployment.task, commit: @deployment.commit)
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
12
|
test "creation on GitHub" do
|
20
|
-
pull_request_response = stub(head: stub(sha: '6dcb09b5b57875f334f61aebed695e2e4193db5e'))
|
21
|
-
@author.github_api.expects(:pull_request).with('shopify/shipit-engine', 7).returns(pull_request_response)
|
22
|
-
|
23
13
|
deployment_response = stub(id: 42, url: 'https://example.com')
|
24
14
|
@author.github_api.expects(:create_deployment).with(
|
25
15
|
'shopify/shipit-engine',
|
26
|
-
|
16
|
+
@deployment.sha,
|
27
17
|
auto_merge: false,
|
28
18
|
required_contexts: [],
|
29
19
|
description: "Via Shipit",
|
30
20
|
environment: @stack.environment,
|
21
|
+
payload: {
|
22
|
+
shipit: {
|
23
|
+
task_id: 4,
|
24
|
+
from_sha: 'f890fd8b5f2be05d1fedb763a3605ee461c39074',
|
25
|
+
to_sha: '467578b362bf2b4df5903e1c7960929361c3435a',
|
26
|
+
},
|
27
|
+
},
|
31
28
|
).returns(deployment_response)
|
32
29
|
|
33
30
|
@deployment.create_on_github!
|