Hi, can someone suggest the following issues i'm c...
# pact-ruby
d
Hi, can someone suggest the following issues i'm currently facing for the provider verification contracts in Ruby. Right now I have 5 consumers which are on
provider_state
and defined under
pact_helper_message.rb
for the event message driven contracts. My config for the
pact-helper_message.rb
as follows below
Copy code
require_relative "provider_states_responses_tracker_service"
require_relative "provider_states_participant_study_service"
require_relative "provider_states_participant_test_plan_service"
require_relative "provider_states_permissions_service"
require_relative "provider_states_test_plan_logic_service"

require File.expand_path("../../../../config/environment", __FILE__)
require "pact/provider/rspec"
require "environment_helpers"

# Set verify variables
pact_base_url = ENV["PACT_BROKER_URL"]
token = ENV["PACT_BROKER_TOKEN"]

# Set variables
provider_version = ENV["GIT_SHA"]
provider_branch = ENV["GIT_BRANCH"] || "main" 
publish_flag = ENV.boolean("CI", default: false)

CONFIG = [
  MyMessageProvider.messages,
  StudyServiceProviderMessage.messages,
  TestPlanServiceMessageProvider.messages,
  PermissionsServiceProviderMessage.messages,
  TestPlanLogicServiceMessageProvider.messages
].reduce(&:merge)

# Debugging: Print CONFIG keys
puts "CONFIG keys: #{CONFIG.keys}"

Pact.message_provider "orders-message" do
  if ENV["PACT_URL"]
    honours_pact_with ENV["CONSUMER_NAME"] do
      pact_uri ENV["PACT_URL"], {token: token}
    end
  else
    honours_pacts_from_pact_broker do
      pact_broker_base_url pact_base_url, {token: token}
      consumer_version_selectors [
        { mainBranch: true }
      ]
    end
  end

  app_version provider_version
  app_version_tags [provider_branch]
  publish_verification_results publish_flag

  builder do |message_description|
    CONFIG[message_description].call
  end
end
Run log: I would like to see fetch pact for
responses-tracker
and
participant-test-plan-service
too, but it is missing for some reason
thinking
Copy code
INFO: Fetching pacts for orders-message from <https://usertesting.pactflow.io> with the selection criteria: latest from main branch, work in progress pacts created after 2023-01-01
INFO: Reading pact at <https://usertesting.pactflow.io/pacts/provider/orders-message/consumer/participant-study-service/pact-version/0ceb7c9c8077f0631b6b404e3b867949047fdf93/metadata/c1tdW2xdPXRydWUmc1tdW2N2XT00NTIxNCZwPWZhbHNl>
WARN: Ignoring unsupported combine AND for path $['data']['study']['createdByUuid']
WARN: Ignoring unsupported combine AND for path $['data']['study']['productType']['type']
WARN: Ignoring unsupported combine AND for path $['data']['study']['studyContext']['accountUuid']
WARN: Ignoring unsupported combine AND for path $['data']['study']['title']
WARN: Ignoring unsupported combine AND for path $['data']['study']['uuid']
WARN: Ignoring unsupported combine AND for path $['id']
WARN: Ignoring unsupported combine AND for path $['data']['study']['testPlanUuid']
WARN: Ignoring unsupported combine AND for path $['data']['study']['uuid']
WARN: Ignoring unsupported combine AND for path $['id']
INFO: Reading pact at <https://usertesting.pactflow.io/pacts/provider/orders-message/consumer/permissions-service/pact-version/e37c088721e1b5b2e468fca3993fe6a95a557b91/metadata/c1tdW2xdPXRydWUmc1tdW2N2XT00NTk1NiZwPWZhbHNl>
INFO: Reading pact at <https://usertesting.pactflow.io/pacts/provider/orders-message/consumer/test-plan-logic-service/pact-version/f80a1e8aa90f78a261951b65da55d8d42181e3d5/metadata/c1tdW2xdPXRydWUmc1tdW2N2XT00NzY5MCZwPWZhbHNl>
WARN: Ignoring unsupported combine AND for path $['data']['testPlan']['id']
WARN: Ignoring unsupported combine AND for path $['data']['testPlan']['logicNodes']
WARN: Ignoring unsupported combine AND for path $['data']['testPlan']['taskGroups']
WARN: Ignoring unsupported combine AND for path $['data']['testPlan']['tasks']
WARN: Ignoring unsupported combine AND for path $['data']['testPlan']['testPlanEntries']
WARN: Ignoring unsupported combine AND for path $['data']['testPlan']['uuid']
[rspec-sidekiq] WARNING! Sidekiq will *NOT* process jobs in this environment. See <https://github.com/wspurgin/rspec-sidekiq/wiki/FAQ-&-Troubleshooting>

DEBUG: The pact at <https://usertesting.pactflow.io/pacts/provider/orders-message/consumer/participant-study-service/pact-version/0ceb7c9c8077f0631b6b404e3b867949047fdf93> is being verified because the pact content belongs to the consumer version matching the following criterion:
    * latest version from the main branch 'main' (2990ad33ff33540b487d0a414d888b3676530dc6)
DEBUG: This pact has previously been successfully verified by orders-message. If this verification fails, it will fail the build. Read more at <https://docs.pact.io/go/pending>

Verifying a pact between participant-study-service and orders-message
  Given a study has been created in orders
    a STUDY_CREATED kafka event
      has matching content
  Given a study has been updated in orders
    a STUDY_UPDATED kafka event
      has matching content

DEBUG: The pact at <https://usertesting.pactflow.io/pacts/provider/orders-message/consumer/permissions-service/pact-version/e37c088721e1b5b2e468fca3993fe6a95a557b91> is being verified because the pact content belongs to the consumer version matching the following criterion:
    * latest version from the main branch 'main' (712b524f30d58ad24bfbebae43182e68db953d73)
DEBUG: This pact has previously been successfully verified by orders-message. If this verification fails, it will fail the build. Read more at <https://docs.pact.io/go/pending>

Verifying a pact between permissions-service and orders-message
  Given a workspace member has been updated
    a WORKSPACE_MEMBERSHIP_UPDATED message
      has matching content
  Given an account has been created
    an ACCOUNT_CREATED message
      has matching content
  Given a workspace member has been added
    a WORKSPACE_MEMBERSHIP_USER_ADDED message
      has matching content
  Given a workspace has been deleted
    a WORKSPACE_DELETED message
      has matching content
  Given a workspace member has been removed
    a WORKSPACE_MEMBERSHIP_REMOVED message
      has matching content
  Given a workspace has been created
    a WORKSPACE_CREATED message
      has matching content
  Given an account membership has been updated
    an ACCOUNT_MEMBERSHIP_UPDATED message
      has matching content
  Given an account membership has been created
    an ACCOUNT_MEMBERSHIP_USER_ADDED message
      has matching content
  Given an account membership has been removed
    an ACCOUNT_MEMBERSHIP_REMOVED message
      has matching content

DEBUG: The pact at <https://usertesting.pactflow.io/pacts/provider/orders-message/consumer/test-plan-logic-service/pact-version/f80a1e8aa90f78a261951b65da55d8d42181e3d5> is being verified because the pact content belongs to the consumer version matching the following criterion:
    * latest version from the main branch 'main' (ea8775a85efb2153771ceddfb063a210d0975b4f)
DEBUG: This pact has previously been successfully verified by orders-message. If this verification fails, it will fail the build. Read more at <https://docs.pact.io/go/pending>

Verifying a pact between test-plan-logic-service and orders-message
  Given a test plan has been updated in orders
    a TEST_PLAN_UPDATED kafka event
      has matching content

