Skip to content

Commit

Permalink
Merge branch 'master' into feat/dry-run
Browse files Browse the repository at this point in the history
  • Loading branch information
bethesque committed Jun 16, 2021
2 parents d7e33ce + 4873334 commit 7630f31
Show file tree
Hide file tree
Showing 81 changed files with 3,219 additions and 720 deletions.
21 changes: 21 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,24 @@ jobs:
ruby-version: ${{ matrix.ruby_version }}
- run: "bundle install"
- run: "bundle exec rake"
pact:
runs-on: "ubuntu-latest"
continue-on-error: true
strategy:
fail-fast: false
matrix:
feature: ["", "publish_contracts", "deployments"]
steps:
- uses: actions/checkout@v2
- uses: ruby/setup-ruby@v1
with:
ruby-version: "2.7"
- run: "bundle install"
- run: |
rm -rf spec/pacts/*
bundle exec rspec spec/service_providers/
bundle exec rake pact:publish:pactflow
env:
PACT_BROKER_TOKEN: ${{ secrets.PACTFLOW_PACT_OSS_TOKEN }}
PACT_BROKER_FEATURES: ${{ matrix.feature }}
TEST_FEATURE: ${{ matrix.feature }}
44 changes: 44 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,47 @@
<a name="v1.44.0"></a>
### v1.44.0 (2021-06-09)

#### Features

* add record-undeployment (feature toggled off) ([951d334](/../../commit/951d334))
* add describe-environment command ([cd11ebb](/../../commit/cd11ebb))
* add record-release (feature toggled off) ([e32e4e5](/../../commit/e32e4e5))

#### Bug Fixes

* hardcode file requires Fixes: https://github.com/pact-foundation/pact_broker-client/issues/88 ([581f2fd](/../../commit/581f2fd))

<a name="v1.43.0"></a>
### v1.43.0 (2021-06-03)

#### Features

* enable --ignore option for can-i-deploy without a feature toggle ([bcc9dfe](/../../commit/bcc9dfe))

<a name="v1.42.0"></a>
### v1.42.0 (2021-05-31)

#### Features

* add list-pacticipants ([fc8ce3b](/../../commit/fc8ce3b))
* add --display-name to create-or-update-pacticipant ([76f323b](/../../commit/76f323b))
* add backtrace to error output when verbose is true ([abf1ef0](/../../commit/abf1ef0))
* add list-environments and describe-environment ([4472d48](/../../commit/4472d48))
* add delete-environment ([361eed1](/../../commit/361eed1))
* add update-environment command ([95276cd](/../../commit/95276cd))
* add create-environment command ([a9fab50](/../../commit/a9fab50))

#### Bug Fixes

* stop long values in columns from being truncated ([18063fd](/../../commit/18063fd))

<a name="v1.41.0"></a>
### v1.41.0 (2021-05-25)

#### Features

* update colours of pact publish output ([2a51e37](/../../commit/2a51e37))

<a name="v1.40.0"></a>
### v1.40.0 (2021-04-26)

Expand Down
4 changes: 4 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,7 @@ if ENV['X_PACT_DEVELOPMENT'] == 'true'
gem 'pact-mock_service', path: '../pact-mock_service'
gem 'pact-support', path: '../pact-support'
end

group :development do
gem 'pry-byebug'
end
57 changes: 39 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,27 +78,48 @@ Usage:
pact-broker can-i-deploy -a, --pacticipant=PACTICIPANT -b, --broker-base-url=BROKER_BASE_URL
Options:
-a, --pacticipant=PACTICIPANT # The pacticipant name. Use once for each pacticipant being checked.
-e, [--version=VERSION] # The pacticipant version. Must be entered after the --pacticipant that it relates to.
-l, [--latest=[TAG]] # Use the latest pacticipant version. Optionally specify a TAG to use the latest version with the specified tag.
[--to=TAG] # This is too hard to explain in a short sentence. Look at the examples.
-b, --broker-base-url=BROKER_BASE_URL # The base URL of the Pact Broker
-u, [--broker-username=BROKER_USERNAME] # Pact Broker basic auth username
-p, [--broker-password=BROKER_PASSWORD] # Pact Broker basic auth password
-k, [--broker-token=BROKER_TOKEN] # Pact Broker bearer token
-o, [--output=OUTPUT] # json or table
# Default: table
-v, [--verbose], [--no-verbose] # Verbose output. Default: false
[--retry-while-unknown=TIMES] # The number of times to retry while there is an unknown verification result (ie. the provider verification is likely still running)
# Default: 0
[--retry-interval=SECONDS] # The time between retries in seconds. Use in conjuction with --retry-while-unknown
# Default: 10
-a, --pacticipant=PACTICIPANT
# The pacticipant name. Use once for each pacticipant being checked.
-e, [--version=VERSION]
# The pacticipant version. Must be entered after the --pacticipant that it relates to.
[--ignore=IGNORE]
# The pacticipant name to ignore. Use once for each pacticipant being ignored.
A specific version can be ignored by also specifying a --version after the pacticipant name option.
-l, [--latest=[TAG]]
# Use the latest pacticipant version. Optionally specify a TAG to use the
latest version with the specified tag.
[--to=TAG]
# This is too hard to explain in a short sentence. Look at the examples.
-o, [--output=OUTPUT]
# json or table
# Default: table
[--retry-while-unknown=TIMES]
# The number of times to retry while there is an unknown verification result
(ie. the provider verification is likely still running)
# Default: 0
[--retry-interval=SECONDS]
# The time between retries in seconds. Use in conjuction with --retry-while-unknown
# Default: 10
-b, --broker-base-url=BROKER_BASE_URL
# The base URL of the Pact Broker
-u, [--broker-username=BROKER_USERNAME]
# Pact Broker basic auth username
-p, [--broker-password=BROKER_PASSWORD]
# Pact Broker basic auth password
-k, [--broker-token=BROKER_TOKEN]
# Pact Broker bearer token
-v, [--verbose], [--no-verbose]
# Verbose output. Default: false
Description:
Returns exit code 0 or 1, indicating whether or not the specified pacticipant versions are compatible. Prints out the relevant
pact/verification details.
Returns exit code 0 or 1, indicating whether or not the specified application (pacticipant) versions are
compatible (ie. safe to deploy). Prints out the relevant pact/verification details, indicating any
missing or failed verification results.
The environment variables PACT_BROKER_BASE_URL, PACT_BROKER_BASE_URL_USERNAME and PACT_BROKER_BASE_URL_PASSWORD may be used
The environment variables PACT_BROKER_BASE_URL, PACT_BROKER_USERNAME and PACT_BROKER_PASSWORD may be used
instead of their respective command line options.
```

Expand Down
179 changes: 79 additions & 100 deletions doc/pacts/markdown/Pact Broker Client - Pact Broker.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@

* [A request for the index resource](#a_request_for_the_index_resource_given_the_pb:pacticipant-version_relation_exists_in_the_index_resource) given the pb:pacticipant-version relation exists in the index resource

* [A request for the index resource](#a_request_for_the_index_resource_given_the_pb:publish-contracts_relations_exists_in_the_index_resource) given the pb:publish-contracts relations exists in the index resource

* [A request for the index resource with the webhook relation](#a_request_for_the_index_resource_with_the_webhook_relation)

* [A request for the list of the latest pacts from all consumers for the Pricing Service'](#a_request_for_the_list_of_the_latest_pacts_from_all_consumers_for_the_Pricing_Service&#39;_given_a_latest_pact_between_Condor_and_the_Pricing_Service_exists) given a latest pact between Condor and the Pricing Service exists
Expand Down Expand Up @@ -66,6 +64,8 @@

* [A request to create a webhook with every possible event type](#a_request_to_create_a_webhook_with_every_possible_event_type_given_the_&#39;Pricing_Service&#39;_and_&#39;Condor&#39;_already_exist_in_the_pact-broker) given the 'Pricing Service' and 'Condor' already exist in the pact-broker

* [A request to determine if Bar can be deployed with all Foo tagged prod, ignoring the verification for Foo version 3.4.5](#a_request_to_determine_if_Bar_can_be_deployed_with_all_Foo_tagged_prod,_ignoring_the_verification_for_Foo_version_3.4.5_given_provider_Bar_version_4.5.6_has_a_successful_verification_for_Foo_version_1.2.3_tagged_prod_and_a_failed_verification_for_version_3.4.5_tagged_prod) given provider Bar version 4.5.6 has a successful verification for Foo version 1.2.3 tagged prod and a failed verification for version 3.4.5 tagged prod

* [A request to get the Pricing Service](#a_request_to_get_the_Pricing_Service_given_the_&#39;Pricing_Service&#39;_already_exists_in_the_pact-broker) given the 'Pricing Service' already exists in the pact-broker

* [A request to get the Pricing Service](#a_request_to_get_the_Pricing_Service_given_the_&#39;Pricing_Service&#39;_does_not_exist_in_the_pact-broker) given the 'Pricing Service' does not exist in the pact-broker
Expand All @@ -84,8 +84,6 @@

* [A request to publish a pact with method put](#a_request_to_publish_a_pact_with_method_put_given_the_&#39;Pricing_Service&#39;_and_&#39;Condor&#39;_already_exist_in_the_pact-broker,_and_Condor_already_has_a_pact_published_for_version_1.3.0) given the 'Pricing Service' and 'Condor' already exist in the pact-broker, and Condor already has a pact published for version 1.3.0

* [A request to publish contracts](#a_request_to_publish_contracts)

* [A request to register the repository URL of a pacticipant](#a_request_to_register_the_repository_URL_of_a_pacticipant_given_the_&#39;Pricing_Service&#39;_already_exists_in_the_pact-broker) given the 'Pricing Service' already exists in the pact-broker

* [A request to register the repository URL of a pacticipant](#a_request_to_register_the_repository_URL_of_a_pacticipant_given_the_&#39;Pricing_Service&#39;_does_not_exist_in_the_pact-broker) given the 'Pricing Service' does not exist in the pact-broker
Expand Down Expand Up @@ -683,33 +681,6 @@ Pact Broker will respond with:
}
}
```
<a name="a_request_for_the_index_resource_given_the_pb:publish-contracts_relations_exists_in_the_index_resource"></a>
Given **the pb:publish-contracts relations exists in the index resource**, upon receiving **a request for the index resource** from Pact Broker Client, with
```json
{
"method": "GET",
"path": "/",
"headers": {
"Accept": "application/hal+json"
}
}
```
Pact Broker will respond with:
```json
{
"status": 200,
"headers": {
"Content-Type": "application/hal+json;charset=utf-8"
},
"body": {
"_links": {
"pb:publish-contracts": {
"href": "http://localhost:1234/HAL-REL-PLACEHOLDER-PB-PUBLISH-CONTRACTS"
}
}
}
}
```
<a name="a_request_for_the_index_resource_with_the_webhook_relation"></a>
Upon receiving **a request for the index resource with the webhook relation** from Pact Broker Client, with
```json
Expand Down Expand Up @@ -1454,6 +1425,83 @@ Pact Broker will respond with:
}
}
```
<a name="a_request_to_determine_if_Bar_can_be_deployed_with_all_Foo_tagged_prod,_ignoring_the_verification_for_Foo_version_3.4.5_given_provider_Bar_version_4.5.6_has_a_successful_verification_for_Foo_version_1.2.3_tagged_prod_and_a_failed_verification_for_version_3.4.5_tagged_prod"></a>
Given **provider Bar version 4.5.6 has a successful verification for Foo version 1.2.3 tagged prod and a failed verification for version 3.4.5 tagged prod**, upon receiving **a request to determine if Bar can be deployed with all Foo tagged prod, ignoring the verification for Foo version 3.4.5** from Pact Broker Client, with
```json
{
"method": "get",
"path": "/matrix",
"query": "q%5B%5D%5Bpacticipant%5D=Bar&q%5B%5D%5Bversion%5D=4.5.6&q%5B%5D%5Bpacticipant%5D=Foo&q%5B%5D%5Btag%5D=prod&latestby=cvpv&ignore%5B%5D%5Bpacticipant%5D=Foo&ignore%5B%5D%5Bversion%5D=3.4.5"
}
```
Pact Broker will respond with:
```json
{
"status": 200,
"headers": {
"Content-Type": "application/hal+json;charset=utf-8"
},
"body": {
"summary": {
"deployable": true,
"ignored": 1
},
"notices": [
{
"text": "some notice",
"type": "info"
}
],
"matrix": [
{
"consumer": {
"name": "Foo",
"version": {
"number": "1.2.3"
}
},
"provider": {
"name": "Bar",
"version": {
"number": "4.5.6"
}
},
"verificationResult": {
"success": true,
"_links": {
"self": {
"href": "http://result"
}
}
}
},
{
"consumer": {
"name": "Foo",
"version": {
"number": "3.4.5"
}
},
"provider": {
"name": "Bar",
"version": {
"number": "4.5.6"
}
},
"verificationResult": {
"success": false,
"_links": {
"self": {
"href": "http://result"
}
}
},
"ignored": true
}
]
}
}
```
<a name="a_request_to_get_the_Pricing_Service_given_the_&#39;Pricing_Service&#39;_already_exists_in_the_pact-broker"></a>
Given **the 'Pricing Service' already exists in the pact-broker**, upon receiving **a request to get the Pricing Service** from Pact Broker Client, with
```json
Expand Down Expand Up @@ -1806,75 +1854,6 @@ Pact Broker will respond with:
}
}
```
<a name="a_request_to_publish_contracts"></a>
Upon receiving **a request to publish contracts** from Pact Broker Client, with
```json
{
"method": "POST",
"path": "/HAL-REL-PLACEHOLDER-PB-PUBLISH-CONTRACTS",
"headers": {
"Content-Type": "application/json",
"Accept": "application/hal+json"
},
"body": {
"pacticipantName": "Foo",
"pacticipantVersionNumber": "5556b8149bf8bac76bc30f50a8a2dd4c22c85f30",
"branch": "main",
"tags": [
"dev"
],
"buildUrl": "http://build",
"contracts": [
{
"consumerName": "Foo",
"providerName": "Bar",
"specification": "pact",
"contentType": "application/json",
"content": "eyJjb25zdW1lciI6eyJuYW1lIjoiRm9vIn0sInByb3ZpZGVyIjp7Im5hbWUiOiJCYXIifSwiaW50ZXJhY3Rpb25zIjpbeyJkZXNjcmlwdGlvbiI6ImFuIGV4YW1wbGUgcmVxdWVzdCIsInByb3ZpZGVyU3RhdGUiOiJhIHByb3ZpZGVyIHN0YXRlIiwicmVxdWVzdCI6eyJtZXRob2QiOiJHRVQiLCJwYXRoIjoiLyIsImhlYWRlcnMiOnt9fSwicmVzcG9uc2UiOnsic3RhdHVzIjoyMDAsImhlYWRlcnMiOnsiQ29udGVudC1UeXBlIjoiYXBwbGljYXRpb24vaGFsK2pzb24ifX19XSwibWV0YWRhdGEiOnsicGFjdFNwZWNpZmljYXRpb24iOnsidmVyc2lvbiI6IjIuMC4wIn19fQ==",
"writeMode": "overwrite"
}
]
}
}
```
Pact Broker will respond with:
```json
{
"status": 200,
"headers": {
"Content-Type": "application/hal+json;charset=utf-8"
},
"body": {
"_embedded": {
"pacticipant": {
"name": "Foo"
},
"version": {
"number": "5556b8149bf8bac76bc30f50a8a2dd4c22c85f30",
"buildUrl": "http://build"
}
},
"logs": [
{
"level": "info",
"message": "some message"
}
],
"_links": {
"pb:pacticipant-version-tags": [
{
"name": "dev"
}
],
"pb:contracts": [
{
"href": "http://some-pact"
}
]
}
}
}
```
<a name="a_request_to_register_the_repository_URL_of_a_pacticipant_given_the_&#39;Pricing_Service&#39;_already_exists_in_the_pact-broker"></a>
Given **the 'Pricing Service' already exists in the pact-broker**, upon receiving **a request to register the repository URL of a pacticipant** from Pact Broker Client, with
```json
Expand Down
9 changes: 9 additions & 0 deletions lib/pact_broker/client/backports.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,13 @@ def compact
def compact!
reject! {|_key, value| value == nil}
end unless method_defined? :compact!

def except(*keys)
if keys.size > 4 && size > 4 # index if O(m*n) is big
h = {}
keys.each { |key| h[key] = true }
keys = h
end
reject { |key, _value| keys.include? key}
end unless method_defined? :except
end
Loading

0 comments on commit 7630f31

Please sign in to comment.