Hi all does anyone have any experience on how to s...
# pactflow
n
Hi all does anyone have any experience on how to set this webhook up? https://docs.pact.io/pact_broker/webhooks/template_library#github---publish-commit-status I tried setting it up in pactflow but am not entirely sure how. What I want is that when the provider verification github workflow that is triggered by the consumer PR either fails or passes, it sends some response to the consumer PR saying that the verification step either passed or failed but having a hard time setting it up.
b
@Noor Hashem what problem are you noticing?
n
Well i've followed the docs here on how to set up the
Contract published that requires verification
webhook and that works great. But for the other webhooks i'm unclear on a few things: 1. Which webhook is the correct one for me to use if I want some kind of status on the consumer PR after the webhook triggers a provider verification github workflow. I was thinking to use the
Verification results published (with any status)
but i'm not sure if this is the correct one for what I want because I also see others like this one here which sound like they do what i want "Report the pact verification status back to the consumer project in Github." 2. After finding the correct webhook, some of them as for a username and password, i'm not too sure what that username and password should be. I think my first step is to find the correct webhook for the job. Does there exist a webhook that actually sends back some kind of status on the consumer PR after the verification step is finished?
b
You’ll want to trigger it for contract published and verification results published, because you won’t always get verification results published if the pact hasn’t changed.
Unfortunately, you’ll need to use a personal access token to authenticate with the Github API, because we haven’t added first class support for integrating with Github yet.
n
Okay so i'd use the two checked in the image attached? And will those send the result back to the consumer PR?
b
if you have the body right
and the auth
from memory, there are some edge cases around the names of the github status check
see if you can put the branch name of the provider in the title
I remember there being some issues with it, but I haven’t re-tested it since adding support for branches.
n
Okay, so i'm currently trying to use this here: https://docs.pact.io/pact_broker/webhooks/template_library#github---publish-commit-status And I have configured it with the image below. But getting the error in the file attached. So I think there might be two issues. The first is that the url they are asking for is this:
"<https://api.github.com/repos/><organization>/<project>/statuses/${pactbroker.consumerVersionNumber}"
I am not too sure what
<project>
would be in my case, from researching I just put the repo name. But the main issue is this error:
Copy code
"message":"No commit found for SHA: 8700f0d",
I think that might be because the commit is on the consumer PR not on master of the consumer repo so it cannot locate it?
b
Can you see if the SHA exists in github by going to https://github.com/<ORG>/<repo>/commit/8700f0d
<https://github.com/ApplyBoard/platform_monorepo_ui/commit/8700f0d>
n
So the page does not exist but I think it is because the url needed is:
<https://github.com/ApplyBoard/platform_monorepo_ui/pull/4500/commits/8700f0d74b44d2af3d7c6d27e2f0e5dbec74b598>
Needs both the PR and commit ids
b
usually the short sha works
is it from another repo?
does the full commit work?
is this a PR from a fork?
n
That link ^ does work, it does not take me to the actual commit itself but takes me to a page attached. This is a PR from a regular repo at our company so no not a fork
b
hm
you don’t have a branch called that SHA do you?
because that icon looks like a branch name
message has been deleted
that’ll be why the short sha doens’t work.
n
Oh no, the branch has a name of
testing_pactflow_webhooks_flow
I am going to try and use the full git hash just in case that is causing any issue
b
click on the branch icon in that screen
I’m really sure that’s a branch
message has been deleted
if it’s a commit, you get a commit page
n
Yes so I got it, my url had
/commits
instead of
/commit
so now i get back the actual commit
b
ah, yes, I can repro that now
so, I wonder if the API needs the full git SHA
n
Yes let me try now
b
Can
’t download the screenshot for some reason
on mobile wifi
n
Not a problem
Im testing it out now and can let you know if it works in 3 mins 🙂
👍🏼 1
So looks like it is working, going to test it a bit more but I can see this message on the PR. this is just one thing. So if I change the consumer expectation it makes a new contract and the can-i-deploy rightfully fails because there is no verification for that version of the pact until the webhook triggers the provider verification github workflow, then we get back the green status show in the image attached on the PR but the can-i-deploy still shows a failing sign on the PR so kind of contradicting.
I know that might be a little confusing ^ so let me know if I can clarify 🙂
Thanks for the help so far Beth!
b
I think you’re going to want to put the provider branch name in the context
👀 1
otherwise, builds from diffefrent branches will overwrrite each otehr.
I’m not at all 100% that you’ll get the expected results unfortunately, because it really needs a proper github aware integration, rather than a generic webhook. but see how you go.
n
Oh okay I will test it out tomorrow as it is late in my timezone! Will update the threads here so that others can know how to do it as well.
b
@Noor Hashem how did you go with this?
n
Hey Beth! Sorry for such a late reply. Took some time off. So things do seem to be working fine with just the integration that you've sent over, i have added the provider branch name to the context. So far I have not run into any issues but that is mainly because I work on one PR and one branch at a time.
b
I’m glad it’s working for you.
Are there any docs you think should be updated?
Would you be interested in submitting a PR with any improvements?
n
Let me review the docs and see where/if there is room for improvements for this step
b
Thanks!