def main(settings: Settings, gha: GithubAction) -> None: # we cannot create a check run or pull request comment # when running on pull_request event from a fork if settings.event_name == 'pull_request' and \ settings.event.get('pull_request', {}).get('head', {}).get('repo', {}).get('full_name') != settings.repo: gha.warning( f'This action is running on a pull_request event for a fork repository. ' f'It cannot do anything useful like creating check runs or pull request comments.' ) return # resolve the files_glob to files files = get_files(settings.files_glob) if len(files) == 0: gha.warning(f'Could not find any files for {settings.files_glob}') else: logger.info(f'reading {settings.files_glob}') logger.debug(f'reading {list(files)}') # get the unit test results parsed = parse_junit_xml_files(files).with_commit(settings.commit) [ gha.error(message=f'Error processing result file: {error.message}', file=error.file, line=error.line, column=error.column) for error in parsed.errors ] # process the parsed results results = get_test_results(parsed, settings.dedup_classes_by_file_name) # turn them into stats stats = get_stats(results) # derive check run conclusion from files conclusion = get_conclusion(parsed, fail_on_failures=settings.fail_on_failures, fail_on_errors=settings.fail_on_errors) # publish the delta stats backoff_factor = max(settings.seconds_between_github_reads, settings.seconds_between_github_writes) gh = get_github(token=settings.token, url=settings.api_url, retries=settings.api_retries, backoff_factor=backoff_factor) gh._Github__requester._Requester__requestRaw = throttle_gh_request_raw( settings.seconds_between_github_reads, settings.seconds_between_github_writes, gh._Github__requester._Requester__requestRaw) Publisher(settings, gh, gha).publish(stats, results.case_results, conclusion)
def main(settings: Settings, gha: GithubAction) -> None: # we cannot create a check run or pull request comment when running on pull_request event from a fork # when event_file is given we assume proper setup as in README.md#support-fork-repositories-and-dependabot-branches if settings.event_file is None and \ settings.event_name == 'pull_request' and \ settings.event.get('pull_request', {}).get('head', {}).get('repo', {}).get('full_name') != settings.repo: # bump the version if you change the target of this link (if it did not exist already) or change the section gha.warning(f'This action is running on a pull_request event for a fork repository. ' f'It cannot do anything useful like creating check runs or pull request comments. ' f'To run the action on fork repository pull requests, see ' f'https://github.com/EnricoMi/publish-unit-test-result-action/blob/v1.20/README.md#support-fork-repositories-and-dependabot-branches') return # resolve the files_glob to files files = get_files(settings.files_glob) if len(files) == 0: gha.warning(f'Could not find any files for {settings.files_glob}') else: logger.info(f'reading {settings.files_glob}') logger.debug(f'reading {list(files)}') # get the unit test results parsed = parse_junit_xml_files(files, settings.time_factor, settings.ignore_runs).with_commit(settings.commit) [gha.error(message=f'Error processing result file: {error.message}', file=error.file, line=error.line, column=error.column) for error in parsed.errors] # process the parsed results results = get_test_results(parsed, settings.dedup_classes_by_file_name) # turn them into stats stats = get_stats(results) # derive check run conclusion from files conclusion = get_conclusion(parsed, fail_on_failures=settings.fail_on_failures, fail_on_errors=settings.fail_on_errors) # publish the delta stats backoff_factor = max(settings.seconds_between_github_reads, settings.seconds_between_github_writes) gh = get_github(token=settings.token, url=settings.api_url, retries=settings.api_retries, backoff_factor=backoff_factor, gha=gha) gh._Github__requester._Requester__requestRaw = throttle_gh_request_raw( settings.seconds_between_github_reads, settings.seconds_between_github_writes, gh._Github__requester._Requester__requestRaw ) Publisher(settings, gh, gha).publish(stats, results.case_results, conclusion)
def main(settings: Settings) -> None: gha = GithubAction() # resolve the files_glob to files files = [str(file) for file in pathlib.Path().glob(settings.files_glob)] if len(files) == 0: gha.warning(f'Could not find any files for {settings.files_glob}') else: logger.info(f'reading {settings.files_glob}') logger.debug(f'reading {list(files)}') # get the unit test results parsed = parse_junit_xml_files(files).with_commit(settings.commit) [ gha.error(message=f'Error processing result file: {error.message}', file=error.file, line=error.line, column=error.column) for error in parsed.errors ] # process the parsed results results = get_test_results(parsed, settings.dedup_classes_by_file_name) # turn them into stats stats = get_stats(results) # derive check run conclusion from files conclusion = get_conclusion(parsed, fail_on_failures=settings.fail_on_failures, fail_on_errors=settings.fail_on_errors) # publish the delta stats gh = get_github(token=settings.token, url=settings.api_url, retries=10, backoff_factor=1) Publisher(settings, gh, gha).publish(stats, results.case_results, settings.compare_earlier, conclusion)