pact_broker 2.82.0 → 2.85.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (221) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -0
  3. data/CHANGELOG.md +53 -0
  4. data/Dockerfile +1 -1
  5. data/db/migrations/20210815_add_provider_version_id_index_to_verifications.rb +7 -0
  6. data/db/migrations/20210816_create_branches_tables.rb +40 -0
  7. data/db/migrations/20210818_add_consumer_version_selectors_to_verification.rb +8 -0
  8. data/db/migrations/20210831_add_index_to_pact_publications.rb +7 -0
  9. data/db/migrations/20210908_add_auto_created.rb +24 -0
  10. data/db/migrations/20210913_add_pending_to_verifications.rb +7 -0
  11. data/issue-reproduction/Dockerfile-pact-broker +1 -1
  12. data/lib/pact/doc/markdown/consumer_contract_renderer.rb +3 -3
  13. data/lib/pact_broker/api/contracts/{verifiable_pacts_json_query_schema.rb → pacts_for_verification_json_query_schema.rb} +1 -1
  14. data/lib/pact_broker/api/contracts/{verifiable_pacts_query_schema.rb → pacts_for_verification_query_string_schema.rb} +1 -1
  15. data/lib/pact_broker/api/decorators/branch_version_decorator.rb +20 -0
  16. data/lib/pact_broker/api/decorators/dashboard_decorator.rb +4 -2
  17. data/lib/pact_broker/api/decorators/embedded_branch_version_decorator.rb +21 -0
  18. data/lib/pact_broker/api/decorators/embedded_tag_decorator.rb +0 -5
  19. data/lib/pact_broker/api/decorators/matrix_decorator.rb +11 -2
  20. data/lib/pact_broker/api/decorators/pacticipant_decorator.rb +8 -0
  21. data/lib/pact_broker/api/decorators/{verifiable_pacts_query_decorator.rb → pacts_for_verification_query_decorator.rb} +2 -2
  22. data/lib/pact_broker/api/decorators/reason_decorator.rb +2 -2
  23. data/lib/pact_broker/api/decorators/verification_summary_decorator.rb +1 -2
  24. data/lib/pact_broker/api/decorators/version_decorator.rb +1 -1
  25. data/lib/pact_broker/api/middleware/configuration.rb +33 -0
  26. data/lib/pact_broker/api/pact_broker_urls.rb +13 -1
  27. data/lib/pact_broker/api/renderers/html_pact_renderer.rb +15 -11
  28. data/lib/pact_broker/api/resources/branch_version.rb +48 -0
  29. data/lib/pact_broker/api/resources/index.rb +6 -0
  30. data/lib/pact_broker/api/resources/pact_versions_for_branch.rb +40 -0
  31. data/lib/pact_broker/api/resources/provider_pacts_for_verification.rb +6 -6
  32. data/lib/pact_broker/api/resources/verifications.rb +7 -2
  33. data/lib/pact_broker/api/resources/version.rb +0 -8
  34. data/lib/pact_broker/api.rb +2 -0
  35. data/lib/pact_broker/app.rb +2 -0
  36. data/lib/pact_broker/badges/service.rb +3 -1
  37. data/lib/pact_broker/config/runtime_configuration.rb +12 -0
  38. data/lib/pact_broker/configuration.rb +33 -29
  39. data/lib/pact_broker/contracts/service.rb +1 -1
  40. data/lib/pact_broker/db/clean/selector.rb +54 -0
  41. data/lib/pact_broker/db/clean.rb +7 -1
  42. data/lib/pact_broker/db/clean_incremental.rb +13 -5
  43. data/lib/pact_broker/db/data_migrations/create_branches.rb +97 -0
  44. data/lib/pact_broker/db/data_migrations/set_pacticipant_main_branch.rb +2 -0
  45. data/lib/pact_broker/db/migrate_data.rb +1 -1
  46. data/lib/pact_broker/db/models.rb +6 -0
  47. data/lib/pact_broker/deployments/deployed_version.rb +4 -0
  48. data/lib/pact_broker/deployments/deployed_version_service.rb +4 -3
  49. data/lib/pact_broker/deployments/environment.rb +4 -0
  50. data/lib/pact_broker/deployments/environment_service.rb +13 -8
  51. data/lib/pact_broker/diagnostic/resources/base_resource.rb +4 -0
  52. data/lib/pact_broker/diagnostic/resources/dependencies.rb +1 -1
  53. data/lib/pact_broker/diagnostic/resources/heartbeat.rb +2 -3
  54. data/lib/pact_broker/doc/views/index/pacticipant-branch-version.markdown +14 -0
  55. data/lib/pact_broker/doc/views/webhooks.markdown +1 -0
  56. data/lib/pact_broker/domain/index_item.rb +15 -17
  57. data/lib/pact_broker/domain/pacticipant.rb +11 -0
  58. data/lib/pact_broker/domain/tag.rb +1 -2
  59. data/lib/pact_broker/domain/verification.rb +29 -14
  60. data/lib/pact_broker/domain/version.rb +112 -29
  61. data/lib/pact_broker/domain/webhook.rb +22 -10
  62. data/lib/pact_broker/domain/webhook_request.rb +2 -2
  63. data/lib/pact_broker/index/service.rb +83 -28
  64. data/lib/pact_broker/locale/en.yml +4 -0
  65. data/lib/pact_broker/matrix/quick_row.rb +6 -6
  66. data/lib/pact_broker/matrix/service.rb +4 -0
  67. data/lib/pact_broker/matrix/unresolved_selector.rb +3 -2
  68. data/lib/pact_broker/metrics/service.rb +7 -1
  69. data/lib/pact_broker/pacts/metadata.rb +7 -2
  70. data/lib/pact_broker/pacts/pact_publication.rb +59 -25
  71. data/lib/pact_broker/pacts/pact_publication_dataset_module.rb +113 -33
  72. data/lib/pact_broker/pacts/pact_publication_selector_dataset_module.rb +18 -13
  73. data/lib/pact_broker/pacts/pact_publication_wip_dataset_module.rb +16 -4
  74. data/lib/pact_broker/pacts/pact_version.rb +13 -1
  75. data/lib/pact_broker/pacts/pacts_for_verification_repository.rb +4 -10
  76. data/lib/pact_broker/pacts/repository.rb +6 -1
  77. data/lib/pact_broker/pacts/selected_pact.rb +20 -0
  78. data/lib/pact_broker/pacts/selector.rb +98 -33
  79. data/lib/pact_broker/pacts/service.rb +21 -0
  80. data/lib/pact_broker/repositories.rb +5 -0
  81. data/lib/pact_broker/services.rb +9 -0
  82. data/lib/pact_broker/test/http_test_data_builder.rb +35 -9
  83. data/lib/pact_broker/test/test_data_builder.rb +32 -26
  84. data/lib/pact_broker/ui/app.rb +7 -1
  85. data/lib/pact_broker/ui/controllers/dashboard.rb +80 -0
  86. data/lib/pact_broker/ui/controllers/groups.rb +23 -8
  87. data/lib/pact_broker/ui/helpers/url_helper.rb +5 -1
  88. data/lib/pact_broker/ui/view_models/index_item.rb +56 -3
  89. data/lib/pact_broker/ui/view_models/matrix_branch.rb +39 -0
  90. data/lib/pact_broker/ui/view_models/matrix_line.rb +11 -16
  91. data/lib/pact_broker/ui/view_models/matrix_tag.rb +0 -1
  92. data/lib/pact_broker/ui/views/dashboard/show.haml +195 -0
  93. data/lib/pact_broker/ui/views/groups/show.html.erb +60 -14
  94. data/lib/pact_broker/ui/views/index/_dashboard_navbar.haml +7 -0
  95. data/lib/pact_broker/ui/views/index/_navbar.haml +0 -7
  96. data/lib/pact_broker/ui/views/index/show-with-tags.haml +14 -11
  97. data/lib/pact_broker/ui/views/index/show.haml +35 -13
  98. data/lib/pact_broker/ui/views/matrix/show.haml +15 -11
  99. data/lib/pact_broker/verifications/pseudo_branch_status.rb +2 -0
  100. data/lib/pact_broker/verifications/repository.rb +6 -11
  101. data/lib/pact_broker/verifications/service.rb +11 -5
  102. data/lib/pact_broker/version.rb +1 -1
  103. data/lib/pact_broker/versions/branch.rb +29 -0
  104. data/lib/pact_broker/versions/branch_head.rb +45 -0
  105. data/lib/pact_broker/versions/branch_service.rb +24 -0
  106. data/lib/pact_broker/versions/branch_version.rb +64 -0
  107. data/lib/pact_broker/versions/branch_version_repository.rb +34 -0
  108. data/lib/pact_broker/versions/eager_loaders.rb +0 -42
  109. data/lib/pact_broker/versions/repository.rb +25 -12
  110. data/lib/pact_broker/versions/service.rb +3 -22
  111. data/lib/pact_broker/webhooks/event_listener.rb +3 -3
  112. data/lib/pact_broker/webhooks/execution_configuration.rb +16 -0
  113. data/lib/pact_broker/webhooks/execution_configuration_creator.rb +3 -0
  114. data/lib/pact_broker/webhooks/job.rb +1 -1
  115. data/lib/pact_broker/webhooks/pact_and_verification_parameters.rb +20 -3
  116. data/lib/pact_broker/webhooks/trigger_service.rb +2 -2
  117. data/lib/pact_broker/webhooks/webhook_execution_result.rb +3 -7
  118. data/lib/pact_broker/webhooks/webhook_request_logger.rb +4 -12
  119. data/lib/pact_broker/webhooks/webhook_request_template.rb +6 -8
  120. data/lib/sequel/plugins/insert_ignore.rb +4 -0
  121. data/lib/sequel/plugins/upsert.rb +4 -0
  122. data/pact_broker.gemspec +4 -0
  123. data/public/javascripts/index.js +152 -50
  124. data/public/javascripts/pact.js +14 -14
  125. data/public/stylesheets/index.css +1 -2
  126. data/public/stylesheets/pact.css +11 -0
  127. data/scaffolding/templates/decorator.rb.erb +3 -1
  128. data/scaffolding/templates/migration.erb +1 -1
  129. data/scaffolding/templates/model.erb +2 -2
  130. data/scaffolding/templates/repository.rb.erb +2 -2
  131. data/scaffolding/templates/repository_spec.rb.erb +1 -1
  132. data/scaffolding/templates/resource.erb +2 -2
  133. data/scaffolding/templates/resource_spec.rb.erb +1 -1
  134. data/scaffolding/templates/service.rb.erb +3 -3
  135. data/scaffolding/templates/service_spec.rb.erb +1 -1
  136. data/script/data/auto-create-things-for-tags.rb +2 -0
  137. data/script/data/branches.rb +35 -0
  138. data/script/data/contract-published-requiring-verification.rb +1 -1
  139. data/script/data/environments.rb +0 -0
  140. data/script/data/issue-494.rb +25 -0
  141. data/script/data/pending.rb +26 -0
  142. data/script/data/tags.rb +35 -0
  143. data/script/data/webhook.rb +22 -0
  144. data/script/seed.rb +50 -89
  145. data/spec/features/create_branch_version_spec.rb +29 -0
  146. data/spec/features/create_tag_spec.rb +1 -1
  147. data/spec/features/create_version_spec.rb +2 -4
  148. data/spec/features/delete_pact_versions_for_branch_spec.rb +34 -0
  149. data/spec/features/get_branch_version_spec.rb +12 -0
  150. data/spec/features/publish_pact_all_in_one_spec.rb +0 -1
  151. data/spec/features/update_version_spec.rb +0 -55
  152. data/spec/fixtures/approvals/modifiable_resources.approved.json +7 -0
  153. data/spec/fixtures/approvals/publish_contract_nothing_exists.approved.json +1 -2
  154. data/spec/fixtures/approvals/publish_contract_nothing_exists_with_webhook.approved.json +1 -2
  155. data/spec/fixtures/approvals/publish_contract_verification_already_exists.approved.json +1 -2
  156. data/spec/fixtures/dashboard.json +4 -2
  157. data/spec/integration/app_spec.rb +6 -6
  158. data/spec/integration/ui/index_spec.rb +0 -2
  159. data/spec/integration/ui/matrix_spec.rb +0 -1
  160. data/spec/lib/pact/doc/markdown/consumer_contract_renderer_spec.rb +2 -2
  161. data/spec/lib/pact_broker/api/contracts/{verifiable_pacts_json_query_schema_combinations_spec.rb → pacts_for_verification_json_query_schema_combinations_spec.rb} +6 -6
  162. data/spec/lib/pact_broker/api/contracts/{verifiable_pacts_json_query_schema_spec.rb → pacts_for_verification_json_query_schema_spec.rb} +3 -3
  163. data/spec/lib/pact_broker/api/contracts/{verifiable_pacts_query_schema_spec.rb → pacts_for_verification_query_string_schema_spec.rb} +3 -3
  164. data/spec/lib/pact_broker/api/decorators/dashboard_decorator_spec.rb +7 -7
  165. data/spec/lib/pact_broker/api/decorators/matrix_decorator_spec.rb +19 -4
  166. data/spec/lib/pact_broker/api/decorators/{verifiable_pacts_query_decorator_spec.rb → pacts_for_verification_query_decorator_spec.rb} +3 -3
  167. data/spec/lib/pact_broker/api/decorators/reason_decorator_spec.rb +2 -2
  168. data/spec/lib/pact_broker/api/decorators/verification_summary_decorator_spec.rb +2 -0
  169. data/spec/lib/pact_broker/api/decorators/version_decorator_spec.rb +7 -3
  170. data/spec/lib/pact_broker/api/decorators/webhook_execution_result_decorator_spec.rb +1 -1
  171. data/spec/lib/pact_broker/api/middleware/configuration_spec.rb +43 -0
  172. data/spec/lib/pact_broker/api/resources/verifications_spec.rb +6 -4
  173. data/spec/lib/pact_broker/api/resources/webhook_execution_spec.rb +1 -1
  174. data/spec/lib/pact_broker/badges/service_spec.rb +22 -0
  175. data/spec/lib/pact_broker/contracts/service_spec.rb +24 -3
  176. data/spec/lib/pact_broker/db/clean_spec.rb +2 -2
  177. data/spec/lib/pact_broker/db/data_migrations/create_branches_spec.rb +57 -0
  178. data/spec/lib/pact_broker/diagnostic/resources/dependencies_spec.rb +4 -4
  179. data/spec/lib/pact_broker/diagnostic/resources/heartbeat_spec.rb +3 -4
  180. data/spec/lib/pact_broker/domain/index_item_spec.rb +1 -1
  181. data/spec/lib/pact_broker/domain/version_spec.rb +127 -36
  182. data/spec/lib/pact_broker/domain/webhook_request_spec.rb +2 -1
  183. data/spec/lib/pact_broker/domain/webhook_spec.rb +15 -5
  184. data/spec/lib/pact_broker/index/service_spec.rb +1 -5
  185. data/spec/lib/pact_broker/index/service_view_spec.rb +144 -0
  186. data/spec/lib/pact_broker/matrix/service_spec.rb +10 -1
  187. data/spec/lib/pact_broker/metrics/service_spec.rb +4 -1
  188. data/spec/lib/pact_broker/pacts/metadata_spec.rb +11 -3
  189. data/spec/lib/pact_broker/pacts/pact_publication_dataset_module_spec.rb +109 -10
  190. data/spec/lib/pact_broker/pacts/pact_publication_latest_verification_spec.rb +29 -0
  191. data/spec/lib/pact_broker/pacts/pact_publication_selector_dataset_module_spec.rb +3 -2
  192. data/spec/lib/pact_broker/pacts/pact_publication_spec.rb +5 -5
  193. data/spec/lib/pact_broker/pacts/repository_find_for_currently_deployed_spec.rb +2 -2
  194. data/spec/lib/pact_broker/pacts/repository_find_for_currently_supported_releases_spec.rb +2 -2
  195. data/spec/lib/pact_broker/pacts/repository_spec.rb +15 -2
  196. data/spec/lib/pact_broker/pacts/selector_spec.rb +45 -3
  197. data/spec/lib/pact_broker/pacts/service_spec.rb +61 -0
  198. data/spec/lib/pact_broker/pacts/verifiable_pact_messages_spec.rb +5 -5
  199. data/spec/lib/pact_broker/relationships/groupify_spec.rb +0 -5
  200. data/spec/lib/pact_broker/ui/view_models/index_item_spec.rb +21 -6
  201. data/spec/lib/pact_broker/verifications/pseudo_branch_status_spec.rb +9 -1
  202. data/spec/lib/pact_broker/verifications/repository_spec.rb +39 -30
  203. data/spec/lib/pact_broker/verifications/service_spec.rb +9 -5
  204. data/spec/lib/pact_broker/versions/branch_service_spec.rb +71 -0
  205. data/spec/lib/pact_broker/versions/branch_version_repository_spec.rb +81 -0
  206. data/spec/lib/pact_broker/versions/branch_version_spec.rb +27 -0
  207. data/spec/lib/pact_broker/versions/repository_spec.rb +91 -6
  208. data/spec/lib/pact_broker/versions/service_spec.rb +4 -3
  209. data/spec/lib/pact_broker/webhooks/job_spec.rb +4 -4
  210. data/spec/lib/pact_broker/webhooks/render_spec.rb +6 -0
  211. data/spec/lib/pact_broker/webhooks/trigger_service_spec.rb +9 -5
  212. data/spec/lib/pact_broker/webhooks/webhook_request_logger_spec.rb +6 -12
  213. data/spec/lib/pact_broker/webhooks/webhook_request_template_spec.rb +3 -2
  214. data/spec/lib/sequel/plugins/upsert_spec.rb +11 -5
  215. data/spec/migrations/44_add_provider_version_to_verification_spec.rb +6 -9
  216. data/spec/service_consumers/pact_helper.rb +2 -0
  217. data/spec/spec_helper.rb +1 -1
  218. data/spec/support/generated_markdown.md +3 -3
  219. metadata +90 -17
  220. data/lib/pact_broker/versions/lazy_loaders.rb +0 -13
  221. data/spec/lib/pact_broker/api/resources/webhook_execution_result_spec.rb +0 -56
