Cyrus Devnomad
10/27/2023, 11:55 AMMatt (pactflow.io / pact-js / pact-go)
Cyrus Devnomad
10/30/2023, 12:11 PMMatt (pactflow.io / pact-js / pact-go)
Matt (pactflow.io / pact-js / pact-go)
mainBranch, deployedOrReleased etc.) of the consumer. This happens when a new consumer or provider contract is pushed.
These have to happen asynchronously and within PactFlow, otherwise the publish command would be held up. In these cases, you would get this result.
This is not a problem for pure Pact testing, because the verification is done when the provider runs a build, so the result is either not published or published - never in betweenCyrus Devnomad
11/01/2023, 9:08 AMMatt (pactflow.io / pact-js / pact-go)
Cyrus Devnomad
11/01/2023, 5:12 PMMatt (pactflow.io / pact-js / pact-go)
record-deployment then you are not using the releases - best to check if you are. Releases are for things like mobile, where you might have multiple versions live in the wild. Most of the time, you wouldn’t need this. See https://docs.pact.io/pact_broker/recording_deployments_and_releases
The concern is how this time might increase as our system becomes more complex, will we be faced with delays of minutes or tens of minutes?I understand, I’d need to check with the dev team to fully understand if this is something to be worried about. How is your pipeline currently configured? At what point does the OAS get published? Perhaps a simple fix is to move it earlier into the pipeline, it sounds like you publish the OAS and immediately check
can-i-deploy .Cyrus Devnomad
11/03/2023, 11:27 AMrecord-deployment then you are not using the releases -
Yes, we are using record-deployment, so we shouldn’t have those released versions.
> How is your pipeline currently configured? At what point does the OAS get published?
We have two pipelines for each service. A build and a deployment pipeline. The publishing of the provider and/or consumer OAS/pact file happens in the build pipeline shortly after the actual build. The can-i-deploy step happens in the deployment pipeline that is triggered immediately after the build pipeline is done. So can-i-deploy is executed, depending on the service, around maybe 30..40 seconds after the publishing command.
> Perhaps a simple fix is to move it earlier into the pipeline, it sounds like you publish the OAS and immediately check can-i-deploy .
The publishing command is executed around 15..20 seconds after the actual build, so maybe there is indeed some potential to place it a bit earlier and closer to the actual build. I will try to bring up this idea in the team.
> I don't think all branches are included, no.
What I see is that whenever we publish a new OAS version, there are new entries in the matrix view for many branches, many of them no longer existing in our DevOps repository. So, it seems that we have some old branches around in the Pactflow that cause unnecessary compatibility checks? The question is how are old branches supposed to disappear from Pactflow? Or are they supposed to remain there for recording reasons? And if they remain there won’t they cause more and more compatibility checks whenever new pact or OAS files are published?Matt (pactflow.io / pact-js / pact-go)
What I see is that whenever we publish a new OAS version, there are new entries in the matrix view for many branches, many of them no longer existing in our DevOps repository. So, it seems that we have some old branches around in the Pactflow that cause unnecessary compatibility checks? The question is how are old branches supposed to disappear from Pactflow? Or are they supposed to remain there for recording reasons? And if they remain there won’t they cause more and more compatibility checks whenever new pact or OAS files are published? (edited)I’ll follow this up. There is a new endpoint that can be used to delete old branches, perhaps that could be something to look into. Let me get back to you in a few days.
Matt (pactflow.io / pact-js / pact-go)
Matt (pactflow.io / pact-js / pact-go)
Matt (pactflow.io / pact-js / pact-go)
name: Clean up application branch in Pactflow
on:
delete:
branches:
- "*"
jobs:
delete-branch-in-pactflow:
name: delete
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: ruby/setup-ruby@v1
- name: Clean up branch for application pactflow-application-saas in Pactflow
run: script/ci/clean-up-pactflow-branch.sh
env:
PACTFLOW_TOKEN: ${{ secrets.PACTFLOW_TOKEN }}
GIT_BRANCH: ${{ github.event.ref }}
The script (needs better error handling!):
#/bin/bash
set -Eeuxo pipefail
APPLICATION="your-app"
PACTFLOW_URL="<https://YOUR_TENANT.pactflow.io>"
echo "Deleting branch ${GIT_BRANCH} for ${APPLICATION} in Pactflow"
ENCODED_GIT_BRANCH=$(echo "$GIT_BRANCH" | ruby -e "require 'erb'; puts ERB::Util.url_encode(ARGF.read.chomp)")
BRANCH_URL="${PACTFLOW_URL}/pacticipants/${APPLICATION}/branches/${ENCODED_GIT_BRANCH}"
curl -X DELETE $BRANCH_URL -H "Authorization: Bearer ${PACTFLOW_TOKEN}"Matt (pactflow.io / pact-js / pact-go)
Cyrus Devnomad
01/11/2024, 9:06 AMMatt (pactflow.io / pact-js / pact-go)