<commit_before>---
version: 2

jobs:
  python:
    docker:
      - image: udata/circleci:2-alpine
      - image: circleci/mongo:3.6-stretch-ram
      - image: redis:alpine
      - 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:
          - py3-cache-v6-{{ arch }}-{{ checksum "python.deps" }}
          - py3-cache-v6-{{ arch }}-{{ .Branch }}
          - py3-cache-v6-{{ arch }}-{{ .Environment.BASE_BRANCH }}
      - run:
          name: Install python dependencies
          command: |
            virtualenv venv
            source venv/bin/activate
            pip install -e . || pip install -e .
            pip install -r requirements/circleci.pip
      - save_cache:
          key: py3-cache-v6-{{ arch }}-{{ checksum "python.deps" }}
          paths:
          - venv
      - save_cache:
          key: py3-cache-v6-{{ arch }}-{{ .Branch }}
          paths:
          - venv
      - run:
          name: Check dependencies
          command: |
            source venv/bin/activate
            pip check
      - run:
          name: Run tests
          command: |
            mkdir -p reports/python
            source venv/bin/activate
            inv test --report --ci
      - store_test_results:
          path: reports/python
      - store_artifacts:
          path: reports/
          destination: reports

      - persist_to_workspace:
          root: .
          paths:
          - venv

  assets:
    docker:
      # TODO make an image based on 2-alpine w/ nvm and phantom deps
      - image: udata/circleci:py3
    environment:
       BASH_ENV: /root/.bashrc
    steps:
      - checkout
      - run:
          name: Compute JS dependencies key
          command: cat .nvmrc package.json > js.deps
      - run:
          name: Get the base reference branch
          command: export BASE_BRANCH=$(base_branch)
      - restore_cache:
          keys:
            - js-cache-{{ arch }}-{{ checksum "js.deps" }}
            - js-cache-{{ arch }}-{{ .Branch }}
            - js-cache-{{ arch }}-{{ .Environment.BASE_BRANCH }}
      - run:
          name: Install NodeJS and dependencies
          command: nvm install && npm install
      - save_cache:
          key: js-cache-{{ arch }}-{{ checksum "js.deps" }}
          paths:
          - node_modules
      - save_cache:
          key: js-cache-{{ arch }}-{{ .Branch }}
          paths:
          - node_modules
      - run:
          name: Execute Karma tests
          command: |
            mkdir -p reports/karma
            REPORT_DIR=reports/karma npm -s run test:unit -- --reporters mocha,junit
      - store_test_results:
          path: reports/karma
      - store_artifacts:
          path: reports/
          destination: reports
      - run:
          name: Compile assets
          command: |
            npm run assets:build
            npm run widgets:build
            npm run oembed:build

      - persist_to_workspace:
          root: .
          paths:
            - udata/static
            - udata/manifest.json

  dist:
    docker:
      - image: udata/circleci:2-alpine
    environment:
       BASH_ENV: /root/.bashrc
    steps:
      - checkout
      - attach_workspace:
          at: .
      - run:
          name: Build a distributable package
          command: |
            source venv/bin/activate
            # Build a wheel release
            if [[ $CIRCLE_TAG ]]; then
                # This is a tagged release
                inv pydist
            elif [[ "$CIRCLE_BRANCH" == feature/* ]]; then
                # This is a feature branch
                inv pydist -b $CIRCLE_BUILD_NUM+${CIRCLE_BRANCH#*/}
            else
                # This is a simple development build
                inv pydist -b $CIRCLE_BUILD_NUM
            fi
      - store_artifacts:
          path: dist
      - persist_to_workspace:
          root: .
          paths:
            - dist

  publish:
    docker:
      - image: udata/circleci:2-alpine
    steps:
      - attach_workspace:
          at: .
      - deploy:
          name: Publish on PyPI
          command: |
            pip install twine
            twine upload --username "${PYPI_USERNAME}" --password "${<PASSWORD>}" dist/*.whl

  github:
    docker:
      - image: apihackers/ghr
    steps:
      - attach_workspace:
          at: .
      - run:
          name: Upload github release
          command: -t ${GITHUB_OAUTH_TOKEN} ${CIRCLE_TAG} dist

workflows:
  version: 2
  build:
    jobs:
      - python:
          filters:
            branches:
              only:
                - master
                - /[0-9]+(\.[0-9]+)+/
                - /pull/[0-9]+/<commit_msg>do not use apihackers/ghr for gh_release<commit_after>---
version: 2

jobs:
  python:
    docker:
      - image: udata/circleci:2-alpine
      - image: circleci/mongo:3.6-stretch-ram
      - image: redis:alpine
      - 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:
          - py3-cache-v6-{{ arch }}-{{ checksum "python.deps" }}
          - py3-cache-v6-{{ arch }}-{{ .Branch }}
          - py3-cache-v6-{{ arch }}-{{ .Environment.BASE_BRANCH }}
      - run:
          name: Install python dependencies
          command: |
            virtualenv venv
            source venv/bin/activate
            pip install -e . || pip install -e .
            pip install -r requirements/circleci.pip
      - save_cache:
          key: py3-cache-v6-{{ arch }}-{{ checksum "python.deps" }}
          paths:
          - venv
      - save_cache:
          key: py3-cache-v6-{{ arch }}-{{ .Branch }}
          paths:
          - venv
      - run:
          name: Check dependencies
          command: |
            source venv/bin/activate
            pip check
      - run:
          name: Run tests
          command: |
            mkdir -p reports/python
            source venv/bin/activate
            inv test --report --ci
      - store_test_results:
          path: reports/python
      - store_artifacts:
          path: reports/
          destination: reports

      - persist_to_workspace:
          root: .
          paths:
          - venv

  assets:
    docker:
      # TODO make an image based on 2-alpine w/ nvm and phantom deps
      - image: udata/circleci:py3
    environment:
       BASH_ENV: /root/.bashrc
    steps:
      - checkout
      - run:
          name: Compute JS dependencies key
          command: cat .nvmrc package.json > js.deps
      - run:
          name: Get the base reference branch
          command: export BASE_BRANCH=$(base_branch)
      - restore_cache:
          keys:
            - js-cache-{{ arch }}-{{ checksum "js.deps" }}
            - js-cache-{{ arch }}-{{ .Branch }}
            - js-cache-{{ arch }}-{{ .Environment.BASE_BRANCH }}
      - run:
          name: Install NodeJS and dependencies
          command: nvm install && npm install
      - save_cache:
          key: js-cache-{{ arch }}-{{ checksum "js.deps" }}
          paths:
          - node_modules
      - save_cache:
          key: js-cache-{{ arch }}-{{ .Branch }}
          paths:
          - node_modules
      - run:
          name: Execute Karma tests
          command: |
            mkdir -p reports/karma
            REPORT_DIR=reports/karma npm -s run test:unit -- --reporters mocha,junit
      - store_test_results:
          path: reports/karma
      - store_artifacts:
          path: reports/
          destination: reports
      - run:
          name: Compile assets
          command: |
            npm run assets:build
            npm run widgets:build
            npm run oembed:build

      - persist_to_workspace:
          root: .
          paths:
            - udata/static
            - udata/manifest.json

  dist:
    docker:
      - image: udata/circleci:2-alpine
    environment:
       BASH_ENV: /root/.bashrc
    steps:
      - checkout
      - attach_workspace:
          at: .
      - run:
          name: Build a distributable package
          command: |
            source venv/bin/activate
            # Build a wheel release
            if [[ $CIRCLE_TAG ]]; then
                # This is a tagged release
                inv pydist
            elif [[ "$CIRCLE_BRANCH" == feature/* ]]; then
                # This is a feature branch
                inv pydist -b $CIRCLE_BUILD_NUM+${CIRCLE_BRANCH#*/}
            else
                # This is a simple development build
                inv pydist -b $CIRCLE_BUILD_NUM
            fi
      - store_artifacts:
          path: dist
      - persist_to_workspace:
          root: .
          paths:
            - dist

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

  github:
    docker:
      - image: udata/circleci:2-alpine
    environment:
       BASH_ENV: /root/.bashrc
    steps:
      - attach_workspace:
          at: .
      - run:
          name: Upload github release
          command: gh_release

workflows:
  version: 2
  build:
    jobs:
      - python:
          filters:
            branches:
              only:
                - master
                - /[0-9]+(\.[0-9]+)+/
                - /pull/[0-9]+/
{'fraction_non_alphanumeric': 0.10264900662251655, 'fraction_numerical': 0.005719446116797111, 'mean_word_length': 1.3098493626882965, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 8, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, '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': '5132178', 'n_tokens_mistral': 3019, 'n_tokens_neox': 2907, 'n_words': 728}