@@ -0,0 +1,7 @@
1
+ %nav{'aria-label': 'breadcrumb'}
2
+ %ol.breadcrumb
3
+ %li.breadcrumb-item
4
+ %a{'href': "#{base_url}/"}
5
+ Home
6
+ %li.breadcrumb-item.active{'aria-current': 'page'}
7
+ Pact publications
@@ -3,12 +3,5 @@
3
3
  .navbar-header
4
4
  %ul.navbar-right#top-left-menu
5
5
  %li
6
- - if tag_toggle
7
- %a{href: "#{base_url}?tags=true"}
8
- Show latest tags
9
- - else
10
- %a{href: "#{base_url}/"}
11
- Hide latest tags
12
-
13
6
  %a{href: "#{base_url}/hal-browser/browser.html"}
14
7
  API Browser
@@ -48,7 +48,13 @@
48
48
  %tbody
49
49
 
50
50
  - index_items.each do | index_item |
51
- %tr{'data-pact-versions-url': index_item.pact_versions_url, 'data-consumer-name': index_item.consumer_name, 'data-provider-name': index_item.provider_name, 'data-integration-url': index_item.integration_url}
51
+ %tr{'data-pact-versions-url': index_item.pact_versions_url,
52
+ 'data-consumer-name': index_item.consumer_name,
53
+ 'data-provider-name': index_item.provider_name,
54
+ 'data-integration-url': index_item.integration_url,
55
+ 'data-pact-tags': index_item.pact_tags,
56
+ 'data-pact-branches': index_item.pact_branches
57
+ }
52
58
  %td.consumer
