From 8201e2fd90852bdffdcb3cac21033d4a4bb694ba Mon Sep 17 00:00:00 2001 From: Rohan McGovern Date: Sat, 23 Feb 2019 06:57:49 +1000 Subject: [PATCH] Move from Travis to Circle CI As an experiment, and due to uncertainty around future of Travis. Some Travis config is left behind for now, and some of the Circle jobs are still set up as a dry-run. --- .circleci/config.yml | 128 +++++++++++++++++++++++++++++++++++++++++++ .travis.yml | 28 +++++----- README.md | 2 +- scripts/push-docs | 2 +- tox.ini | 28 ++++++++++ 5 files changed, 172 insertions(+), 16 deletions(-) create mode 100644 .circleci/config.yml diff --git a/.circleci/config.yml b/.circleci/config.yml new file mode 100644 index 00000000..deb6c6a9 --- /dev/null +++ b/.circleci/config.yml @@ -0,0 +1,128 @@ +version: 2.1 + +workflows: + version: 2 + ci-cd: + jobs: + - tox: + name: Python 2.6 tests + toxenv: py26 + install_py26: true + image_tag: 2.7.15-jessie + - tox: + name: Python 2.7 tests + toxenv: py27 + image_tag: 2.7.15-stretch + - tox: + name: Python 3.6 tests + toxenv: py36 + - tox: + name: Static checks + toxenv: static + - tox: + name: Coverage + toxenv: cov-circle-py27,cov-circle-py36 + # For coveralls token. + # How to make it work for pull requests?? + context: secrets + - tox: + name: Build docs + toxenv: docs + # For pushing to gh-pages + context: secrets + post-steps: + - run: scripts/push-docs + - release: + name: Release to PyPI + # For twine credentials + context: secrets + # Only release if all tests passed + requires: + - Python 2.6 tests + - Python 2.7 tests + - Python 3.6 tests + - Static checks + - Coverage + - Build docs + filters: + tags: + only: /^v.*/ + +jobs: + release: + docker: + - image: circleci/python:3.6.8-stretch + working_directory: ~/repo + steps: + - checkout + - run: sudo apt-get install twine + - run: python ./setup.py sdist bdist_wheel + - run: >- + if ! test -z "${TWINE_USERNAME}" && ! test -z "${CIRCLE_TAG}"; then + echo twine upload --skip-existing dist/*.tar.gz dist/*.whl + fi + + tox: + parameters: + toxenv: + description: "tox environment to execute" + type: string + image_tag: + description: tag of circleci/python image + default: 3.6.8-stretch + type: string + install_py26: + default: false + type: boolean + + docker: + - image: circleci/python:<< parameters.image_tag >> + + working_directory: ~/repo + + steps: + - when: + condition: <> + steps: + - run: >- + sudo /bin/sh -c ' + echo "deb http://ppa.launchpad.net/fkrull/deadsnakes/ubuntu trusty main" > + /etc/apt/sources.list.d/deadsnakes.list' + - run: gpg --keyserver keyserver.ubuntu.com --recv-keys 'FF39 97E8 3CD9 69B4 09FB 24BC 5BB9 2C09 DB82 666C' + - run: gpg --export DB82666C | sudo apt-key add - + - run: sudo apt-get update + - run: sudo apt-get remove python2.7 + - run: sudo rm -rf /usr/local + - run: sudo apt-get install python2.6 + - run: >- + curl -L https://github.com/pypa/get-pip/raw/3de61057f0037f4a12b4a3c6936e9ee91d07a811/2.6/get-pip.py -o /tmp/get-pip.py && + echo '02b9553a4fc36740ff183c40ce413d4ae840d17099e16a43ef4f7996230ea173 /tmp/get-pip.py' | sha256sum --check + - run: sudo python2.6 /tmp/get-pip.py -vvv + + - restore_cache: + key: v1-local-venv-<< parameters.image_tag >> + + - checkout + + - restore_cache: + key: v1-cache-pip-{{ checksum "requirements.txt" }}-{{ checksum "test-requirements.txt" }} + + - run: + name: install tox + command: | + pip install --user tox + + - save_cache: + key: v1-local-venv-<< parameters.image_tag >> + paths: + - "~/.local" + + - run: + name: run tests + command: | + ~/.local/bin/tox -e << parameters.toxenv >> + + - save_cache: + key: v1-cache-pip-{{ checksum "requirements.txt" }}-{{ checksum "test-requirements.txt" }} + paths: + - "~/.cache/pip" diff --git a/.travis.yml b/.travis.yml index 3e90cfe4..5ad098ae 100644 --- a/.travis.yml +++ b/.travis.yml @@ -20,8 +20,8 @@ matrix: env: TOX_ENV=static - python: "3.6" env: TOX_ENV=docs - - python: "3.6" - env: TOX_ENV=cov-travis-py27,cov-travis-py36 +# - python: "3.6" +# env: TOX_ENV=cov-travis-py27,cov-travis-py36 - python: "2.6" env: TOX_ENV=py26 ITER=1 - python: "2.6" @@ -31,15 +31,15 @@ matrix: - python: "3.6" env: TOX_ENV=py36 ITER=1 script: tox -e $TOX_ENV -after_success: -- test $TOX_ENV = docs && scripts/push-docs -deploy: - provider: pypi - user: rohanpm - password: - secure: AYK5kq8zbBcpnhZPWwO6xxMh/FvMpUMBrC31xrNi+e8z607MW+VnF4b5B/x8j2Ls722nCodg6Ms+PHOY6CD+8DDyAkqOthhJlrAeJrhrY0JPQ3nwnMheENi0yHimKm+XX7u9gKV/1/DNs5Pt9YvnxXq1QFifLCvbagcwvAAu0US+IgVR9erfZdw2FsV6fLMi/+ZkUFmvgidRx79AFfeIJcc81bK5s85YNXxL4plrgatbx4NXbvjtX5uI3n68xHhZod2IlLL7WSff38/K+LRTDTNiiOvNEcIVEidNICeKD8a3wE1PesRpfCdeGsJe7bGi3GqZKgDn7dr1gok/9cjpCyZ4QuDYHoP63qCOfku4F8QLV/A26TvDGMlOMrbfJWUCw3/7nzKYeW+Dd5siZmDGLCw6z9lR1epp1OJ+RGC/w8Yhh3eZ3VblX50VL7O1qJH/AMw44Z9tfzKQm3e3XwPZuxr1xq7e/ko76DBznEWfYSYAahAwEqNu7s725jnfBeFKnjqbTw+C0LvELei6/t1XYeEAGNv29CNgxi2MctQfHJfuD847E3K+vKaGtkKfHaDgfffJw2gJ/wzKMBNwEE3OHGDrmeFxaUMT4SoEkewb00HX0QbjqJhGiYVLuRj/MLgWP+SRdUes0j8xi9zzwJTTkPWzty+HoyTkBQFTYrWFlUk= - on: - tags: true - condition: $TOX_ENV = py36 - distributions: sdist bdist_wheel - skip_existing: true +#after_success: +#- test $TOX_ENV = docs && scripts/push-docs +# deploy: +# provider: pypi +# user: rohanpm +# password: +# secure: AYK5kq8zbBcpnhZPWwO6xxMh/FvMpUMBrC31xrNi+e8z607MW+VnF4b5B/x8j2Ls722nCodg6Ms+PHOY6CD+8DDyAkqOthhJlrAeJrhrY0JPQ3nwnMheENi0yHimKm+XX7u9gKV/1/DNs5Pt9YvnxXq1QFifLCvbagcwvAAu0US+IgVR9erfZdw2FsV6fLMi/+ZkUFmvgidRx79AFfeIJcc81bK5s85YNXxL4plrgatbx4NXbvjtX5uI3n68xHhZod2IlLL7WSff38/K+LRTDTNiiOvNEcIVEidNICeKD8a3wE1PesRpfCdeGsJe7bGi3GqZKgDn7dr1gok/9cjpCyZ4QuDYHoP63qCOfku4F8QLV/A26TvDGMlOMrbfJWUCw3/7nzKYeW+Dd5siZmDGLCw6z9lR1epp1OJ+RGC/w8Yhh3eZ3VblX50VL7O1qJH/AMw44Z9tfzKQm3e3XwPZuxr1xq7e/ko76DBznEWfYSYAahAwEqNu7s725jnfBeFKnjqbTw+C0LvELei6/t1XYeEAGNv29CNgxi2MctQfHJfuD847E3K+vKaGtkKfHaDgfffJw2gJ/wzKMBNwEE3OHGDrmeFxaUMT4SoEkewb00HX0QbjqJhGiYVLuRj/MLgWP+SRdUes0j8xi9zzwJTTkPWzty+HoyTkBQFTYrWFlUk= +# on: +# tags: true +# condition: $TOX_ENV = py36 +# distributions: sdist bdist_wheel +# skip_existing: true diff --git a/README.md b/README.md index 32e9643d..49c19ff6 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ A library of composable Python executors and futures. -[![Build Status](https://travis-ci.org/rohanpm/more-executors.svg?branch=master)](https://travis-ci.org/rohanpm/more-executors) +[![Build Status](https://circleci.com/gh/rohanpm/more-executors/tree/master.svg?style=svg)](https://circleci.com/gh/rohanpm/more-executors/tree/master) [![Coverage Status](https://coveralls.io/repos/github/rohanpm/more-executors/badge.svg?branch=master)](https://coveralls.io/github/rohanpm/more-executors?branch=master) - [API documentation](https://rohanpm.github.io/more-executors/) diff --git a/scripts/push-docs b/scripts/push-docs index 7091f41d..fed07292 100755 --- a/scripts/push-docs +++ b/scripts/push-docs @@ -1,7 +1,7 @@ #!/bin/bash set -e -if [ "$TRAVIS_BRANCH" != "master" ] || [ $TRAVIS_PULL_REQUEST != "false" ]; then +if [ "${TRAVIS_BRANCH:-${CIRCLE_BRANCH}}" != "master" ] || [ $TRAVIS_PULL_REQUEST != "false" ] || [ "${CIRCLE_PULL_REQUEST}" != "" ]; then echo "Docs would now be pushed, if this were submitted to master." exit 0 fi diff --git a/tox.ini b/tox.ini index 21dca60f..2c05a82f 100644 --- a/tox.ini +++ b/tox.ini @@ -6,6 +6,12 @@ deps=-rtest-requirements.txt commands=pytest -v {posargs} whitelist_externals=sh +[testenv:py26] +basepython=python2.6 + +[testenv:py27] +basepython=python2.7 + [testenv:static] deps= flake8 @@ -26,6 +32,28 @@ usedevelop=true commands= pytest --cov-report=html --cov=more_executors {posargs} +[testenv:cov-circle-py27] +passenv = COVERALLS_REPO_TOKEN CIRCLECI CIRCLE_* CI_PULL_REQUEST +deps= + -rtest-requirements.txt + pytest-cov + coveralls +usedevelop=true +commands= + pytest --cov=more_executors {posargs} + coveralls --output=coverage.json + +[testenv:cov-circle-py36] +passenv = COVERALLS_REPO_TOKEN CIRCLECI CIRCLE_* CI_PULL_REQUEST +deps= + -rtest-requirements.txt + pytest-cov + coveralls +usedevelop=true +commands= + pytest --cov=more_executors {posargs} + sh -c 'if ! test -z "$\{COVERALLS_REPO_TOKEN\}"; then coveralls --merge=coverage.json; fi' + [testenv:cov-travis-py27] passenv = TRAVIS TRAVIS_* deps=