shipit-engine 0.15.0 → 0.16.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (111) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +34 -1
  3. data/app/assets/javascripts/shipit/page_updater.js.coffee +63 -0
  4. data/app/assets/javascripts/shipit/stacks.js.coffee +9 -21
  5. data/app/assets/stylesheets/_base/_base.scss +2 -2
  6. data/app/assets/stylesheets/_base/_colors.scss +0 -1
  7. data/app/assets/stylesheets/_base/_forms.scss +14 -0
  8. data/app/assets/stylesheets/_pages/_commits.scss +16 -6
  9. data/app/assets/stylesheets/_pages/_settings.scss +8 -0
  10. data/app/assets/stylesheets/_pages/_stacks.scss +1 -1
  11. data/app/controllers/shipit/api/base_controller.rb +7 -3
  12. data/app/controllers/shipit/api/ccmenu_controller.rb +33 -0
  13. data/app/controllers/shipit/api/pull_requests_controller.rb +36 -0
  14. data/app/controllers/shipit/api/stacks_controller.rb +1 -0
  15. data/app/controllers/shipit/ccmenu_url_controller.rb +22 -0
  16. data/app/controllers/shipit/pull_requests_controller.rb +30 -0
  17. data/app/controllers/shipit/stacks_controller.rb +7 -2
  18. data/app/controllers/shipit/webhooks_controller.rb +1 -2
  19. data/app/helpers/shipit/github_url_helper.rb +8 -2
  20. data/app/helpers/shipit/shipit_helper.rb +9 -0
  21. data/app/helpers/shipit/stacks_helper.rb +22 -7
  22. data/app/jobs/shipit/background_job/unique.rb +19 -1
  23. data/app/jobs/shipit/cache_deploy_spec_job.rb +1 -1
  24. data/app/jobs/shipit/merge_pull_requests_job.rb +26 -0
  25. data/app/jobs/shipit/perform_task_job.rb +1 -1
  26. data/app/jobs/shipit/refresh_pull_request_job.rb +8 -0
  27. data/app/models/concerns/shipit/deferred_touch.rb +6 -1
  28. data/app/models/shipit/anonymous_user.rb +4 -0
  29. data/app/models/shipit/application_record.rb +5 -0
  30. data/app/models/shipit/commit.rb +51 -49
  31. data/app/models/shipit/commit_message.rb +32 -0
  32. data/app/models/shipit/deploy.rb +5 -0
  33. data/app/models/shipit/deploy_spec.rb +26 -1
  34. data/app/models/shipit/deploy_spec/file_system.rb +6 -1
  35. data/app/models/shipit/deploy_spec/kubernetes_discovery.rb +10 -13
  36. data/app/models/shipit/deploy_spec/npm_discovery.rb +2 -1
  37. data/app/models/shipit/duration.rb +3 -1
  38. data/app/models/shipit/hook.rb +1 -0
  39. data/app/models/shipit/pull_request.rb +252 -0
  40. data/app/models/shipit/stack.rb +33 -17
  41. data/app/models/shipit/status.rb +1 -16
  42. data/app/models/shipit/status/common.rb +45 -0
  43. data/app/models/shipit/status/group.rb +82 -0
  44. data/app/models/shipit/status/missing.rb +30 -0
  45. data/app/models/shipit/status/unknown.rb +33 -0
  46. data/app/models/shipit/unlimited_api_client.rb +10 -0
  47. data/app/serializers/shipit/commit_serializer.rb +1 -1
  48. data/app/serializers/shipit/pull_request_serializer.rb +20 -0
  49. data/app/serializers/shipit/stack_serializer.rb +6 -2
  50. data/app/views/layouts/shipit.html.erb +41 -39
  51. data/app/views/shipit/ccmenu/project.xml.builder +13 -0
  52. data/app/views/shipit/commits/_commit.html.erb +1 -1
  53. data/app/views/shipit/deploys/_deploy.html.erb +1 -1
  54. data/app/views/shipit/pull_requests/_pull_request.html.erb +29 -0
  55. data/app/views/shipit/pull_requests/index.html.erb +20 -0
  56. data/app/views/shipit/shared/_author.html.erb +7 -0
  57. data/app/views/shipit/stacks/_header.html.erb +5 -0
  58. data/app/views/shipit/stacks/settings.html.erb +13 -0
  59. data/app/views/shipit/stacks/show.html.erb +3 -2
  60. data/app/views/shipit/statuses/_group.html.erb +1 -1
  61. data/app/views/shipit/tasks/_task.html.erb +1 -1
  62. data/config/initializers/inflections.rb +3 -0
  63. data/config/locales/en.yml +1 -3
  64. data/config/routes.rb +8 -0
  65. data/db/migrate/20170130113633_create_shipit_pull_requests.rb +25 -0
  66. data/db/migrate/20170208143657_add_pull_request_number_and_title_to_commits.rb +7 -0
  67. data/db/migrate/20170208154609_backfill_merge_commits.rb +13 -0
  68. data/db/migrate/20170209160355_add_branch_to_pull_requests.rb +5 -0
  69. data/db/migrate/20170215123538_add_merge_queue_enabled_to_stacks.rb +5 -0
  70. data/db/migrate/20170220152410_improve_users_indexing.rb +6 -0
  71. data/db/migrate/20170221102128_improve_tasks_indexing.rb +8 -0
  72. data/db/migrate/20170221130336_add_last_revalidated_at_on_pull_requests.rb +10 -0
  73. data/lib/shipit.rb +2 -0
  74. data/lib/shipit/version.rb +1 -1
  75. data/lib/tasks/cron.rake +1 -0
  76. data/test/controllers/api/ccmenu_controller_test.rb +57 -0
  77. data/test/controllers/api/commits_controller_test.rb +1 -1
  78. data/test/controllers/api/pull_requests_controller_test.rb +59 -0
  79. data/test/controllers/ccmenu_controller_test.rb +33 -0
  80. data/test/controllers/pull_requests_controller_test.rb +31 -0
  81. data/test/controllers/webhooks_controller_test.rb +3 -4
  82. data/test/dummy/config/environments/development.rb +3 -1
  83. data/test/dummy/data/stacks/shopify/junk/production/git/README.md +8 -0
  84. data/test/dummy/data/stacks/shopify/junk/production/git/circle.yml +4 -0
  85. data/test/dummy/data/stacks/shopify/junk/production/git/shipit.yml +4 -0
  86. data/test/dummy/db/development.sqlite3 +0 -0
  87. data/test/dummy/db/schema.rb +45 -11
  88. data/test/dummy/db/seeds.rb +33 -10
  89. data/test/dummy/db/test.sqlite3 +0 -0
  90. data/test/fixtures/shipit/commits.yml +14 -0
  91. data/test/fixtures/shipit/pull_requests.yml +56 -0
  92. data/test/fixtures/shipit/stacks.yml +5 -1
  93. data/test/fixtures/shipit/statuses.yml +8 -0
  94. data/test/helpers/json_helper.rb +16 -14
  95. data/test/jobs/merge_pull_requests_job_test.rb +59 -0
  96. data/test/models/commits_test.rb +104 -49
  97. data/test/{unit → models}/deploy_spec_test.rb +138 -12
  98. data/test/models/deploys_test.rb +10 -4
  99. data/test/models/pull_request_test.rb +197 -0
  100. data/test/models/stacks_test.rb +46 -53
  101. data/test/models/status/group_test.rb +44 -0
  102. data/test/models/status/missing_test.rb +23 -0
  103. data/test/models/status_test.rb +3 -6
  104. data/test/unit/csv_serializer_test.rb +10 -2
  105. metadata +57 -12
  106. data/app/models/shipit/missing_status.rb +0 -21
  107. data/app/models/shipit/status_group.rb +0 -35
  108. data/app/models/shipit/unknown_status.rb +0 -48
  109. data/app/views/shipit/commits/_commit_author.html.erb +0 -7
  110. data/test/models/missing_status_test.rb +0 -23
  111. data/test/models/status_group_test.rb +0 -26
