SHARE
TWEET

Untitled

a guest Mar 20th, 2019 54 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. version: 2
  2.  
  3. jobs:
  4.  
  5.   # Building and testing the project
  6.   # Useful when a PR is open, for example
  7.   build-and-test:
  8.     # Our environment, Python 3.6.8
  9.     docker:
  10.       - image: circleci/python:3.6.8
  11.  
  12.     # The steps for our build-and-test
  13.     steps:
  14.       # Get the code
  15.       - checkout
  16.  
  17.       # Cache can be tricky at first, but this means
  18.       # Please, restore my cache (what is actually on the cache will be defined later)
  19.       # if the text key `deps-{{ checksum "poetry.lock" }}` changes (and it WILL change everytime poetry.lock is updated since we rely on its checksum)
  20.       # and poetry.lock is updated every time we add a new dependency to our project
  21.       - restore_cache:
  22.           keys:
  23.             - deps-{{ checksum "poetry.lock" }}
  24.  
  25.       # Let's install the dependencies
  26.       - run:
  27.           name: Install Dependencies
  28.           command: |
  29.             poetry install
  30.      
  31.       # Save's the specified path as a cache. This is the path Poetry uses to install the dependencies
  32.       # So if you don't install anything new, this folder won't change and the cache will be effective
  33.       - save_cache:
  34.           key: deps-{{ checksum "poetry.lock" }}
  35.           paths:
  36.             - /home/circleci/.cache/pypoetry/virtualenvs
  37.  
  38.       # Another step, run flake8
  39.       - run:
  40.           name: Run flake8
  41.           command: |
  42.             poetry run flake8 .
  43.  
  44.       # Last step, runs our tests ommiting the dependencies path (so we don't take their coverage into account)
  45.       # And send our coverage somewhere, in this case, coveralls
  46.       - run:
  47.           name: Run Pytest, report coverage
  48.           command: |
  49.             poetry run coverage run --omit="/home/circleci/.cache/pypoetry/virtualenvs" -m pytest
  50.             poetry run coveralls
  51.  
  52.   # This is the definition of another job, the one we use to publish the package to PyPI
  53.   deployment:
  54.  
  55.     # Same environment
  56.     docker:
  57.         - image: circleci/python:3.6.8
  58.       steps:
  59.  
  60.         # Gets the code
  61.         - checkout
  62.  
  63.         # Use `poetry publish` to Publish the package using username and password from CircleCI environment variables
  64.         # Which can be configured inside CircleCI's interface
  65.         - run:
  66.             name: Push to PyPI
  67.             command: |
  68.               poetry publish --build --username "${PYPI_USERNAME}" --password "${PYPI_PASSWORD}" --no-interaction
  69.  
  70. # In the workflows section, we specify when we want to run the jobs defined
  71. workflows:
  72.   version: 2
  73.  
  74.   # The build-and-test we will run EVERYTIME a piece of code changes
  75.   build-and-test-workflow:
  76.     jobs:
  77.       - build-and-test
  78.  
  79.   # The deployment workflow publishes the package
  80.   deployment-workflow:
  81.     jobs:
  82.  
  83.       # Runs build and test, but now just on Git tags (created from a GitHub release)
  84.       - build-and-test:
  85.           filters:
  86.             tags:
  87.               only: /v[0-9]+(\.[0-9]+)*/
  88.             branches:
  89.               ignore: /.*/
  90.  
  91.       # Runs the deployment job, just with the tags as well
  92.       - deployment:
  93.           requires:
  94.             - build-and-test
  95.           filters:
  96.               tags:
  97.                 only: /v[0-9]+(\.[0-9]+)*/
  98.               branches:
  99.                 ignore: /.*/
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top