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

Changes to allow MergeBot to post to the Commit Status API #19

Merged
merged 4 commits into from
Jul 19, 2017

Conversation

jasonkuster
Copy link
Owner

No description provided.

COMMIT_STATE_PENDING = 'pending'
COMMIT_STATE_SUCCESS = 'success'
COMMIT_STATE_ERROR = 'error'
COMMIT_STATE_FAILURE = 'failure'

Choose a reason for hiding this comment

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

what's difference between error and failure? Probably some documents here or other place?

Copy link
Owner Author

Choose a reason for hiding this comment

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

Error is a problem that happened on MergeBot's side -- something that should be retried. Failure indicates something went wrong that wasn't MergeBot's fault -- bad rebase, tests failed, merge conflict, etc.

Copy link
Owner Author

Choose a reason for hiding this comment

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

Added a comment here to clarify.

@@ -155,14 +169,46 @@ def post_info(self, content, logger):
"""
self.post_pr_comment('Info: {}'.format(content), logger)

def post_commit_status(self, state, url, description, context, logger):
""" Posts a commit status update to this PR.
Copy link

@markflyhigh markflyhigh Jul 11, 2017

Choose a reason for hiding this comment

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

Please correct me if I'm wrong, it looks like a function that posts/updates merge status to the particular PR. If that's true, how about something like post/update_merge_status? since commit makes me think of a specific commit in a PR.

Copy link
Owner Author

Choose a reason for hiding this comment

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

It is actually attached to a particular commit, and is using the "Commit Status API" from GitHub.

https://developer.github.com/v3/repos/statuses/

Statuses need to be attached to specific commits since they are what represent the HEAD of a particular pull request. GitHub doesn't have any other way to do this.

Choose a reason for hiding this comment

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

got it.

@@ -289,6 +319,17 @@ def merge_git_pr(self, pr):
_set_up(tmp_dir)
self.execute_merge_lifecycle(pr, tmp_dir, pr_logger)
except AssertionError as exc:
pr.post_commit_status(
state=github_helper.COMMIT_STATE_FAILURE,

Choose a reason for hiding this comment

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

why "failure" not "error"?

Also i'm thinking if someone that first use mergebot, how can they tell difference between failure and error status? Do I miss anything that contains more instructions?

Choose a reason for hiding this comment

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

looks like the description tell the difference.

Copy link
Owner Author

Choose a reason for hiding this comment

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

AssertionErrors indicate something has gone preventably wrong in the PR (as mentioned in the above comment) and thus FAILURE is the appropriate level.

Choose a reason for hiding this comment

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

got it.

state=github_helper.COMMIT_STATE_ERROR,
url=MERGEBOT_ITEM_URL.format(
name=self.config.name, number=pr.get_num()),
description='MergeBot shutdown; resubmit when mergebot is back up.',

Choose a reason for hiding this comment

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

can we provide a url for health check? or some instructions? If I'm new to mergebot and got this message, I'll have no idea when mergebot is back up.

Copy link
Owner Author

Choose a reason for hiding this comment

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

I'll update the URL to the top-level MergeBot page which indicates whether MergeBot is back up, but all of the URLs on these point to the MergeBot frontend.

Copy link
Owner Author

Choose a reason for hiding this comment

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

Updated URL.

# In the case of shutdown, we still post back to the pull request
# because otherwise if mergebot is stopped and restarted we will try
# this pull request again. If mergebot is modified to work with webhooks
# this can be removed.
pr.post_info('MergeBot shutting down; please resubmit when MergeBot is '

Choose a reason for hiding this comment

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

do we need to post similar content comparing to line 286? I guess it's another comment just right next to the above one?

Copy link
Owner Author

Choose a reason for hiding this comment

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

I'm not sure what you mean by this -- in this section we're both updating the commit status (line ~286), and posting a comment on the PR indicating the same message.

Choose a reason for hiding this comment

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

I previously thought the status commit is the place where people commenting on a PR. I think it's good now 👍

state=github_helper.COMMIT_STATE_PENDING,
url=MERGEBOT_ITEM_URL.format(
name=self.config.name, number=pr_num),
description='Started Work',

Choose a reason for hiding this comment

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

start merging or start running jenkins build?

Copy link
Owner Author

Choose a reason for hiding this comment

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

This indicates that MergeBot has begun work on this PR. I could add additional commit status updates which show when the status changes in intermediary ways, if that's something you think would be useful.

Choose a reason for hiding this comment

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

That's clear enough. I have better understanding after saw the real case :)

Signed-off-by: Jason Kuster <[email protected]>
Copy link

@markflyhigh markflyhigh left a comment

Choose a reason for hiding this comment

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

Thank you. Just one more question.

@@ -155,14 +169,46 @@ def post_info(self, content, logger):
"""
self.post_pr_comment('Info: {}'.format(content), logger)

def post_commit_status(self, state, url, description, context, logger):
""" Posts a commit status update to this PR.

Choose a reason for hiding this comment

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

got it.

state=github_helper.COMMIT_STATE_PENDING,
url=MERGEBOT_ITEM_URL.format(
name=self.config.name, number=pr_num),
description='Started Work',

Choose a reason for hiding this comment

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

That's clear enough. I have better understanding after saw the real case :)

# In the case of shutdown, we still post back to the pull request
# because otherwise if mergebot is stopped and restarted we will try
# this pull request again. If mergebot is modified to work with webhooks
# this can be removed.
pr.post_info('MergeBot shutting down; please resubmit when MergeBot is '

Choose a reason for hiding this comment

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

I previously thought the status commit is the place where people commenting on a PR. I think it's good now 👍

@@ -289,6 +319,17 @@ def merge_git_pr(self, pr):
_set_up(tmp_dir)
self.execute_merge_lifecycle(pr, tmp_dir, pr_logger)
except AssertionError as exc:
pr.post_commit_status(
state=github_helper.COMMIT_STATE_FAILURE,

Choose a reason for hiding this comment

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

got it.

pr.post_commit_status(
state=github_helper.COMMIT_STATE_ERROR,
url=job_url,
description='Timed out waiting for job start.',

Choose a reason for hiding this comment

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

Sometimes Jenkins doesn't have enough executors so job will be queued. Is it possible that job is queued and timed out on mergebot side?

Copy link
Owner Author

Choose a reason for hiding this comment

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

I believe this will still find queued jobs, but I'll investigate that and get back to you.

Copy link
Owner Author

Choose a reason for hiding this comment

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

It doesn't appear to find queued jobs. I've bumped the timeout to 10 minutes to compensate -- if jobs are waiting longer than 10 minutes we probably need new executors.

Choose a reason for hiding this comment

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

There will be resource waste if timeout here since Jenkins will run the queued job anyway. Another issue is created and we can address it in another PR.

@markflyhigh
Copy link

LGTM

@jasonkuster jasonkuster merged commit 3244a16 into master Jul 19, 2017
@jasonkuster jasonkuster deleted the commitstatus branch July 19, 2017 17:15
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