shipit-engine 0.11.0 → 0.12.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (85) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +41 -37
  3. data/app/assets/javascripts/task/tty.js.coffee +40 -22
  4. data/app/assets/stylesheets/_pages/_deploy.scss +1 -0
  5. data/app/controllers/shipit/api/locks_controller.rb +3 -3
  6. data/app/controllers/shipit/api/stacks_controller.rb +14 -1
  7. data/app/controllers/shipit/commit_checks_controller.rb +9 -2
  8. data/app/controllers/shipit/shipit_controller.rb +1 -1
  9. data/app/controllers/shipit/stacks_controller.rb +11 -5
  10. data/app/controllers/shipit/status_controller.rb +1 -1
  11. data/app/controllers/shipit/webhooks_controller.rb +15 -5
  12. data/app/helpers/shipit/deploys_helper.rb +1 -1
  13. data/app/helpers/shipit/shipit_helper.rb +2 -0
  14. data/app/jobs/shipit/perform_commit_checks_job.rb +2 -0
  15. data/app/jobs/shipit/perform_task_job.rb +18 -8
  16. data/app/models/shipit/commit.rb +22 -12
  17. data/app/models/shipit/commit_checks.rb +20 -53
  18. data/app/models/shipit/deploy.rb +1 -1
  19. data/app/models/shipit/ephemeral_commit_checks.rb +76 -0
  20. data/app/models/shipit/stack.rb +40 -10
  21. data/app/models/shipit/status.rb +14 -8
  22. data/app/models/shipit/status_group.rb +1 -1
  23. data/app/models/shipit/task.rb +2 -0
  24. data/app/models/shipit/unknown_status.rb +4 -0
  25. data/app/models/shipit/user.rb +9 -1
  26. data/app/serializers/shipit/stack_serializer.rb +6 -1
  27. data/app/views/shipit/commit_checks/_checks.html.erb +13 -0
  28. data/app/views/shipit/commit_checks/show.html.erb +5 -0
  29. data/app/views/shipit/stacks/_header.html.erb +1 -1
  30. data/app/views/shipit/stacks/show.html.erb +15 -0
  31. data/config/routes.rb +2 -1
  32. data/db/migrate/20140226233935_create_baseline.rb +10 -10
  33. data/db/migrate/20160802092812_add_continuous_delivery_delayed_since_to_stacks.rb +5 -0
  34. data/db/migrate/20160822131405_add_locked_since_to_stacks.rb +5 -0
  35. data/lib/shipit.rb +4 -0
  36. data/lib/shipit/command.rb +1 -1
  37. data/lib/shipit/commands.rb +10 -7
  38. data/lib/shipit/csv_serializer.rb +1 -1
  39. data/lib/shipit/stack_commands.rb +17 -5
  40. data/lib/shipit/task_commands.rb +2 -2
  41. data/lib/shipit/version.rb +1 -1
  42. data/lib/snippets/push-to-heroku +20 -16
  43. data/test/controllers/api/deploys_controller_test.rb +8 -8
  44. data/test/controllers/api/hooks_controller_test.rb +11 -9
  45. data/test/controllers/api/locks_controller_test.rb +16 -6
  46. data/test/controllers/api/outputs_controller_test.rb +1 -1
  47. data/test/controllers/api/stacks_controller_test.rb +48 -3
  48. data/test/controllers/api/tasks_controller_test.rb +6 -6
  49. data/test/controllers/commit_checks_controller_test.rb +3 -3
  50. data/test/controllers/deploys_controller_test.rb +13 -13
  51. data/test/controllers/rollbacks_controller_test.rb +7 -7
  52. data/test/controllers/stacks_controller_test.rb +36 -29
  53. data/test/controllers/tasks_controller_test.rb +14 -14
  54. data/test/controllers/webhooks_controller_test.rb +16 -25
  55. data/test/dummy/config/application.rb +0 -3
  56. data/test/dummy/config/environments/test.rb +2 -2
  57. data/test/dummy/data/stacks/byroot/junk/production/git/bar.txt +2 -0
  58. data/test/dummy/data/stacks/byroot/junk/production/git/bin/slow +7 -0
  59. data/test/dummy/data/stacks/byroot/junk/production/git/bin/timeout +10 -0
  60. data/test/dummy/data/stacks/byroot/junk/production/git/dkfdsf +0 -0
  61. data/test/dummy/data/stacks/byroot/junk/production/git/dskjfsd +0 -0
  62. data/test/dummy/data/stacks/byroot/junk/production/git/dslkjfjsdf +0 -0
  63. data/test/dummy/data/stacks/byroot/junk/production/git/plopfizz +0 -0
  64. data/test/dummy/data/stacks/byroot/junk/production/git/sd +0 -0
  65. data/test/dummy/data/stacks/byroot/junk/production/git/sdkfjsdf +1 -0
  66. data/test/dummy/data/stacks/byroot/junk/production/git/sdlfjsdfdsfj +0 -0
  67. data/test/dummy/data/stacks/byroot/junk/production/git/sdlkfjsdlkfjsdlkfjdsfsdfksdfjsldkfjsdlkfjsdf +0 -0
  68. data/test/dummy/data/stacks/byroot/junk/production/git/shipit.yml +21 -0
  69. data/test/dummy/data/stacks/byroot/junk/production/git/toto.txt +2 -0
  70. data/test/dummy/db/development.sqlite3 +0 -0
  71. data/test/dummy/db/schema.rb +15 -13
  72. data/test/dummy/db/test.sqlite3 +0 -0
  73. data/test/fixtures/shipit/commit_deployments.yml +8 -8
  74. data/test/fixtures/shipit/output_chunks.yml +12 -12
  75. data/test/fixtures/shipit/tasks.yml +9 -1
  76. data/test/fixtures/shipit/users.yml +9 -2
  77. data/test/jobs/perform_task_job_test.rb +14 -11
  78. data/test/models/commits_test.rb +33 -14
  79. data/test/models/stacks_test.rb +78 -4
  80. data/test/models/users_test.rb +16 -0
  81. data/test/unit/commands_test.rb +4 -0
  82. data/test/unit/deploy_commands_test.rb +1 -1
  83. metadata +133 -34
  84. data/app/jobs/shipit/git_mirror_update_job.rb +0 -14
  85. data/app/views/shipit/deploys/_checks.html.erb +0 -11
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c4329e9e481f6b7065a401570ebd011d1ea4fb19
4
- data.tar.gz: ef736fcc3a561d2db82c35795092388abbbfc90a
3
+ metadata.gz: 38e2344717e450b3db3cb9248f16c2b475b2955b
4
+ data.tar.gz: cc5af413a0c7a25602639dd52be6d620220880e8
5
5
  SHA512:
