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

use a script instead of piping to stdin in run_docker_build #337

Merged
merged 8 commits into from
Mar 2, 2018
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
1 change: 1 addition & 0 deletions conda_smithy/feedstock_content/.gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
*.pyc

build_artifacts
.circleci/build.sh
48 changes: 31 additions & 17 deletions conda_smithy/templates/run_docker_build.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
# 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 All @@ -25,6 +26,7 @@ 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
Expand All @@ -37,19 +39,15 @@ fi

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

cat << EOF | {{ docker.executable }} run -i \
-v "${RECIPE_ROOT}":/home/conda/recipe_root \
-v "${FEEDSTOCK_ROOT}":/home/conda/feedstock_root \
-e CONFIG="$CONFIG" \
-e HOST_USER_ID="${HOST_USER_ID}" \
-a stdin -a stdout -a stderr \
{{ docker.image }} \
{{ docker.command }} || exit 1
ARTIFACTS="$FEEDSTOCK_ROOT/build_artifacts"

test -d "$ARTIFACTS" || mkdir "$ARTIFACTS"
DONE_CANARY="$ARTIFACTS/conda-forge-build-done"
rm -f "$DONE_CANARY"

cat << EOF > "$FEEDSTOCK_ROOT/.circleci/build.sh"

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

echo "$config" > ~/.condarc
Expand All @@ -60,17 +58,33 @@ conda install --yes --quiet conda-forge-ci-setup=1
{% if build_setup -%}
{{ build_setup }}{% endif -%}

conda build /home/conda/recipe_root -m /home/conda/feedstock_root/.ci_support/${CONFIG}.yaml --quiet || exit 1
conda build /home/conda/recipe_root -m /home/conda/feedstock_root/.ci_support/${CONFIG}.yaml --quiet
{%- for owner, channel in channels['targets'] %}
{{ upload_script }} /home/conda/recipe_root {{ owner }} --channel={{ channel }} -m /home/conda/feedstock_root/.ci_support/${CONFIG}.yaml || exit 1
{{ upload_script }} /home/conda/recipe_root {{ owner }} --channel={{ channel }} -m /home/conda/feedstock_root/.ci_support/${CONFIG}.yaml
{%- endfor %}

touch /home/conda/feedstock_root/build_artifacts/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
echo "BINSTAR_TOKEN=${BINSTAR_TOKEN}" > "${FEEDSTOCK_ROOT}/env"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Put this inside .circleci folder?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually would it make sense to save this in a directory that is not mounted in the container? To propose an arbitrary option, what about ~/.conda-smithy/upload.token?

set -x
test -f "$FEEDSTOCK_ROOT/build_artifacts/conda-forge-build-done" || exit 1

# Create and run the container in two commands,
# so the token env isn't on disk too long

CONTAINER=$(docker create -t \
-v "${RECIPE_ROOT}":/home/conda/recipe_root \
-v "${FEEDSTOCK_ROOT}":/home/conda/feedstock_root \
--env-file ${FEEDSTOCK_ROOT}/env \
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was not aware of this option. Nice fix!

-e HOST_USER_ID="${HOST_USER_ID}" \
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You've missed the CONFIG env variable here.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

{{ docker.image }} \
{{ docker.command }} \
/home/conda/feedstock_root/.circleci/build.sh || exit $?)

rm "${FEEDSTOCK_ROOT}/env"
# do it
docker start -i $CONTAINER

# verify that the end of the script was reached
test -f "$DONE_CANARY"