pact_broker 2.117.1 → 2.118.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/CHANGELOG.md +12 -0
- data/db/migrations/20251202_add_has_messages_column_to_pact_versions.rb +7 -0
- data/db/migrations/20251202_populate_has_messages_in_pact_versions.rb +29 -0
- data/lib/pact_broker/api/resources/index.rb +3 -3
- data/lib/pact_broker/api.rb +3 -3
- data/lib/pact_broker/config/runtime_configuration.rb +9 -8
- data/lib/pact_broker/doc/views/index/latest-branch-pact-versions.markdown +1 -1
- data/lib/pact_broker/doc/views/index/latest-main-branch-pact-versions.markdown +1 -1
- data/lib/pact_broker/doc/views/index/main-branch-pact-versions.markdown +1 -1
- data/lib/pact_broker/pacts/interactions/types.rb +44 -0
- data/lib/pact_broker/pacts/pact_publication_selector_dataset_module.rb +11 -2
- data/lib/pact_broker/pacts/repository.rb +5 -2
- data/lib/pact_broker/test/test_data_builder.rb +13 -7
- data/lib/pact_broker/version.rb +1 -1
- data/lib/pact_broker/versions/branch_version_repository.rb +15 -9
- metadata +5 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 8d5c79b9a890f8984e3e2975740672d1b6c4810a88f750202692144d54b006b2
|
|
4
|
+
data.tar.gz: 4fb8df1387017108768afd83f9117cab1a4cf274ce9f4a66a0701ca848474b5d
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: f1916525083f39001b263ddcd4d41867dec84b640f76b1ce8cd5b8e50c8341ef7e340a6c3f85d129ca56db79984fba48b1e348751ebb19adf5400cbdeaea3808
|
|
7
|
+
data.tar.gz: e7d66f051526f19300d62bf772082324ba8774c03341380b9de219d7ce0b6113776124a4d88a66adaf1eade5b61667a38877036e76f3f29eb83bbfdbecc98410
|
data/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,15 @@
|
|
|
1
|
+
<a name="v2.118.0"></a>
|
|
2
|
+
### v2.118.0 (2026-01-02)
|
|
3
|
+
|
|
4
|
+
#### Features
|
|
5
|
+
|
|
6
|
+
* added has_messages column to pact_versions table (#880) ([34741dae](/../../commit/34741dae))
|
|
7
|
+
|
|
8
|
+
#### Bug Fixes
|
|
9
|
+
|
|
10
|
+
* remove route overlap and add tests for new routes ([45a81474](/../../commit/45a81474))
|
|
11
|
+
* restore latest pact for branch endpoint ([cb867957](/../../commit/cb867957))
|
|
12
|
+
|
|
1
13
|
<a name="v2.117.1"></a>
|
|
2
14
|
### v2.117.1 (2025-11-02)
|
|
3
15
|
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
require "pact_broker/pacts/content"
|
|
2
|
+
require "pact_broker/pacts/interactions/types"
|
|
3
|
+
|
|
4
|
+
Sequel.migration do
|
|
5
|
+
up do
|
|
6
|
+
batch_size = 500
|
|
7
|
+
offset = 0
|
|
8
|
+
|
|
9
|
+
loop do
|
|
10
|
+
rows = from(:pact_versions).order(:id).limit(batch_size).offset(offset).all
|
|
11
|
+
break if rows.empty?
|
|
12
|
+
|
|
13
|
+
rows.each do |row|
|
|
14
|
+
content = PactBroker::Pacts::Content.from_json(row[:content])
|
|
15
|
+
has_messages = PactBroker::Pacts::Interactions::Types.for(content).has_messages?
|
|
16
|
+
|
|
17
|
+
from(:pact_versions)
|
|
18
|
+
.where(id: row[:id])
|
|
19
|
+
.update(has_messages: has_messages)
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
offset += batch_size
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
down do
|
|
27
|
+
|
|
28
|
+
end
|
|
29
|
+
end
|
|
@@ -57,19 +57,19 @@ module PactBroker
|
|
|
57
57
|
},
|
|
58
58
|
"pb:latest-branch-pact-versions" =>
|
|
59
59
|
{
|
|
60
|
-
href: base_url + "/pacts/provider/{provider}/consumer/{consumer}/branch/{branch}/latest",
|
|
60
|
+
href: base_url + "/pacts/provider/{provider}/consumer/{consumer}/branch/{branch}/latest/versions",
|
|
61
61
|
title: "Latest version of pact for a provider, for a named consumers branch",
|
|
62
62
|
templated: true
|
|
63
63
|
},
|
|
64
64
|
"pb:main-branch-pact-versions" =>
|
|
65
65
|
{
|
|
66
|
-
href: base_url + "/pacts/provider/{provider}/consumer/{consumer}/branch",
|
|
66
|
+
href: base_url + "/pacts/provider/{provider}/consumer/{consumer}/branch/versions",
|
|
67
67
|
title: "All versions of pacts for a provider, for a named consumers main branch",
|
|
68
68
|
templated: true
|
|
69
69
|
},
|
|
70
70
|
"pb:latest-main-branch-pact-versions" =>
|
|
71
71
|
{
|
|
72
|
-
href: base_url + "/pacts/provider/{provider}/consumer/{consumer}/branch/latest",
|
|
72
|
+
href: base_url + "/pacts/provider/{provider}/consumer/{consumer}/branch/latest/versions",
|
|
73
73
|
title: "Latest version of pact for a provider, for a named consumers main branch",
|
|
74
74
|
templated: true
|
|
75
75
|
},
|
data/lib/pact_broker/api.rb
CHANGED
|
@@ -33,10 +33,10 @@ module PactBroker
|
|
|
33
33
|
add ["pacts", "provider", :provider_name, "consumer", :consumer_name, "versions"], Api::Resources::PactVersions, {resource_name: "pact_publications"}
|
|
34
34
|
add ["pacts", "provider", :provider_name, "consumer", :consumer_name, "versions", :consumer_version_number], Api::Resources::Pact, {resource_name: "pact_publication", deprecated: true} # Not the standard URL, but keep for backwards compatibility
|
|
35
35
|
add ["pacts", "provider", :provider_name, "consumer", :consumer_name, "tag", :tag], Api::Resources::TaggedPactVersions, {resource_name: "tagged_pact_publications"}
|
|
36
|
-
add ["pacts", "provider", :provider_name, "consumer", :consumer_name, "branch"], Api::Resources::PactVersionsForBranch, {resource_name: "pact_publications_for_main_branch"}
|
|
37
|
-
add ["pacts", "provider", :provider_name, "consumer", :consumer_name, "branch", "latest"], Api::Resources::PactVersionsForBranch, {resource_name: "latest_pact_publications_for_main_branch"}
|
|
38
|
-
add ["pacts", "provider", :provider_name, "consumer", :consumer_name, "branch", :branch_name, "latest"], Api::Resources::PactVersionsForBranch, {resource_name: "latest_pact_publications_for_branch"}
|
|
36
|
+
add ["pacts", "provider", :provider_name, "consumer", :consumer_name, "branch", "versions"], Api::Resources::PactVersionsForBranch, {resource_name: "pact_publications_for_main_branch"}
|
|
39
37
|
add ["pacts", "provider", :provider_name, "consumer", :consumer_name, "branch", :branch_name], Api::Resources::PactVersionsForBranch, {resource_name: "pact_publications_for_branch"}
|
|
38
|
+
add ["pacts", "provider", :provider_name, "consumer", :consumer_name, "branch", "latest", "versions"], Api::Resources::PactVersionsForBranch, {resource_name: "latest_pact_publications_for_main_branch"}
|
|
39
|
+
add ["pacts", "provider", :provider_name, "consumer", :consumer_name, "branch", :branch_name, "latest", "versions"], Api::Resources::PactVersionsForBranch, {resource_name: "latest_pact_publications_for_branch"}
|
|
40
40
|
|
|
41
41
|
# Pacts
|
|
42
42
|
add ["pacts", "provider", :provider_name, "consumer", :consumer_name, "version", :consumer_version_number], Api::Resources::Pact, {resource_name: "pact_publication"}
|
|
@@ -1,12 +1,4 @@
|
|
|
1
1
|
require "anyway_config"
|
|
2
|
-
require "pact_broker/config/runtime_configuration_logging_methods"
|
|
3
|
-
require "pact_broker/config/runtime_configuration_database_methods"
|
|
4
|
-
require "pact_broker/config/runtime_configuration_coercion_methods"
|
|
5
|
-
require "pact_broker/version"
|
|
6
|
-
require "pact_broker/config/runtime_configuration_basic_auth_methods"
|
|
7
|
-
require "pact_broker/string_refinements"
|
|
8
|
-
require "pact_broker/hash_refinements"
|
|
9
|
-
require "pact_broker/error"
|
|
10
2
|
|
|
11
3
|
module Anyway
|
|
12
4
|
module Tracing
|
|
@@ -20,6 +12,15 @@ module Anyway
|
|
|
20
12
|
end
|
|
21
13
|
end
|
|
22
14
|
|
|
15
|
+
require "pact_broker/config/runtime_configuration_logging_methods"
|
|
16
|
+
require "pact_broker/config/runtime_configuration_database_methods"
|
|
17
|
+
require "pact_broker/config/runtime_configuration_coercion_methods"
|
|
18
|
+
require "pact_broker/version"
|
|
19
|
+
require "pact_broker/config/runtime_configuration_basic_auth_methods"
|
|
20
|
+
require "pact_broker/string_refinements"
|
|
21
|
+
require "pact_broker/hash_refinements"
|
|
22
|
+
require "pact_broker/error"
|
|
23
|
+
|
|
23
24
|
module PactBroker
|
|
24
25
|
module Config
|
|
25
26
|
class RuntimeConfiguration < Anyway::Config
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
|
|
3
3
|
Allowed methods: `GET`
|
|
4
4
|
|
|
5
|
-
Path: `/pacts/provider/{provider}/consumer/{consumer}/branch/{branch}/latest`
|
|
5
|
+
Path: `/pacts/provider/{provider}/consumer/{consumer}/branch/{branch}/latest/versions`
|
|
6
6
|
|
|
7
7
|
Returns the latest pact version with the specified consumer, provider and consumer version branch.
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
|
|
3
3
|
Allowed methods: `GET`
|
|
4
4
|
|
|
5
|
-
Path: `/pacts/provider/{provider}/consumer/{consumer}/branch/latest`
|
|
5
|
+
Path: `/pacts/provider/{provider}/consumer/{consumer}/branch/latest/versions`
|
|
6
6
|
|
|
7
7
|
Lists all latest pact version with the specified consumer, provider and the consumers main branch.
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
module PactBroker
|
|
2
|
+
module Pacts
|
|
3
|
+
module Interactions
|
|
4
|
+
class Types
|
|
5
|
+
# Pact Spec v4+ message interaction types
|
|
6
|
+
MESSAGE_TYPES = [
|
|
7
|
+
"Asynchronous/Messages",
|
|
8
|
+
"Synchronous/Messages"
|
|
9
|
+
].freeze
|
|
10
|
+
|
|
11
|
+
def initialize(content)
|
|
12
|
+
@content = content
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def self.for(content)
|
|
16
|
+
new(content)
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def has_messages?
|
|
20
|
+
if spec_version < 4.0
|
|
21
|
+
# Pre-v4: messages in "messages" key
|
|
22
|
+
content.messages&.any? || false
|
|
23
|
+
else
|
|
24
|
+
# V4+: messages are typed interactions
|
|
25
|
+
content.interactions&.any? { |i| message_interaction?(i) } || false
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
private
|
|
30
|
+
|
|
31
|
+
attr_reader :content
|
|
32
|
+
|
|
33
|
+
def message_interaction?(interaction)
|
|
34
|
+
interaction.is_a?(Hash) &&
|
|
35
|
+
MESSAGE_TYPES.include?(interaction["type"])
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
def spec_version
|
|
39
|
+
content.pact_specification_version.to_f
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
end
|
|
@@ -46,9 +46,18 @@ module PactBroker
|
|
|
46
46
|
|
|
47
47
|
def for_main_branches
|
|
48
48
|
consumers_join = { Sequel[:pact_publications][:consumer_id] => Sequel[:consumers][:id] }
|
|
49
|
-
|
|
50
|
-
|
|
49
|
+
branch_versions_join = {
|
|
50
|
+
Sequel[:branch_versions][:version_id] => Sequel[:pact_publications][:consumer_version_id],
|
|
51
|
+
Sequel[:branch_versions][:branch_name] => Sequel[:consumers][:main_branch]
|
|
52
|
+
}
|
|
53
|
+
base_query = self
|
|
54
|
+
|
|
55
|
+
if no_columns_selected?
|
|
56
|
+
base_query = base_query.select_all_qualified.select_append(Sequel[:branch_versions][:branch_name].as(:branch_name))
|
|
57
|
+
end
|
|
58
|
+
base_query
|
|
51
59
|
.join(:pacticipants, consumers_join, { table_alias: :consumers })
|
|
60
|
+
.join(:branch_versions, branch_versions_join)
|
|
52
61
|
.remove_overridden_revisions_from_complete_query
|
|
53
62
|
end
|
|
54
63
|
|
|
@@ -14,6 +14,7 @@ require "pact_broker/pacts/selectors"
|
|
|
14
14
|
require "pact_broker/feature_toggle"
|
|
15
15
|
require "pact_broker/pacts/pacts_for_verification_repository"
|
|
16
16
|
require "pact_broker/pacts/content"
|
|
17
|
+
require "pact_broker/pacts/interactions/types"
|
|
17
18
|
require "pact_broker/policies"
|
|
18
19
|
|
|
19
20
|
module PactBroker
|
|
@@ -394,14 +395,16 @@ module PactBroker
|
|
|
394
395
|
end
|
|
395
396
|
|
|
396
397
|
def create_pact_version consumer_id, provider_id, sha, json_content
|
|
398
|
+
content = Content.from_json(json_content)
|
|
397
399
|
PactBroker::Pacts::PactVersion.new(
|
|
398
400
|
consumer_id: consumer_id,
|
|
399
401
|
provider_id: provider_id,
|
|
400
402
|
sha: sha,
|
|
401
403
|
content: json_content,
|
|
402
404
|
created_at: Sequel.datetime_class.now,
|
|
403
|
-
interactions_count:
|
|
404
|
-
messages_count:
|
|
405
|
+
interactions_count: content.interactions&.count || 0,
|
|
406
|
+
messages_count: content.messages&.count || 0,
|
|
407
|
+
has_messages: Interactions::Types.for(content).has_messages?
|
|
405
408
|
).upsert
|
|
406
409
|
end
|
|
407
410
|
|
|
@@ -456,6 +456,9 @@ module PactBroker
|
|
|
456
456
|
parameters = default_parameters.merge(parameters)
|
|
457
457
|
parameters.delete(:provider_version)
|
|
458
458
|
verification = PactBroker::Domain::Verification.new(parameters)
|
|
459
|
+
if pact.nil?
|
|
460
|
+
@pact = find_pact(@consumer.name, @consumer_version.number, @provider.name)
|
|
461
|
+
end
|
|
459
462
|
pact_version = PactBroker::Pacts::Repository.new.find_pact_version(@consumer, @provider, pact.pact_version_sha)
|
|
460
463
|
@provider_version = version_repository.find_by_pacticipant_id_and_number_or_create(provider.id, provider_version_number)
|
|
461
464
|
branch_version = PactBroker::Versions::BranchVersionRepository.new.add_branch(@provider_version, branch) if branch
|
|
@@ -714,13 +717,16 @@ module PactBroker
|
|
|
714
717
|
def default_json_content
|
|
715
718
|
{
|
|
716
719
|
"consumer" => {
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
720
|
+
"name" => consumer.name
|
|
721
|
+
},
|
|
722
|
+
"provider" => {
|
|
723
|
+
"name" => provider.name
|
|
724
|
+
},
|
|
725
|
+
"interactions" => [],
|
|
726
|
+
"metadata" => {
|
|
727
|
+
"pactSpecification" => { "version" => "4.0" }
|
|
728
|
+
},
|
|
729
|
+
"random" => rand
|
|
724
730
|
}.to_json
|
|
725
731
|
end
|
|
726
732
|
|
data/lib/pact_broker/version.rb
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
require "pact_broker/versions/branch_version"
|
|
2
2
|
require "pact_broker/services"
|
|
3
|
+
require "pact_broker/logging"
|
|
3
4
|
|
|
4
5
|
module PactBroker
|
|
5
6
|
module Versions
|
|
@@ -21,16 +22,21 @@ module PactBroker
|
|
|
21
22
|
end
|
|
22
23
|
|
|
23
24
|
def add_branch(version, branch_name, auto_created: false)
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
branch_version.
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
25
|
+
PactBroker.logger.info("BranchVersionRepository#add_branch method called with version #{version.inspect} and branch_name '#{branch_name}'")
|
|
26
|
+
Sequel::Model.db.transaction do
|
|
27
|
+
branch = find_or_create_branch(version.pacticipant, branch_name)
|
|
28
|
+
branch_version = version.branch_version_for_branch(branch)
|
|
29
|
+
if branch_version
|
|
30
|
+
PactBroker.logger.info("Updating branch version #{branch_version.inspect}, time: #{Time.now}")
|
|
31
|
+
branch_version.update(updated_at: Sequel.datetime_class.now)
|
|
32
|
+
else
|
|
33
|
+
PactBroker.logger.info("Creating branch version time: #{Time.now}")
|
|
34
|
+
branch_version = PactBroker::Versions::BranchVersion.new(version: version, branch: branch, auto_created: auto_created).insert_ignore
|
|
35
|
+
PactBroker::Versions::BranchHead.new(branch: branch, branch_version: branch_version).upsert
|
|
36
|
+
end
|
|
37
|
+
pacticipant_service.maybe_set_main_branch(version.pacticipant, branch_name)
|
|
38
|
+
branch_version
|
|
31
39
|
end
|
|
32
|
-
pacticipant_service.maybe_set_main_branch(version.pacticipant, branch_name)
|
|
33
|
-
branch_version
|
|
34
40
|
end
|
|
35
41
|
|
|
36
42
|
# Deletes a branch version - that is, removes a version from a branch.
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: pact_broker
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 2.
|
|
4
|
+
version: 2.118.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Bethany Skurrie
|
|
@@ -579,6 +579,8 @@ files:
|
|
|
579
579
|
- db/migrations/20231002_add_version_id_index_to_released_version.rb
|
|
580
580
|
- db/migrations/20231003_add_version_id_index_to_deployed_version.rb
|
|
581
581
|
- db/migrations/20240112_add_client_language_verified_by_to_verification.rb
|
|
582
|
+
- db/migrations/20251202_add_has_messages_column_to_pact_versions.rb
|
|
583
|
+
- db/migrations/20251202_populate_has_messages_in_pact_versions.rb
|
|
582
584
|
- db/migrations/migration_helper.rb
|
|
583
585
|
- docs/CONFIGURATION.md
|
|
584
586
|
- docs/api/PACTICIPANTS.md
|
|
@@ -1001,6 +1003,7 @@ files:
|
|
|
1001
1003
|
- lib/pact_broker/pacts/generate_interaction_sha.rb
|
|
1002
1004
|
- lib/pact_broker/pacts/generate_sha.rb
|
|
1003
1005
|
- lib/pact_broker/pacts/head_pact.rb
|
|
1006
|
+
- lib/pact_broker/pacts/interactions/types.rb
|
|
1004
1007
|
- lib/pact_broker/pacts/latest_pact_publication_id_for_consumer_version.rb
|
|
1005
1008
|
- lib/pact_broker/pacts/lazy_loaders.rb
|
|
1006
1009
|
- lib/pact_broker/pacts/merger.rb
|
|
@@ -1287,7 +1290,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
1287
1290
|
- !ruby/object:Gem::Version
|
|
1288
1291
|
version: '0'
|
|
1289
1292
|
requirements: []
|
|
1290
|
-
rubygems_version:
|
|
1293
|
+
rubygems_version: 4.0.3
|
|
1291
1294
|
specification_version: 4
|
|
1292
1295
|
summary: See description
|
|
1293
1296
|
test_files: []
|