<commit_before>---
version: 2

jobs:
  python:
    docker:
      - image: udata/circleci
      - image: mongo:3.2
      - image: redis
      - image: udata/elasticsearch:2.4.5
    environment:
       BASH_ENV: /root/.bashrc
    steps:
      - checkout
      - run:
          name: Compute Python dependencies key
          command: cat requirements/*.pip > python.deps
      - run:
          name: Get the base reference branch
          command: export BASE_BRANCH=$(base_branch)
      - restore_cache:
          keys:
          - py-cache-{{ checksum "python.deps" }}
          - py-cache-{{ .Branch }}
          - py-cache-{{ .Environment.BASE_BRANCH }}
      - run:
          name: Install python dependencies
          command: |
            virtualenv venv
            source venv/bin/activate
            pip install -U --pre udata[test]
            pip install -e . || pip install -e .
            pip install -r requirements/circleci.pip
      - save_cache:
          key: py-cache-{{ checksum "python.deps" }}
          paths:
          - venv
      - save_cache:
          key: py-cache-{{ .Branch }}
          paths:
          - venv
      - run:
          name: Run tests
          command: |
            mkdir -p reports/python
            source venv/bin/activate
            nosetests --with-xunit --xunit-file=reports/python/tests.xml  udata_croquemort
      - store_test_results:
          path: reports/python
      - store_artifacts:
          path: reports/
          destination: reports

      - persist_to_workspace:
          root: .
          paths:
          - venv

  dist:
    docker:
      - image: udata/circleci
    environment:
       BASH_ENV: /root/.bashrc
    steps:
      - checkout
      - attach_workspace:
          at: .
      - run:
          name: Build a distributable package
          command: |
            source venv/bin/activate
            if [[ $CIRCLE_TAG ]]; then inv pydist; else inv pydist -b $CIRCLE_BUILD_NUM; fi
      - store_artifacts:
          path: dist
      - persist_to_workspace:
          root: .
          paths:
            - dist

  publish:
    docker:
      - image: udata/circleci
    steps:
      - attach_workspace:
          at: .
      - run:
          name: Install Twine
          command: pip install twine
      - deploy:
          name: Publish on PyPI
          command: twine upload --username "${PYPI_USERNAME}" --password "${PYPI_PASSWORD}" dist/*.whl

workflows:
  version: 2
  build:
    jobs:
      - python:
          filters:
            tags:
              only: /v[0-9]+(\.[0-9]+)*/
      - dist:
          requires:
            - python
          filters:
            tags:
              only: /v[0-9]+(\.[0-9]+)*/
      - publish:
          requires:
            - dist
          filters:
            branches:
              only:
                - master
                - /v[0-9]+(\.[0-9]+)*/
            tags:
              only: /v[0-9]+(\.[0-9]+)*/<commit_msg>Circle CI context<commit_after>---
version: 2

jobs:
  python:
    docker:
      - image: udata/circleci
      - image: mongo:3.2
      - image: redis
      - image: udata/elasticsearch:2.4.5
    environment:
       BASH_ENV: /root/.bashrc
    steps:
      - checkout
      - run:
          name: Compute Python dependencies key
          command: cat requirements/*.pip > python.deps
      - run:
          name: Get the base reference branch
          command: export BASE_BRANCH=$(base_branch)
      - restore_cache:
          keys:
          - py-cache-{{ checksum "python.deps" }}
          - py-cache-{{ .Branch }}
          - py-cache-{{ .Environment.BASE_BRANCH }}
      - run:
          name: Install python dependencies
          command: |
            virtualenv venv
            source venv/bin/activate
            pip install -U --pre udata[test]
            pip install -e . || pip install -e .
            pip install -r requirements/circleci.pip
      - save_cache:
          key: py-cache-{{ checksum "python.deps" }}
          paths:
          - venv
      - save_cache:
          key: py-cache-{{ .Branch }}
          paths:
          - venv
      - run:
          name: Run tests
          command: |
            mkdir -p reports/python
            source venv/bin/activate
            nosetests --with-xunit --xunit-file=reports/python/tests.xml  udata_croquemort
      - store_test_results:
          path: reports/python
      - store_artifacts:
          path: reports/
          destination: reports

      - persist_to_workspace:
          root: .
          paths:
          - venv

  dist:
    docker:
      - image: udata/circleci
    environment:
       BASH_ENV: /root/.bashrc
    steps:
      - checkout
      - attach_workspace:
          at: .
      - run:
          name: Build a distributable package
          command: |
            source venv/bin/activate
            if [[ $CIRCLE_TAG ]]; then inv pydist; else inv pydist -b $CIRCLE_BUILD_NUM; fi
      - store_artifacts:
          path: dist
      - persist_to_workspace:
          root: .
          paths:
            - dist

  publish:
    docker:
      - image: udata/circleci
    steps:
      - attach_workspace:
          at: .
      - run:
          name: Install Twine
          command: pip install twine
      - deploy:
          name: Publish on PyPI
          command: twine upload --username "${PYPI_USERNAME}" --password "${PYPI_PASSWORD}" dist/*.whl

workflows:
  version: 2
  build:
    jobs:
      - python:
          filters:
            tags:
              only: /v[0-9]+(\.[0-9]+)*/
      - dist:
          requires:
            - python
          filters:
            tags:
              only: /v[0-9]+(\.[0-9]+)*/
      - publish:
          requires:
            - dist
          filters:
            branches:
              only:
                - master
                - /v[0-9]+(\.[0-9]+)*/
            tags:
              only: /v[0-9]+(\.[0-9]+)*/
          context: org-global
{'fraction_non_alphanumeric': 0.1091336467427804, 'fraction_numerical': 0.007723304231027535, 'mean_word_length': 1.2327586206896552, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5482379', 'n_tokens_mistral': 1802, 'n_tokens_neox': 1762, 'n_words': 415}