def publish_comment( self, title: str, stats: UnitTestRunResults, pull_request: PullRequest, check_run: Optional[CheckRun] = None, cases: Optional[UnitTestCaseResults] = None) -> PullRequest: # compare them with earlier stats base_commit_sha = self.get_base_commit_sha(pull_request) logger.debug(f'comparing against base={base_commit_sha}') base_check_run = self.get_check_run(base_commit_sha) base_stats = self.get_stats_from_check_run( base_check_run) if base_check_run is not None else None stats_with_delta = get_stats_delta( stats, base_stats, 'base') if base_stats is not None else stats logger.debug(f'stats with delta: {stats_with_delta}') # gather test lists from check run and cases before_all_tests, before_skipped_tests = self.get_test_lists_from_check_run( base_check_run) all_tests, skipped_tests = get_all_tests_list( cases), get_skipped_tests_list(cases) test_changes = SomeTestChanges(before_all_tests, all_tests, before_skipped_tests, skipped_tests) logger.info('creating comment') details_url = check_run.html_url if check_run else None summary = get_long_summary_md(stats_with_delta, details_url, test_changes, self._settings.test_changes_limit) pull_request.create_issue_comment(f'## {title}\n{summary}') return pull_request
def update_or_create_links_comment(self, github_pr: PullRequest, build_result: CiBuildResult): github_comment = self._find_bot_pr_comment(github_pr) if github_comment: self._update_links_comment(github_pr, github_comment, build_result) else: new_bot_comment = self._generate_comment(github_pr, build_result) github_pr.create_issue_comment(new_bot_comment.to_text(self._settings.comment))
def check_for_changelogs(pr: PullRequest) -> None: for change in pr.get_files(): if change.filename == 'requirements.txt': lines = build_changelog(change) for comment in pr.get_issue_comments(): if comment.body.startswith('# Changelogs'): # Changelog comment comment.edit(body='\n'.join(lines)) break else: pr.create_issue_comment('\n'.join(lines))
def publish_comment(self, title: str, stats: UnitTestRunResults, pull_request: PullRequest, check_run: Optional[CheckRun] = None) -> None: # compare them with earlier stats base_commit_sha = pull_request.base.sha if pull_request else None self._logger.debug('comparing against base={}'.format(base_commit_sha)) base_stats = self.get_stats_from_commit(base_commit_sha) stats_with_delta = get_stats_delta( stats, base_stats, 'base') if base_stats is not None else stats self._logger.debug('stats with delta: {}'.format(stats_with_delta)) self._logger.info('creating comment') details_url = check_run.html_url if check_run else None pull_request.create_issue_comment('## {}\n{}'.format( title, get_long_summary_md(stats_with_delta, details_url))) return pull_request
def close_pullreq_with_comment(pullreq: PullRequest, comment: str) -> None: pullreq.create_issue_comment(comment) pullreq.edit(state='closed')