From 70cbee0468d1c691f0a20958568fb95e20ec9614 Mon Sep 17 00:00:00 2001 From: Richard Frank Date: Wed, 23 Mar 2016 10:14:07 -0400 Subject: [PATCH] BLD: Only upload to anaconda if on master --- .travis.yml | 5 +++-- ci/make_conda_packages.py | 18 ++++++++++-------- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/.travis.yml b/.travis.yml index 96db8756..70c3bc58 100644 --- a/.travis.yml +++ b/.travis.yml @@ -46,20 +46,21 @@ script: - flake8 zipline tests # deactive env to get access to anaconda command - source deactivate + - if [[ "$TRAVIS_SECURE_ENV_VARS" = "true" && "$TRAVIS_BRANCH" = "master" && "$TRAVIS_PULL_REQUEST" = "false" ]]; then DO_UPLOAD="true"; else DO_UPLOAD="false"; fi - | for recipe in $(ls -d conda/*/ | xargs -I {} basename {}); do if [[ "$recipe" = "zipline" ]]; then continue; fi conda build conda/$recipe --python=$CONDA_PY --numpy=$CONDA_NPY --skip-existing -c quantopian -c https://conda.anaconda.org/quantopian/label/ci RECIPE_OUTPUT=$(conda build conda/$recipe --python=$CONDA_PY --numpy=$CONDA_NPY --output) - if [[ -f "$RECIPE_OUTPUT" && "$TRAVIS_SECURE_ENV_VARS" = "true" ]]; then anaconda -t $ANACONDA_TOKEN upload "$RECIPE_OUTPUT" -u quantopian --label ci; fi + if [[ -f "$RECIPE_OUTPUT" && "$DO_UPLOAD" = "true" ]]; then anaconda -t $ANACONDA_TOKEN upload "$RECIPE_OUTPUT" -u quantopian --label ci; fi done # unshallow the clone so the conda build can clone it. - git fetch --unshallow - exec 3>&1; ZP_OUT=$(conda build conda/zipline --python=$CONDA_PY --numpy=$CONDA_NPY -c quantopian -c https://conda.anaconda.org/quantopian/label/ci | tee >(cat - >&3)) - ZP_OUTPUT=$(echo "$ZP_OUT" | grep "anaconda upload" | awk '{print $NF}') - - if [[ "$TRAVIS_SECURE_ENV_VARS" = "true" ]]; then anaconda -t $ANACONDA_TOKEN upload $ZP_OUTPUT -u quantopian --label ci; fi + - if [[ "$DO_UPLOAD" = "true" ]]; then anaconda -t $ANACONDA_TOKEN upload $ZP_OUTPUT -u quantopian --label ci; fi # reactivate env (necessary for coveralls) - source activate testenv diff --git a/ci/make_conda_packages.py b/ci/make_conda_packages.py index 162ef1e7..240e2606 100644 --- a/ci/make_conda_packages.py +++ b/ci/make_conda_packages.py @@ -25,11 +25,11 @@ def iter_stdout(cmd): PKG_PATH_PATTERN = re.compile(".* anaconda upload (?P.+)$") -def main(): +def main(env, do_upload): for recipe in get_immediate_subdirectories('conda'): cmd = ["conda", "build", os.path.join('conda', recipe), - "--python", os.environ['CONDA_PY'], - "--numpy", os.environ['CONDA_NPY'], + "--python", env['CONDA_PY'], + "--numpy", env['CONDA_NPY'], "--skip-existing", "-c", "quantopian", "-c", "https://conda.anaconda.org/quantopian/label/ci"] @@ -44,10 +44,8 @@ def main(): if match: output = match.group('pkg_path') - if (output and os.path.exists(output) and - os.environ.get('ANACONDA_TOKEN')): - - cmd = ["anaconda", "-t", os.environ['ANACONDA_TOKEN'], + if output and os.path.exists(output) and do_upload: + cmd = ["anaconda", "-t", env['ANACONDA_TOKEN'], "upload", output, "-u", "quantopian", "--label", "ci"] for line in iter_stdout(cmd): @@ -55,4 +53,8 @@ def main(): if __name__ == '__main__': - main() + env = os.environ.copy() + main(env, + do_upload=(env.get('ANACONDA_TOKEN') and + env.get('APPVEYOR_REPO_BRANCH') == 'master') and + 'APPVEYOR_PULL_REQUEST_NUMBER' not in env)