version: 2.1

commands:
  restore_npm_cache:
    description: 'Restore npm cache'
    steps:
      - restore_cache:
          keys:
            - v1-dependencies-{{ checksum "package.json" }}
            - v1-dependencies-
  save_npm_cache:
    description: 'Save npm cache'
    steps:
      - save_cache:
          paths:
            - node_modules
          key: v1-dependencies-{{ checksum "package.json" }}

jobs:
  build_test:
    parallelism: 1
    docker:
      - image: circleci/node:12.18-browsers
    working_directory: ~/repo
    steps:
      - checkout
      - restore_npm_cache
      - run: npm install
      - run: npm rebuild node-sass
      - run: npm run test_without_watch
      # - run: npm run e2e
      - run: npm run coveralls
      - store_artifacts:
          path: ~/repo/coverage
          destination: coverage

  deploy:
    parallelism: 1
    docker:
      - image: circleci/node:12.18-browsers
    working_directory: ~/repo
    steps:
      - checkout
      - restore_npm_cache
      - run: npm install
      - run: git config --global user.name $GIT_USER_NAME
      - run: git config --global user.email $GIT_USER_EMAIL
      - run: npm run deploy

workflows:
  version: 2
  build-and-test:
    jobs:
      - build_test:
          filters:
            branches:
              ignore:
                - master
                - gh-pages
  deploy:
    jobs:
      - deploy:
          filters:
            branches:
              only: master

version: 2.1

commands:
  restore_npm_cache:
    description: "Restore npm cache"
    steps:
      - restore_cache:
          keys:
            - v1-dependencies-{{ checksum "package.json" }}
            - v1-dependencies-
  save_npm_cache:
    description: "Save npm cache"
    steps:
      - save_cache:
          paths:
            - node_modules
          key: v1-dependencies-{{ checksum "package.json" }}

jobs:
  build_test:
    parallelism: 1
    docker:
      - image: circleci/node:12.18-browsers
    working_directory: ~/repo
    steps:
      - checkout
      - restore_npm_cache
      - run: npm install
      - run: npm rebuild node-sass
      - run: npm run build
      - run: npm run test_without_watch
      # - run: npm run e2e
      - run: npm run coveralls
      - store_artifacts:
          path: ~/repo/coverage
          destination: coverage

  deploy:
    parallelism: 1
    docker:
      - image: circleci/node:12.18-browsers
    working_directory: ~/repo
    steps:
      - checkout
      - restore_npm_cache
      - run: npm install
      - run: git config --global user.name $GIT_USER_NAME
      - run: git config --global user.email $GIT_USER_EMAIL
      - run: npm run deploy

workflows:
  version: 2
  build-and-test:
    jobs:
      - build_test:
          filters:
            branches:
              ignore:
                - master
                - gh-pages
  deploy:
    jobs:
      - deploy:
          filters:
            branches:
              only: master

Add build process to CircleCI
Add build process to CircleCI