53
59
  %a{:href => index_item.consumer_group_url }
54
60
  = index_item.consumer_name
@@ -58,10 +64,9 @@
58
64
  - if index_item.display_consumer_version_number
59
65
  %button.clippy.invisible{ title: "Copy to clipboard" }
60
66
  %span.copy-icon
61
- - if index_item.consumer_version_branch
62
- - branch_class = index_item.latest_for_branch? ? "tag badge badge-dark" : "tag badge badge-secondary"
63
- %div{"class": branch_class}
64
- = "branch: " + index_item.consumer_version_branch
67
+ - index_item.consumer_version_branches.each do | branch_name |
68
+ %div{"class": "tag badge badge-dark"}
69
+ = "branch: " + branch_name
65
70
  - index_item.consumer_version_latest_tag_names.each do | tag_name |
66
71
  .tag.badge.badge-primary
67
72
  = "tag: " + tag_name
@@ -85,10 +90,9 @@
85
90
  - if index_item.display_provider_version_number
86
91
  %button.clippy.invisible{ title: "Copy to clipboard" }
87
92
  %span.copy-icon
88
- - if index_item.provider_version_branch
89
- - branch_class = "tag badge badge-dark"
90
- %div{"class": branch_class}
91
- = "branch: " + index_item.provider_version_branch
93
+ - index_item.provider_version_branches.each do | branch_name |
94
+ %div{"class": "tag badge badge-dark"}
95
+ = "branch: " + branch_name
92
96
  - index_item.provider_version_latest_tag_names.each do | tag_name |
