<commit_before>version: 2
jobs:
  build:
    docker:
      - image: circleci/node:7.10

    steps:
      - checkout

      # Setup known_hosts so the VM allows ssh access without the prompt
      - run: mkdir -p ~/.ssh && echo '|1|lngQecMeLZI49/+fr5Ee0gOWaKE=|arylHILm4qsNJewDKKwFKOijBxE= ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYT<KEY>AAAA<KEY>AAABBBLONO0airQQL9d1rOZzT/p3SBH8acSYaN4N8qJezd/0UbnF8SBi+m1wB2nay5o0HQBQTM6O+MKXDwzYec886K78=' >> ~/.ssh/known_hosts

      # Download and cache dependencies
      - restore_cache:
          keys:
            - v1-dependencies-{{ checksum "npm-shrinkwrap.json" }}

      - run: npm install

      - save_cache:
          paths:
            - node_modules
          key: v1-dependencies-{{ checksum "npm-shrinkwrap.json" }}

      # Setup environment to prep build
      - run: |
          cp config/database.config.example.js config/database.config.js
          cp config/s3.config.example.js config/s3.config.js
          cp config/ghost.config.example.js config/ghost.config.js
          ./scripts/get-ghost-config.sh

      # Test that we can build without errors
      - run: npm run build-production

      # Test and lint
      - run: npm test
      - run: npm run lint

      - deploy:
          name: Deploy to staging if tests pass and we're on master
          command: |
            if [ "${CIRCLE_BRANCH}" == "master" ]; then
              ssh gazelle@172.16.17.32 ./deployment/update-beta.sh
            fi

      - deploy:
          name: Deploy to productoin if tests pass and we're on stable
          command: |
            if [ "${CIRCLE_BRANCH}" == "stable" ]; then
              ssh gazelle@172.16.17.326 ./deployment/update-production.sh
            fi<commit_msg>Add workflows and parallelism to our CircleCI config (#208)<commit_after>defaults: &defaults
  working_directory: ~/gazelle-server
  docker:
    - image: circleci/node:7.10


version: 2
jobs:
  checkout_code:
    <<: *defaults
    steps:
      - checkout

      # Complete setup
      - run: |
          cp config/database.config.example.js config/database.config.js
          cp config/s3.config.example.js config/s3.config.js
          cp config/ghost.config.example.js config/ghost.config.js

      # Cache it
      - run:
          name: save the SHA1 hash of git commit being built to file
          command: echo $CIRCLE_SHA1 > .circle-sha

      - save_cache:
          key: v1-repo-{{ checksum ".circle-sha" }}
          paths:
            - ~/gazelle-server

  install_dependencies:
    <<: *defaults
    steps:
      - run:
          name: save SHA to a file
          command: echo $CIRCLE_SHA1 > .circle-sha
      - restore_cache:
          keys:
            - v1-repo-{{ checksum ".circle-sha" }}

      # Download and cache dependencies
      - restore_cache:
          keys:
            - v2-dependencies-{{ checksum "npm-shrinkwrap.json" }}

      - run: npm install

      - save_cache:
          paths:
            - node_modules
          key: v2-dependencies-{{ checksum "npm-shrinkwrap.json" }}

  build:
    <<: *defaults
    steps:
      - run:
          name: save SHA to a file
          command: echo $CIRCLE_SHA1 > .circle-sha
      - restore_cache:
          keys:
            - v1-repo-{{ checksum ".circle-sha" }}

      - restore_cache:
          keys:
            - v2-dependencies-{{ checksum "npm-shrinkwrap.json" }}

      # Complete config
      - run: ./scripts/get-ghost-config.sh
      # Test that we can build without errors
      - run: npm run build-production

  test:
    <<: *defaults
    steps:
      - run:
          name: save SHA to a file
          command: echo $CIRCLE_SHA1 > .circle-sha
      - restore_cache:
          keys:
            - v1-repo-{{ checksum ".circle-sha" }}

      - restore_cache:
          keys:
            - v2-dependencies-{{ checksum "npm-shrinkwrap.json" }}

      - run: npm test

  lint:
    <<: *defaults
    steps:
      - run:
          name: save SHA to a file
          command: echo $CIRCLE_SHA1 > .circle-sha
      - restore_cache:
          keys:
            - v1-repo-{{ checksum ".circle-sha" }}

      - restore_cache:
          keys:
            - v2-dependencies-{{ checksum "npm-shrinkwrap.json" }}

      - run: npm run lint

  prep_deploy:
    <<: *defaults
    steps:
      # Setup known_hosts so the VM allows ssh access without the prompt
      - run:
          name: Add server ssh key to known_hosts
          command: mkdir -p ~/.ssh && echo '|1|lngQecMeLZI49/+fr5Ee0gOWaKE=|arylHILm4qsNJewDKKwFKOijBxE= ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBLONO0airQQL9d1rOZzT/p3SBH8acSYaN4N8qJezd/0UbnF8SBi+m1wB2nay5o0HQBQTM6O+MKXDwzYec886K78=' >> ~/.ssh/known_hosts
      - persist_to_workspace:
          root: ~/.ssh
          paths:
            - known_hosts

  deploy_staging:
    <<: *defaults
    steps:
      - attach_workspace:
          at: ~/.ssh

      - run:
          name: Deploy to staging
          command: ssh gazelle@172.16.17.32 ./deployment/update-beta.sh

  deploy_production:
    <<: *defaults
    steps:
      - attach_workspace:
          at: ~/.ssh

      - run:
          name: Deploy to production
          command: ssh gazelle@172.16.17.32 ./deployment/update-production.sh

workflows:
  version: 2
  build_test_deploy:
    jobs:
      - checkout_code
      - install_dependencies:
          requires:
            - checkout_code
      - build:
          requires:
            - install_dependencies
      - test:
          requires:
            - install_dependencies
      - lint:
          requires:
            - install_dependencies
      - prep_deploy
      - deploy_staging:
          requires:
            - build
            - test
            - lint
            - prep_deploy
          filters:
            branches:
              only: master
      - deploy_production:
          requires:
            - build
            - test
            - lint
            - prep_deploy
          filters:
            branches:
              only: stable
{'fraction_non_alphanumeric': 0.09878998839714902, 'fraction_numerical': 0.02171390684568208, 'mean_word_length': 1.66401766004415, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 14, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 4, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5175227', 'n_tokens_mistral': 2093, 'n_tokens_neox': 1928, 'n_words': 423}