Hi Team ! I’m using Pact on my NodeJs project. My ...
# pact-js
p
Hi Team ! I’m using Pact on my NodeJs project. My project is generating
dist
folder on GithubActions CI, and also Pack JSON files on
pact
folder. How do you share those JSON files between repositories in Github ? You are using releases or some other method ?
t
Usually you would use the pact broker. Have a look in the documentation at pact.io
There’s a docker image if you want to host your own. Or, if you want an easy and quick setup, the fine folks at pactflow do a SaaS broker. You can find them at pactflow.io
p
Thank you for your response 🙂 I’m looking rather for something on github. This are only Json files - we do not want to introduce new tool in our system 🙂
t
The broker provides about half the value of pact- it is what enables the deploy safety check
If you don’t want to introduce your own build services, then I’d recommend the pactflow hosted broker.
p
Yes i know that solution, we will consider that as well 🙂 Question Was about Github itself Few minutes ago I was able to create release only for pact using
yarn pubish
. This is something that is acceptable Second option is to use S3 bucket which we already using for other files. But maybe you also have another options using Github
t
I don’t understand the question, sorry.
p
Sorry, let me rephrase that for you 🙂 We want to share contract files using only CI - Github and Github Actions - Do you have any recomendations / examples how to do that ?
t
Aha, I understand. My first recommendation is don’t do it that way, as without a Broker you will lose the ability to reason about deploy safety (which is a key part of the value of pact tests) Otherwise, I would check the GitHub actions documentation for sharing build artefacts between workflows
p
Thank you for response 🙂 Its not possible to share artifacts between repositories. In my question I was referring to this point of Pact docs: https://docs.pact.io/getting_started/sharing_pacts#3-use-githubbitbucket-url I though that you have any examples of implementation
t
Ah right. I think that means committing the pact into the consumer repo, and then downloading it in the provider repo.
I’m not aware of any examples, I’m afraid. It’s definitely not the recommended way - teams doing this typically do it only for a week or two
p
Got it 🙂 Thank you For help !
y
I would probably have an event that triggers a workflow in another repository, on change of your pacts folder https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows but being aware of the caveats of what you will lose https://docs.pact.io/pact_broker#can-i-use-pact-without-a-pact-broker
• ensure that your contract tests have passed successfully before deploying a consumer or provider application (can-i-deploy)
• ensure that the provider verification takes place every time a pact changes (webhooks)
• ensure backwards compatibility between services is maintained (branches/tags)
• allow contracts to change without breaking provider builds (pending pacts)
You would need to roll your own for these. You may find that actually sharing contracts and validating them without using Pact at all, would probably provide you more benefit, without introducing another tool (Pact) into the mix, without its counterpart (the Pact Broker)