Hi All, What are the best practices for provider v...
# general
t
Hi All, What are the best practices for provider versioning? Is it possible to make the versioning dynamic? I went through the docs that recommend appending the commit sha to the version but how do you decide whether it should be v1 or v2 dynamically or does the developer need to update the Provider version on each change to the provider? ref-https://docs.pact.io/getting_started/versioning_in_the_pact_broker Any help will be appreciated!
👋 1
m
The version can be really whatever you want, but it definitely needs to be automated. Every single time you change the provider, the version should change. Hence why we recommend the SHA. It also needs to be able to be reproduced (e.g. when you run other commands). The version of the provider must therefore be stable
t
Thanks for the speedy response @Matt (pactflow.io / pact-js / pact-go) So I am a bit unclear ...At present, when I verify a contract from the provider end, I manually enter the provider version, update it when it is a major change in the api. (Sample go code for the same) I was thinking of making this version dynamic but how to identify if the change is a major update eg:api update or a minor patch. FYI I am a newbie to pact
Copy code
_, err := pact.VerifyProvider(
		s.T(),
		types.VerifyRequest{
			ProviderBaseURL:            providerBaseURL,
			PactURLs:                   []string{"<http://pactbroker-gamma.comp-tech.net:9292/pacts/provider/agent_template/consumer/gemini/latest>"},
			CustomProviderHeaders:      []string{customHeader},
			PublishVerificationResults: true,
			ProviderVersion:            "1.0.0",
			BrokerUsername:             brokerUsername,
			BrokerPassword:             brokerPassword,
		},
	)
m
OK cool. This versioning is unrelated to Pact. It’s the version of your code. Some teams like to use versions like
x.y.z
(semver) but this is no use in Pact, because each version could map to different commits - some of which may or may not be compatible with other things. If you’re confused about what to put here, don’t overthink it - just put your git sha in there
✅ 1
At the top the TL;DR is what I’d follow:
To avoid race conditions, the application (pacticipant) version number that is used to publish pacts and verification results should either be or contain the commit (ie. the git SHA or equivalent for your version control system).
thankyou 1
^ I wrote this tool to solve this problem nicely
🙌 1