12 interactions, 0 failures
WARN: Ignoring unsupported combine AND for path $['data']['study']['createdByUuid']
WARN: Ignoring unsupported combine AND for path $['data']['study']['productType']['type']
WARN: Ignoring unsupported combine AND for path $['data']['study']['studyContext']['accountUuid']
WARN: Ignoring unsupported combine AND for path $['data']['study']['title']
WARN: Ignoring unsupported combine AND for path $['data']['study']['uuid']
WARN: Ignoring unsupported combine AND for path $['id']
WARN: Ignoring unsupported combine AND for path $['data']['study']['testPlanUuid']
WARN: Ignoring unsupported combine AND for path $['data']['study']['uuid']
WARN: Ignoring unsupported combine AND for path $['id']
WARN: Ignoring unsupported combine AND for path $['data']['testPlan']['id']
WARN: Ignoring unsupported combine AND for path $['data']['testPlan']['logicNodes']
WARN: Ignoring unsupported combine AND for path $['data']['testPlan']['taskGroups']
WARN: Ignoring unsupported combine AND for path $['data']['testPlan']['tasks']
WARN: Ignoring unsupported combine AND for path $['data']['testPlan']['testPlanEntries']
WARN: Ignoring unsupported combine AND for path $['data']['testPlan']['uuid']
s
So you have specified consumer_version_selectors with mainBranch true that pulls in pacts from the latest version from the main branch of each consumer. Use of this selector requires that the consumer has configured the
mainBranch
property, and has set a branch name when publishing the pacts. Can you please verify if you have specified the main branch for the two services.
☝️ 1
y
Yep, that would be my first port of call. Out of interest which library are you using to generate your pact files, as you have matchers which pact-ruby is unable to process It would require https://github.com/pact-foundation/pact-support/pull/86 to process through rules correctly.
d
@Sauparna Gupta - It looks like for me it is working only if i put the
latest:true
and it is recognising the pact consumer contracts, when i try with
mainBranch:true
it doesnt work. I know pact recommending not to use
latest:true
wondering if you have any new solution here?
s
Can you please verify if you have specified the main branch for the two services?
d
Do you mean the consumer contract services? Where can i check them? I have specified in provider service which i shared with you already. I dont think we can specify in consumer side for
main
, we can only run them as part of the push on
main
, is that what you mean?
s
yes
/pacticipants/<pacticipant_name>/settings/version-control
in the UI there will an option for main branch
its a blank page
<pacticipant_name>
- Is this consumer or provider service name?
y
d
The above endpoint supposed to be access through UI from pactflow or CLI?
s
try the cli in the link
d
Copy code
pact-broker describe-pacticipant --name=participant-test-plan-service -b, --broker-base-url=<https://usertesting.pactflow.io/>
ERROR: "pact-broker describe_pacticipant" was called with arguments ["-b,"]
Usage: "pact-broker describe-pacticipant --name=NAME -b, --broker-base-url=BROKER_BASE_URL"
what am i doing wrong here?
y
provide one of these
Copy code
-b, --broker-base-url
-b
is an alias
s
-b flag ain't required
yes
use the token as well
Copy code
-k, [--broker-token=BROKER_TOKEN]
d
Copy code
Name: participant-test-plan-service
Display Name: Participant Test Plan Service
Main Branch: main
Updated At: '2024-05-15T15:12:19+00:00'
Created At: '2023-10-26T09:57:30+00:00'
s
ok
d
Copy code
Name: responses-tracker
Display Name: Responses Tracker
Main Branch: main
Updated At: '2024-02-12T20:46:42+00:00'
Created At: '2024-02-12T20:46:41+00:00'
these are the 2 services not fetching when i run provider verifications when i tag the consumerVersion as
mainBranch: true
s
can you try
main_branch: true
y
can you show a view of the pact in your pact broker? or if in the new UI, the consumer application, showing it’s relationship to your provider
order-service
d
can you try
main_branch: true
I already tried this but it was only fetching up for these 3 StudyServiceProviderMessage, TestPlanLogicServiceMessageProvider, TestPlanLogicServiceMessageProvider
not fetching the
MyMessageProvider, TestPlanServiceMessageProvider
Right now
orders-message
versions control has the mainBranch set to
master
but the consumers version control for the mainBranch is always to
main
, so there are 2 different mainBranch names here, for provider it is using
master
and all the consumers mainBranch called
main
, i guess as long as the consumers are
main
for the mainBranch we should be good, correct?
Screenshot 2024-08-22 at 16.13.08.png
y
correct, that should be handled by the broker. when you specify the mainBranch property it should retrieve any consumers for that provider, then get the latest pact on the main branch specified in the broker for that consumer. for each of the consumers failing to verify, do they have any other service dependencies? is the latest pact on each of the main branches for the consumers that are failing to verify, pointing at
orders-message
?
d
Its not about failing , but it is failed to fetch those services from
main
Here is the log:
Copy code
/usr/src/app/vendor/bundle/ruby/3.2.0/gems/io-event-1.3.2/lib/io/event/support.rb:24: warning: IO::Buffer is experimental and both the Ruby and C interface may change in the future!
DEPRECATION WARNING: ActiveSupport::PerThreadRegistry is deprecated and will be removed in Rails 7.1.
Use `Module#thread_mattr_accessor` instead.
 (called from <top (required)> at /usr/src/app/config/application.rb:11)
SPEC_OPTS='' /usr/local/bin/ruby -S pact verify --pact-helper ./spec/contract/service_consumers/pact_helper_message.rb
/usr/src/app/vendor/bundle/ruby/3.2.0/gems/io-event-1.3.2/lib/io/event/support.rb:24: warning: IO::Buffer is experimental and both the Ruby and C interface may change in the future!
DEPRECATION WARNING: ActiveSupport::PerThreadRegistry is deprecated and will be removed in Rails 7.1.
Use `Module#thread_mattr_accessor` instead.
 (called from <top (required)> at /usr/src/app/config/application.rb:11)
