Alan Boshier
07/25/2024, 10:43 AM[{"branch":"develop", "consumer": "foo"}] as my consumer version selector, and the verification test indicated that it was using version 2.37.0 of the pact as the "latest version" from the develop branch of pacticipant foo.
However if I ran this query against the pact broker db:
select p.name, b."name", v."number" from branch_heads bh
inner join pacticipants p on p.id = bh.pacticipant_id
inner join branches b on b.id = bh.branch_id
inner join versions v on v.id = bh.version_id
where p."name" = 'foo'
and b."name" = 'develop'
it returned me the value 2.37.0-develop+5.cb7bd044. (this was what I expected, as it represents the absolute-version of the latest commit on that branch, i.e. 5 commits on from the commit tagged with 2.37.0)
Would the pact broker be using some different logic internally when being asked for latest version on a branch that could explain this discrepancy?
If I then republished the pacts again from the head of the branch, then the consumer version selector correctly returned 2.37.0-develop+5.cb7bd044Matt (pactflow.io / pact-js / pact-go)
Matt (pactflow.io / pact-js / pact-go)
Matt (pactflow.io / pact-js / pact-go)
Alan Boshier
07/25/2024, 11:18 AMdius/pact-broker:2.96.0.0Alan Boshier
07/25/2024, 11:21 AMabsolute-version.Matt (pactflow.io / pact-js / pact-go)
Matt (pactflow.io / pact-js / pact-go)
absolute-version , if it were semver ordered then I could imagine it might be expected to work differently (possibly)Alan Boshier
07/25/2024, 11:22 AMMatt (pactflow.io / pact-js / pact-go)
Alan Boshier
07/25/2024, 11:27 AM2.37.0. At this point absolute-version reports the version to be 2.37.0 as expected and my release pipeline publishes the pacts from that commit with this version.
Of course, due to the way absolute-version works, this in effect changes the version of the pacts currently at the "head" of the develop branch, because everything is calculated as an offset from the last release-tagged commit.
e.g. if the version representing the head was 2.36.5+11, and the release tag 2.37 is applied to the commit with version 2.36.5+7, then the current head becomes "re-versioned" to 2.37+4.Matt (pactflow.io / pact-js / pact-go)
Matt (pactflow.io / pact-js / pact-go)
Alan Boshier
07/25/2024, 11:29 AM2.37.0 is the latest, I guess I was offered false encouragement that SQL returns me what I really wanted as the latest 2.37.0-develop+5.
That feels to me that something inside the pact broker is calculating the latest in a different way.Alan Boshier
07/25/2024, 11:32 AMabsolute-version works is something of a headache; from what you are saying the move is away from anything other than date-ordering on versions, so it feels like whatever I do has to live in that world.Matt (pactflow.io / pact-js / pact-go)
Matt (pactflow.io / pact-js / pact-go)
Alan Boshier
07/25/2024, 11:39 AMabsolute-version doesn't guarantee immutable versioning due to its offset-related behaviour, in that the same git commit can map to different versions over time as previous commits are tagged.
So I guess I'm faced with two possible ways forward:
• come up with some versioning scheme that is immutable, or;
• continue to use absolute-version, but when a commit is retrospectively tagged with a release, come up with some way of telling the pact-broker "hey, what you thought was version X is now version Y"
On the latter approach, I guess just republishing the pacts at the head of the branch after a retrospective tagging would suffice.
But it would be interesting to know what others do who rely on absolute-version.Matt (pactflow.io / pact-js / pact-go)
Alan Boshier
07/25/2024, 11:50 AM