Joel Whalen
09/16/2024, 5:10 PMcan-i-merge
not waiting the full 8 minutes I've set for the retry interval, which is causing it to fail since it isn't waiting for verification status to be published. I've set the arguments retry-while-unknown=25 retry-interval=20
. This used to work before but only broke now, I don't see any changes to how we are invoking the pact cli.
Here is my yaml
command in github actions:
make -sC "${SERVICE_FOLDER}" dev pact_can_i_merge pacticipant=${{ inputs.stack }}-${{ inputs.service }} version=${{ github.sha }} retry-while-unknown=25 retry-interval=20
and pact_can_i_merge
is defined in a makefile like so:
pact_can_i_merge:
$(call compose,$(compose_files),--profile pact_broker run pact-broker-cli pact-broker can-i-merge --pacticipant $(pacticipant) --version $(version) --retry-while-unknown=$(retry-while-unknown) --retry-interval=$(retry-interval))
which is invoking a docker compose that looks like this
pact-broker-cli:
image: pactfoundation/pact-cli:latest-multi
# We only want to run this service in CI, not locally
profiles:
- pact_broker
depends_on:
- test
environment:
PACT_BROKER_BASE_URL: <<https://my-pactflow-url.com>>
PACT_BROKER_TOKEN: ${PACTFLOW_TOKEN}
PACT_CONSUMER_BRANCH: ${PACT_CONSUMER_BRANCH}
PACT_CONSUMER_APP_VERSION: ${PACT_CONSUMER_APP_VERSION}
volumes:
- pacts_data:/pact/pacts
Yousaf Nabi (pactflow.io)
🕙18:57:02 [🧱 INT] ❯ time pact-broker can-i-merge -b <http://localhost:9292> --pacticipant consumer --version foo --retry-while-unknown=5 --retry-interval=1
Waiting for 1 verification result to be published (maximum of 5 seconds)
Computer says no ¯\_(ツ)_/¯
CONSUMER | C.VERSION | PROVIDER | P.VERSION | SUCCESS? | RESULT#
---------|-----------|----------|-----------|----------|--------
consumer | foo | provider | ??? | ??? |
There is no verified pact between version foo of consumer and a version of provider from the main branch (no such version exists)
pact-broker can-i-merge -b <http://localhost:9292> --pacticipant consumer foo 0.16s user 0.07s system 4% cpu 5.414 total
just set it going with your values now (with 1.75.4 of the cli)
time pact-broker can-i-merge -b <http://localhost:9292> --pacticipant consumer --version foo --retry-while-unknown=25 --retry-interval=20
Waiting for 1 verification result to be published (maximum of 500 seconds)
Waiting for 1 verification result to be published (maximum of 500 seconds)
Computer says no ¯\_(ツ)_/¯
CONSUMER | C.VERSION | PROVIDER | P.VERSION | SUCCESS? | RESULT#
---------|-----------|----------|-----------|----------|--------
consumer | foo | provider | ??? | ??? |
There is no verified pact between version foo of consumer and a version of provider from the main branch (no such version exists)
pact-broker can-i-merge -b <http://localhost:9292> --pacticipant consumer foo 0.19s user 0.14s system 0% cpu 8:21.17 total
~ via 🐳 desktop-linux took 8m21s
my broker client is the latest version (running standalone not via docker) I am not the latest broker image howeverYousaf Nabi (pactflow.io)
1.75.4
& 1.76.1
which covers a change around can-i-deploy skipping for dry runs.Yousaf Nabi (pactflow.io)
🕙19:21:25 [🔴 ERROR] ❯ docker run pactfoundation/pact-cli:latest pact-broker can-i-merge -b <http://host.docker.internal:9393> --pacticipant "pactflow-example-consumer" --version 2 --retry-while-unknown=25 --retry-interval=20
Waiting for 1 verification result to be published (maximum of 500 seconds)
Computer says no ¯\_(ツ)_/¯
CONSUMER | C.VERSION | PROVIDER | P.VERSION | SUCCESS? | RESULT#
--------------------------|-----------|---------------------------|-----------|----------|--------
pactflow-example-consumer | 2 | pactflow-example-provider | ??? | ??? |
There is no verified pact between version 2 of pactflow-example-consumer and the latest version of pactflow-example-provider from the main branch (no versions exist for this branch)
example-consumer on master@origin:master via v20.10.0 took 8m22s
Joel Whalen
10/02/2024, 4:00 PMpact-cli
was not the issue, and sorry it took so long for me to come back to this. I figured out the root cause of the issue, and it was not pact: the problem was github actions and the silly workaround we are doing to deal with pact in a monorepo in gha. We have a job named pact-consumer-test
in the monorepo that runs the consumer tests in our monorepo that has these two steps:
- name: Run Consumer Tests
if: inputs.service == 'flow-controller'
env:
PACT_BROKER_BASE_URL: <https://updaterinc.pactflow.io/>
PACTFLOW_TOKEN: ${{ secrets.PACTFLOW_TOKEN }}
PACT_CONSUMER_BRANCH: ${{ github.ref_name }}
PACT_CONSUMER_APP_VERSION: ${{ github.sha }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SERVICE_FOLDER: ${{ github.workspace }}/stacks/${{ inputs.stack }}/${{ inputs.service }}
DOCKER_BUILDKIT: "1"
COMPOSE_DOCKER_CLI_BUILD: "1"
# To support local env files, we must explicitly create this env file here since these variables are NOT being passed in by the docker compose
run: |
echo "PACT_BROKER_BASE_URL=$PACT_BROKER_BASE_URL" >> ${SERVICE_FOLDER}/test/.env
echo "PACTFLOW_TOKEN=$PACTFLOW_TOKEN" >> ${SERVICE_FOLDER}/test/.env
echo "PACT_CONSUMER_BRANCH=$PACT_CONSUMER_BRANCH" >> ${SERVICE_FOLDER}/test/.env
echo "PACT_CONSUMER_APP_VERSION=$PACT_CONSUMER_APP_VERSION" >> ${SERVICE_FOLDER}/test/.env
make -sC "${SERVICE_FOLDER}" service_pact_consumer_test
make -sC "${SERVICE_FOLDER}" pact_consumer_test_publish
shell: sh
- name: Force this job to run for can-i-merge to work in the provider
if: inputs.service == 'normalizer'
run: echo "Pacticipant ${{ inputs.stack }}-${{ inputs.service }} does not require consumer tests to run at this time."
shell: sh
then later in the CI yaml file we have the can-i-merge
job, which has a requirement that pact-consumer-test
runs first:
pact-can-i-merge:
needs:
- pact-consumer-test
The problem is that we added a new provider, which is another service in the monorepo called partner-custom-tasks
, which would skip the pact-consumer-tests
job since this new provider service doesn't have any consumer tests. The fix was to amend the if statement in pact-consumer-tests
with the new provider:
- name: Force this job to run for can-i-merge to work in the provider
# If you're adding a new provider, and it doesn't have any consumer tests, then add it to the if statement here.
if: (inputs.service == 'normalizer' || inputs.service == 'custom-tasks')
run: echo "Pacticipant ${{ inputs.stack }}-${{ inputs.service }} is not a consumer, therefore does not require consumer tests to run at this time."
shell: sh
tl;dr: managing consumers and providers in a monorepo in github actions is tricky because some services are consumers; some services are providers; and some services are both consumers and providers, and github actions doesn't have a great way to deal with the needs
field in these cases.Joel Whalen
10/02/2024, 4:02 PMcan-i-merge
, and then just don't rely on the needs
field at all I suppose