<commit_before>version: 2.1

#########################
# Aliases
#########################

aliases:
  - &store_test_results
    store_test_results:
      path: ~/repo/test_results.xml
  - &persist_to_workspace
    persist_to_workspace:
      root: ~/repo
      paths: ['.']
  - &attach_workspace
    attach_workspace:
      at: .

#########################
# Executors
#########################

executors:
  node:
    docker:
      - image: circleci/node:8-browsers
    working_directory: ~/repo

#########################
# Commands
#########################

commands:
  yarn_install:
    steps:
      - run:
          name: Installing Dependencies
          command: yarn install --frozen-lockfile
  yarn_lint:
    steps:
      - run:
          name: Linting
          command: yarn lint
  test_all:
    steps:
      - run:
          name: Run All Tests
          command: >
            yarn testall $(circleci tests glob "test/**/*.test.*" | circleci tests split --split-by=timings --timings-type=classname) || (yarn git-clean; yarn git-reset; yarn testall $(circleci tests glob "test/**/*.test.*" | circleci tests split --split-by=timings --timings-type=classname))
          environment:
            JEST_JUNIT_OUTPUT: 'reports/junit/js-test-results.xml'
            JEST_JUNIT_CLASSNAME: '{filepath}'
  test_ie11:
    steps:
      - run:
          name: Test in ie11
          command: 'if [[ ! -z $BROWSERSTACK_USERNAME ]]; then yarn testall test/integration/production/; else echo "Not running for PR"; fi'
          environment:
            BROWSERSTACK: 'true'
            BROWSER_NAME: 'ie'
  test_safari:
    steps:
      - run:
          name: Test in Safari
          command: 'if [[ ! -z $BROWSERSTACK_USERNAME ]]; then yarn testall test/integration/production/; else echo "Not running for PR"; fi'
          environment:
            BROWSERSTACK: 'true'
            BROWSER_NAME: 'safari'
  test_firefox:
    steps:
      - run:
          name: Test in Firefox
          command: 'if [[ ! -z $BROWSERSTACK_USERNAME ]]; then yarn testall test/integration/production/; else echo "Not running for PR"; fi'
          environment:
            BROWSERSTACK: 'true'
            BROWSER_NAME: 'firefox'
  save_npm_token:
    steps:
      - run:
          name: Potentially save npm token
          command: '([[ ! -z $NPM_TOKEN ]] && echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" >> ~/.npmrc) || echo "Did not write npm token"'
  publish_canary:
    steps:
      - run:
          name: Potentially publish canary release
          command: 'if ls ~/.npmrc >/dev/null 2>&1 && [[ $(git describe --exact-match 2> /dev/null || :) =~ -canary ]]; then yarn run lerna publish from-git --npm-tag canary --yes; else  echo "Did not publish"; fi'
  publish_stable:
    steps:
      - run:
          name: Potentially publish stable release
          command: 'if ls ~/.npmrc >/dev/null 2>&1 && [[ ! $(git describe --exact-match 2> /dev/null || :) =~ -canary ]]; then yarn run lerna publish from-git --yes; else  echo "Did not publish"; fi'

#########################
# Jobs
#########################

jobs:
  build:
    executor: node
    steps:
      - checkout
      - yarn_install
      - yarn_lint
      - *persist_to_workspace
  test:
    parallelism: 3
    executor: node
    steps:
      - *attach_workspace
      - test_all
      - *store_test_results
  test-ie11:
    executor: node
    steps:
      - *attach_workspace
      - test_ie11
  test-safari:
    executor: node
    steps:
      - *attach_workspace
      - test_safari
  test-firefox:
    executor: node
    steps:
      - *attach_workspace
      - test_firefox
  deploy:
    executor: node
    steps:
      - *attach_workspace
      - save_npm_token
      - publish_canary
      - publish_stable

#########################
# Workflows
#########################

workflows:
  version: 2
  build-test-and-deploy:
    jobs:
      - build
      - test:
          requires:
            - build
      - test-ie11:
          requires:
            - build
          filters:
            branches:
              only:
                - master
                - canary
      - test-safari:
          requires:
            - build
            - test
            - test-ie11
          filters:
            branches:
              only:
                - master
                - canary
      - test-firefox:
          requires:
            - build
            - test
            - test-ie11
            - test-safari
          filters:
            branches:
              only:
                - master
                - canary
      - deploy:
          requires:
            - test
          filters:
            branches:
              only:
                - master
                - canary
