Skip to content

Commit

Permalink
use set -e to simplify exit codes in docker build
Browse files Browse the repository at this point in the history
  • Loading branch information
minrk committed Feb 8, 2017
1 parent 7b8dddb commit df12dee
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions conda_smithy/templates/run_docker_build.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
# changes to this script, consider a proposal to conda-smithy so that other feedstocks can also
# benefit from the improvement.

set -e

FEEDSTOCK_ROOT=$(cd "$(dirname "$0")/.."; pwd;)
RECIPE_ROOT=$FEEDSTOCK_ROOT/{{ recipe_dir }}

Expand Down Expand Up @@ -33,6 +35,7 @@ rm -f "$DONE_CANARY"

cat << EOF > "$FEEDSTOCK_ROOT/ci_support/build.sh"
set -e
export PYTHONUNBUFFERED=1
echo "$config" > ~/.condarc
Expand All @@ -44,7 +47,7 @@ conda install --yes --quiet conda-forge-build-setup
{{ build_setup }}{% endif -%}
{%- block build %}
conda build /recipe_root --quiet || exit 1
conda build /recipe_root --quiet
{%- endblock -%}
# signal build-done with a file to protect against
Expand All @@ -63,20 +66,20 @@ CONTAINER=$(docker create -t \
{{ docker.command }} /feedstock_root/ci_support/build.sh || exit $?)

# build
docker start -i $CONTAINER || exit 1
test -f "$DONE_CANARY" || exit 1
docker start -i $CONTAINER
test -f "$DONE_CANARY"
rm -f "$DONE_CANARY"

# commit, so we can run upload in the same environment
IMAGE=$(docker commit $CONTAINER || exit 1)
IMAGE=$(docker commit $CONTAINER)

# upload with the token passed through stdin
# FIXME: Should this run if there is no token?
cat << EOF | docker run --rm -i \
$VOLUMES \
$IMAGE \
{{ docker.command }} || exit $?
set -e
export BINSTAR_TOKEN=${BINSTAR_TOKEN}
{%- block test_and_upload %}
Expand All @@ -89,7 +92,7 @@ export BINSTAR_TOKEN=${BINSTAR_TOKEN}
touch /feedstock_root/build_artefacts/conda-forge-build-done
EOF

test -f "$DONE_CANARY" || exit 1
test -f "$DONE_CANARY"
# everything succeeded, remove our container and image
docker rm -f "$CONTAINER"
docker rmi "$IMAGE"
Expand Down

0 comments on commit df12dee

Please sign in to comment.