-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Send Build Status Report Using GitHub Status API #5865
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
Send Build Status Report Using GitHub Status API #5865
Conversation
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 pretty simple and like a good approach. Just a few small tidbits I noticed.
readthedocs/core/utils/__init__.py
Outdated
@@ -125,6 +128,10 @@ def prepare_build( | |||
options['soft_time_limit'] = time_limit | |||
options['time_limit'] = int(time_limit * 1.2) | |||
|
|||
if build: | |||
# Send pending Build Status to Git Status API | |||
send_build_status.delay(build.id, BUILD_STATUS_PENDING) |
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.
not sure if calling this from here is the best place. I don't have a suggestion yet, but I'll try to dig the code. Also, we have signals to report the build status, maybe we can use those
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.
@stsewd I couldn't not find a better place for this . we should send the status report as soon as possible. please suggest me a better place when you get time :)
09ca1ad
to
9b10ea6
Compare
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.
Good changes and refactors. This is getting closer 👍
I also want to test this locally, but probably won't have time today for it.
self.send_build_status( | ||
self.build['id'], BUILD_STATUS_FAILURE | ||
) | ||
elif self.build_env.successful: |
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.
What is the other state here? Should this just be an else
? If not, we should do an else
with a log.warning
.
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.
@ericholscher there are no other states (BuildEnvironment
) , it will succeed or fail (in the Build Environment) at this point of the build. we could add an warning if we want. but I don't think we need to :)
# TODO: Send build status for other providers. | ||
|
||
|
||
def send_external_build_status(build_pk, state): |
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.
Shouldn't this function be in utils
instead of tasks
?
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 will just create a circular import error, as the send_build_status
task is already in the task.py
file
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 on my side 👍
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.
Just some small things, nothing blocking 👍
tasks.send_build_status(external_build, BUILD_STATUS_SUCCESS) | ||
|
||
send_build_status.assert_not_called() | ||
mock_logger.info.assert_called_with( |
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.
I don't think mocking the logger is needed for this test
self.assertFalse(success) | ||
mock_logger.exception.assert_called_with( | ||
'GitHub commit status creation failed for project: %s', | ||
self.project, |
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 like there is an extra level of indentation here
🎉 |
Sending build status
pending
andsuncess
orfailed
using GitHub Status API.Will extend this for other services in the future (e.g: gitlab, bitbucket)
TODO: