Skip to content

Send site notification on Build status reporting failure and follow DRY #6033

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

Merged
merged 10 commits into from
Aug 7, 2019

Conversation

saadmk11
Copy link
Member

@saadmk11 saadmk11 commented Aug 2, 2019

ref: #6014

@saadmk11 saadmk11 added the PR: work in progress Pull request is not ready for full review label Aug 2, 2019
@saadmk11 saadmk11 requested review from ericholscher and a team August 2, 2019 09:00
@saadmk11 saadmk11 removed the PR: work in progress Pull request is not ready for full review label Aug 2, 2019
@saadmk11 saadmk11 changed the title Send site notification on Build status reporting failure Send site notification on Build status reporting failure and follow DRY Aug 3, 2019
@saadmk11
Copy link
Member Author

saadmk11 commented Aug 3, 2019

As I was Adding the User communication part to the task I saw that we were using some of the same code more than once. So, I tried to follow DRY and moved some of the redundant code to projects.models.Project as methods. I think this approach is much cleaner and reusable for the future when we add other providers. :)

Copy link
Member

@ericholscher ericholscher left a comment

Choose a reason for hiding this comment

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

This looks like a good approach. We should make sure the messaging doesn't overwhelm the user. We definitely need to confirm it only shows up once even if the build fails multiple times (this would be a good test).

try:
if build.project.remote_repository.account.provider == 'github':
service = GitHubService(
if provider_name == 'GitHub':
Copy link
Member

Choose a reason for hiding this comment

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

This should be a constant. Also, why are we checking the name instead of build.project.remote_repository.account.provider like previously?

Copy link
Member Author

Choose a reason for hiding this comment

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

previously we were just getting the provider name by using build.project.remote_repository.account.provider but now we have a better way project.git_provider_name as this actually checks which provider the project is from and project.git_service_class() get the actual class the projects needs (e.g: GitHubService) so we don't need that anymore.

@saadmk11 saadmk11 closed this Aug 7, 2019
@saadmk11 saadmk11 reopened this Aug 7, 2019
@saadmk11 saadmk11 requested a review from ericholscher August 7, 2019 10:09
Copy link
Member

@ericholscher ericholscher left a comment

Choose a reason for hiding this comment

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

Looks good with a change to the notification type.

@@ -355,3 +355,6 @@
)

GITHUB_PR_PULL_PATTERN = 'pull/{id}/head:external-{id}'

# Git provider names
GITHUB = 'GitHub'
Copy link
Member

Choose a reason for hiding this comment

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

This isn't a good name, since it has specialized caps. It should likely be GITHUB_BRAND or something,

Copy link
Member Author

Choose a reason for hiding this comment

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

GITHUB_PROVIDER_NAME maybe?

@saadmk11
Copy link
Member Author

saadmk11 commented Aug 7, 2019

Updated the Changes :)

@ericholscher ericholscher merged commit e80b0da into readthedocs:master Aug 7, 2019
@saadmk11 saadmk11 deleted the user-communication branch August 7, 2019 19:06
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.

2 participants