/usr/src/app/config/initializers/sidekiq.rb:67: warning: Sidekiq's Delayed Extensions will be removed in Sidekiq 7.0
AssetSync: using /usr/src/app/config/initializers/asset_sync.rb
PACT_BROKER_URL: <https://usertesting.pactflow.io/>
PACT_BROKER_TOKEN: **********************
GIT_SHA: abcc710ceff680f338f11cb2779b8ae321c6dd75
GIT_BRANCH: main
CI: true
CONFIG keys: ["A message with the Test Plan Published event", "A message with the Study Created event", "A message with the Study Context Updated event", "a STUDY_CREATED kafka event", "a STUDY_UPDATED kafka event", "a TEST_PLAN_PUBLISHED kafka event", "an ACCOUNT_CREATED message", "an ACCOUNT_MEMBERSHIP_USER_ADDED message", "an ACCOUNT_MEMBERSHIP_REMOVED message", "an ACCOUNT_MEMBERSHIP_UPDATED message", "a WORKSPACE_CREATED message", "a WORKSPACE_DELETED message", "a WORKSPACE_MEMBERSHIP_USER_ADDED message", "a WORKSPACE_MEMBERSHIP_UPDATED message", "a WORKSPACE_MEMBERSHIP_REMOVED message", "a TEST_PLAN_UPDATED kafka event"]
INFO: Fetching pacts for orders-message from <https://usertesting.pactflow.io/> with the selection criteria: latest from main branch
INFO: Reading pact at <https://usertesting.pactflow.io/pacts/provider/orders-message/consumer/participant-study-service/pact-version/0ceb7c9c8077f0631b6b404e3b867949047fdf93/metadata/c1tdW2xdPXRydWUmc1tdW2N2XT00NTIxNA>
WARN: Ignoring unsupported combine AND for path $['data']['study']['createdByUuid']
WARN: Ignoring unsupported combine AND for path $['data']['study']['productType']['type']
WARN: Ignoring unsupported combine AND for path $['data']['study']['studyContext']['accountUuid']
WARN: Ignoring unsupported combine AND for path $['data']['study']['title']
WARN: Ignoring unsupported combine AND for path $['data']['study']['uuid']
WARN: Ignoring unsupported combine AND for path $['id']
WARN: Ignoring unsupported combine AND for path $['data']['study']['testPlanUuid']
WARN: Ignoring unsupported combine AND for path $['data']['study']['uuid']
WARN: Ignoring unsupported combine AND for path $['id']
INFO: Reading pact at <https://usertesting.pactflow.io/pacts/provider/orders-message/consumer/permissions-service/pact-version/e37c088721e1b5b2e468fca3993fe6a95a557b91/metadata/c1tdW2xdPXRydWUmc1tdW2N2XT00NTk1Ng>
INFO: Reading pact at <https://usertesting.pactflow.io/pacts/provider/orders-message/consumer/test-plan-logic-service/pact-version/f80a1e8aa90f78a261951b65da55d8d42181e3d5/metadata/c1tdW2xdPXRydWUmc1tdW2N2XT00NzY5MA>
WARN: Ignoring unsupported combine AND for path $['data']['testPlan']['id']
WARN: Ignoring unsupported combine AND for path $['data']['testPlan']['logicNodes']
WARN: Ignoring unsupported combine AND for path $['data']['testPlan']['taskGroups']
WARN: Ignoring unsupported combine AND for path $['data']['testPlan']['tasks']
WARN: Ignoring unsupported combine AND for path $['data']['testPlan']['testPlanEntries']
WARN: Ignoring unsupported combine AND for path $['data']['testPlan']['uuid']
[33m[rspec-sidekiq] WARNING! Sidekiq will *NOT* process jobs in this environment. See <https://github.com/wspurgin/rspec-sidekiq/wiki/FAQ-&-Troubleshooting>[0m

DEBUG: The pact at <https://usertesting.pactflow.io/pacts/provider/orders-message/consumer/participant-study-service/pact-version/0ceb7c9c8077f0631b6b404e3b867949047fdf93> is being verified because the pact content belongs to the consumer version matching the following criterion:
    * latest version from the main branch 'main' (2990ad33ff33540b487d0a414d888b3676530dc6)

Verifying a pact between participant-study-service and orders-message
  Given a study has been created in orders
    a STUDY_CREATED kafka event
Verifying message: a STUDY_CREATED kafka event
[32m      has matching content[0m
  Given a study has been updated in orders
    a STUDY_UPDATED kafka event
Verifying message: a STUDY_UPDATED kafka event
[32m      has matching content[0m

DEBUG: The pact at <https://usertesting.pactflow.io/pacts/provider/orders-message/consumer/permissions-service/pact-version/e37c088721e1b5b2e468fca3993fe6a95a557b91> is being verified because the pact content belongs to the consumer version matching the following criterion:
    * latest version from the main branch 'main' (712b524f30d58ad24bfbebae43182e68db953d73)

Verifying a pact between permissions-service and orders-message
  Given a workspace member has been updated
    a WORKSPACE_MEMBERSHIP_UPDATED message
Verifying message: a WORKSPACE_MEMBERSHIP_UPDATED message
[32m      has matching content[0m
  Given an account has been created
    an ACCOUNT_CREATED message
Verifying message: an ACCOUNT_CREATED message
[32m      has matching content[0m
  Given a workspace member has been added
    a WORKSPACE_MEMBERSHIP_USER_ADDED message
Verifying message: a WORKSPACE_MEMBERSHIP_USER_ADDED message
[32m      has matching content[0m
  Given a workspace has been deleted
    a WORKSPACE_DELETED message
Verifying message: a WORKSPACE_DELETED message
[32m      has matching content[0m
  Given a workspace member has been removed
    a WORKSPACE_MEMBERSHIP_REMOVED message
Verifying message: a WORKSPACE_MEMBERSHIP_REMOVED message
[32m      has matching content[0m
  Given a workspace has been created
    a WORKSPACE_CREATED message
Verifying message: a WORKSPACE_CREATED message
[32m      has matching content[0m
  Given an account membership has been updated
    an ACCOUNT_MEMBERSHIP_UPDATED message
Verifying message: an ACCOUNT_MEMBERSHIP_UPDATED message
[32m      has matching content[0m
  Given an account membership has been created
    an ACCOUNT_MEMBERSHIP_USER_ADDED message
Verifying message: an ACCOUNT_MEMBERSHIP_USER_ADDED message
[32m      has matching content[0m
  Given an account membership has been removed
    an ACCOUNT_MEMBERSHIP_REMOVED message
Verifying message: an ACCOUNT_MEMBERSHIP_REMOVED message
[32m      has matching content[0m

DEBUG: The pact at <https://usertesting.pactflow.io/pacts/provider/orders-message/consumer/test-plan-logic-service/pact-version/f80a1e8aa90f78a261951b65da55d8d42181e3d5> is being verified because the pact content belongs to the consumer version matching the following criterion:
    * latest version from the main branch 'main' (ea8775a85efb2153771ceddfb063a210d0975b4f)

Verifying a pact between test-plan-logic-service and orders-message
  Given a test plan has been updated in orders
    a TEST_PLAN_UPDATED kafka event
Verifying message: a TEST_PLAN_UPDATED kafka event
[32m      has matching content[0m

[32m12 interactions, 0 failures[0m
WARN: Ignoring unsupported combine AND for path $['data']['study']['createdByUuid']
WARN: Ignoring unsupported combine AND for path $['data']['study']['productType']['type']
WARN: Ignoring unsupported combine AND for path $['data']['study']['studyContext']['accountUuid']
WARN: Ignoring unsupported combine AND for path $['data']['study']['title']
WARN: Ignoring unsupported combine AND for path $['data']['study']['uuid']
WARN: Ignoring unsupported combine AND for path $['id']
WARN: Ignoring unsupported combine AND for path $['data']['study']['testPlanUuid']
WARN: Ignoring unsupported combine AND for path $['data']['study']['uuid']
WARN: Ignoring unsupported combine AND for path $['id']
WARN: Ignoring unsupported combine AND for path $['data']['testPlan']['id']
WARN: Ignoring unsupported combine AND for path $['data']['testPlan']['logicNodes']
WARN: Ignoring unsupported combine AND for path $['data']['testPlan']['taskGroups']
WARN: Ignoring unsupported combine AND for path $['data']['testPlan']['tasks']
WARN: Ignoring unsupported combine AND for path $['data']['testPlan']['testPlanEntries']
WARN: Ignoring unsupported combine AND for path $['data']['testPlan']['uuid']
INFO: Tagging version abcc710ceff680f338f11cb2779b8ae321c6dd75 of orders-message as "main"
INFO: Verification results published to <https://usertesting.pactflow.io/pacts/provider/orders-message/consumer/participant-study-service/pact-version/0ceb7c9c8077f0631b6b404e3b867949047fdf93/verification-results/73545>
INFO: Tagging version abcc710ceff680f338f11cb2779b8ae321c6dd75 of orders-message as "main"
INFO: Verification results published to <https://usertesting.pactflow.io/pacts/provider/orders-message/consumer/permissions-service/pact-version/e37c088721e1b5b2e468fca3993fe6a95a557b91/verification-results/73546>
INFO: Tagging version abcc710ceff680f338f11cb2779b8ae321c6dd75 of orders-message as "main"
INFO: Verification results published to <https://usertesting.pactflow.io/pacts/provider/orders-message/consumer/test-plan-logic-service/pact-version/f80a1e8aa90f78a261951b65da55d8d42181e3d5/verification-results/73547>
From the above log its only fetch'd
3
services instead all of them
5
, those 2 services which i mentioned above unable to fetch for some reason when i have the
mainBranch: true
y
I dont think the latest on the main branch of those consumers is pointing at
orders-message
d
How can i check that?
y
Copy code
DEBUG: The pact at <https://usertesting.pactflow.io/pacts/provider/orders-message/consumer/permissions-service/pact-version/e37c088721e1b5b2e468fca3993fe6a95a557b91> is being verified because the pact content belongs to the consumer version matching the following criterion:
    * latest version from the main branch 'main'
look at each consumer application where the provider is failing to find pacts, and check the latest application version in the list for its main branch, it should reference the
orders-message
provider (but I don’t think it will)
that should be different to the other 3 that are, where the latest on the main branch, is pointing to the
orders-message
d
So do we expect when we go to this link
<https://usertesting.pactflow.io/pacticipants/participant-test-plan-service/versions/02c7c8067f6cddb952934a6180b84466b91991e7?branch=main>
and we should see the provider
orders-message
?
Yes i can confirm that i dont see the
orders-message
under
pacticipants
for the missing consumers above.
look at each consumer application where the provider is failing to find pacts, and check the latest application version in the list for its main branch, it should reference the
orders-message
provider (but I don’t think it will)
What might be the cause for not showing the application version not showing the latest as
main
? Can you suggest?
y
What might be the cause for not showing the application version not showing the latest as
main
? Can you suggest?
Possibly a consumer having multiple providers, and publishing each pact with a different version number (possibly suffixed with a service name) or for pact spec versions v3, you could not mix http and message pact services, so if you have a provider which does both, they should have distinct names for the http portion and the message portion. pact spec v4 allows for mixed interactions in a pact file, but pact ruby does not yet support it
d
Yes right now one of the service
participant-test-plan-service
acting like a provider and consumer with
orders-message
provider. At the same time. and
responses-tracker
service acting like a consumer for 2 different providers
orders-message
&
participant-test-plan-service
For example, this is how we are publishing the contracts for
responses-tracker
which is consuming from 2 different providers
orders-message
&
participant-test-plan-service
Copy code
name: Run contract tests
on:
  push:
    branches:
      - main
  pull_request:
    types: [opened, synchronize, closed]
    branches:
      - main

env:
  sub_application_name: "responsesTracker"
  version: ${{ github.sha }}
  pactfiles: "target/pacts"
  BRANCH_NAME: ${{ github.head_ref || github.ref_name }}
  PACT_BROKER_BASE_URL: "<https://usertesting.pactflow.io>"
  PACT_BROKER_TOKEN: ${{ secrets.PACT_BROKER_TOKEN }}

jobs:
  run-contract-tests:
    runs-on: ubuntu-latest
    steps:
    - name: Checkout
      uses: actions/checkout@v4
    - name: Set up JDK 21
      uses: actions/setup-java@v4
      with:
        java-version: '21'
        distribution: 'temurin'
    - name: Contract Test
      run: sbt -v clean +${{ env.sub_application_name }}/ContractTest/test
      env:
        GITHUB_TOKEN: "foobar"
        GH_ANALYTICS_PACKAGES_TOKEN: ${{ secrets.GA_READ }}
    - name: Upload pactfiles
      uses: actions/upload-artifact@v4
      with:
        name: Pactfiles
        path: ${{ env.pactfiles }}

  publish-pacts:
    needs: run-contract-tests
    runs-on: ubuntu-latest
    steps:
    - name: Checkout
      uses: actions/checkout@v4
    - name: Download pactfiles
      uses: actions/download-artifact@v4
      with:
        name: Pactfiles
        path: ${{ env.pactfiles }}
    - name: Set up Ruby
      uses: ruby/setup-ruby@v1
      with:
        ruby-version: 3.1.2
    - name: Install pact_broker-client
      run: gem install pact_broker-client
    - name: Publish Pacts
      run: |
        for pactfile in responses-tracker-orders-message.json responses-tracker-participant-test-plan-service.json; do
          CONSUMER_NAME=$(basename $pactfile .json)
          CONSUMER_NAME=${CONSUMER_NAME#responses-tracker-}
          CONSUMER_VERSION="${{ env.version }}-${CONSUMER_NAME}"
          pact-broker publish ${{ env.pactfiles }}/$pactfile \
            --consumer-app-version $CONSUMER_VERSION \
            --branch ${{ env.BRANCH_NAME }} \
            --broker-base-url ${{ env.PACT_BROKER_BASE_URL }} \
            --broker-token ${{ env.PACT_BROKER_TOKEN }}
        done
y
so that loop will publish twice and therefore the first in the for loop will not be the latest (that will be the 2nd in your for loop) you can publish a directory rather than indiv files, and then all the pacts get published under the same version/branch
this version differs on each publish
CONSUMER_VERSION="${{ env.version }}-${CONSUMER_NAME}"
--consumer-app-version $CONSUMER_VERSION
they should be the same 👍
to clarify, you shoudn’t have the consumer name appended to the version, you should be able to do the for loop if you don’t change the versions between each publish
d
Is this what you mean?
Copy code
for pactfile in responses-tracker-orders-message.json responses-tracker-participant-test-plan-service.json; do
            pact-broker publish ${{ env.pactfiles }}/$pactfile \
              --consumer-app-version ${{ env.version }} \
              --branch ${{ env.BRANCH_NAME }} \
              --broker-base-url ${{ env.PACT_BROKER_BASE_URL }} \
              --broker-token ${{ env.PACT_BROKER_TOKEN }}
          done
👌 1
y
yeah I think that should do it
d
This is what i was doing before, but for some reason both the services are using the same consumer version
Since it is the same consumer version , 2 different providers are struggling to find verifications and they are considering it as one provider
thats why i have to differentiate the consumer version by adding
-
y
the workaround you’ve performed would only mask the underlying problem, so best to unpick that, and raise the original issue. Using Pact in the way you are, is not the way it was intended, and you are getting the correct information back from your consumer version selectors, based on your current setup.
d
So the best way to revert back to the original state without
-
's and figure out the fix, correct?
y
correct, same consumer version for both files, republish from main branch. check what your provider orders-message then gets when checking via mainBranch consumer version selector
if not what you expect, report back
d
what do you mean republish from main branch? Is this mean publishing on your push whenever you raise PR and also republish when it is merged to main, correcT?
y
however you want to go about it, you can raise a pr and do it that way or you could just update your ci script and push from the main branch to kick off the ci again. you could equally just republish the pact contents manually with the cli tool and the correct version number that matches your main branches head. whatever you feel comfortable with
d
why is our new UI doesnt show the other provider for any branch? How can we view that other than main?
y
top left, there is a branch selector dropdown, you have main selected
d
Right now this is how it shows for the branch which i republished with the change you suggested
👌 1
basically we would expect the same on
main
once this is merged
y
yeah, you can try with
branch: "RAD-xyz"
in your providers consumer version selectors to see if it picks them both up
locally, to check if you wanted
d
checking..
As expected its only fetching the
responses-tracker
not both
Copy code
DEBUG: The pact at <https://usertesting.pactflow.io/pacts/provider/orders-message/consumer/responses-tracker/pact-version/c9190d1a20d497a5e810efbe994581cde96590e7> is being verified because the pact content belongs to the consumer version matching the following criterion:
    * latest version from branch 'RAD-32507-fix-publishing-contracts' (d47dc12b734785ab5d260066af608e2842ec02ef)
i guess this is correct
y
correct, orders message is one provider, pacticipant-test-plan-service is the other. once you have both services that are missing in the same state as your photo, your order-message service will see them both
d
I was running the verification above under
orders-message
for the
responses-tracker
consumer
so basically i need to check if the
participant-test-plan-service
will pick up the same consumer version selector for
responses-tracker
correct?
y
yep, there was also a 5th service that
orders-message
wasn’t picking up.
d
orders-message
is a provider here
y
participant-test-plan-service
is both a provider to
responses-tracker
and a consumer or
orders-message
your original query was that
orders-message
was not picking up both
responses-tracker
and
participant-test-plan-service
so you’ll need to do some work in the consumer pipeline of
participant-test-plan-service
as well possibly (you haven’t shown that ci workflow)
d
Here is the
participant-test-plan-service
CI flow • It is a consumer of
orders-message
• Provider to
participant-video-service
&
responses-tracker
Here is the CI flow for
participant-test-plan-service
Copy code
name: Pact Checks

on:
  push:
    branches:
      - main
  pull_request:
    types: [opened, synchronize, closed]
    branches:
      - main

env:
  CI: true
  PACT_BROKER_TOKEN: ${{ secrets.PACT_BROKER_TOKEN }}
  PACT_BROKER_BASE_URL: '<https://usertesting.pactflow.io>'
  BRANCH: ${{ github.head_ref || github.ref_name }}
  PUBLISH_VERIFICATION_RESULTS: true
  VERSION: ${{ github.sha }}

jobs:
  pact-checks:
    permissions:
      contents: read
      packages: read
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
      - uses: actions/setup-node@v3
        with:
          node-version: 20

      - name: Setup npm token
        run: npm config set "//npm.pkg.github.com/:_authToken=${{ secrets.GITHUB_TOKEN }}"

      - name: Install dependencies
        run: npm ci

      - name: Execute Pact contract tests (Consumer)
        run: npm run test:contract:consumer

      - name: Execute Pact contract tests (Provider)
        run: npm run test:contract:provider
      
      - name: Publish Pacts (Consumer POV)
        run: |
          npm run pact:broker:download --if-present
          npm run pact:publish --if-present -- --consumer-app-version ${{ env.VERSION }} --branch ${{ env.BRANCH }} --broker-base-url ${{ env.PACT_BROKER_BASE_URL }} --broker-token ${{ env.PACT_BROKER_TOKEN }}

      # - name: Can I Deploy Pacts (Consumer & Provider POV)
      #   run: |
      #     npm run pact:can-i-deploy --if-present -- --pacticipant participant-test-plan-service --version ${{ env.VERSION }} --broker-base-url ${{ env.PACT_BROKER_BASE_URL }} --broker-token ${{ env.PACT_BROKER_TOKEN }} --retry-while-unknown=10 --retry-interval=30
we are not doing
can-i-deploy
just now until we understood the flow and it works correctly
y
Copy code
npm run pact:publish --if-present -- --consumer-app-version ${{ env.VERSION }} --branch ${{ env.BRANCH }} --broker-base-url ${{ env.PACT_BROKER_BASE_URL }} --broker-token ${{ env.PACT_BROKER_TOKEN }}
this looks ok although i’ve not seen the
--if-present
flag before used. what is in the package.json under
pact:publish
? can you check the view of that application, and check its main branch?
d
"pact:publish": "pact-broker publish ./pacts/*.json",
y
we are not doing
can-i-deploy
just now until we understood the flow and it works correctly (edited)
that makes sense, you can also run it in dry run mode so you can see if it works and gain confidence , before switching over
d
Copy code
"test:contract:consumer": "mocha -r ts-node/register 'test/contract/consumer/**/*.ts' --timeout 20000 --exit",
		"test:contract:provider": "mocha -r ts-node/register 'test/contract/provider/**/*.ts' --timeout 20000 --exit",
I did
can-i-deploy
already in another PR, this is what is says
Copy code
Computer says no ¯\_(ツ)_/¯

CONSUMER                      | C.VERSION                                                       | PROVIDER                      | P.VERSION  | SUCCESS? | RESULT#
------------------------------|-----------------------------------------------------------------|-------------------------------|------------|----------|--------
participant-test-plan-service | 9c0b0b7...                                                      | orders-message                | ???        | ???      |        
participant-video-service     | a41bcff...                                                      | participant-test-plan-service | 9c0b0b7... | true     | 1      
responses-tracker             | ba3f6cc2b9b2f42b2787bd6752569d921c74233f-participant-test-pl... | participant-test-plan-service | 9c0b0b7... | true     | 2      

VERIFICATION RESULTS
--------------------
1. <https://usertesting.pactflow.io/pacts/provider/participant-test-plan-service/consumer/participant-video-service/pact-version/f9ba2fda0a19a88a73f5ed5a611754e97b5969e4/metadata/Y3ZuPWE0MWJjZmY5ZDdjNzNiN2M5Y2M1OGQ0NWY5MGEzOTMxM2UzYmM3MDg/verification-results/73298> (success)
2. <https://usertesting.pactflow.io/pacts/provider/participant-test-plan-service/consumer/responses-tracker/pact-version/40c76b20d00be4284c37539ed1dd38a97bfed695/metadata/Y3ZuPWJhM2Y2Y2MyYjliMmY0MmIyNzg3YmQ2NzUyNTY5ZDkyMWM3NDIzM2YtcGFydGljaXBhbnQtdGVzdC1wbGFuLXNlcnZpY2U/verification-results/73299> (success)

WARN: It is recommended to specify the environment into which you are deploying. Without the environment, this result will not be reliable.
There is no verified pact between version 9c0b0b7fef90ee36d58d246d4d3f6145608d11e2 of participant-test-plan-service and the latest version of orders-message (253267ca7294f9d843e6e06280a4c660a50f2519)
Error: Process completed with exit code 1.
i guess the above one works once we resolved the main issues
👌 1
y
ok make a branch that matches the name we made earlier but for
participant-test-plan-service
and run it thru ci so it publishes a pact, then show us the application view in the broker if you don’t mind
d
you mean like this for
participant-test-plan-service
Copy code
options.consumerVersionSelectors = [{ consumer: consumerName, branch: "RAD-32507-fix-publishing-contracts" }];
y
no lets still concentrate on
orders-message
and its 5 consumers. one of them is
participant-test-plan-service
so lets first make a branch called
RAD-32507-fix-publishing-contracts
for
participant-test-plan-service
and push that commit Once that is published to PactFlow, you can run your provider
orders-message
with
branch: "RAD-32507-fix-publishing-contracts"
locally, which will should now pick up the 2 previously missing consumers that you originally reported. That would effectively fill in this result (once results are published to pactflow etc)
Copy code
CONSUMER                      | C.VERSION                                                       | PROVIDER                      | P.VERSION  | SUCCESS? | RESULT#
------------------------------|-----------------------------------------------------------------|-------------------------------|------------|----------|--------
participant-test-plan-service | 9c0b0b7...                                                      | orders-message                | ???        | ???      |
d
> so lets first make a branch called
RAD-32507-fix-publishing-contracts
for
participant-test-plan-service
and push that commit Which commit we supposed to do at
participant-test-plan-service
?
y
probably best making a new branch from
main
and pushing that
it will have the same commit version, but a diff branch
that’s fine, we are going to target the latest pact for a particular branch ``RAD-32507-fix-publishing-contracts` in our consumer version selectors
d
sorry, im bit confused! So im making a new branch from
participant-test-plan-service
and commit something, correcT?
y
it’s okay! you probably don’t even need to commit something. we just want to trigger your CI system, on a branch called
RAD-32507-fix-publishing-contracts
you might be able to get away with creating a new branch from master in your git UI, or you may need to actually create a new branch and make any type of commit.
1
d
before i created this branch
RAD-32507-fix-publishing-contract
from
responses-tracker
service - FYI
y
yes, you but have a missing relationship between
orders-message
(provider) and `participant-test-plan-service`(consumer) this was one of the missing consumers. the other being
responses-tracker
so we want to check
participant-test-plan-service
is correctly publishing pact files, so that
orders-message
can discover them
1
once that is sorted, we can worry about
participant-test-plan-service
as a provider role.
1
so 1.
responses-tracker
(consumer) publish pacts to
RAD-32507-fix-publishing-contract
2.
participant-test-plan-service
(consumer) publish pacts to
RAD-32507-fix-publishing-contract
3.
orders-message
(provider) uses
branch: RAD-32507-fix-publishing-contract
in consumer version selectors 4.
orders-message
discovers
responses-tracker
&
participant-test-plan-service
5. Everybody celebrates
d
> 1.
participant-test-plan-service
(consumer) publish pacts to
RAD-32507-fix-publishing-contract
What should i need to change here at this service?
npm run pact:publish --if-present -- --consumer-app-version ${{ env.VERSION }} --branch ${{ "RAD-32507-fix-publishing-contract" }}
- this ?
y
Trigger this workflow https://pact-foundation.slack.com/archives/C9VHVEDE1/p1724345829751949?thread_ts=1724278606.805609&amp;cid=C9VHVEDE1 Just need a branch with that name.
Copy code
env:
  CI: true
  PACT_BROKER_TOKEN: ${{ secrets.PACT_BROKER_TOKEN }}
  PACT_BROKER_BASE_URL: '<https://usertesting.pactflow.io>'
  BRANCH: ${{ github.head_ref || github.ref_name }}
  PUBLISH_VERIFICATION_RESULTS: true
  VERSION: ${{ github.sha }}
how do you normally create a new branch and push the commit to your version control system?
run the workflow, check the output of the publish step, and check the
participant-test-plan-service
view in pactflow, for the newly created branch
d
okay, i can just create a branch and update the details above with the branch name to this in CI
BRANCH: "RAD-32507-fix-publishing-contract"
y
dont change the name manually, its configured to pick it up from the github head_ref variable
which is the branch
d
should be like this?
BRANCH: ${{ github.head_ref || github.ref_name }}
y
pretty sure head_ref is empty if it isnt a pull request but ref_name will be set on a regular commit
you can also just set
--auto-detect-version-properties
which will detect the version & branch for you
d
Copy code
env:
  CI: true
  PACT_BROKER_TOKEN: ${{ secrets.PACT_BROKER_TOKEN }}
  PACT_BROKER_BASE_URL: '<https://usertesting.pactflow.io>'
  BRANCH: ${{ github.head_ref || github.ref_name }}
  PUBLISH_VERIFICATION_RESULTS: true
  VERSION: ${{ github.sha }}
y
then you don’t need to set
--consumer-app-version <version>
or
--branch <branch>
d
where do you add this
--auto-detect-version-properties
?
like this
npm run pact:publish --if-present -- --auto-detect-version-properties --broker-base-url ${{ env.PACT_BROKER_BASE_URL }} --broker-token ${{ env.PACT_BROKER_TOKEN }}
?
y
spot on
1
d
doing now
y
and then once the CI has run, we can take a look at the output of the publish step
nice one
🙌 1
d
Copy code
Updated participant-test-plan-service version d239e7558fc6201247d6cdaf1ff0c207fdcc1c1e with branch xcanchal/fix/RAD-29690-contract-testing-iteration
Pact successfully published for participant-test-plan-service version d239e7558fc6201247d6cdaf1ff0c207fdcc1c1e and provider orders-message.
  View the published pact at <https://usertesting.pactflow.io/pacts/provider/orders-message/consumer/participant-test-plan-service/version/d239e7558fc6201247d6cdaf1ff0c207fdcc1c1e>
publish-pacts output 🔝
y
ok cool, we are on a slightly different branch name
Copy code
xcanchal/fix/RAD-29690-contract-testing-iteration
to that set on the other service
Copy code
RAD-32507-fix-publishing-contract
do you want to align them both?
you can also update it to use auto-detect-version properties
d
are you saying use the same branch name?
y
yes, just if you want to check that
orders-message
can find them both with a single selector
but if they both end up on main, it’ll work 👍 (given that you update your selectors on
orders-message
provider back to
mainBranch
🙂 )
d
xcanchal/fix/RAD-29690-contract-testing-iteration
this is the working branch where i updated the CI flow changes to use
auto-detect-version properties
i will create a new branch from main called
RAD-32507-fix-publishing-contract
and push the same commit again
y
ok that is fine. If you merge both those PR’s to main, and run your
orders-message
provider, it should find all the consumers pacts
i will create a new branch from main called
RAD-32507-fix-publishing-contract
and push the same commit agai
Great, this will just allow you to be sure your
orders-message
consumer can find the two missing consumers, but I am sure it will just work once merged
d
i tried
orders-message
already by giving the
consumer_version_selectors [{branch: "RAD-32507-fix-publishing-contracts"}]
but it was still fetching one, not both
y
after publishing
participant-test-plan-service
on that branch too? we only did it for
response-tracker
d
> after publishing
participant-test-plan-service
on that branch too? > yes this was done from this branch
xcanchal/fix/RAD-29690-contract-testing-iteration
Im trying now with the same branch name as you originally suggested
RAD-32507-fix-publishing-contracts
at
participant-test-plan-service
hmm unfortunatly
orders-message
still fetching only
responses-tracker
not
participant-test-plan-service
sad
Copy code
INFO: Fetching pacts for orders-message from <https://usertesting.pactflow.io> with the selection criteria: latest from branch RAD-32507-fix-publishing-contracts
INFO: Reading pact at <https://usertesting.pactflow.io/pacts/provider/orders-message/consumer/responses-tracker/pact-version/c9190d1a20d497a5e810efbe994581cde96590e7/metadata/c1tdW2JdPVJBRC0zMjUwNy1maXgtcHVibGlzaGluZy1jb250cmFjdHMmc1tdW2xdPXRydWUmc1tdW2N2XT00ODIyNg>

DEBUG: The pact at <https://usertesting.pactflow.io/pacts/provider/orders-message/consumer/responses-tracker/pact-version/c9190d1a20d497a5e810efbe994581cde96590e7> is being verified because the pact content belongs to the consumer version matching the following criterion:
    * latest version from branch 'RAD-32507-fix-publishing-contracts' (d47dc12b734785ab5d260066af608e2842ec02ef)

Verifying a pact between responses-tracker and orders-message
  A message with the test plan published event
    has matching content
  Given A study is created
    A message with the Study Created event
      has matching content
  Given A study is created
    A message with the Study Created event
      has matching content
  Given A study is created
    A message with the Study Created event
      has matching content
  Given The study context is updated
    A message with the Study Context Updated event
      has matching content
  Given The study context is updated
    A message with the Study Context Updated event
      has matching content
  Given The study context is updated
    A message with the Study Context Updated event
      has matching content
y
please check ci output from publish step on the new branch for ``participant-test-plan-service` and pactflow view
d
Copy code
Please update imports to @pact-foundation/pact-cli 
  <https://github.com/pact-foundation/pact-js-core/issues/488>
Updated participant-test-plan-service version 391dde4b2a62ba908c201f50092e5a3fd8a421c0 with branch RAD-32507-fix-publishing-contract
Pact successfully published for participant-test-plan-service version 391dde4b2a62ba908c201f50092e5a3fd8a421c0 and provider orders-message.
  View the published pact at <https://usertesting.pactflow.io/pacts/provider/orders-message/consumer/participant-test-plan-service/version/391dde4b2a62ba908c201f50092e5a3fd8a421c0>
  Events detected: contract_published (pact content is the same as previous versions with tags  and no new tags were applied)
  No enabled webhooks found for the detected events
which
pacticipant
i need to check in pactflow UI?
y
participant-test-plan-service
please
d
Screenshot 2024-08-22 at 18.50.52.png
it is showing here though,
responses-tracker
also there, it is hiding at the bottom
y
hmm okay I am interested in the relationship between
participant-test-plan-service
as a consumer and
orders-message
as a provider, and the pact published to
RAD-32507-fix-publishing-contract
That looks correct, so I am also confused as to why the provider
orders-message
cannot find it with `branch:
RAD-32507-fix-publishing-contract
in the consumer version selectors. Can we check what you have set in the consumer version selectors on the
orders-message
provider? Is it only the branch name?
They are both message pacts, from both consumers correct?
d
Yes
orders-message
consumerVersionSelectors
Copy code
honours_pacts_from_pact_broker do
      pact_broker_base_url pact_base_url, {token: token}
      consumer_version_selectors [{branch: "RAD-32507-fix-publishing-contracts"}]
yes they both are
message
pacts from both the consumers
the test i did not in CI, but running locally though, is that makes any difference?
y
In
require_relative "provider_states_participant_test_plan_service"
what does that contain? is the name correct?
Pact.provider_states_for "Participant Test Plan Service" do
the test i did not in CI, but running locally though, is that makes any difference?
This should be fine, if your token has access to that team where the pacts are published
ahhhhh
d
yes all the names are correct
y
wait
Updated participant-test-plan-service version 391dde4b2a62ba908c201f50092e5a3fd8a421c0 with branch RAD-32507-fix-publishing-contract
contract signular
Copy code
honours_pacts_from_pact_broker do
      pact_broker_base_url pact_base_url, {token: token}
      consumer_version_selectors [{branch: "RAD-32507-fix-publishing-contracts"}]
contracts pluralised
d
oh no
wait
will do again
is there any way we can update the branch name?
y
I think you can call https://github.com/pact-foundation/pact_broker-client?tab=readme-ov-file#create-or-update-version and provide the same version but new branch
d
yay! its worked finally dance
👏 2
so i assume it will work once i merged to main too
1
regarding the
can-i-deploy
what do you suggest?
and also for publishing pacts, do you want us to change for all the consumers to use
--auto-detect-version-properties
?
y
and also for publishing pacts, do you want us to change for all the consumers to use
--auto-detect-version-properties
?
up to you, but makes it consistent and easy for users to understand (but not need to know the mechanics behind branches/commits and how to get/parse them in their workflow)
regarding the
can-i-deploy
what do you suggest?
use environments, record versions of your application once they are deployed into an env use can-i-deploy with the --dry-run flag
Copy code
When dry-run is enabled, always exit process with a success
                code. Can also be enabled by setting the environment variable
                PACT_BROKER_CAN_I_DEPLOY_DRY_RUN=true. This mode is useful when
                setting up your CI/CD pipeline for the first time, or in a
                'break glass' situation where you need to knowingly deploy what
                Pact considers a breaking change. For the second scenario, it
                is recommended to use the environment variable and just set it
                for the build required to deploy that particular version, so
                you don't accidentally leave the dry run mode enabled.
              # Default: false
also setup webhooks so that when you publish a new consumer contract, it is automatically verified by your provider by triggering a provider build by PACT_URL https://docs.pact.io/pact_broker/webhooks
d
Yes we are doing the web hooks, however its need a new token for each provider service, which is causing too much work. Is there any suggestion here to use the tokens?
Right now we don’t have any environments but the versions. I guess can-i-deploy is only for consumer workflow isnt it? Or provider also? If I start implementing this for participant-test-plan-service the above approach is enough for now? Or do you suggest adding some sort of tags or environments ?
Hey @Yousaf Nabi (pactflow.io), i have merged both the PR's, but some reason i only see
reponses-tracker
picked up but not the
participant-test-plan-service
when i run the
orders-message
provider verification
here is the log for the
publish-pacts
for
participant-test-plan-service
Copy code
Updated participant-test-plan-service version dfe43a44c6b852e03a5d30558d41f2adeaacaf8d with branch main
Pact successfully published for participant-test-plan-service version dfe43a44c6b852e03a5d30558d41f2adeaacaf8d and provider orders-message.
  View the published pact at <https://usertesting.pactflow.io/pacts/provider/orders-message/consumer/participant-test-plan-service/version/dfe43a44c6b852e03a5d30558d41f2adeaacaf8d>
  Events detected: contract_published (pact content is the same as previous versions with tags  and no new tags were applied), contract_requiring_verification_published (pact content is the same as previous versions with tags  and no new tags were applied)
  Webhook "Orders - Verification" triggered for event contract_requiring_verification_published.
    View logs at <https://usertesting.pactflow.io/triggered-webhooks/494d0c11-d522-454e-8aae-28fa38b30cb0/logs>
On a branch it showed in pactflow
But on main it doesnt thinking
y
you've got a new version published on main, 35 minutes ago. Your version is one behind.
d
When is the version actually updates?
whenever we published?
How do i get the
orders-message
to show on
main
now, i would expect to show automatically as soon as we publish the contracts on each PR run or merge etc
y
this states the pact content is the same, and as a webhook has been triggered, it means there hasn't been a verification published for any of those pacts
Copy code
Events detected: contract_published (pact content is the same as previous versions with tags  and no new tags were applied), contract_requiring_verification_published (pact content is the same as previous versions with tags  and no new tags were applied)
  Webhook "Orders - Verification" triggered for event contract_requiring_verification_published.
    View logs at <https://usertesting.pactflow.io/triggered-webhooks/494d0c11-d522-454e-8aae-28fa38b30cb0/logs>
the version is only updated when you publish a new pact for that consumer. something else published a pact under a different version 35 minutes.
Heading off on holiday for the weekend, and we have bank holiday on Monday. good luck getting it sorted
d
have a good weekend, thanks for your help so far
Morning @Yousaf Nabi (pactflow.io), hope you had a good long weekend
@Sauparna Gupta - Hey! Can you help me here?
s
Can you brief me th eproblem here please
d
Sure, we have a service
participant-test-plan-service
acting like a provider and consumer as shown in the screenshot. However since it is also consumer for
orders-message
service, right now on
participant-test-plan-service
main
branch we don't see the latest version of
orders-message
. The latest thing we found from here
My concern is we shouldn't be triggering the webhook if the content is the same, even if it does go to main. I was trying to add tag for this publish. Forcing a webhook trigger with a tag feels like an anti-pattern to me.
s
a webhook can be triggered based on different events. https://docs.pactflow.io/docs/user-interface/settings/webhooks It all depends on the use case. But lets say the contract isn't changing. contract is essentially an expectation for consumer and the expectation doesn't change but the provider's response changed. Then its critical to know that the contract for a particular version is valid against the provider version against which the contract will be validated.
d
is there anyway right now i can publish the contracts from the branch
main
from the consumer? Because of this we don't have a provider verification on branch
main
for the provider
s
if you disable webhooks that will disable any provider verification when you publish.
d
main issue here is
orders-message
(provider) doesnt have a
participant-test-plan-service
(consumer) consumer version from
main
s
in order message you can use consumer version selectors and set the to verify against main branch of a particular consumer.
d
I have already done that, it is not finding it when i select on
mainBranch
right now orders-message has 5 consumers, and we have 4 working on
main
only the
participant-test-plan-service
is missing since we dont have version for this service from main
s
consumer_version_selectors [ { consumer: "<your service", main_branch: true }, { main_branch: true } ]
I rememeber the issue.
Ok so how about we try to specify the order-message pacticipant name in the consumer side when writing pact test. and merge the code with main when the pipeline will run it will create a pact file for the main branch with version for consumer which willl have the provider as order message and when you re-run the pipeline in provider I think it should pick it up.
d
okay, I have also
workflow_dispatch
event which i can run manually from github actions by passing a specific consumer. Will it do the same?
s
See what I'm assuming is that the pact file from main branch of consumer probably doesn't have the provider specified correctly for which it can't find the consumer participant.. for order-message
I would like you to verify that
d
Copy code
honours_pacts_from_pact_broker do
      pact_broker_base_url pact_base_url, {token: token}
      consumer_version_selectors [{consumer: 'participant-test-plan-service', mainBranch: true}]
    end
like this? and merge and let it run on main, and revert the change again by removing the consumer?
s
i didin't understand the revert part. But this will only pull in the main branch from participant-test-plan-service and ignore the rest of the consumers
d
Sorry, i misunderstood. Yes lets see if we can fix this from your suggestion
i let you know
@Sauparna Gupta - I can see the
orders-message
is picking up correctly now and all running 🎉
However, for
can-i-deploy
, we still have some issues
Copy code
There is no verified pact between the latest version of responses-tracker (efe0bd4a4d904622442fd00be7cdb5953e7922e7) and version 98dc2164cc843db389d8ed1ba6e164bbf70ed293 of participant-test-plan-service
Error: Process completed with exit code 1.
Computer says no ¯\_(ツ)_/¯
CONSUMER                      | C.VERSION  | PROVIDER                      | P.VERSION  | SUCCESS? | RESULT#
------------------------------|------------|-------------------------------|------------|----------|--------
participant-test-plan-service | 98dc216... | orders-message                | faa0f82... | true     | 1      
participant-video-service     | 5276954... | participant-test-plan-service | 98dc216... | true     | 2      
responses-tracker             | efe0bd4... | participant-test-plan-service | ???        | ???      |        
VERIFICATION RESULTS
--------------------
1. <https://usertesting.pactflow.io/pacts/provider/orders-message/consumer/participant-test-plan-service/pact-version/bb102df14d5bde4a336622904cf7acb8bc24919c/metadata/Y3ZuPTk4ZGMyMTY0Y2M4NDNkYjM4OWQ4ZWQxYmE2ZTE2NGJiZjcwZWQyOTM/verification-results/75061> (success)
2. <https://usertesting.pactflow.io/pacts/provider/participant-test-plan-service/consumer/participant-video-service/pact-version/a129dc4f121189051c484b5c2ce6c357e982f0c5/metadata/Y3ZuPTUyNzY5NTQyMDUwZTYwNGViMWEzY2E1NGY1MzM2YjU0YmY3ZWQ4N2I/verification-results/75067> (success)
WARN: It is recommended to specify the environment into which you are deploying. Without the environment, this result will not be reliable.
There is no verified pact between the latest version of responses-tracker (efe0bd4a4d904622442fd00be7cdb5953e7922e7) and version 98dc2164cc843db389d8ed1ba6e164bbf70ed293 of participant-test-plan-service
Error: Process completed with exit code 1.
party parrot 1
this is the command
Copy code
un npm run pact:can-i-deploy --if-present -- --pacticipant participant-test-plan-service --version 98dc2164cc843db389d8ed1ba6e164bbf70ed293 --broker-base-url <https://usertesting.pactflow.io> --broker-token *** --retry-while-unknown=10 --retry-interval=30
s
will check tomorrow morning.
1
d
Hi, let me know when you have time on this today
I would like to know if this is good approach to use the pact-publish for one of the service who has 2 providers
Copy code
for pactfile in responses-tracker-orders-message.json responses-tracker-participant-test-plan-service.json; do
            pact-broker publish ${{ env.pactfiles }}/$pactfile \
              --auto-detect-version-properties \
              --broker-base-url ${{ env.PACT_BROKER_BASE_URL }} \
              --broker-token ${{ env.PACT_BROKER_TOKEN }}
          done
I'm using
--auto-detect-version-properties
here instead
--version
s
can I deply is failing because verification is missing for lastest version. Get the pacts verified by provider for latest branch and should be good I think
y
i would remove the for loop and just publish in one step. ( publish the pact dir not the indiv pact file ) doing it in two steps isnt necessary.
👍 1
d
do you mean like this? @Yousaf Nabi (pactflow.io)
Copy code
pact-broker publish ${{ env.pactfiles }} \
            --auto-detect-version-properties \
            --branch ${{ env.BRANCH_NAME }} \
            --broker-base-url ${{ env.PACT_BROKER_BASE_URL }} \
            --broker-token ${{ env.PACT_BROKER_TOKEN }}
y
yep
d
@Yousaf Nabi (pactflow.io) - I had the same issue again not picking up
participant-test-plan-service
for
orders-message
service. I thought the above change for
responses-tracker
should fix by adding the
--auto-detect
versions
y
show us the view of both services in pactflow. you only have one verification task by consumer version selectors and not url so you never verify when a pact is published
which is also why pacts cant be pre verified and it is failing to find results.
please share a full view of your system as it stands, a view of each service.
d
These are 3 services we are dealing right now
Im working in a branch now by removing the for loop as above for the
responses-tracker
and added the
--auto-detect
flag instead the
--consumer-version
, let me know if you want me to merge that?
🔝
y
no trigger a pact verification for each provider by pact url as advised by the cli output from the publish pact command. this should ideally be done by webhook but you can do it manually. that is how pact ensures there is a verification for your head of your provider. and also provides additional webhooks with the commit sha or any deployed or released versions. why does the latest main of part-test-plan-service not reference orders-message as a provider?
d
So the next step is trigger the verification for each service?
How can i do that manually?
pact-broker verify --provider my-provider --broker-base-url <https://usertesting.pactflow.io> --broker-token <PACT_BROKER_TOKEN>
- is this correct?
@Yousaf Nabi (pactflow.io) can you confirm?
d
Before i do the above, can i make this change to main for
responses-tracker
first? Since we are using
for
loop and
--consumer-version
tag here
why does the latest main of part-test-plan-service not reference orders-message as a provider?
It is disappeared again
Hey @Yousaf Nabi (pactflow.io), for some reason
participant-test-plan-service
looking into the previous version instead the latest, looks like the latest version doesnt have
orders-message
provider verification again? Is it worth removing the latest version?
Looks like we have an issue triggering the webhook manually as a test from UI here, it is sending 10-20 triggers at the same time to github actions workflow, is this known issue?
@Yousaf Nabi (pactflow.io) quick check here for
participant-test-plan-service
, right now
orders-message
doesnt run verifications unless if the consumer
participant-test-plan-service
merged something on their main. Why is that? It doesnt happen to other consumers with orders-message but only with this service thinking
@Yousaf Nabi (pactflow.io), can you confirm when you have a moment 🔝