Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add PR branch validation #47

Closed
wants to merge 1 commit into from

Conversation

ivanayov
Copy link
Contributor

@ivanayov ivanayov commented Apr 1, 2018

This checks if the branch a pull request is raised from is
non-master. Validates, as well, if a pull request is raised against
the default branch. If the validation is not successful, the pull
request labels are applied: "review/target-branch" if the target
branch is not the default and "review/source-branch"
if the source branch is named "master". The source branch validation
leaves a warning comment, suggesting to raise a new pull request from
a named branch

Signed-off-by: Ivana Yovcheva (VMware) [email protected]

Raised in issue #17

@alexellis
Copy link
Owner

Check how to update pull status with go-github

This scenario cannot be recovered without raising a new PR from a different remote branch so I'd suggest not using the status API and instead using a label.

Via @rgee0 in the issue description:

Upon submission of a PR Derek should check the originating branch name, and if he finds master the PR closed with a message advising the user that they should re-submit from a non-master branch. Also, check that pull request is against master / default.

@alexellis
Copy link
Owner

@iyovcheva looks like the PR is breaking on CI. We should run a local docker build before pushing commits up to GitHub - it can reveal build/test errors ahead of time.

@ivanayov ivanayov force-pushed the check-pull-branch branch 4 times, most recently from 9fc9436 to 965d216 Compare April 4, 2018 11:28
@ivanayov
Copy link
Contributor Author

ivanayov commented Apr 4, 2018

@alexellis @rgee0 can you please review?

@ivanayov ivanayov changed the title [WIP] Add PR branch validation Add PR branch validation Apr 4, 2018
@alexellis
Copy link
Owner

We don't have any assign reviewer capability. Feel free to raise an issue suggesting it

@ivanayov ivanayov changed the title Add PR branch validation [WIP] Add PR branch validation Apr 4, 2018
@ivanayov ivanayov changed the title [WIP] Add PR branch validation Add PR branch validation Apr 5, 2018
pullRequestHandler.go Outdated Show resolved Hide resolved
pullRequestHandler.go Outdated Show resolved Hide resolved
pullRequestHandler.go Outdated Show resolved Hide resolved
body := `Thank you for your contribution. It appears that you are submitting changes directly from your master branch,
we encourage you to raise a new pull request from a named branch i.e. git checkout -b my_feature. `

