Alan Boshier
04/19/2023, 11:01 AMabsolute-version
to get the version V of X and then do something like this:
./pact-broker can-i-deploy --to-environment=E --pacticipant=X --version=V
However, if my consumer contracts that X relies on are inside the library L, I assume the equivalent check would be (assuming L is at versions Lv, and that X doesn't have any consumer contracts of its own):
./pact-broker can-i-deploy --to-environment=E --pacticipant=L --version=Lv
To make this work, my deployment script for X needs to know the "pact identity" of the library L (which is not a big deal), but also needs to know the the "pact version" of L.
Typically I have used "git version" for pact versions (i.e. something based on the branch+tag+commits_since_tag) as that unambiguously defines the code state of the pacticipant. In that setup, my deployment script just uses npx absolute-version
to compute V.
In the case of a library being the pacticipant, that technique isn't going to work (since the script in running in a git repo for X, not L). This would mean that L would need a different pact versioning approach that
didn't rely on git state (e.g. a maven version or an node package version of the library component itself).
Such versions must change if the contracts change in any way; in the git versioning approach above this happens automatically, but in the maven/package versioning approach I must increment the version when I make contract-changing modifications to the library. And then ensure that new version is incorporated into my deploy script for X.
Does that sound like the right approach, or are there better ways to approach this? tiaTimothy Jones
04/19/2023, 12:43 PMTimothy Jones
04/19/2023, 12:46 PMTimothy Jones
04/19/2023, 12:47 PMdeployment
in that you can have multiple releases of that application out in one environment.Timothy Jones
04/19/2023, 12:49 PMrecord-support-ended
Alan Boshier
04/19/2023, 12:53 PMTimothy Jones
04/19/2023, 12:55 PMTimothy Jones
04/19/2023, 12:59 PMabsolute-version
! Maybe I can ask you a couple questions if you don’t mind -
1) In semver, the prerelease information (between the -
and the +
) is supposed to define an order - to this end, I’m thinking I should move the commits since release to be after the branch name. It’s not an exact ordering, because two copies of the same branch might have the same number of (different) commits. This would of course be a breaking change. Do you think it’s an improvement?
2) I’m thinking of replacing the SNAPSHOT
string with DIRTY
so that it better reflects the purpose. What do you think?
3) Would a strict mode where it would fail if there was no tags found be useful to you?Alan Boshier
04/19/2023, 1:16 PM2.2.0-develop+2.97baa48
isn't the commits since release (2
) already after the branch name (develop
)?
That said, from my own perspective I don't think the current format is an issue for the way we are operating with pact, so I would be wary of any changes that broke existing behaviours.
On the subject of absolute-version
, the thing I struggled with was the impact of tagging a release in git on version numbers; e.g. with the above example adding a no-change release tag of 2.2.1
to the develop
branch means that the versions 2.2.0-develop+2.97baa48
and 2.2.1-develop
are "identical" in contract terms but it took a bit of thinking through to deal with that explicitly in build/deploy scripts.Timothy Jones
04/19/2023, 1:31 PM2.0.0-develop.2+97baa48
, because the prerelease part is supposed to define an ordering, but the build metadata after +
doesn’t. I do agree, though. I don’t like the idea of mucking with the format too much.
the impact of tagging a release in git on version numbersAh yeah. That’s something I’ve been meaning to call out in the documentation. It’s absolute in that each version number identifies (in a human readable way) one specific unique place in the repository history. But one specific unique place in the history might have more than one absolute-version.
Timothy Jones
04/19/2023, 1:31 PMTimothy Jones
04/19/2023, 1:35 PMare “identical” in contract terms but it took a bit of thinking through to deal with that explicitly in build/deploy scripts.There’s a neat Broker subtlety too - if you upload identical contracts, it doesn’t need to re-verify them. But you’re right in that if you go: • Publish contract • Bump version • Can-i-deploy Then the broker will say it doesn’t know that version 😕
Alan Boshier
04/19/2023, 1:38 PM.
and +
in the version string at that point, I would avoid breaking it if it doesn't need fixing.
Or, add a new optional switch to absolute-version
which can force the new format if there are important justifications for it?Timothy Jones
04/19/2023, 1:42 PM--strict
option). The use case for the .
to +
change is if anyone is using the between-release versions to (slightly inaccurately) programatically reason about which version is more recent. One advantage of leaving it like it is is that people won’t be encouraged to do that 😂
Thanks for the chat. I reckon I’ll leave it as-is.Timothy Jones
04/19/2023, 1:42 PM