Пример #1
0
def main(
    verbose: bool,
    expansion_file: str,
    evg_api_config: str,
    build_variant: str,
    selected_tests_config: str,
):
    """
    Select tasks to be run based on changed files in a patch build.

    :param verbose: Log extra debug information.
    :param expansion_file: Configuration file.
    :param evg_api_config: Location of configuration file to connect to evergreen.
    :param build_variant: Build variant to query tasks from.
    :param selected_tests_config: Location of config file to connect to elected-tests service.
    """
    _configure_logging(verbose)

    evg_api = RetryingEvergreenApi.get_api(config_file=evg_api_config)
    evg_conf = parse_evergreen_file(EVERGREEN_FILE)
    selected_tests_service = SelectedTestsService.from_file(
        selected_tests_config)

    repo = Repo(".")
    changed_files = find_changed_files(repo)
    buildscripts.resmokelib.parser.set_options()
    LOGGER.debug("Found changed files", files=changed_files)

    config_dict_of_suites_and_tasks = run(evg_api, evg_conf, expansion_file,
                                          selected_tests_service,
                                          changed_files, build_variant)
    write_file_dict(SELECTED_TESTS_CONFIG_DIR, config_dict_of_suites_and_tasks)
Пример #2
0
def find_changed_tests(repo: Repo) -> Set[str]:
    """
    Find the changed tests.

    Use git to find which files have changed in this patch.
    TODO: This should be expanded to search for enterprise modules.
    The returned file paths are in normalized form (see os.path.normpath(path)).

    :returns: Set of changed tests.
    """
    changed_files = find_changed_files(repo)
    LOGGER.debug("Found changed files", files=changed_files)
    changed_tests = {os.path.normpath(path) for path in changed_files if _is_file_a_test_file(path)}
    LOGGER.debug("Found changed tests", files=changed_tests)
    return changed_tests
def find_changed_tests(repos: Iterable[Repo]) -> Set[str]:
    """
    Find the changed tests.

    Use git to find which files have changed in this patch.
    The returned file paths are in normalized form (see os.path.normpath(path)).

    :returns: Set of changed tests.
    """
    all_changed_tests = set()
    for repo in repos:
        changed_files = find_changed_files(repo)
        LOGGER.debug("Found changed files", files=changed_files)
        changed_tests = {
            os.path.normpath(path)
            for path in changed_files if is_file_a_test_file(path)
        }
        LOGGER.debug("Found changed tests", files=changed_tests)
        all_changed_tests.update(changed_tests)
    return all_changed_tests