From 43acd61901e26fdb2faf89baa3e9b2c7647fc89e Mon Sep 17 00:00:00 2001 From: Felix Fontein Date: Mon, 18 May 2020 22:18:31 +0200 Subject: [PATCH] ansible-test local change detection: use --base-branch if specified (#69508) --- .../69508-ansible-test-local-changes-detection.yml | 2 ++ test/lib/ansible_test/_internal/ci/local.py | 6 ++++-- test/lib/ansible_test/_internal/cli.py | 6 +++--- test/lib/ansible_test/_internal/config.py | 2 +- 4 files changed, 10 insertions(+), 6 deletions(-) create mode 100644 changelogs/fragments/69508-ansible-test-local-changes-detection.yml diff --git a/changelogs/fragments/69508-ansible-test-local-changes-detection.yml b/changelogs/fragments/69508-ansible-test-local-changes-detection.yml new file mode 100644 index 00000000000..1157f945fd9 --- /dev/null +++ b/changelogs/fragments/69508-ansible-test-local-changes-detection.yml @@ -0,0 +1,2 @@ +bugfixes: +- "ansible-test - for local change detection, allow to specify branch to compare to with ``--base-branch`` for all types of tests (https://github.com/ansible/ansible/pull/69508)." diff --git a/test/lib/ansible_test/_internal/ci/local.py b/test/lib/ansible_test/_internal/ci/local.py index d9187efb920..fbb850b8306 100644 --- a/test/lib/ansible_test/_internal/ci/local.py +++ b/test/lib/ansible_test/_internal/ci/local.py @@ -203,9 +203,11 @@ class LocalChanges: # diff of all tracked files from fork point to working copy self.diff = self.git.get_diff([self.fork_point]) - @staticmethod - def is_official_branch(name): # type: (str) -> bool + def is_official_branch(self, name): # type: (str) -> bool """Return True if the given branch name an official branch for development or releases.""" + if self.args.base_branch: + return name == self.args.base_branch + if name == 'devel': return True diff --git a/test/lib/ansible_test/_internal/cli.py b/test/lib/ansible_test/_internal/cli.py index 341ae06e0a4..e4ddb3c5ffc 100644 --- a/test/lib/ansible_test/_internal/cli.py +++ b/test/lib/ansible_test/_internal/cli.py @@ -309,6 +309,9 @@ def parse_args(): test.add_argument('--metadata', help=argparse.SUPPRESS) + test.add_argument('--base-branch', + help='base branch used for change detection') + add_changes(test, argparse) add_environments(test) @@ -527,9 +530,6 @@ def parse_args(): choices=SUPPORTED_PYTHON_VERSIONS + ('default',), help='python version: %s' % ', '.join(SUPPORTED_PYTHON_VERSIONS)) - sanity.add_argument('--base-branch', - help=argparse.SUPPRESS) - sanity.add_argument('--enable-optional-errors', action='store_true', help='enable optional errors') diff --git a/test/lib/ansible_test/_internal/config.py b/test/lib/ansible_test/_internal/config.py index a005056b837..b0d153c5c1a 100644 --- a/test/lib/ansible_test/_internal/config.py +++ b/test/lib/ansible_test/_internal/config.py @@ -193,6 +193,7 @@ class TestConfig(EnvironmentConfig): self.unstaged = args.unstaged # type: bool self.changed_from = args.changed_from # type: str self.changed_path = args.changed_path # type: t.List[str] + self.base_branch = args.base_branch # type: str self.lint = args.lint if 'lint' in args else False # type: bool self.junit = args.junit if 'junit' in args else False # type: bool @@ -241,7 +242,6 @@ class SanityConfig(TestConfig): self.list_tests = args.list_tests # type: bool self.allow_disabled = args.allow_disabled # type: bool self.enable_optional_errors = args.enable_optional_errors # type: bool - self.base_branch = args.base_branch # type: str self.info_stderr = self.lint