comment := &github.IssueComment{
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/IssueComment/PullRequestComment

pullRequestHandler.go Outdated Show resolved Hide resolved
pullRequestHandler.go Outdated Show resolved Hide resolved
pullRequestHandler.go Outdated Show resolved Hide resolved
pullRequestHandler_test.go Outdated Show resolved Hide resolved
pullRequestHandler_test.go Outdated Show resolved Hide resolved
pullRequestHandler.go Outdated Show resolved Hide resolved
pullRequestHandler.go Outdated Show resolved Hide resolved
@alexellis
Copy link
Owner

alexellis commented Apr 17, 2018

Let's make the minor changes suggested today and then do some e2e testing:

  • Create your own GitHub App - and save the cert / pem
  • Install it on one of your repos
  • Run ngrok and point the derek function back to your GitHub app or run your OpenFaaS somewhere accessible like DigitalOcean

Then trigger the function and check the behaviour.

This will also be an opportunity for us to update the documentation on how to test / build / develop with Derek.

@alexellis
Copy link
Owner

@iyovcheva I see you pushed some changes. Please could you respond to the comment?

@alexellis
Copy link
Owner

alexellis commented May 7, 2018

@iyovcheva please could you run through some end-to-end testing using the instructions above? I pinged 20 days ago and think this would be a useful feature for the project.

While you are deploying Derek for testing it may make sense to take some cropped screenshots and update the testing instructions for future contributors such as @neolit123

cc @rgee0

@alexellis
Copy link
Owner

@ivanayov end-to-end testing needed on this. I'll mark WIP until we have that done.

Thanks, Alex

@alexellis alexellis changed the title Add PR branch validation [WIP] Add PR branch validation Jun 23, 2018
@neolit123
Copy link
Contributor

@alexellis @ivanayov

hi, Alex. i spoke briefly with Ivana about this and i could be missing some detail.

would a complete e2e for a bot that handles PRs mean that a certain repository has to be clobbered - i.e. the testing code would create a branch in a repository somewhere, make a change to a file and then submit a PR for this file. the testing code would then validate if the source and destination branches match a criteria. at least that's how a see a complete e2e test.

would it make sense to attempt to handle that via unit tests only. if even possible?
thanks.

@alexellis
Copy link
Owner

End to end testing means that your code is validated running in a live environment showing it does what it says it should. We don't want to discover bugs after releasing a new version of the code and deploying it to "production".

Unit tests are also an important part of regression testing, but it's difficult to produce the correct conditions to show all the moving parts are working as expected.

So for this change deploy Derek to your OpenFaaS instance, point your GitHub App at the endpoint and then add the app to your test repo. After that fire an event to trigger the behaviour.

This should be quick to test.

@neolit123
Copy link
Contributor

ah, so this is a one-shot manual e2e test to verify that this PR works.
for some reason i though that the request is to add the branch verification as part of CI.

@rgee0
Copy link
Contributor

rgee0 commented Jun 23, 2018

I tend to pull up a clean OF instance on Digital Ocean and deploy Derek to it. I put some Ansible together to provision a droplet and deploy OF - https://github.com/rgee0/openfaas-DO

I do have a test repo that does get clobbered, but thats what its there for.

Test the feature partitions: master to master, branch to master, branch to non-master, master to branch. Because this is relatively quick testing I'd also ensure the existing features still function.

The github facility to view and re-send requests also comes in useful.

@neolit123
Copy link
Contributor

just an idea to throw out there; probably considered already.

how about you guys integrate Derek as a continuous deployment?

proposal:

  • contributor submits PR to this main Derek repo.
  • Travis builds Derek and deploys it somewhere in the cloud.
  • this test build in the cloud is statically bound to the following repo to be manually clobbered by users: https://github.com/alexellis/derek-test, or maybe https://github.com/openfaas/derek-test
  • the contributor is instructed to test his change in that repo via CI output or a bot message.
  • the maintainer can verify the same.

this is great for new contributors who don't have (e.g.) digital ocean accounts or enough knowledge to do the deployment them self. also speeds up the verification process of new features.

potential problem here would be that if multiple PRs are submitted on top of each other the derek-test would operate on the latest Derek that ended up being deployed. the addition of the Derek version command to dump a build SHA is mandatory here.

@rgee0 @alexellis @ivanayov
WDYT?
let me know if this is any good and if you want me to log an issue for it.

@ivanayov
Copy link
Contributor Author

ivanayov commented Jul 6, 2018

@neolit123 This sounds like a good idea.

@MrTinD Just tested his PR and has a test environment, so I asked him if he can help with the e2e testing of this as well.

@ivanayov
Copy link
Contributor Author

ivanayov commented Jul 6, 2018

@MrTinD shared his test environment with me, so I can do e2e test the next days

This  checks  if  the  branch  a  pull  request  is  raised  from  is
non-master.  Validates,  as well,  if a pull request is raised against
the  default  branch.  If the validation  is not successful,  the pull
request labels are applied: "review/target-branch" if the target
branch is not  the  default  and  "review/source-branch"
if the source branch is named  "master".  The source branch validation
leaves a warning comment,  suggesting to raise a new pull request from
a named branch

Signed-off-by: Ivana Yovcheva (VMware) <[email protected]>
@ivanayov ivanayov changed the title [WIP] Add PR branch validation Add PR branch validation Nov 22, 2018
@sesam
Copy link

sesam commented Oct 9, 2020

This PR is for the last item in the feature wish-list from the end of the README, right? Do you think this implementation is complete?

@alexellis
Copy link
Owner

Hi Simon,

Why do you ask?

I would say we should close the PR as the author is no longer active, and the PR is quite old now and out of sync. I would have to take a detailed look to understand if it's complete.

Alex

@alexellis alexellis closed this Oct 9, 2020
@sesam
Copy link

sesam commented Oct 10, 2020 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants