Open ims-swilkinson opened 1 year ago
Hey @ims-swilkinson
can you confirm if the request was to verify a pact by URL, to be fetched from a broker (with a view to verify, and optionally publish the results back) as a result of webhook triggered provider jobs
https://docs.pact.io/pact_broker/webhooks#events
or was there also a request to be able to read files from a local file system (in which case, using a named function verify_with_broker
- it wouldn't make sense to publish results of local files verification to a broker, unless it was retrieved from the broker.
Hopefully we can clarify and then get this feature out to you!
So there are at least three use cases for verifying
and 4 file sources
Rust distinguishes between file and dir, I would need to test if the ruby provider verifier will also accept a dir as as a arg (assume it will)
To verify a pact at a known URL (eg. when a verification is triggered by a 'contract content changed' webhook), pass in the pact URL(s) as the first argument(s) to the command, and do NOT set any of the other parameters apart from the base URL and credentials.
--pact-broker-base-url=PACT_BROKER_BASE_URL
Verify a local file, provided by a file or dir, verification results should never be published and therefore this step does not require a broker
Verify a pact from a remote url, which will be retrieve from a pact broker, for a contract that has changed and requires verification.
This step may publish verification results back to a broker, but this should really only be done in CI (it is traditionally user toggleable, and hooked up to an IS_CI
or similar env var in their CI flow
note - this step does not require additional pact broker options
Verify remote pacts, provided by querying the Pact Broker via consumer version selectors, verification results may be published
IS_CI
or similar env var in their CI flowPact Python appears to
verify_with_pact_url
or verify_with_pact_uri
or similar naming, which is similar to verify_with_broker
verify_with_pact_url
can then only accept parameters relevant for that purposeverify_with_broker
signature remains unchangeduses these options
const opts = {
...baseOpts,
pactUrls: [process.env.PACT_URL],
stateHandlers: stateHandlers,
requestFilter: requestFilter
};
const fetchPactsDynamicallyOpts = {
provider: 'pactflow-example-provider',
consumerVersionSelectors: [
{ mainBranch: true },
{ deployed: true },
{ matchingBranch: true }
],
pactBrokerUrl: process.env.PACT_BROKER_BASE_URL,
// https://docs.pact.io/pact_broker/advanced_topics/pending_pacts
enablePending: true,
// https://docs.pact.io/pact_broker/advanced_topics/wip_pacts
includeWipPactsSince: '2020-01-01'
};
const opts = {
...baseOpts,
...fetchPactsDynamicallyOpts,
stateHandlers: stateHandlers,
requestFilter: requestFilter
};
There is some commonality between the modes the verifying with a broker
https://github.com/pactflow/example-provider/blob/master/src/product/pact.setup.js
const baseOpts = {
logLevel: "INFO",
providerBaseUrl: "http://localhost:8080",
providerVersion: process.env.GIT_COMMIT,
providerVersionBranch: process.env.GIT_BRANCH, // the recommended way of publishing verification results with the branch property
verbose: process.env.VERBOSE === "true",
};
so this func
should probably have never allowed for setting wip pacts, or enable pending if its not for verifying with a broker.
There is a function called verify_with_broker
, one would assume for that reason.
I've given this a go in #356
I am not a pythonista at all, so happy for reviews, feedback, additional commits 👍🏾
Hey @ims-swilkinson
can you confirm if the request was to verify a pact by URL, to be fetched from a broker (with a view to verify, and optionally publish the results back) as a result of webhook triggered provider jobs
https://docs.pact.io/pact_broker/webhooks#events
or was there also a request to be able to read files from a local file system (in which case, using a named function
verify_with_broker
- it wouldn't make sense to publish results of local files verification to a broker, unless it was retrieved from the broker.Hopefully we can clarify and then get this feature out to you!
Sorry for the late reply. Yes this is for verifying using the URL passed in a webhook request, not for local files.
Thanks. Would you be up for a PR as per Yousaf's comments?
I'm using
pact-python
version 1.7.0. There doesn't seem to be a way to verify with a specific pact by passing in a pact URL.I tried passing a
pact_url
kwarg intoMessageProvider.verify_with_broker
but this always gives me the errorpact.verify_wrapper.PactException: Pact urls or Pact broker required
.