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_content_check to features #104

Merged
merged 1 commit into from
Nov 22, 2018
Merged

Add pr_content_check to features #104

merged 1 commit into from
Nov 22, 2018

Conversation

burtonr
Copy link
Contributor

@burtonr burtonr commented Nov 10, 2018

Description

This commit adds a new feature for pr_content_check
This feature will verify that the incoming PR has
something in the description (aka body)

If there is no description, the invalid label will be applied
and a comment will be added to the PR with a link to the
contributing guide.

Signed-off-by: Burton Rheutan [email protected]

Motivation and Context

How Has This Been Tested?

Unit tests added and passing

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I've read the CONTRIBUTION guide
  • I have signed-off my commits with git commit -s
  • I have added tests to cover my changes.
  • All new and existing tests passed.

USER_GUIDE.md Outdated Show resolved Hide resolved
installationID,
config.PrivateKey)

if tokenErr != nil {
Copy link
Owner

Choose a reason for hiding this comment

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

probably better to bubble up an error and handle properly than blow up. I know this may have been refactored out, but that now means it's getting eyes on it. My hope is to remove all log.Fatal* calls and panic so we can use Derek as an SDK in the future.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I wasn't quite sure how the error should be handled. For now, just writing the error to stdout and returning before the token is used to prevent a panic

Copy link
Owner

Choose a reason for hiding this comment

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

How about returning an error from the function?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I agree that returning the error and letting the main.go handle all the errors is probably the right way to handle this. However, the way it is implemented here is consistent with the rest of the pullRequestHandler.go file.

I think the change to return the error should be in a follow up PR to make that change across the entire file. It would make for a cleaner commit/change log and keep this change set focused on checking the PR description.

log.Fatalf("%s limit: %d, remaining: %d", assignLabelErr, res.Limit, res.Remaining)
}

body := `Thank you for your contribution. I've just checked and your Pull Request doesn't appear to have any description.
Copy link
Owner

Choose a reason for hiding this comment

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

Seems consistent with the previous messages we used.

@rgee0 do you have any input on this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't quite have that English "personality", so I'd appreciate input into proper phrasing 😄
I know Derek's personality is one of his strong points!

Copy link
Contributor

Choose a reason for hiding this comment

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

The two comments are very similar. Is there a way we can extract the main part and just update the 'problem detail' when using it?

Thank you for your contribution. I've just checked and <problem detail>. That's something we need before your Pull Request can be merged. Please see our [contributing guide]( + contributingURL + ).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If it's ok, we could do this in a follow up PR. I think there's more to think about than this one instance.

I may have a solution you can see here: https://play.golang.org/p/FByvDuUR4g2
Not sure where the struct would be defined though. I was thinking in a new file within the handlers package so that it could be used in other handlers.

main.go Outdated
deleted = "deleted"
dcoCheck = "dco_check"
comments = "comments"
deleted = "deleted"
Copy link
Owner

Choose a reason for hiding this comment

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

Maybe the opened const could go here if it's not present already?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

added the const in the pullRequestHandler.go file as that's the only place it's used. Similar to these consts which are only used in the main.go file.

Happy to move it if you'd prefer all the const definitions are in one place.

Copy link
Owner

@alexellis alexellis left a comment

Choose a reason for hiding this comment

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

Overall looks like what we were looking for which is great, please see feedback from @ivanayov @rgee0 and myself.

@burtonr burtonr changed the title Add no_empty_pr to features Add pr_content_check to features Nov 14, 2018
@@ -143,3 +196,7 @@ func hasUnsigned(req types.PullRequestOuter, client *github.Client) (bool, error
func isSigned(msg string) bool {
return strings.Contains(msg, "Signed-off-by:")
}

func missingDescription(pr types.PullRequest) bool {
Copy link
Owner

Choose a reason for hiding this comment

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

Can you call this hasDescription please?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

updated. Changing the name redefines this function, so I've updated it to return > 0 rather than the previous implementation of == 0

I've updated the calling function and the tests to reflect this new change

@alexellis
Copy link
Owner

This is not strictly a pr_content_check (the PR being a series of commits - we don't check them at all, and this doesn't speak to how we check them) - I'd prefer to see this more descriptive such as: pr_description_required or mandatory_pr_description.

Alex

@ivanayov
Copy link
Contributor

I would vote for pr_description_required as it's best descriptive.

This commit adds a new feature for pr_description_required
This feature will verify that the incoming PR has
something in the description (aka body)

If there is no description, the invalid label will be applied
and a comment will be added to the PR with a link to the
contributing guide.

Signed-off-by: Burton Rheutan <[email protected]>
@burtonr
Copy link
Contributor Author

burtonr commented Nov 22, 2018

@alexellis This is ready now.

I've updated the feature name to the even better, more descriptive: pr_description_required
I've addressed your comments

I've also got the version of Derek deployed and installed to test end to end on one of my repos.

PR Missing a description:
screenshot from 2018-11-22 00-48-50

PR with description:
screenshot from 2018-11-22 00-51-54

and finally, a PR with unsigned commits, and no description:
screenshot from 2018-11-22 00-54-26

@martindekov
Copy link
Contributor

Before this getting merged I would suggest to add pr_description_required in the .DEREK.yml file configuration of probably commented out so we know from where to manage this label

@alexellis
Copy link
Owner

@martindekov can we add that after the merge?

@alexellis alexellis merged commit 7aeec85 into alexellis:master Nov 22, 2018
@martindekov
Copy link
Contributor

Yeah ^ it was just suggestion

@burtonr burtonr deleted the pr-description-check branch November 22, 2018 15:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Mark PRs as invalid which have no description
5 participants