Carlos V
02/20/2024, 10:45 AMComputer says no
on can-i-deploy
. Steps taken on thread.Carlos V
02/20/2024, 10:46 AMVERSION=1.0.0 CI=true PACT_BROKER_BASE_URL=<http://localhost:9292> make test
2. Provider test selector:
ConsumerVersionSelectors: []provider.Selector{
&provider.ConsumerVersionSelector{
MainBranch: true,
},
&provider.ConsumerVersionSelector{
DeployedOrReleased: true,
},
&provider.ConsumerVersionSelector{
MatchingBranch: true,
},
},
3. pact-broker create-or-update-version --broker-base-url "<http://localhost:9292>" --pacticipant provider-service --version 1.0.0
4,
pact-broker can-i-deploy --broker-base-url "<http://localhost:9292>" --pacticipant provider-service --to-environment dev --version 1.0.0
5. Computer says yes \o/
6. There are no missing dependencies
7. pact-broker record-release --pacticipant provider-service --version "1.0.0" --environment dev --broker-base-url "<http://localhost:9292>"
Recorded release of provider-service version 1.0.0 to dev environment in the Pact Broker.Carlos V
02/20/2024, 10:48 AMpact-broker publish "./backend/pacts/" --consumer-app-version 1.0.0 --branch "master" --broker-base-url "<http://localhost:9292>"
2. pact-broker create-or-update-version --broker-base-url "<http://localhost:9292>" --pacticipant consumer-service --version 1.0.0
3. Created/updated pacticipant version 1.0.0 in the Pact Broker
4. pact-broker can-i-deploy --broker-base-url "<http://localhost:9292>" --pacticipant consumer-service --to-environment dev --version "1.0.0"
Computer says no ¯\_(ツ)_/¯
CONSUMER | C.VERSION | PROVIDER | P.VERSION | SUCCESS? | RESULT#
---------------------|-----------|-------------------------|-----------|----------|--------
consumer-service | 1.0.0 | provider-service | ??? | ??? |
There is no verified pact between version 1.0.0 of consumer-service and the version of provider-service currently in dev (1.0.0)Yousaf Nabi (pactflow.io)
Carlos V
02/20/2024, 11:21 AMYousaf Nabi (pactflow.io)
Carlos V
02/20/2024, 11:33 AMmake test
on the provider would run this go test, wouldn’t this handle that verification:
err := verifier.VerifyProvider(t, provider.VerifyRequest{
BrokerURL: os.Getenv("PACT_BROKER_BASE_URL"),
ProviderBaseURL: "http://" + serverAddress,
PublishVerificationResults: os.Getenv("CI") == "true",
ProviderVersion: os.Getenv("VERSION"),
ProviderBranch: "master",
Provider: "provider-service",
ConsumerVersionSelectors: []provider.Selector{
&provider.ConsumerVersionSelector{
MainBranch: true,
},
&provider.ConsumerVersionSelector{
DeployedOrReleased: true,
},
&provider.ConsumerVersionSelector{
MatchingBranch: true,
},
},
})
Carlos V
02/20/2024, 11:33 AMYousaf Nabi (pactflow.io)
MainBranch
consumer version selector, but that would rely on you running that provider verification job again (either manually) or on the next provider change, in order for it to verify it and publish results.
that time gap for feedback is usually too long, which is why you have a task utilising webhooks, your verification task should accept a pactUrl and if one exists not pass any consumer version selectors to the broker. This is a verification triggered by a pact change.Carlos V
02/21/2024, 9:19 AM❯ pact-broker publish "./backend/pacts/" --consumer-app-version 1.0.0 --branch "master" --broker-base-url "<http://127.0.0.1:9292>"
Updated consumer-service version 1.0.0 with branch master
Pact successfully republished for consumer-service version 1.0.0 and provider provider-service with no content changes.
View the published pact at <http://127.0.0.1:9292/pacts/provider/provider-service/consumer/consumer-service/version/1.0.0>
Events detected: contract_published, contract_requiring_verification_published
Next steps:
* Add Pact verification tests to the provider-service build. See <https://docs.pact.io/go/provider_verification>
* Configure separate provider-service pact verification build and webhook to trigger it when the pact content changes. See <https://docs.pact.io/go/webhooks>
Provider:
❯ VERSION=1.0.0 CI=true PACT_BROKER_BASE_URL=<http://127.0.0.1:9292> make test
go test -v ./...
=== RUN TestHTTPProvider
⇨ http server started on 127.0.0.1:8080
2024-02-20T10:20:22.394984Z INFO ThreadId(11) pact_verifier::pact_broker: Fetching path '/' from pact broker
2024-02-20T10:20:22.411647Z INFO ThreadId(11) pact_verifier::pact_broker: Fetching path '/pacts/provider/provider-service/for-verification' from pact broker
2024-02-20T10:20:22.442008Z ERROR ThreadId(11) pact_verifier: No pacts found for provider 'provider-service' matching the given consumer version selectors in pact broker '<http://127.0.0.1:9292>': Link/Resource was not found - No pacts were found for this provider
2024-02-20T10:20:22.442563Z WARN ThreadId(11) pact_verifier: Ignoring no pacts error - No pacts found for provider 'provider-service' matching the given consumer version selectors in pact broker '<http://127.0.0.1:9292>'
2024-02-20T10:20:22.442801Z WARN ThreadId(11) pact_matching::metrics:
=== RUN TestHTTPProvider/Provider_pact_verification
--- PASS: TestHTTPProvider (0.45s)
--- PASS: TestHTTPProvider/Provider_pact_verification (0.00s)
PASS
Consumer match version is a few message above.Carlos V
02/21/2024, 9:19 AMYousaf Nabi (pactflow.io)
View the published pact at <http://127.0.0.1:9292/pacts/provider/provider-service/consumer/consumer-service/version/1.0.0>
Carlos V
02/21/2024, 10:51 AMCarlos V
02/21/2024, 10:52 AM&provider.ConsumerVersionSelector{
MainBranch: true,
}
Carlos V
02/21/2024, 10:52 AM