93
97
  .tag.badge.badge-primary
94
98
  = "tag: " + tag_name
@@ -108,8 +112,7 @@
108
112
  - if index_item.warning?
109
113
  %span.warning-icon{ 'aria-hidden': true }
110
114
  %td
111
- - if index_item.show_settings?
112
- %span.integration-settings.kebab-horizontal{ 'aria-hidden': true }
115
+ %span.integration-settings.kebab-horizontal{ 'aria-hidden': true }
113
116
 
114
117
  %div.pagination.text-center
115
118
 
@@ -13,7 +13,7 @@
13
13
  = error
14
14
 
15
15
  %form{action: "#{base_url}"}
16
- .field
16
+ .search-field
17
17
  %label{for: 'search'}
18
18
  Search
19
19
  %input{name: 'search', id: 'search', class: 'search', value: search}
@@ -27,11 +27,11 @@
27
27
  %th.consumer
28
28
  Consumer
29
29
  %span.sort-icon.relationships-sort
30
- %th.pact
31
30
 
32
31
  %th.provider
33
32
  Provider
34
33
  %span.sort-icon.relationships-sort
34
+ %th.pact
35
35
  %th
36
36
  %th
37
37
  Latest pact<br>published
@@ -42,31 +42,42 @@
42
42
  %th
