<commit_before># See CircleCI upstream's docs on this config format:
#   https://circleci.com/docs/2.0/language-python/
#
version: 2
jobs:
  build:
    docker:
      # This is built from tools/circleci/images/Dockerfile .
      - image: gregprice/circleci:trusty-python-3.test

    working_directory: ~/repo

    steps:
      - checkout

      - run:
          name: create cache directories
          command: |
              dirs=(/srv/zulip-{npm,venv}-cache)
              sudo mkdir -p "${dirs[@]}"
              sudo chown -R circleci "${dirs[@]}"
      - restore_cache:
          keys:
          - v1-node-base2
          - v1-node-base1
      - restore_cache:
          keys:
          - v1-venv-base2
          - v1-venv-base1

      - run:
          name: install dependencies
          command: |
            # Install moreutils so we can use `ts` and `mispipe` in the following.
            sudo apt-get install -y moreutils

            # TODO: Install and use codecov.

            # CircleCI sets the following in Git config at clone time:
            #   url.ssh://git@github.com.insteadOf https://github.com
            # This breaks the Git clones in the NVM `install.sh` we run
            # in `install-node`.
            # TODO: figure out why that breaks, and whether we want it.
            #   (Is it an optimization?)
            rm -f /home/circleci/.gitconfig

            # This is the main setup job for the test suite
            mispipe "tools/travis/setup-backend" ts

            # Cleaning caches is mostly unnecessary in Circle, because
            # most builds don't get to write to the cache.
            # mispipe "scripts/lib/clean-unused-caches --verbose --threshold 0" ts

      - save_cache:
          paths:
            - /srv/zulip-npm-cache
          key: v1-node-base2
      - save_cache:
          paths:
            - /srv/zulip-venv-cache
          key: v1-venv-base2
      # TODO: in Travis we also cache ~/zulip-emoji-cache, ~/node, ~/misc

      # The moment of truth!
      - run:
          name: run tests
          command: |
            . /srv/zulip-py3-venv/bin/activate
            mispipe ./tools/travis/backend ts

      # - store_artifacts:  # TODO
      #     path: var/casper/
      #     # also /tmp/zulip-test-event-log/
      #     destination: test-reports

      # TODO: notify zulipbot<commit_msg>circleci: Run frontend tests in circleci.<commit_after># See CircleCI upstream's docs on this config format:
#   https://circleci.com/docs/2.0/language-python/
#
version: 2
jobs:
  build:
    docker:
      # This is built from tools/circleci/images/Dockerfile .
      - image: gregprice/circleci:trusty-python-3.test

    working_directory: ~/repo

    steps:
      - checkout

      - run:
          name: create cache directories
          command: |
              dirs=(/srv/zulip-{npm,venv}-cache)
              sudo mkdir -p "${dirs[@]}"
              sudo chown -R circleci "${dirs[@]}"
      - restore_cache:
          keys:
          - v1-node-base2
          - v1-node-base1
      - restore_cache:
          keys:
          - v1-venv-base2
          - v1-venv-base1

      - run:
          name: install dependencies
          command: |
            # Install moreutils so we can use `ts` and `mispipe` in the following.
            sudo apt-get install -y moreutils

            # TODO: Install and use codecov.

            # CircleCI sets the following in Git config at clone time:
            #   url.ssh://git@github.com.insteadOf https://github.com
            # This breaks the Git clones in the NVM `install.sh` we run
            # in `install-node`.
            # TODO: figure out why that breaks, and whether we want it.
            #   (Is it an optimization?)
            rm -f /home/circleci/.gitconfig

            # This is the main setup job for the test suite
            mispipe "tools/travis/setup-backend" ts

            # Cleaning caches is mostly unnecessary in Circle, because
            # most builds don't get to write to the cache.
            # mispipe "scripts/lib/clean-unused-caches --verbose --threshold 0" ts

      - save_cache:
          paths:
            - /srv/zulip-npm-cache
          key: v1-node-base2
      - save_cache:
          paths:
            - /srv/zulip-venv-cache
          key: v1-venv-base2
      # TODO: in Travis we also cache ~/zulip-emoji-cache, ~/node, ~/misc

      # The moment of truth!  Run the tests.

      - run:
          name: run backend tests
          command: |
            . /srv/zulip-py3-venv/bin/activate
            mispipe ./tools/travis/backend ts

      - run:
          name: run frontend tests
          command: |
            . /srv/zulip-py3-venv/bin/activate
            mispipe ./tools/travis/frontend ts

      # - store_artifacts:  # TODO
      #     path: var/casper/
      #     # also /tmp/zulip-test-event-log/
      #     destination: test-reports

      # TODO: notify zulipbot
{'fraction_non_alphanumeric': 0.09961608405738533, 'fraction_numerical': 0.007476257829864619, 'mean_word_length': 1.5178026449643947, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 4, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 2, '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': '7088499', 'n_tokens_mistral': 1547, 'n_tokens_neox': 1479, 'n_words': 416}