diff --git a/devel/ci/bodhi_ci/cli.py b/devel/ci/bodhi_ci/cli.py index 5a7295d7e9..35905a3b58 100755 --- a/devel/ci/bodhi_ci/cli.py +++ b/devel/ci/bodhi_ci/cli.py @@ -84,6 +84,10 @@ def _set_concurrency(ctx, param, value): failfast_option = click.option( '--failfast', '-x', is_flag=True, callback=_set_context, expose_value=False, help='Exit immediately upon error.') +onlytests_option = click.option( + '--only-tests', '-k', metavar="EXPRESSION", callback=_set_context, expose_value=False, + help='only run tests which match the given substring expression. ' + 'See the pytest documentation for the -k option for details.') no_build_option = click.option( '--no-build', is_flag=True, callback=_set_context, expose_value=False, help='Do not run docker build if the image already exists.') @@ -187,6 +191,7 @@ def pre_commit(ctx, releases): @concurrency_option @container_runtime_option @failfast_option +@onlytests_option @no_build_option @releases_option @modules_option @@ -232,6 +237,7 @@ def integration_build(ctx, releases): @concurrency_option @container_runtime_option @failfast_option +@onlytests_option @no_build_option @releases_option @archive_path_option diff --git a/devel/ci/bodhi_ci/constants.py b/devel/ci/bodhi_ci/constants.py index c0633bec6f..1144f9b317 100644 --- a/devel/ci/bodhi_ci/constants.py +++ b/devel/ci/bodhi_ci/constants.py @@ -4,6 +4,7 @@ import os import uuid + CONTAINER_NAME = 'bodhi-ci' # We label the containers we run so it's easy to find them when we run _stop_all_jobs() at the end. # UUID is used so that one bodhi-ci process does not stop jobs started by a different one. @@ -16,6 +17,7 @@ concurrency=multiprocessing.cpu_count(), container_runtime='docker', failfast=False, + only_tests=None, init=True, # If True, we will try to skip running any builds if suitable builds already exist. no_build=False, diff --git a/devel/ci/bodhi_ci/integration.py b/devel/ci/bodhi_ci/integration.py index 047160c8b0..1903d6c252 100755 --- a/devel/ci/bodhi_ci/integration.py +++ b/devel/ci/bodhi_ci/integration.py @@ -191,6 +191,8 @@ def __init__(self, *args, **kwargs): self._popen_kwargs["env"]["CONTAINER_RUNTIME"] = self.options["container_runtime"] if self.options["failfast"]: self._command.append('-x') + if self.options["only_tests"]: + self._command.extend(['-k', self.options["only_tests"]]) if self.options["archive"]: self._command.append( f'--junit-xml={self.options["archive_path"]}/' diff --git a/devel/ci/bodhi_ci/unit.py b/devel/ci/bodhi_ci/unit.py index 98e475bd66..5332d48461 100755 --- a/devel/ci/bodhi_ci/unit.py +++ b/devel/ci/bodhi_ci/unit.py @@ -44,6 +44,8 @@ def __init__(self, *args, **kwargs): pytest_flags = '--junit-xml=nosetests.xml -v tests' if self.options["failfast"]: pytest_flags += ' -x' + if self.options["only_tests"]: + pytest_flags += f' -k {self.options["only_tests"]}' modules = " ".join(self.options["modules"])