-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
Conversation
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 |
There was a problem hiding this 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).
readthedocs/projects/tasks.py
Outdated
try: | ||
if build.project.remote_repository.account.provider == 'github': | ||
service = GitHubService( | ||
if provider_name == 'GitHub': |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this 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.
readthedocs/projects/constants.py
Outdated
@@ -355,3 +355,6 @@ | |||
) | |||
|
|||
GITHUB_PR_PULL_PATTERN = 'pull/{id}/head:external-{id}' | |||
|
|||
# Git provider names | |||
GITHUB = 'GitHub' |
There was a problem hiding this comment.
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,
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
GITHUB_PROVIDER_NAME
maybe?
Updated the Changes :) |
ref: #6014