Skip to content
Snippets Groups Projects
Commit 759e9305 authored by André Anjos's avatar André Anjos :speech_balloon:
Browse files

[ci] Allow builds to define their custom condarc to be used

parent 2db104b3
No related branches found
No related tags found
1 merge request!82Allow builds to define their custom condarc to be used
Pipeline #32332 passed
......@@ -18,3 +18,4 @@ build
record.txt
miniconda.sh
miniconda/
.DS_Store
......@@ -195,3 +195,13 @@ def select_conda_recipe_append(paths, branch):
from .constants import CONDA_RECIPE_APPEND as default
return select_build_file(default, paths, branch) or default
def select_user_condarc(paths, branch):
'''Selects the user condarc file to read (if any)
See :py:func:`select_build_file` for implementation details. If no recipe
condarc is found by :py:func:`select_build_file`, then returns ``None``.
'''
return select_build_file('condarc', paths, branch)
......@@ -14,7 +14,7 @@ from . import bdt
from ..constants import SERVER, WEBDAV_PATHS, BASE_CONDARC
from ..deploy import deploy_conda_package, deploy_documentation
from ..ci import read_packages, comment_cleanup, uniq, \
select_conda_build_config, select_conda_recipe_append
select_conda_build_config, select_conda_recipe_append, select_user_condarc
from ..log import verbosity_option, get_logger, echo_normal
logger = get_logger(__name__)
......@@ -278,7 +278,11 @@ def base_build(order, group, python, dry_run):
this context.
"""
condarc = os.path.join(os.environ['CONDA_ROOT'], 'condarc')
condarc = select_user_condarc(paths=[recipe, os.curdir],
branch=os.environ.get('CI_COMMIT_REF_NAME'))
condarc = condarc or os.path.join(os.environ['CONDA_ROOT'], 'condarc')
if os.path.exists(condarc):
logger.info('Loading (this build\'s) CONDARC file from %s...', condarc)
with open(condarc, 'rb') as f:
......@@ -375,6 +379,11 @@ def test(ctx, dry_run):
# Use custom variants and append files if available on recipe-dir
recipe_dir = os.path.join(os.path.realpath(os.curdir), 'conda')
condarc = select_user_condarc(paths=[recipe, os.curdir],
branch=os.environ.get('CI_COMMIT_REF_NAME'))
if condarc is not None:
logger.info('Condarc configuration file: %s', condarc)
variants_file = select_conda_build_config(paths=[recipe_dir, os.curdir],
branch=os.environ.get('CI_COMMIT_REF_NAME'))
logger.info('Conda build configuration file: %s', variants_file)
......@@ -387,7 +396,7 @@ def test(ctx, dry_run):
ctx.invoke(test,
package = glob.glob(os.path.join(os.environ['CONDA_ROOT'], 'conda-bld',
'*', os.environ['CI_PROJECT_NAME'] + '*.tar.bz2')),
condarc=None, #custom build configuration
condarc=condarc,
config=variants_file,
append_file=append_file,
server=SERVER,
......@@ -429,6 +438,11 @@ def build(ctx, dry_run):
# Use custom variants and append files if available on recipe-dir
recipe_dir = os.path.join(os.path.realpath(os.curdir), 'conda')
condarc = select_user_condarc(paths=[recipe, os.curdir],
branch=os.environ.get('CI_COMMIT_REF_NAME'))
if condarc is not None:
logger.info('Condarc configuration file: %s', condarc)
variants_file = select_conda_build_config(paths=[recipe_dir, os.curdir],
branch=os.environ.get('CI_COMMIT_REF_NAME'))
logger.info('Conda build configuration file: %s', variants_file)
......@@ -441,7 +455,7 @@ def build(ctx, dry_run):
ctx.invoke(build,
recipe_dir=[recipe_dir],
python=os.environ['PYTHON_VERSION'], #python version
condarc=None, #custom build configuration
condarc=condarc,
config=variants_file,
no_test=False,
append_file=append_file,
......@@ -552,6 +566,11 @@ def nightlies(ctx, order, dry_run):
# Use custom variants and append files if available on recipe-dir
recipe_dir = os.path.join(clone_to, 'conda')
condarc = select_user_condarc(paths=[recipe, os.curdir],
branch=os.environ.get('CI_COMMIT_REF_NAME'))
if condarc is not None:
logger.info('Condarc configuration file: %s', condarc)
variants_file = select_conda_build_config(paths=[recipe_dir, os.curdir],
branch=os.environ.get('CI_COMMIT_REF_NAME'))
logger.info('Conda build configuration file: %s', variants_file)
......@@ -563,7 +582,7 @@ def nightlies(ctx, order, dry_run):
ctx.invoke(build,
recipe_dir=[recipe_dir],
python=os.environ['PYTHON_VERSION'], #python version
condarc=None, #custom build configuration
condarc=condarc,
config=variants_file,
no_test=False,
append_file=append_file,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment