Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

override configuration file via command buildtest build -c #684

Merged
merged 1 commit into from
Mar 13, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion buildtest/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
from buildtest.schemas.utils import load_schema, load_recipe
from buildtest.system import Slurm, LSF, Cobalt, system
from buildtest.utils.command import BuildTestCommand
from buildtest.utils.file import resolve_path
from buildtest.utils.tools import deep_get
from buildtest.exceptions import BuildTestError

Expand Down Expand Up @@ -274,12 +275,16 @@ def load_settings(settings_path=None):
return load_recipe(settings_path)


def resolve_settings_file():
def resolve_settings_file(settings_path=None):
"""Returns path to buildtest settings file that should be used. If there
is a user defined buildtest settings ($HOME/.buildtest/config.yml) it will
be honored, otherwise default settings from buildtest will be used.
"""

if settings_path:
settings_path = resolve_path(settings_path)
return settings_path

# if buildtest settings file exist return it otherwise return default file
if os.path.exists(USER_SETTINGS_FILE):
return USER_SETTINGS_FILE
Expand Down
9 changes: 6 additions & 3 deletions buildtest/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,12 @@ def main():
if args.debug:
streamlog(args.debug)

# invoking load_settings will attempt to initialize buildtest settings and
# load the schema
settings_file = resolve_settings_file()
# resolve_settings_file will resolve settings file for buildtest in the following order:
# 1. Command Line: 'buildtest build -c config.yml'
# 2. User Configuration: $HOME/.buildtest/config.yml
# 3. Default Settings: $BUILDTEST_ROOT/buildtest/settings/config.yml
settings_file = resolve_settings_file(args.config)

logger.info(f"Processing buildtest configuration file: {settings_file}")
check_settings(settings_file)

Expand Down
3 changes: 3 additions & 0 deletions buildtest/menu/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,9 @@ def build_menu(self):
type=positive_number,
help="Rebuild test X number of times. Must be a positive number between [1-50]",
)
parser_build.add_argument(
"-c", "--config", help="Specify path to buildtest configuration file"
)

def buildspec_menu(self):
"""This method implements ``buildtest buildspec`` command"""
Expand Down