diff --git a/conda_smithy/configure_feedstock.py b/conda_smithy/configure_feedstock.py index 3ce69495a..ee4d8ef78 100755 --- a/conda_smithy/configure_feedstock.py +++ b/conda_smithy/configure_feedstock.py @@ -178,9 +178,7 @@ def render_circle(jinja_env, forge_config, forge_dir): forge_config['upload_script'] = "upload_or_check_non_existence" # TODO: Conda has a convenience for accessing nested yaml content. - templates = forge_config.get('templates', {}) - template_name = templates.get('run_docker_build', - 'run_docker_build_matrix.tmpl') + template_name = 'run_docker_build.tmpl' template = jinja_env.get_template(template_name) target_fname = os.path.join(forge_dir, 'ci_support', 'run_docker_build.sh') with write_file(target_fname) as fh: @@ -650,7 +648,7 @@ def main(forge_file_directory): config = {'docker': {'executable': 'docker', 'image': 'condaforge/linux-anvil', 'command': 'bash'}, - 'templates': {'run_docker_build': 'run_docker_build_matrix.tmpl'}, + 'templates': {}, 'travis': {}, 'circle': {}, 'appveyor': {}, @@ -702,7 +700,8 @@ def main(forge_file_directory): tmplt_dir = os.path.join(conda_forge_content, 'templates') # Load templates from the feedstock in preference to the smithy's templates. - env = Environment(loader=FileSystemLoader([os.path.join(forge_dir, 'templates'), + env = Environment(extensions=['jinja2.ext.do'], + loader=FileSystemLoader([os.path.join(forge_dir, 'templates'), tmplt_dir])) copy_feedstock_content(forge_dir) diff --git a/conda_smithy/templates/circle.yml.tmpl b/conda_smithy/templates/circle.yml.tmpl index 5c5be5688..e9b82d481 100644 --- a/conda_smithy/templates/circle.yml.tmpl +++ b/conda_smithy/templates/circle.yml.tmpl @@ -1,3 +1,10 @@ +{%- macro matrix_case_name(matrix_item) -%} + build + {%- for dep, ver in matrix_item -%} + __{{ dep }}_{{ ver }} + {%- endfor %} +{%- endmacro -%} + version: 2 jobs: @@ -14,9 +21,16 @@ jobs: # The Circle-CI build should not be active, but if this is not true for some reason, do a fast finish. command: exit 0 {%- else %} - build: +{%- for case in matrix %} + {{ matrix_case_name(case) }}: working_directory: ~/test machine: true + {%- if case[0] %} + environment: + {%- for dep, ver in case %} + - {{ dep }}: "{{ ver }}" + {%- endfor -%} + {%- endif %} steps: - checkout - run: @@ -26,9 +40,18 @@ jobs: ./ci_support/checkout_merge_commit.sh - run: command: docker pull condaforge/linux-anvil + {%- if case[0] %} + - run: + name: Print conda-build environment variables + command: | + {%- for dep, ver in case %} + echo {{ '"' }}{{ dep }}{{ '=${' }}{{ dep }}{{ '}"' }} + {%- endfor -%} + {%- endif %} - run: # Run, test and (if we have a BINSTAR_TOKEN) upload the distributions. command: ./ci_support/run_docker_build.sh +{%- endfor -%} {%- endif -%} {%- endblock %} @@ -44,7 +67,9 @@ workflows: ignore: - /.*/ {%- else %} - - build +{%- for case in matrix %} + - {{ matrix_case_name(case) }} +{%- endfor -%} {%- endif -%} {%- endblock %} {# #} diff --git a/conda_smithy/templates/run_docker_build.tmpl b/conda_smithy/templates/run_docker_build.tmpl index 90d57163f..58c5131ed 100644 --- a/conda_smithy/templates/run_docker_build.tmpl +++ b/conda_smithy/templates/run_docker_build.tmpl @@ -1,3 +1,16 @@ +{%- macro matrix_env_vars(a_matrix) -%} + {{ '-e HOST_USER_ID="${HOST_USER_ID}" \\' }} + {%- set vars_used = [] %} + {%- for case in a_matrix -%} + {%- for dep, ver in case -%} + {%- if dep not in vars_used %} + -e {{ dep }}="${{ "{" }}{{ dep }}{{ "}" }}" \ + {%- do vars_used.append(dep) -%} + {%- endif -%} + {%- endfor -%} + {%- endfor -%} +{%- endmacro -%} + #!/usr/bin/env bash # PLEASE NOTE: This script has been automatically generated by conda-smithy. Any changes here @@ -40,7 +53,7 @@ rm -f "$FEEDSTOCK_ROOT/build_artefacts/conda-forge-build-done" cat << EOF | {{ docker.executable }} run -i \ -v "${RECIPE_ROOT}":/recipe_root \ -v "${FEEDSTOCK_ROOT}":/feedstock_root \ - -e HOST_USER_ID="${HOST_USER_ID}" \ + {{ matrix_env_vars(matrix) }} -a stdin -a stdout -a stderr \ {{ docker.image }} \ {{ docker.command }} || exit 1 @@ -59,12 +72,10 @@ conda install --yes --quiet conda-forge-build-setup {% if build_setup -%} {{ build_setup }}{% endif -%} -{%- block build %} conda build /recipe_root --quiet || exit 1 {%- for owner, channel in channels['targets'] %} {{ upload_script }} /recipe_root {{ owner }} --channel={{ channel }} || exit 1 -{%- endfor -%} -{%- endblock -%} +{%- endfor %} touch /feedstock_root/build_artefacts/conda-forge-build-done EOF diff --git a/conda_smithy/templates/run_docker_build_matrix.tmpl b/conda_smithy/templates/run_docker_build_matrix.tmpl deleted file mode 100644 index d182cef7d..000000000 --- a/conda_smithy/templates/run_docker_build_matrix.tmpl +++ /dev/null @@ -1,19 +0,0 @@ -{%- extends "run_docker_build.tmpl" -%} -{% macro matrix_env(matrix_item) -%} - {%- for dep_name, version in matrix_item %} - export {{ dep_name }}={{version }} - {%- endfor %} -{%- endmacro -%} - -{%- block build -%} - # Embarking on {{ matrix|length }} case(s). -{%- for case in matrix %} - {%- if case %} - {{- matrix_env(case) }} - {%- endif -%} - {{- super()|indent(4) }} -{% endfor %}{% endblock -%} -{%- block test_and_upload -%}{% for case in matrix -%} - {{ matrix_env(case) }} - {{- super()|indent(4) }} -{%- endfor -%}{% endblock -%}