@@ -1,21 +0,0 @@
1
- module Shipit
2
- class MissingStatus < SimpleDelegator
3
- def initialize(instance, missing_statuses)
4
- @missing_statuses = missing_statuses
5
- super(instance)
6
- end
7
-
8
- def state
9
- 'missing'
10
- end
11
-
12
- def success?
13
- false
14
- end
15
-
16
- def description
17
- statuses = @missing_statuses.to_sentence
18
- I18n.t('missing_status.description', missing_statuses: statuses, count: @missing_statuses.size)
19
- end
20
- end
21
- end
@@ -1,35 +0,0 @@
1
- module Shipit
2
- class StatusGroup
3
- STATES_PRIORITY = %w(failure error pending success).freeze
4
-
5
- attr_reader :statuses, :significant_status
6
-
7
- def initialize(significant_status, visible_statuses)
8
- @significant_status = significant_status
9
- @statuses = visible_statuses
10
- end
11
-
12
- delegate :pending?, :success?, :error?, :failure?, :unknown?, :state, to: :significant_status
13
-
14
- def description
15
- "#{success_count} / #{statuses.count} checks OK"
16
- end
17
-
18
- def target_url
19
- end
20
-
21
- def to_partial_path
22
- 'statuses/group'
23
- end
24
-
25
- def group?
26
- true
27
- end
28
-
29
- private
30
-
31
- def success_count
32
- @statuses.count { |s| s.state == 'success'.freeze }
33
- end
34
- end
35
- end
@@ -1,48 +0,0 @@
1
- module Shipit
2
- UnknownStatus = Struct.new(:commit) do
3
- def state
4
- 'unknown'
5
- end
6
- alias_method :simple_state, :state
7
-
8
- def unknown?
9
- true
10
- end
11
-
12
- def pending?
13
- false
14
- end
15
-
16
- def success?
17
- false
18
- end
19
-
20
- def error?
21
- false
22
- end
23
-
24
- def failure?
25
- false
26
- end
27
-
28
- def group?
29
- false
30
- end
31
-
32
- def target_url
33
- nil
34
- end
35
-
36
- def description
37
- ''
38
- end
39
-
40
- def context
41
- 'ci/unknown'
42
- end
43
-
44
- def to_partial_path
45
- 'shipit/statuses/status'
46
- end
47
- end
48
- end
@@ -1,7 +0,0 @@
1
- <a href="<%= github_user_url(commit.author.login) %>" class="commit-author">
2
- <%= github_avatar(commit.author, size: 80, class: 'commit-author__avatar') %>
3
- <div class="commit-author__name">
4
- <span class="commit-author__name__real-name"><%= commit.author.name %></span>
5
- <span class="commit-author__name__username"><%= commit.author.login %></span>
6
- </div>
7
- </a>
@@ -1,23 +0,0 @@
1
- require 'test_helper'
2
-
3
- module Shipit
4
- class MissingStatusTest < ActiveSupport::TestCase
5
- setup do
6
- @real_status = shipit_statuses(:first_pending)
7
- @status = MissingStatus.new(@real_status, %w(ci/very-important style/very-important-too))
8
- end
9
-
10
- test "#state is 'missing'" do
11
- assert_equal 'missing', @status.state
12
- end
13
-
14
- test "#description explains the situation" do
15
- message = 'ci/very-important and style/very-important-too are required for deploy but were not sent'
16
- assert_equal message, @status.description
17
- end
18
-
19
- test "#success? is false" do
20
- refute_predicate @status, :success?
21
- end
22
- end
23
- end
@@ -1,26 +0,0 @@
1
- require 'test_helper'
2
-
3
- module Shipit
4
- class StatusGroupTest < ActiveSupport::TestCase
5
- setup do
6
- @commit = shipit_commits(:second)
7
- @group = StatusGroup.new(@commit.significant_status, @commit.visible_statuses)
8
- end
9
-
10
- test "#description is a summary of the statuses" do
11
- assert_equal '1 / 2 checks OK', @group.description
12
- end
13
-
14
- test "#group? returns true" do
15
- assert_equal true, @group.group?
16
- end
17
-
18
- test "#target_url returns nil" do
19
- assert_nil @group.target_url
20
- end
21
-
22
- test "#state is significant's status state" do
23
- assert_equal @commit.significant_status.state, @group.state
24
- end
25
- end
26
- end