43
43
  %tbody
44
44
  - index_items.each do | index_item |
45
- %tr{'data-pact-versions-url': index_item.pact_versions_url, 'data-consumer-name': index_item.consumer_name, 'data-provider-name': index_item.provider_name, 'data-integration-url': index_item.integration_url}
46
- %td
47
- %td.consumer
45
+ %tr{
46
+ 'class':'pact-row',
47
+ 'data-pact-versions-url': index_item.pact_versions_url,
48
+ 'data-consumer-name': index_item.consumer_name,
49
+ 'data-provider-name': index_item.provider_name,
50
+ 'data-integration-url': index_item.integration_url,
51
+ 'data-href': index_item.dashboard_url,
52
+ 'data-index': "true"
53
+ }
54
+ %td{'role':"button"}
55
+ %td.consumer{'role':"button"}
48
56
  %a{ href: index_item.consumer_group_url }
49
57
  = index_item.consumer_name
50
- %td.pact
58
+ %td.provider{'role':"button"}
59
+ %a{ href: index_item.provider_group_url }
60
+ = index_item.provider_name
61
+ %td.pact{'role':"button"}
51
62
  %span.pact
52
63
  %a{ href: index_item.latest_pact_url, :title => "View pact" }
53
64
  %span.pact-matrix
54
65
  %a{ href: index_item.pact_matrix_url, title: "View pact matrix" }
55
- %td.provider
56
- %a{ href: index_item.provider_group_url }
57
- = index_item.provider_name
58
- %td
59
- %td{"data-text": index_item.publication_date_of_latest_pact_order}
66
+ %td{'role':"button"}
67
+ %td{"data-text": index_item.publication_date_of_latest_pact_order, 'role':"button"}
60
68
  = index_item.publication_date_of_latest_pact
61
- %td{class: "table-#{index_item.webhook_status}"}
69
+ %td{class: "table-#{index_item.webhook_status}", 'role':"button"}
62
70
  %a{ href: index_item.webhook_url }
63
71
  = index_item.webhook_label
64
72
 
65
- %td{ class: "table-#{index_item.pseudo_branch_verification_status}", title: index_item.verification_tooltip, "data-toggle": "tooltip", "data-placement": "left" }
73
+ %td{ class: "table-#{index_item.pseudo_branch_verification_status}", title: index_item.verification_tooltip, "data-toggle": "tooltip", "data-placement": "left", 'role':"button"}
66
74
  %div
67
75
  = index_item.last_verified_date
68
76
  - if index_item.warning?
69
77
  %span.warning-icon{ 'aria-hidden': true }
78
+ - if index_item.failed_and_pact_pending?
79
+ %div
80
+ (pact pending)
70
81
  %td
71
82
  %span.integration-settings.kebab-horizontal{ 'aria-hidden': true }
72
83
 
@@ -75,6 +86,11 @@
75
86
  - pagination_locals = { page_number: page_number, page_size: page_size, pagination_record_count: pagination_record_count, current_page_size: current_page_size }
76
87
  != render :haml, :'index/_pagination', :layout => false, locals: pagination_locals
77
88
 
