Skip to content

Commit

Permalink
bodhi-ci: add an option to run only selected tests
Browse files Browse the repository at this point in the history
Signed-off-by: Aurélien Bompard <aurelien@bompard.org>
  • Loading branch information
abompard committed Feb 17, 2022
1 parent e3e664e commit 4369cfc
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 0 deletions.
6 changes: 6 additions & 0 deletions devel/ci/bodhi_ci/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.')
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions devel/ci/bodhi_ci/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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,
Expand Down
2 changes: 2 additions & 0 deletions devel/ci/bodhi_ci/integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"]}/'
Expand Down
2 changes: 2 additions & 0 deletions devel/ci/bodhi_ci/unit.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"])

Expand Down

0 comments on commit 4369cfc

Please sign in to comment.