def get_travis_directories(package_list): """Get list of packages that need to be tested on Travis CI. See: https://travis-ci.com/ If the current Travis build is for a pull request (PR), this will limit the directories to the ones impacted by the PR. Otherwise it will just test all package directories. :type package_list: list :param package_list: The list of **all** valid packages with unit tests. :rtype: list :returns: A list of all package directories where tests need to be run. """ if in_travis_pr(): pr_against_branch = travis_branch() return get_changed_packages('HEAD', pr_against_branch, package_list) else: return package_list
def get_test_packages(): """Get a list of packages which need tests run. Filters the package list in the following order: * Check command line for packages passed in as positional arguments * Check if the the local remote and local branch environment variables have been set to specify a remote branch to diff against. * Check if in Travis, then limit the subset based on changes in a Pull Request ("push" builds to branches may not have any filtering) * Just use all packages An additional check is done for the cases when a diff is computed (i.e. using local remote and local branch environment variables, and on Travis). Once the filtered list of **changed** packages is found, the package dependency graph is used to add any additional packages which depend on the changed packages. :rtype: list :returns: A list of all package directories where tests need be run. """ all_packages = get_package_directories() local_diff = local_diff_branch() parser = get_parser() args = parser.parse_args() if args.packages is not UNSET_SENTINEL: verify_packages(args.packages, all_packages) return sorted(args.packages) elif local_diff is not None: changed_packages = get_changed_packages('HEAD', local_diff, all_packages) return follow_dependencies(changed_packages, all_packages) elif in_travis(): changed_packages = get_travis_directories(all_packages) return follow_dependencies(changed_packages, all_packages) else: return all_packages
def get_test_packages(): """Get a list of packages which need tests run. Filters the package list in the following order: * Check command line for packages passed in as positional arguments * Check if the the local remote and local branch environment variables have been set to specify a remote branch to diff against. * Check if in Travis, then limit the subset based on changes in a Pull Request ("push" builds to branches may not have any filtering) * Just use all packages An additional check is done for the cases when a diff is computed (i.e. using local remote and local branch environment variables, and on Travis). Once the filtered list of **changed** packages is found, the package dependency graph is used to add any additional packages which depend on the changed packages. :rtype: list :returns: A list of all package directories where tests need be run. """ all_packages = get_package_directories() local_diff = local_diff_branch() parser = get_parser() args = parser.parse_args() if args.packages is not UNSET_SENTINEL: verify_packages(args.packages, all_packages) return sorted(args.packages) elif local_diff is not None: changed_packages = get_changed_packages( 'HEAD', local_diff, all_packages) return follow_dependencies(changed_packages, all_packages) elif in_travis(): changed_packages = get_travis_directories(all_packages) return follow_dependencies(changed_packages, all_packages) else: return all_packages