89
+ :css
90
+ .table tbody tr:hover td, .table tbody tr:hover th {
91
+ background-color: #ccc;
92
+ cursor: pointer;
93
+ }
78
94
 
79
95
  :javascript
80
96
  $(function(){
@@ -89,6 +105,12 @@
89
105
  //td, so need to append it to a div
90
106
  $(td).tooltip({container: $(td).first()});
91
107
  });
108
+
109
+ $(function(){
110
+ $(".table").on("click", "td[role=\"button\"]", function (e) {
111
+ window.location = $(this).parent("tr").data("href");
112
+ });
113
+ });
92
114
  });
93
115
 
94
116
  $(".reset-search").on("click", function() {
@@ -11,9 +11,13 @@
11
11
  %script{type: 'text/javascript', src: "#{base_url}/js/bootstrap.bundle.min.js?v=#{PactBroker::VERSION}"}
12
12
 
13
13
  .container
14
- .navbar-right
15
- %a{href: "#{base_url}/"}
16
- Home
14
+ %nav{'aria-label': 'breadcrumb'}
15
+ %ol.breadcrumb
16
+ %li.breadcrumb-item
17
+ %a{'href': "#{base_url}/"}
18
+ Home
19
+ %li.breadcrumb-item.active{'aria-current': 'page'}
20
+ The Matrix
17
21
  %h1.page-header
18
22
  The Matrix
19
23
  - if defined?(badge_url) && badge_url
@@ -136,11 +140,11 @@
136
140
  - if line.display_consumer_version_number
137
141
  %button.clippy.invisible{ title: "Copy to clipboard" }
138
142
  %span.copy-icon
139
- - if line.consumer_version_branch
140
- .tag-parent{"title": line.consumer_version_branch_tooltip, "data-toggle": "tooltip", "data-placement": "right"}
141
- - branch_class = line.consumer_version_latest_for_branch? ? "tag badge badge-dark" : "tag badge badge-secondary"
143
+ - line.consumer_version_branches.each do | branch |
144
+ .tag-parent{"title": branch.tooltip, "data-toggle": "tooltip", "data-placement": "right"}
145
+ - branch_class = branch.latest? ? "tag badge badge-dark" : "tag badge badge-secondary"
142
146
  %div{"class": branch_class}
143
- = "branch: " + line.consumer_version_branch
147
+ = "branch: " + branch.name
144
148
  - line.consumer_versions_in_environments.each do | version_in_environment |
145
149
  .tag-parent{"title": version_in_environment.tooltip, "data-toggle": "tooltip", "data-placement": "right"}
146
150
  %a{href: version_in_environment.url}
@@ -173,11 +177,11 @@
173
177
  - if line.display_provider_version_number
174
178
  %button.clippy.invisible{ title: "Copy to clipboard" }
175
179
  %span.copy-icon
176
- - if line.provider_version_branch
177
- .tag-parent{"title": line.provider_version_branch_tooltip, "data-toggle": "tooltip", "data-placement": "right"}
178
- - branch_class = line.provider_version_latest_for_branch? ? "tag badge badge-dark" : "tag badge badge-secondary"
180
+ - line.provider_version_branches.each do | branch |
181
+ .tag-parent{"title": branch.tooltip, "data-toggle": "tooltip", "data-placement": "right"}
182
+ - branch_class = branch.latest? ? "tag badge badge-dark" : "tag badge badge-secondary"
179
183
  %div{"class": branch_class}
180
- = "branch: " + line.provider_version_branch
184
+ = "branch: " + branch.name
181
185
  - line.provider_versions_in_environments.each do | version_in_environment |
182
186
  .tag-parent{"title": version_in_environment.tooltip, "data-toggle": "tooltip", "data-placement": "right"}
183
187
  %a{href: version_in_environment.url}
@@ -28,6 +28,8 @@ module PactBroker
28
28
  else
29
29
  :success
30
30
  end
31
+ elsif latest_verification.failed_and_pact_pending?
32
+ :failed_pending
31
33
  else
32
34
  :failed
33
35
  end
@@ -19,14 +19,13 @@ module PactBroker
19
19
  Sequence.next_val
20
20
  end
21
21
 
22
- def create verification, provider_version_number, pact
23
- provider = pacticipant_repository.find_by_name(pact.provider_name)
24
- consumer = pacticipant_repository.find_by_name(pact.consumer_name)
25
- version = version_repository.find_by_pacticipant_id_and_number_or_create(provider.id, provider_version_number)
26
- verification.pact_version_id = pact_version_id_for(pact)
22
+ def create verification, provider_version_number, pact_version
23
+ version = version_repository.find_by_pacticipant_id_and_number_or_create(pact_version.provider_id, provider_version_number)
24
+ verification.pact_version_id = pact_version.id
27
25
  verification.provider_version = version
28
- verification.provider_id = provider.id
29
- verification.consumer_id = consumer.id
26
+ verification.provider_id = pact_version.provider_id
27
+ verification.consumer_id = pact_version.consumer_id
28
+ verification.tag_names = version.tag_names # TODO pass this in from contracts service
30
29
  verification.save
31
30
  update_latest_verification_id(verification)
32
31
  verification
@@ -150,10 +149,6 @@ module PactBroker
150
149
  provider = pacticipant_repository.find_by_name!(options.fetch(:and))
151
150
  PactBroker::Domain::Verification.where(provider: provider, consumer: consumer).delete
152
151
  end
153
-
154
- def pact_version_id_for pact
155
- PactBroker::Pacts::PactPublication.select(:pact_version_id).where(id: pact.id)
156
- end
157
152
  end
158
153
  end
159
154
  end
@@ -27,16 +27,22 @@ module PactBroker
27
27
  verification_repository.next_number
28
28
  end
29
29
 
30
- def create next_verification_number, params, pact, event_context
31
- logger.info "Creating verification #{next_verification_number} for pact_id=#{pact.id}", payload: params.reject{ |k,_| k == "testResults"}
30
+ # verified_pacts is an array of SelectedPact objects
31
+ def create next_verification_number, params, verified_pacts, event_context
32
+ first_verified_pact = verified_pacts.first
33
+ logger.info "Creating verification #{next_verification_number} for pact_version_sha=#{first_verified_pact.pact_version_sha}", payload: params.reject{ |k,_| k == "testResults"}
32
34
  verification = PactBroker::Domain::Verification.new
33
35
  provider_version_number = params.fetch("providerApplicationVersion")
34
36
  PactBroker::Api::Decorators::VerificationDecorator.new(verification).from_hash(params)
35
37
  verification.wip = params.fetch("wip")
38
+ verification.pact_pending = params.fetch("pending")
36
39
  verification.number = next_verification_number
37
- verification = verification_repository.create(verification, provider_version_number, pact)
38
-
39
- broadcast_events(verification, pact, event_context)
40
+ verification.consumer_version_selector_hashes = event_context[:consumer_version_selectors]
41
+ pact_version = pact_repository.find_pact_version(first_verified_pact.consumer, first_verified_pact.provider, first_verified_pact.pact_version_sha)
42
+ verification = verification_repository.create(verification, provider_version_number, pact_version)
43
+ # TODO set the latest_verification_id on each PactPublication
44
+ # TODO broadcast the verified_pacts for the webhooks
45
+ broadcast_events(verification, first_verified_pact.pact, event_context)
40
46
 
41
47
  verification
42
48
  end
@@ -1,3 +1,3 @@
1
1
  module PactBroker
2
- VERSION = "2.82.0"
2
+ VERSION = "2.85.1"
3
3
  end
@@ -0,0 +1,29 @@
1
+ require "pact_broker/db"
2
+ require "pact_broker/repositories/helpers"
3
+
4
+ module PactBroker
5
+ module Versions
6
+ class Branch < Sequel::Model(:branches)
7
+ plugin :timestamps, update_on_create: true
8
+ plugin :insert_ignore, identifying_columns: [:name, :pacticipant_id]
9
+
10
+ associate(:many_to_one, :pacticipant, :class => "PactBroker::Domain::Pacticipant", :key => :pacticipant_id, :primary_key => :id)
11
+ end
12
+ end
13
+ end
14
+
15
+ # Table: branches
16
+ # Columns:
17
+ # id | integer | PRIMARY KEY GENERATED BY DEFAULT AS IDENTITY
18
+ # name | text |
19
+ # pacticipant_id | integer | NOT NULL
20
+ # created_at | timestamp without time zone | NOT NULL
21
+ # updated_at | timestamp without time zone | NOT NULL
22
+ # Indexes:
23
+ # branches_pkey | PRIMARY KEY btree (id)
24
+ # branches_pacticipant_id_name_index | UNIQUE btree (pacticipant_id, name)
25
+ # Foreign key constraints:
26
+ # branches_pacticipant_id_fkey | (pacticipant_id) REFERENCES pacticipants(id) ON DELETE CASCADE
27
+ # Referenced By:
28
+ # branch_heads | branch_heads_branch_id_fkey | (branch_id) REFERENCES branches(id) ON DELETE CASCADE
29
+ # branch_versions | branch_versions_branches_fk | (branch_id) REFERENCES branches(id) ON DELETE CASCADE
@@ -0,0 +1,45 @@
1
+ require "pact_broker/db"
2
+ require "pact_broker/repositories/helpers"
3
+
4
+ module PactBroker
5
+ module Versions
6
+ class BranchHead < Sequel::Model
7
+ plugin :upsert, identifying_columns: [:branch_id]
8
+ set_primary_key :branch_id
9
+ unrestrict_primary_key
10
+
11
+ associate(:many_to_one, :branch, :class => "PactBroker::Versions::Branch", :key => :branch_id, :primary_key => :id)
12
+ associate(:many_to_one, :branch_version, :class => "PactBroker::Versions::BranchVersion", :key => :branch_version_id, :primary_key => :id)
13
+ associate(:many_to_one, :version, :class => "PactBroker::Domain::Version", :key => :version_id, :primary_key => :id)
14
+
15
+ def before_save
16
+ super
17
+ self.pacticipant_id = branch.pacticipant_id
18
+ self.version_id = branch_version.version_id
19
+ self.branch_name = branch.name
20
+ end
21
+
22
+ def branch_name
23
+ branch.name
24
+ end
25
+ end
26
+ end
27
+ end
28
+
29
+ # Table: branch_heads
30
+ # Columns:
31
+ # id | integer | PRIMARY KEY GENERATED BY DEFAULT AS IDENTITY
32
+ # branch_id | integer | NOT NULL
33
+ # branch_version_id | integer | NOT NULL
34
+ # version_id | integer | NOT NULL
35
+ # pacticipant_id | integer | NOT NULL
36
+ # branch_name | text | NOT NULL
37
+ # Indexes:
38
+ # branch_heads_pkey | PRIMARY KEY btree (id)
39
+ # branch_heads_branch_id_index | UNIQUE btree (branch_id)
40
+ # branch_heads_branch_name_index | btree (branch_name)
41
+ # branch_heads_pacticipant_id_index | btree (pacticipant_id)
42
+ # branch_heads_version_id_index | btree (version_id)
43
+ # Foreign key constraints:
44
+ # branch_heads_branch_id_fkey | (branch_id) REFERENCES branches(id) ON DELETE CASCADE
45
+ # branch_heads_branch_version_id_fkey | (branch_version_id) REFERENCES branch_versions(id) ON DELETE CASCADE
@@ -0,0 +1,24 @@
1
+ require "pact_broker/logging"
2
+ require "pact_broker/repositories"
3
+ require "pact_broker/messages"
4
+
5
+ module PactBroker
6
+ module Versions
7
+ class BranchService
8
+ extend PactBroker::Repositories
9
+
10
+ def self.find_branch_version(pacticipant_name:, branch_name:, version_number:, **)
11
+ BranchVersion.where(
12
+ version: PactBroker::Domain::Version.where_pacticipant_name_and_version_number(pacticipant_name, version_number),
13
+ branch: Branch.where(name: branch_name)
14
+ ).single_record
15
+ end
16
+
17
+ def self.find_or_create_branch_version(pacticipant_name:, branch_name:, version_number:, **)
18
+ pacticipant = pacticipant_repository.find_by_name_or_create(pacticipant_name)
19
+ version = version_repository.find_by_pacticipant_id_and_number_or_create(pacticipant.id, version_number)
20
+ branch_version_repository.add_branch(version, branch_name)
21
+ end
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,64 @@
1
+ require "pact_broker/db"
2
+ require "pact_broker/repositories/helpers"
3
+
4
+ module PactBroker
5
+ module Versions
6
+ class BranchVersion < Sequel::Model(:branch_versions)
7
+ plugin :timestamps, update_on_create: true
8
+ plugin :insert_ignore, identifying_columns: [:branch_id, :version_id]
9
+ plugin :upsert, identifying_columns: [:branch_id, :version_id]
10
+
11
+ associate(:many_to_one, :branch, :class => "PactBroker::Versions::Branch", :key => :branch_id, :primary_key => :id)
12
+ associate(:many_to_one, :version, :class => "PactBroker::Domain::Version", :key => :version_id, :primary_key => :id)
13
+ associate(:many_to_one, :branch_head, :class => "PactBroker::Versions::BranchHead", :key => :branch_id, :primary_key => :branch_id)
14
+
15
+ dataset_module do
16
+ def find_latest_for_branch(branch)
17
+ max_version_order = BranchVersion.select(Sequel.function(:max, :version_order)).where(branch_id: branch.id)
18
+ BranchVersion.where(branch_id: branch.id, version_order: max_version_order).single_record
19
+ end
20
+ end
21
+
22
+ def before_save
23
+ super
24
+ self.version_order = version.order
25
+ self.pacticipant_id = version.pacticipant_id
26
+ self.branch_name = branch.name
27
+ end
28
+
29
+ def latest?
30
+ branch_head.branch_version_id == id
31
+ end
32
+
33
+ def version_number
34
+ version.number
35
+ end
36
+
37
+ def pacticipant
38
+ branch.pacticipant
39
+ end
40
+ end
41
+ end
42
+ end
43
+
44
+ # Table: branch_versions
45
+ # Columns:
46
+ # id | integer | PRIMARY KEY GENERATED BY DEFAULT AS IDENTITY
47
+ # branch_id | integer | NOT NULL
48
+ # version_id | integer | NOT NULL
49
+ # version_order | integer | NOT NULL
50
+ # pacticipant_id | integer | NOT NULL
51
+ # branch_name | text | NOT NULL
52
+ # created_at | timestamp without time zone | NOT NULL
53
+ # updated_at | timestamp without time zone | NOT NULL
54
+ # Indexes:
55
+ # branch_versions_pkey | PRIMARY KEY btree (id)
56
+ # branch_versions_branch_id_version_id_index | UNIQUE btree (branch_id, version_id)
57
+ # branch_versions_branch_name_index | btree (branch_name)
58
+ # branch_versions_pacticipant_id_branch_id_version_order_index | btree (pacticipant_id, branch_id, version_order)
59
+ # branch_versions_version_id_index | btree (version_id)
60
+ # Foreign key constraints:
61
+ # branch_versions_branches_fk | (branch_id) REFERENCES branches(id) ON DELETE CASCADE
62
+ # branch_versions_versions_fk | (version_id) REFERENCES versions(id) ON DELETE CASCADE
63
+ # Referenced By:
64
+ # branch_heads | branch_heads_branch_version_id_fkey | (branch_version_id) REFERENCES branch_versions(id) ON DELETE CASCADE