def update_pr_files(pr_number):
    pr = Issue.get(pr_number)
    files_response = paginated_github_request(get_pulls_base() + "/%i/files" % pr_number,
                                              oauth_token=oauth_token, etag=pr.files_etag)
    if files_response is None:
        return "Files for PR %i are up-to-date" % pr_number
    else:
        pr.files_json, pr.files_etag = files_response
        pr.put()  # Write our modifications back to the database
        return "Done updating files for PR %i" % pr_number
Exemple #2
0
def update_pr_files(pr_number):
    pr = Issue.get(pr_number)
    files_response = paginated_github_request(PULLS_BASE + "/%i/files" % pr_number,
                                              oauth_token=oauth_token, etag=pr.files_etag)
    if files_response is None:
        return "Files for PR %i are up-to-date" % pr_number
    else:
        pr.files_json, pr.files_etag = files_response
        pr.put()  # Write our modifications back to the database
        return "Done updating files for PR %i" % pr_number
def update_pr_review_comments(pr_number):
    pr = Issue.get(pr_number)
    pr_comments_response = paginated_github_request(get_pulls_base() + '/%i/comments' % pr_number,
                                                    oauth_token=oauth_token)
    # TODO: after fixing #32, re-enable etags here: etag=self.pr_review_comments_etag)
    if pr_comments_response is None:
        return "Review comments for PR %i are up-to-date" % pr_number
    else:
        pr.pr_comments_json, pr.pr_comments_etag = pr_comments_response
        pr.cached_commenters = pr._compute_commenters()
        pr.put()  # Write our modifications back to the database
        return "Done updating review comments for PR %i" % pr_number
Exemple #4
0
def update_pr_review_comments(pr_number):
    pr = Issue.get(pr_number)
    pr_comments_response = paginated_github_request(PULLS_BASE + '/%i/comments' % pr_number,
                                                    oauth_token=oauth_token)
    # TODO: after fixing #32, re-enable etags here: etag=self.pr_review_comments_etag)
    if pr_comments_response is None:
        return "Review comments for PR %i are up-to-date" % pr_number
    else:
        pr.pr_comments_json, pr.pr_comments_etag = pr_comments_response
        pr.cached_commenters = pr._compute_commenters()
        pr.put()  # Write our modifications back to the database
        return "Done updating review comments for PR %i" % pr_number
def update_pr_comments(pr_number):
    pr = Issue.get(pr_number)
    comments_response = paginated_github_request(get_issues_base() +
                                                 '/%i/comments' % pr_number,
                                                 oauth_token=oauth_token)
    # TODO: after fixing #32, re-enable etags here: etag=self.comments_etag)
    if comments_response is None:
        return "Comments for PR %i are up-to-date" % pr_number
    else:
        pr.comments_json, pr.comments_etag = comments_response
        pr.cached_commenters = pr._compute_commenters()
        pr.cached_last_jenkins_outcome = None
        pr.last_jenkins_outcome  # force recomputation of Jenkins outcome
        pr.put()  # Write our modifications back to the database

        # Delete out-of-date comments from AmplabJenkins and SparkQA.
        jenkins_comment_to_preserve = pr.last_jenkins_comment
        sparkqa_token = app.config["SPARKQA_GITHUB_OAUTH_KEY"]
        amplabjenkins_token = app.config["AMPLAB_JENKINS_GITHUB_OAUTH_KEY"]
        sparkqa_start_comments = {}  # Map from build ID to build start comment
        build_start_regex = r"Test build #(\d+) has started"
        build_end_regex = r"Test build #(\d+) (has finished|timed out)"
        for comment in (pr.comments_json or []):
            author = comment["user"]["login"]
            # Delete all comments from AmplabJenkins unless they are the comments that should be
            # displayed on the Spark PR dashboard. If we do not know which comment to preserve, then
            # do not delete any comments from AmplabJenkins.
            if jenkins_comment_to_preserve \
                    and author == "AmplabJenkins" \
                    and comment["url"] != jenkins_comment_to_preserve["url"]:
                raw_github_request(comment["url"],
                                   oauth_token=amplabjenkins_token,
                                   method="DELETE")
            elif author == "SparkQA":
                # Only delete build start notification comments from SparkQA and only delete them
                # after we've seen the corresponding build finished message.
                start_regex_match = re.search(build_start_regex,
                                              comment["body"])
                if start_regex_match:
                    sparkqa_start_comments[start_regex_match.groups()
                                           [0]] = comment
                else:
                    end_regex_match = re.search(build_end_regex,
                                                comment["body"])
                    if end_regex_match:
                        start_comment = sparkqa_start_comments.get(
                            end_regex_match.groups()[0])
                        if start_comment:
                            raw_github_request(start_comment["url"],
                                               oauth_token=sparkqa_token,
                                               method="DELETE")
        return "Done updating comments for PR %i" % pr_number
def update_pr_comments(pr_number):
    pr = Issue.get(pr_number)
    comments_response = paginated_github_request(get_issues_base() + '/%i/comments' % pr_number,
                                                 oauth_token=oauth_token)
    # TODO: after fixing #32, re-enable etags here: etag=self.comments_etag)
    if comments_response is None:
        return "Comments for PR %i are up-to-date" % pr_number
    else:
        pr.comments_json, pr.comments_etag = comments_response
        pr.cached_commenters = pr._compute_commenters()
        pr.cached_last_jenkins_outcome = None
        pr.last_jenkins_outcome  # force recomputation of Jenkins outcome
        pr.put()  # Write our modifications back to the database

        # Delete out-of-date comments from AmplabJenkins and SparkQA.
        jenkins_comment_to_preserve = pr.last_jenkins_comment
        sparkqa_token = app.config["SPARKQA_GITHUB_OAUTH_KEY"]
        amplabjenkins_token = app.config["AMPLAB_JENKINS_GITHUB_OAUTH_KEY"]
        sparkqa_start_comments = {}  # Map from build ID to build start comment
        build_start_regex = r"Test build #(\d+) has started"
        build_end_regex = r"Test build #(\d+) (has finished|timed out)"
        for comment in (pr.comments_json or []):
            author = comment["user"]["login"]
            # Delete all comments from AmplabJenkins unless they are the comments that should be
            # displayed on the Spark PR dashboard. If we do not know which comment to preserve, then
            # do not delete any comments from AmplabJenkins.
            if jenkins_comment_to_preserve \
                    and author == "AmplabJenkins" \
                    and comment["url"] != jenkins_comment_to_preserve["url"]:
                raw_github_request(comment["url"], oauth_token=amplabjenkins_token, method="DELETE")
            elif author == "SparkQA":
                # Only delete build start notification comments from SparkQA and only delete them
                # after we've seen the corresponding build finished message.
                start_regex_match = re.search(build_start_regex, comment["body"])
                if start_regex_match:
                    sparkqa_start_comments[start_regex_match.groups()[0]] = comment
                else:
                    end_regex_match = re.search(build_end_regex, comment["body"])
                    if end_regex_match:
                        start_comment = sparkqa_start_comments.get(end_regex_match.groups()[0])
                        if start_comment:
                            raw_github_request(start_comment["url"], oauth_token=sparkqa_token,
                                               method="DELETE")
        return "Done updating comments for PR %i" % pr_number