tests/recipes/click-test-feedstock/.circleci/run_docker_build.sh
#!/usr/bin/env bash

# PLEASE NOTE: This script has been automatically generated by conda-smithy. Any changes here
# will be lost next time ``conda smithy rerender`` is run. If you would like to make permanent
# changes to this script, consider a proposal to conda-smithy so that other feedstocks can also
# benefit from the improvement.

FEEDSTOCK_ROOT=$(cd "$(dirname "$0")/.."; pwd;)
RECIPE_ROOT=$FEEDSTOCK_ROOT/recipe

docker info

config=$(cat <<CONDARC

channels:
 - conda-forge
 - defaults

conda-build:
 root-dir: /feedstock_root/build_artefacts

show_channel_urls: true

CONDARC
)

# In order for the conda-build process in the container to write to the mounted
# volumes, we need to run with the same id as the host machine, which is
# normally the owner of the mounted volumes, or at least has write permission
HOST_USER_ID=$(id -u)
# Check if docker-machine is being used (normally on OSX) and get the uid from
# the VM
if hash docker-machine 2> /dev/null && docker-machine active > /dev/null; then
    HOST_USER_ID=$(docker-machine ssh $(docker-machine active) id -u)
fi

rm -f "$FEEDSTOCK_ROOT/build_artefacts/conda-forge-build-done"

cat << EOF | docker run -i \
                        -v "${RECIPE_ROOT}":/recipe_root \
                        -v "${FEEDSTOCK_ROOT}":/feedstock_root \
                        -e CONFIG="$CONFIG" \
                        -a stdin -a stdout -a stderr \
                        condaforge/linux-anvil \
                        bash || exit 1

set -e
set +x
export BINSTAR_TOKEN=${BINSTAR_TOKEN}
set -x
export PYTHONUNBUFFERED=1

echo "$config" > ~/.condarc

conda install --yes --quiet conda-forge-ci-setup
source run_conda_forge_build_setup

# testing purposes: get conda-build from defaults
conda install -n root --quiet --yes -c defaults conda-build

conda build /recipe_root -m /feedstock_root/.ci_support/circle_${CONFIG}.yaml --quiet --suppress-variables || exit 1
upload_or_check_non_existence /recipe_root conda-forge --channel=main -m /feedstock_root/.ci_support/circle_${CONFIG}.yaml || exit 1

touch /feedstock_root/build_artefacts/conda-forge-build-done
EOF

# double-check that the build got to the end
# see https://github.com/conda-forge/conda-smithy/pull/337
# for a possible fix
set -x
test -f "$FEEDSTOCK_ROOT/build_artefacts/conda-forge-build-done" || exit 1
