pact-foundation / pact-js

JS version of Pact. Pact is a contract testing framework for HTTP APIs and non-HTTP asynchronous messaging systems.
https://pact.io
Other
1.59k stars 343 forks source link

No new version of Provider published #576

Closed m-radzikowski closed 3 years ago

m-radzikowski commented 3 years ago

Issue Classification

Bug Report

Software versions

Behaviour

I'm implementing the CI/CD flow for the Pact Provider and Consumer and I have 2 problems, maybe somehow related.

The CI/CD is common for both services, but some steps do not run if not needed. The flow is:

This is slightly different from the flow in docs, but needed to make compromises.

Now, I try to deploy both Provider and Consumer for the first time. I'm using pactflow as a broker, which is initially empty.

When I run CI for the Provider, it breaks on can-i-deploy, because no contracts are available yet.

$ ts-node pactVerifier.ts
250 | [2021-01-14T10:22:38.726Z]  INFO: pact@9.14.0/665 on 2a9fb392732c: Verifying provider
251 | [2021-01-14T10:22:38.734Z]  INFO: pact-node@10.11.1/665 on 2a9fb392732c: Verifying Pacts.
252 | [2021-01-14T10:22:38.735Z]  INFO: pact-node@10.11.1/665 on 2a9fb392732c: Verifying Pact Files
253 | [2021-01-14T10:22:41.829Z]  INFO: pact-node@10.11.1/665 on 2a9fb392732c: Pact Verification succeeded.

$ /...path/node_modules/.bin/pact-broker can-i-deploy -a 'My Provider' -b https://company.pactflow.io -k secret --to dne-132 --version 1.0.0-4fd8338f4927bb26430300fb0c90c1c58a866c48
272 | Computer says no ¯\_(ツ)_/¯
273 |  
274 | No pacts or verifications have been published for version 1.0.0-4fd8338f4927bb26430300fb0c90c1c58a866c48 of My Provider

I was looking into pact broker repo and found this issue and this commit that seem to solve this problem, but yet I'm still facing it.

So what I did was:

  1. Deploy Provider - runs verify but fails on can-i-deploy (log above)
  2. Deploy Consumer - publishes contracts but also fails on can-i-deploy
  3. Re-deploy provider - now can-i-deploy passes

Then I merged Provider to master which triggered a new build. I expected it to do the verification and pass. But for some reason, although in VerifierOptions I have publishVerificationResult: true, it seems like the new version was not published to pactflow. In UI I don't see the new version (there is only the one with pre-merge commit, the one with merge commit is missing), and the CI/CD failed on adding a tag:

243 | [2021-01-14T15:18:55.182Z]  INFO: pact@9.14.0/665 on 35ef670ecd55: Verifying provider
244 | [2021-01-14T15:18:55.192Z]  INFO: pact-node@10.11.1/665 on 35ef670ecd55: Verifying Pacts.
245 | [2021-01-14T15:18:55.194Z]  INFO: pact-node@10.11.1/665 on 35ef670ecd55: Verifying Pact Files
246 | [2021-01-14T15:18:58.423Z]  INFO: pact-node@10.11.1/665 on 35ef670ecd55: Pact Verification succeeded.

...

264 | $ /...path/node_modules/.bin/pact-broker create-version-tag -a 'My Provider' -b https://company.pactflow.io -k secret --version 1.0.0-97e77f7d0a5a3326f37cb735def87470aa663be4 --tag test

269 | Could not create tag. Version 1.0.0-97e77f7d0a5a3326f37cb735def87470aa663be4 of My Provider does not exist.

So, I guess my problem is partially about pact broker, partially about pact-js and publishing verifier results, and maybe partially about the CI/CD flow. Can you point me to what can be the problem(s) here?

bethesque commented 3 years ago

We need more logs from the merge build to see if/why/why not the verification results from that merge build were published. Do you have the output from the build that worked that showed the tags being created and the results being published?

m-radzikowski commented 3 years ago

Ok, you know, I created a simple reproduction repo of the problems I'm facing. In fact, I have problems with verifying the Provider for the first time. I think the fact I didn't see the Provider version update could be my fault with how I have tags set up.

The repo with reproduction and description of problems with deploying Provider for the first time: https://github.com/m-radzikowski/pact-js-issue576

Please tell me if I should create a separate ticket for it in a different repo (or move it if needed and possible).

bethesque commented 3 years ago

Create a separate ticket in the Pact Broker repository please.

m-radzikowski commented 3 years ago

Created: https://github.com/pact-foundation/pact_broker/issues/372