danger / Peril

Adding support for PR push events

Adding support for PR push events

April 13, 2018 · 4:04pm(Edited 2 months ago)
I'm running into a problem with Danger: it doesn't run for PRs from forks because we don't allow our secrets to be used for obvious security reasons.
I wanted to move us entirely over to Peril (which doesn't have this problem since both the logs and the code running are separated from the repo), but the issue was that it wouldn't run for PR updates. Looking at the GitHub event docs, it seems like what I want is the push event, but specific to a PR. If one could listen to pull_request.push one could basically entirely replace Danger with Peril.
Is there any chance support for that could be added to Peril?

April 25, 2018 · 4:27pm

That's already supported, yeah! Any

like-fill
0
reply

Hah, you can run code directly on just one action in the settings definition

like-fill
0
reply
{
"settings": {
"modules": ["danger-plugin-spellcheck", "danger-plugin-yarn", "@slack/client", "semver-sort"]
},
"rules": {
"create": "danger/peril-settings@org/new_tag.ts",
"pull_request.closed": "danger/peril-settings@org/aeryn.ts",
"pull_request": ["danger/peril-settings@org/debug.ts", "danger/peril-settings@org/changelog.ts"]
}
}
like-fill
0
reply
like-fill
0
reply

I got that

like-fill
0
reply

But I'm looking for basically pull_request.push which doesn't exist as far as I could tell?

like-fill
0
reply

I've used rules perfectly fine, I just couldn't find a reference to pull_request.push in the gitHub docs so I assumed it wouldn't work?

like-fill
0
reply

That's basically what I need to replace Danger with Peril

like-fill
0
reply

synchronized is what you're thinking of

like-fill
0
reply

that's when a new commit is added

like-fill
0
reply

Oh shit for real? pull_request.synchronized ?

like-fill
0
reply

Damn I thought I had to listen to push events manually and filter them out

like-fill
0
reply

Perfect, I'll try that—thank you!

like-fill
0
reply

Yep, about 95% certain

like-fill
0
reply

Yeah, that's what I see in my events when I push to a PR, I can update the docs

like-fill
1
reply

You're the best

like-fill
0
reply

Thank you, that makes so much sense!

like-fill
0
reply

it might need to be on both opened and synchronize to get the exact same behavior

like-fill
1
reply

That's fine, it's idempotent anyway so if it runs twice it won't hurt anybody

like-fill
0
reply

Is it synchronize or synchronized?

like-fill
0
reply

docs imply synchronize

like-fill
0
reply

trying to get an event I can verify, since I started getting statuses it's so much noise now

like-fill
0
reply

That'd be very inconsistent given it's opened and edited , but I'll just add bnoth

like-fill
0
reply

Can't hurt to have both either

like-fill
0
reply

hah

like-fill
0
reply

I agree though, so I wonder if it is, will verify

like-fill
0
reply
like-fill
1
reply

Thanks for double checking! That'd be great to put in the docs to make it easier to move from Danger to Peril

like-fill
0
reply

Done

like-fill
0
reply
like-fill
0
reply

Oh damn it just went away

like-fill
0
reply

Now that I've commented out the flow plugin

like-fill
0
reply
🙄
like-fill
0
reply

I'm a dummy

like-fill
0
reply

Managed to make it happen again by enabling the flow plugin and making it fail in a PR, here's a screenshot:

like-fill
0
reply
like-fill
0
reply

at a guess, it's likely related to how the flow plugin reads the content of files from the modfied

like-fill
0
reply

Interestingly, all that PR does is call github.utils.fileContents and fail/warn . Now I'm wondering, is there any chance there's a bug where the credentials aren't passed to fileContents ?

like-fill
0
reply

Because the weird thing is that Peril removes the comment about the fail if I uncomment the flow plugin

like-fill
0
reply

So that means Peril is getting the GitHub permissions perfectly fine

like-fill
0
reply

Yeah, sounds like it to me

like-fill
0
reply

can you make an issue for ti, doesn't have to be in-depth

like-fill
0
reply

just "this is suspicious"

like-fill
0
reply

So getting an error saying "Bad credentials" has to have something to do with the flow plugin, but also Peril is getting the GitHub creds perfectly fine

like-fill
0
reply

Otherwise it wouldn't be able to comment at all

like-fill
0
reply

might not be passing it correctly somehow

like-fill
0
reply
like-fill
0
reply

@orta any clue why it could fail with a "Bad credential" error but still be able to comment on the PR? That doesn't make any sense, does it?

like-fill
0
reply

Not from an outsider's perspective, but I can think of a few places where it could get out of sync

like-fill
0
reply
Your message here...

*bold*_italic_`code````codeblock```