Hi guys I published my pact with producer and cons...
# general
g
Hi guys I published my pact with producer and consumer currently it is tag to my pull request branch do I need to tag it to my
main
as well ? how should I organise this?
m
I'm not sure I follow the question But to use branches, you would set the branch in the Pact CLI publish command (consumer side) and on the verification options (provider side)
Howtocli
g
so the above is the pacts I published from my CI successfully but when I created another branch my tests is failing because of
Copy code
2023-07-28T03:52:17.177190Z ERROR ThreadId(03) pact_verifier: Failed to load pact - Could not load pacts from pact broker 
Link/Resource was not found - No pacts were found for this provider
thats why im curious if I need to tag my pacts to
main
so the other pull request running CI can verify on
m
How are you telling the provider build to discover the pacts?
What's the configuration?
g
this is how my provider is configured
Copy code
const p = new MessageProviderPact({
    messageProviders: {
      'publish generate keypair': providerWithMetadata(
        async () => {
          const mockKeypair = {
            keyPair: {
              publicKey: {},
              privateKey: {},
            },
            expiration: 1721191988872,
            notBefore: 1689655988872,
            kid: '68d371b2-0b1e-4921-9f03-06987f3645a1',
            alg: 'ES256',
          };
          return getGenerateKeypairEvent({ result: mockKeypair });
        },
        {
          'content-type': 'application/json',
        }
      ),
    },
    logLevel: LOG_LEVEL as LogLevel,
    provider: 'KafkaGenerateKeyPairProvider',
    ...(BROKER_URL
      ? {
          // Broker validation
          pactBrokerUrl: BROKER_URL,
          pactBrokerUsername: process.env.PACT_BROKER_USERNAME,
          pactBrokerPassword: process.env.PACT_BROKER_PASSWORD,
          providerVersionBranch: process.env.GIT_BRANCH,
        }
      : {
          // For local validation
          pactUrls: [path.resolve(process.cwd(), 'pacts')],
        }),
    consumerVersionSelectors: [
      {
        matchingBranch: true,
      },
    ],
  });
m
Do the branches line up?
I'd also recommend using the setup here if you missed it: https://docs.pact.io/pact_broker/advanced_topics/consumer_version_selectors#recommended
g
where do I set it for the pact_broker ? Im using the pact-broker cli to publish currently
Copy code
pact-broker publish pacts
        --verbose --consumer-app-version $$BUILDKITE_COMMIT
        --tag-with-git-branch
or is this something I configure when deploying my pact-broker container?
m
I'm asking if the provider's branch matches the consumer's
g
nope it doesnt the provider is tagged on a separate branch so is the consumer
m
So the matching branch selector won't work for you
Have a read of the above guide, it should help
The issue is you're saying "find all pacts that use the same branch as me" but there are no pacts with the same branch name
I'd also highly recommend the CI/CD guide: howtolearn
s
Here are a number of useful hands-on labs that teach all of the key concepts: https://docs.pactflow.io/docs/workshops and https://docs.pact.io/implementation_guides/workshops
g
alright thanks Matt will check it out! would you also know any pacts examples done using https://buildkite.com/?
m
We'll, we use it at PactFlow but nothing publi
It should matter the CI you use
g
yep all good mate I will implement the concepts 👌 thanks!
🙌 1