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

Refine PR Builder Code #5933

Merged
18 changes: 12 additions & 6 deletions readthedocs/core/views/hooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,17 +111,23 @@ def get_or_create_external_version(project, identifier, verbose_name):
defaults={'identifier': identifier, 'active': True},
)

if not created:
# identifier will change if there is a new commit to the Pull/Merge Request
if external_version.identifier != identifier:
external_version.identifier = identifier
external_version.save()
else:
if created:
log.info(
'(Create External Version) Added Version: [%s] ', ' '.join(
external_version.slug
Copy link
Member

Choose a reason for hiding this comment

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

Why are we calling join on a slug?

Copy link
Member Author

Choose a reason for hiding this comment

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

Opps! I was doing something else forgot to remove it sorry.

)
)
else:
# identifier will change if there is a new commit to the Pull/Merge Request
if external_version.identifier != identifier:
external_version.identifier = identifier
external_version.save()

log.info(
'(Update External Version) Updated Version: [%s] ', ' '.join(
external_version.slug
)
)
return external_version


Expand Down
4 changes: 2 additions & 2 deletions readthedocs/oauth/services/github.py
Original file line number Diff line number Diff line change
Expand Up @@ -352,9 +352,9 @@ def send_build_status(self, build, state):
)
if resp.status_code == 201:
log.info(
"GitHub '%s' commit status created for project: %s",
github_build_state,
"GitHub commit status created for project: %s, commit status: %s",
project,
github_build_state,
)
return True

Expand Down
9 changes: 6 additions & 3 deletions readthedocs/projects/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -578,18 +578,21 @@ def run_build(self, docker, record):

if self.build_env.failed:
self.send_notifications(self.version.pk, self.build['id'])
# send build failure status to git Status API
# if the build failed, send build failure status to git Status API
# to show status report on the providers pull/merge request UI.
Copy link
Member

Choose a reason for hiding this comment

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

This is still just explaining what the code does. We can just remove these comments, we don't need to explain anything here.

send_external_build_status(
version=self.version, build_pk=self.build['id'], status=BUILD_STATUS_FAILURE
)
elif self.build_env.successful:
# send build successful status to git Status API
# if the build succeed, send build successful status to git Status API
# to show status report on the providers pull/merge request UI.
send_external_build_status(
version=self.version, build_pk=self.build['id'], status=BUILD_STATUS_SUCCESS
)
else:
msg = 'Unhandled Build Status'
# send build failure status to git Status API when Unhandled Build Status Found.
# if unhandled build status found, send build failure status to git Status API
# to show status report on the providers pull/merge request UI.
send_external_build_status(
version=self.version, build_pk=self.build['id'], status=BUILD_STATUS_FAILURE
)
Expand Down