<commit_msg>[Enhancement]: Refactor circleCI config (#7963)<commit_after>version: 2.1

#########################
# Aliases
#########################

aliases:
  - &store_test_results
    store_test_results:
      path: ~/repo/test_results.xml
  - &persist_to_workspace
    persist_to_workspace:
      root: ~/repo
      paths: ['.']
  - &attach_workspace
    attach_workspace:
      at: .

#########################
# Executors
#########################

executors:
  node:
    docker:
      - image: circleci/node:8-browsers
    working_directory: ~/repo

#########################
# Commands
#########################

commands:
  yarn_install:
    steps:
      - run:
          name: Installing Dependencies
          command: yarn install --frozen-lockfile
  yarn_lint:
    steps:
      - run:
          name: Linting
          command: yarn lint
  test_all:
    steps:
      - run:
          name: Run All Tests
          command: |
            yarn testall $(
              circleci tests glob "test/**/*.test.*" | \
              circleci tests split --split-by=timings --timings-type=classname
            ) || (
              yarn git-clean
              yarn git-reset
              yarn testall $(
                circleci tests glob "test/**/*.test.*" | \
                circleci tests split --split-by=timings --timings-type=classname
              )
            )
          environment:
            JEST_JUNIT_OUTPUT: 'reports/junit/js-test-results.xml'
            JEST_JUNIT_CLASSNAME: '{filepath}'
  test_browser:
    parameters:
      browser:
        type: string
    steps:
      - run:
          name: Test in a browser
          command: |
            if [[ ! -z $BROWSERSTACK_USERNAME ]]; then
              yarn testall test/integration/production/
            else
              echo "Not running for PR"
            fi
          environment:
            BROWSERSTACK: 'true'
            BROWSER_NAME: << parameters.browser >>
  save_npm_token:
    steps:
      - run:
          name: Potentially save npm token
          command: |
            ([[ ! -z $NPM_TOKEN ]] && echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" >> ~/.npmrc) || echo "Did not write npm token"
  publish_canary:
    steps:
      - run:
          name: Potentially publish canary release
          command: |
            if \
              ls ~/.npmrc >/dev/null 2>&1 && \
              [[ $(git describe --exact-match 2> /dev/null || :) =~ -canary ]]; \
            then
              yarn run lerna publish from-git --npm-tag canary --yes
            else
              echo "Did not publish"
            fi
  publish_stable:
    steps:
      - run:
          name: Potentially publish stable release
          command: |
            if \
              ls ~/.npmrc >/dev/null 2>&1 && \
              [[ ! $(git describe --exact-match 2> /dev/null || :) =~ -canary ]]; \
            then
              yarn run lerna publish from-git --yes
            else
              echo "Did not publish"
            fi

#########################
# Jobs
#########################

jobs:
  build:
    executor: node
    steps:
      - checkout
      - yarn_install
      - yarn_lint
      - *persist_to_workspace
  test:
    parallelism: 3
    executor: node
    steps:
      - *attach_workspace
      - test_all
      - *store_test_results
  test-ie11:
    executor: node
    steps:
      - *attach_workspace
      - test_browser:
          browser: 'ie'
  test-safari:
    executor: node
    steps:
      - *attach_workspace
      - test_browser:
          browser: 'safari'
  test-firefox:
    executor: node
    steps:
      - *attach_workspace
      - test_browser:
          browser: 'firefox'
  deploy:
    executor: node
    steps:
      - *attach_workspace
      - save_npm_token
      - publish_canary
      - publish_stable

#########################
# Workflows
#########################

workflows:
  version: 2
  build-test-and-deploy:
    jobs:
      - build
      - test:
          requires:
            - build
      - test-ie11:
          requires:
            - build
          filters:
            branches:
              only:
                - master
                - canary
      - test-safari:
          requires:
            - build
            - test
            - test-ie11
          filters:
            branches:
              only:
                - master
                - canary
      - test-firefox:
          requires:
            - build
            - test
            - test-ie11
            - test-safari
          filters:
            branches:
              only:
                - master
                - canary
      - deploy:
          requires:
            - test
          filters:
            branches:
              only:
                - master
                - canary

{'fraction_non_alphanumeric': 0.1450820528901432, 'fraction_numerical': 0.005017246785826278, 'mean_word_length': 1.4975202297050378, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 22, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 4}, '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': '5589344', 'n_tokens_mistral': 2906, 'n_tokens_neox': 2790, 'n_words': 649}