6
- metadata.gz: e79a3a01a5d2c71d48dc0bc0ec8ae032721046cccecb5680c876b82c0c246da5ce75a4812ee24afe9aeeaca06d5749637bffb6cb2f9b9aa374fe96f2c790cbff
7
- data.tar.gz: 60bde57fcfbd57ff17bc6d0d64785b81bf2e2cfd9ee69d5c9849911a5a6936ceccd9ac80fb2a50bb10254a9789084b26f1095acc43b7c7593ebcd19255d93554
6
+ metadata.gz: b27627cdf81dd03bb8f4f0db181d4e9e00759469350f67d793c99c02fb6dfd9518edda0673bb79c234efb5d5025916b581f0c99b8fb62d1159e9420028c35cec
7
+ data.tar.gz: 7932b8299a15e244982322f760e700138feb36dfbe2bac6818b547a06c9b82dad57edc82aa7835744fcb0d9c061810e0e129a3c2be2e3445e7e5af76f50d23e0
data/README.md CHANGED
@@ -8,7 +8,7 @@
8
8
  * control the pace of development by pushing, locking, and rolling back deploys from within Shipit
9
9
  * enforce checklists and provide monitoring right at the point of deployment.
10
10
 
11
- Shipit's compatible with just about anything that you can deploy using a script. It natively detects stacks using [bundler](http://bundler.io/) and [Capistrano](http://capistranorb.com/), and it has tools that make it easy to deploy to [Heroku](https://www.heroku.com/) or [RubyGems](https://rubygems.org/). At Shopify, we've used Shipit to sychronize and deploy hundreds of projects across dozens of teams, using Python, Rails, RubyGems, Java, and Go.
11
+ Shipit is compatible with just about anything that you can deploy using a script. It natively detects stacks using [bundler](http://bundler.io/) and [Capistrano](http://capistranorb.com/), and it has tools that make it easy to deploy to [Heroku](https://www.heroku.com/) or [RubyGems](https://rubygems.org/). At Shopify, we've used Shipit to synchronize and deploy hundreds of projects across dozens of teams, using Python, Rails, RubyGems, Java, and Go.
12
12
 
13
13
  This guide aims to help you [set up](#installation-and-setup), [use](#using-shipit), and [understand](#reference) Shipit.
14
14
 
@@ -41,7 +41,7 @@ This guide aims to help you [set up](#installation-and-setup), [use](#using-ship
41
41
 
42
42
  <h3 id="installation">Installation</h3>
43
43
 
44
- *Shipit requires a database (MySQL, PostgreSQL or SQLite3), redis, and Ruby 2.1 or superior.*
44
+ *Shipit requires a database (MySQL, PostgreSQL or SQLite3), Redis, and Ruby 2.1 or superior.*
45
45
 
46
46
  Shipit provides you with a Rails template. To bootstrap your Shipit installation:
47
47
 
@@ -61,7 +61,7 @@ Shipit should just work right out of the box &mdash; you probably won't need to
61
61
 
62
62
  1. If you locked the gem to a specific version in your Gemfile, update it there.
63
63
  2. Update the `shipit-engine` gem with `bundle update shipit-engine`.
64
- 3. Install new migrations with `rake shipit:install:migrations db:migrate`
64
+ 3. Install new migrations with `rake shipit:install:migrations db:migrate`.
65
65
 
66
66
  * * *
67
67
 
@@ -90,7 +90,7 @@ A **stack** is composed of a GitHub repository, a branch, and a deployment envir
90
90
  * deploy any undeployed commits by clicking **Deploy**
91
91
  * rollback to an earlier build by clicking **Rollback to this deploy**
92
92
  * adjust the stack's settings by clicking the gear icon in the page header
93
- * perform any custom tasks that are defined in the `shipit.yml` file.
93
+ * perform any custom tasks that are defined in the `shipit.yml` file
94
94
  4. When you're ready to deploy an undeployed commit, click the relevant **Deploy** button on the stack's overview page.
95
95
  5. From the **Deploy** page, complete the checklist, then click **Create deploy**.
96
96
 
@@ -105,27 +105,27 @@ From a stack's **Settings** page, you can:
105
105
  * change the deploy URL
106
106
  * enable and disable continuous deployment
107
107
  * lock and unlock deploys through Shipit
108
- * resychronize the stack with GitHub
109
- * delete the stack from Shipit.
108
+ * resynchronize the stack with GitHub
109
+ * delete the stack from Shipit
110
110
 
111
111
  * * *
112
112
 
113
- <h2 id="reference">III. REFERENCE</h3>
113
+ <h2 id="reference">III. REFERENCE</h2>
114
114
 
115
- <h3 id="configuring-shipit">Configuring <code>shipit.yml</code></h2>
115
+ <h3 id="configuring-shipit">Configuring <code>shipit.yml</code></h3>
116
116
 
117
117
  The settings in the `shipit.yml` file relate to the different things you can do with Shipit:
118
118
 
119
- * [Installing dependencies](#installing-dependencies) (`dependencies`)
119
+ * [Installing Dependencies](#installing-dependencies) (`dependencies`)
120
120
  * [Deployment](#deployment) (`deploy`, `rollback`, `fetch`)
121
121
  * [Environment](#environment) (`machine.environment`, `machine.directory`, `machine.cleanup`)
122
122
  * [CI](#ci) (`ci.require`, `ci.hide`, `ci.allow_failures`)
123
- * [Custom tasks](#custom-tasks) (`restart`, `unlock`)
123
+ * [Custom Tasks](#custom-tasks) (`restart`, `unlock`)
124
124
  * [Review Process](#review-process) (`monitor`, `checklist`, `checks`)
125
125
 
126
126
  All the settings in `shipit.yml` are optional. Most applications can be deployed from Shipit without any configuration.
127
127
 
128
- Aslo, if your repository is deployed different ways depending on the environment, you can have alternative `shipit.yml` by including the environment name.
128
+ Also, if your repository is deployed different ways depending on the environment, you can have an alternative `shipit.yml` by including the environment name.
129
129
 
130
130
  For example for a stack like: `my-org/my-repo/staging`, `shipit.staging.yml` will have priority over `shipit.yml`.
131
131
 
@@ -135,11 +135,11 @@ For example for a stack like: `my-org/my-repo/staging`, `shipit.staging.yml` wil
135
135
 
136
136
  The **<code>dependencies</code>** step allows you to install all the packages your deploy script needs.
137
137
 
138
- <h4 id="bundler-support">Bundler</h3>
138
+ <h4 id="bundler-support">Bundler</h4>
139
139
 
140
140
  If your application uses Bundler, Shipit will detect it automatically and take care of the `bundle install` and prefix your commands with `bundle exec`.
141
141
 
142
- By default the following gem groups will be ignored:
142
+ By default, the following gem groups will be ignored:
143
143
 
144
144
  - `default`
145
145
  - `production`
@@ -162,7 +162,7 @@ dependencies:
162
162
  - debug
163
163
  ```
164
164
 
165
- <h4 id="other-dependencies">Other dependencies</h3>
165
+ <h4 id="other-dependencies">Other dependencies</h4>
166
166
 
167
167
  If your deploy script uses another tool to install dependencies, you can install them manually via `dependencies.override`:
168
168
 
@@ -172,24 +172,24 @@ dependencies:
172
172
  - npm install
173
173
  ```
174
174
 
175
- **<code>dependencies.pre</code>** If you wish to execute commands before Shipit install the dependencies you can specify them here:
175
+ **<code>dependencies.pre</code>** If you wish to execute commands before Shipit installs the dependencies, you can specify them here.
176
176
 
177
177
  For example:
178
178
 
179
179
  ```yml
180
- depedencies:
180
+ dependencies:
181
181
  pre:
182
182
  - mkdir tmp/
183
183
  - cp -R /var/cache/ tmp/cache
184
184
  ```
185
185
  <br>
186
186
 
187
- **<code>dependencies.post</code>** If you wish to execute commands after Shipit installed the dependencies you can specify them here:
187
+ **<code>dependencies.post</code>** If you wish to execute commands after Shipit installed the dependencies, you can specify them here:
188
188
 
189
189
  For example:
190
190
 
191
191
  ```yml
192
- depedencies:
192
+ dependencies:
193
193
  post:
194
194
  - cp -R tmp/cache /var/cache/
195
195
  ```
@@ -211,7 +211,7 @@ deploy:
211
211
  ```
212
212
  <br>
213
213
 
214
- **<code>deploy.pre</code>** If you wish to execute commands before Shipit execute your deploy script you can specify them here:
214
+ **<code>deploy.pre</code>** If you wish to execute commands before Shipit executes your deploy script, you can specify them here.
215
215
 
216
216
  For example:
217
217
 
@@ -222,7 +222,7 @@ deploy:
222
222
  ```
223
223
  <br>
224
224
 
225
- **<code>deploy.post</code>** If you wish to execute commands after Shipit executed your deploy script you can specify them here:
225
+ **<code>deploy.post</code>** If you wish to execute commands after Shipit executed your deploy script, you can specify them here.
226
226
 
227
227
  For example:
228
228
 
@@ -234,7 +234,7 @@ deploy:
234
234
  <br>
235
235
 
236
236
 
237
- You can also accept custom environment variables defined by the user that trigger the deploy:
237
+ You can also accept custom environment variables defined by the user that triggers the deploy:
238
238
 
239
239
  **<code>deploy.variables</code>** contains an array of variable definitions.
240
240
 
@@ -250,9 +250,9 @@ deploy:
250
250
  ```
251
251
  <br>
252
252
 
253
- **<code>deploy.max_commits</code>** allow to set a limit to the number of commits being shipped per deploys.
253
+ **<code>deploy.max_commits</code>** allows you to set a limit to the number of commits being shipped per deploys.
254
254
 
255
- Human users will be warned that they are not respecting the recommandation, but allowed to continue.
255
+ Human users will be warned that they are not respecting the recommendation, but allowed to continue.
256
256
 
257
257
  For example:
258
258
 
@@ -262,7 +262,7 @@ deploy:
262
262
  ```
263
263
  <br>
264
264
 
265
- **<code>rollback.override</code>** contains an array of the shell commands required to rollback the application to a previous state. Shipit will try to infer it from the repository structure, but you can change the default inference. This key defaults to disabled unless Capistrano is detected.
265
+ **<code>rollback.override</code>** contains an array of the shell commands required to rollback the application to a previous state. Shipit will try to infer it from the repository structure, but you can change the default inference. This key defaults to `disabled` unless Capistrano is detected.
266
266
 
267
267
  For example:
268
268
 
@@ -273,7 +273,7 @@ rollback:
273
273
  ```
274
274
  <br>
275
275
 
276
- **<code>rollback.pre</code>** If you wish to execute commands before Shipit execute your rollback script you can specify them here:
276
+ **<code>rollback.pre</code>** If you wish to execute commands before Shipit executes your rollback script, you can specify them here:
277
277
 
278
278
  For example:
279
279
 
@@ -284,7 +284,7 @@ rollback:
284
284
  ```
285
285
  <br>
286
286
 
287
- **<code>rollback.post</code>** If you wish to execute commands after Shipit executed your rollback script you can specify them here:
287
+ **<code>rollback.post</code>** If you wish to execute commands after Shipit executed your rollback script, you can specify them here:
288
288
 
289
289
  For example:
290
290
 
@@ -296,7 +296,7 @@ rollback:
296
296
  <br>
297
297
 
298
298
 
299
- **<code>fetch</code>** contains an array of the shell commands that Shipit executes to check the revision of the currently-deployed version. This key defaults to disabled.
299
+ **<code>fetch</code>** contains an array of the shell commands that Shipit executes to check the revision of the currently-deployed version. This key defaults to `disabled`.
300
300
 
301
301
  For example:
302
302
  ```yml
@@ -316,7 +316,7 @@ machine:
316
316
 
317
317
  <h3 id="directory">Directory</h3>
318
318
 
319
- **<code>machine.directory</code>** specify a subfolder in which to execute all tasks. Useful for repositories containing multiple applications or if you don't want your deploy scripts to be located at the root.
319
+ **<code>machine.directory</code>** specifies a subfolder in which to execute all tasks. Useful for repositories containing multiple applications or if you don't want your deploy scripts to be located at the root.
320
320
 
321
321
  For example:
322
322
  ```yml
@@ -326,7 +326,7 @@ machine:
326
326
 
327
327
  <h3 id="cleanup">Cleanup</h3>
328
328
 
329
- **<code>machine.cleanup</code>** specify wether or not the deploy working directory should cleaned up once the deploy completed. Defaults to `true`, but can be useful to disable temporarily to investigate bugs.
329
+ **<code>machine.cleanup</code>** specifies whether or not the deploy working directory should be cleaned up once the deploy completed. Defaults to `true`, but can be useful to disable temporarily to investigate bugs.
330
330
 
331
331
  For example:
332
332
  ```yml
@@ -377,7 +377,7 @@ tasks:
377
377
  - ssh deploy@myserver.example.com 'touch myapp/restart.txt'
378
378
  ```
379
379
 
380
- By default custom tasks are not allowed to be triggered while a deploy is running. But if it's safe for that specific task you can change that behavior with the `allow_concurrency` attribute:
380
+ By default, custom tasks are not allowed to be triggered while a deploy is running. But if it's safe for that specific task, you can change that behavior with the `allow_concurrency` attribute:
381
381
 
382
382
  ```yml
383
383
  tasks:
@@ -436,7 +436,7 @@ review:
436
436
  <br>
437
437
 
438
438
  **<code>review.checks</code>** contains a list of commands that will be executed during the pre-deploy review step.
439
- Their output appears on the deployment page in Shipit.
439
+ Their output appears on the deployment page in Shipit, and if continuous delivery is enabled, deploys will only be triggered if those commands are successful.
440
440
 
441
441
  For example:
442
442
 
@@ -446,6 +446,8 @@ review:
446
446
  - bundle exec rake db:migrate:status
447
447
  ```
448
448
 
449
+
450
+
449
451
  ***
450
452
  <h2 id="configuring-secrets">Configuring <code>secrets.yml</code></h2>
451
453
 
@@ -465,11 +467,13 @@ production:
465
467
 
466
468
  The value for `id` is your application's *Client ID*, and the value for `secret` is your application's *Client Secret* &mdash; both of these should appear on your application's GitHub page.
467
469
 
470
+ Note: When setting up your application in Github, set the *Authorization callback URL* to `<yourdomain>/github/auth/github/callback`.
471
+
468
472
  The `teams` key is optional, and required only if you want to restrict access to a set of GitHub teams.
469
473
 
470
- If it's missing the Shipit installation will be public unless you setup another authentication method.
474
+ If it's missing, the Shipit installation will be public unless you setup another authentication method.
471
475
 
472
- After you change the list of time you have to invoke `bin/rake teams:fetch` in production so that a webhook is setup to keep the list of members up to date.
476
+ After you change the list of teams, you have to invoke `bin/rake teams:fetch` in production so that a webhook is setup to keep the list of members up to date.
473
477
 
474
478
  For example:
475
479
 
@@ -528,7 +532,7 @@ production:
528
532
 
529
533
  <br>
530
534
 
531
- **`commands_inactivity_timeout`** is the duration after which shipit will terminate a command if no ouput was received. Default is `300` (5 minutes).
535
+ **`commands_inactivity_timeout`** is the duration after which Shipit will terminate a command if no ouput was received. Default is `300` (5 minutes).
532
536
 
533
537
  For example:
534
538
  ```yml
@@ -540,9 +544,9 @@ production:
540
544
 
541
545
  Your deploy scripts have access to the following environment variables:
542
546
 
543
- * `SHIPIT`: Set to "1" allow your script to know it's executed by Shipit
544
- * `SHIPIT_LINK`: URL to the task output, usefull to broadcast it in an IRC channel
545
- * `USER`: Full name of the user that triggered the deploy/task
547
+ * `SHIPIT`: Set to `1` to allow your script to know it's executed by Shipit
548
+ * `SHIPIT_LINK`: URL to the task output, useful to broadcast it in an IRC channel
549
+ * `SHIPIT_USER`: Full name of the user that triggered the deploy/task
546
550
  * `EMAIL`: Email of the user that triggered the deploy/task (if available)
547
551
  * `ENVIRONMENT`: The stack environment (e.g `production` / `staging`)
548
552
  * `BRANCH`: The stack branch (e.g `master`)
@@ -1,11 +1,35 @@
1
1
  class OutputLines
2
2
  constructor: (@screen, @render) ->
3
+ @renderingCache = {}
4
+
5
+ append: (lines) ->
6
+ @screen.append(@renderLines(@filter(lines)))
7
+
8
+ setFilter: ->
9
+ true
10
+
11
+ filter: (lines) ->
12
+ lines
13
+
14
+ highlight: (line) ->
15
+ line
16
+
17
+ renderLines: (lines) ->
18
+ for line in lines
19
+ @highlight(@renderingCache[line] ||= @render(line))
20
+
21
+ class @ClusterizeOutputLines extends OutputLines
22
+ constructor: (@screen, @render) ->
23
+ super
24
+ @raw = []
3
25
  @query = ''
4
26
  @highlightRegexp = null
5
- @raw = []
6
- @renderingCache = {}
7
27
  @stripCache = {}
8
28
 
29
+ append: (lines) ->
30
+ @raw = @raw.concat(lines)
31
+ super
32
+
9
33
  setFilter: (query) ->
10
34
  if @query = query
11
35
  @screen.options.no_data_text = 'No matches'
@@ -17,20 +41,12 @@ class OutputLines
17
41
  reset: ->
18
42
  @screen.update(@renderLines(@filter(@raw)))
19
43
 
20
- filter: (lines) ->
21
- return lines unless @query
22
- line for line in lines when @strip(line).includes(@query)
23
-
24
44
  strip: (line) ->
25
45
  @stripCache[line] ||= AnsiStream.strip(line)
26
46
 
27
- append: (lines) ->
28
- @raw = @raw.concat(lines)
29
- @screen.append(@renderLines(@filter(lines)))
30
-
31
- renderLines: (lines) ->
32
- for line in lines
33
- @highlight(@renderingCache[line] ||= @render(line))
47
+ filter: (lines) ->
48
+ return lines unless @query
49
+ line for line in lines when @strip(line).includes(@query)
34
50
 
35
51
  buildHighlightRegexp: (query) ->
36
52
  pattern = query.replace(/[|\\{}()[\]^$+*?.]/g, '\\$&').replace(/(\s+)/g, '(<[^>]+>)*$1(<[^>]+>)*')
@@ -41,7 +57,6 @@ class OutputLines
41
57
 
42
58
  renderedLine.replace(@highlightRegexp, '<mark>$1</mark>').replace(/(<mark>[^<>]*)((<[^>]+>)+)([^<>]*<\/mark>)/, '$1</mark>$2<mark>$4');
43
59
 
44
-
45
60
  class @TTY
46
61
  FORMATTERS = []
47
62
  STICKY_SCROLL_TOLERENCE = 200
@@ -55,14 +70,17 @@ class @TTY
55
70
  constructor: ($body) ->
56
71
  @outputLines = []
57
72
  @$code = $body.find('code')
58
- @$container = @$code.closest('.clusterize-scroll')
59
- scroller = new Clusterize(
60
- no_data_text: 'Loading...'
61
- tag: 'div'
62
- contentElem: @$code[0]
63
- scrollElem: @$container[0]
64
- )
65
- @output = new OutputLines(scroller, (line) => @createLine(@formatChunks(line)))
73
+ @$container = @$code.closest('.task-output-container')
74
+ if @$container.hasClass('clusterize-scroll')
75
+ scroller = new Clusterize(
76
+ no_data_text: 'Loading...'
77
+ tag: 'div'
78
+ contentElem: @$code[0]
79
+ scrollElem: @$container[0]
80
+ )
81
+ @output = new ClusterizeOutputLines(scroller, (line) => @createLine(@formatChunks(line)))
82
+ else
83
+ @output = new OutputLines(@$code, (line) => @createLine(@formatChunks(line)))
66
84
 
67
85
  filterOutput: (query) =>
68
86
  @output.setFilter(query)
@@ -194,6 +194,7 @@
194
194
  border-color: $green;
195
195
  }
196
196
 
197
+ &[data-status="failed"],
197
198
  &[data-status="failure"],
198
199
  &[data-status="error"] {
199
200
  border-color: $bright-red;
@@ -10,7 +10,7 @@ module Shipit
10
10
  if stack.locked?
11
11
  render json: {message: 'Already locked'}, status: :conflict
12
12
  else
13
- stack.update(lock_reason: params.reason, lock_author: current_user)
13
+ stack.lock(params.reason, current_user)
14
14
  render_resource stack
15
15
  end
16
16
  end
@@ -19,12 +19,12 @@ module Shipit
19
19
  requires :reason, String, presence: true
20
20
  end
21
21
  def update
22
- stack.update(lock_reason: params.reason, lock_author: current_user)
22
+ stack.lock(params.reason, current_user)
23
23
  render_resource stack
24
24
  end
25
25
 
26
26
  def destroy
27
- stack.update(lock_reason: nil, lock_author: nil)
27
+ stack.unlock
28
28
  render_resource stack
29
29
  end
30
30
  end
@@ -1,12 +1,25 @@
1
1
  module Shipit
2
2
  module Api
3
3
  class StacksController < BaseController
4
- require_permission :read, :stack
4
+ require_permission :read, :stack, only: %i(index show)
5
+ require_permission :write, :stack, only: %i(create)
5
6
 
6
7
  def index
7
8
  render_resources stacks
8
9
  end
9
10
 
11
+ params do
12
+ requires :repo_owner, String
13
+ requires :repo_name, String
14
+ accepts :environment, String
15
+ accepts :branch, String
16
+ accepts :deploy_url, String
17
+ accepts :ignore_ci, Boolean
18
+ end
19
+ def create
20
+ render_resource Stack.create(params)
21
+ end
22
+
10
23
  def show
11
24
  render_resource stack
12
25
  end
@@ -1,12 +1,19 @@
1
1
  module Shipit
2
2
  class CommitChecksController < ShipitController
3
+ def show
4
+ checks.schedule
5
+ end
6
+
3
7
  params do
4
8
  accepts :since, Integer, default: 0
5
9
  end
6
10
  def tail
7
11
  output = checks.output(since: params.since)
8
- next_offset = params.since + output.bytesize
9
- url = stack_tail_commit_checks_path(stack, sha: commit.sha, since: next_offset) unless checks.finished?
12
+ url = nil
13
+ unless checks.finished?
14
+ next_offset = params.since + output.bytesize
15
+ url = stack_tail_commit_checks_path(stack, sha: commit.sha, since: next_offset)
16
+ end
10
17
 
11
18
  render json: {url: url, output: output, status: checks.status}
12
19
  end