version: 2
jobs:
  test-node:
    docker:
      - image: circleci/node:8.10
    steps:
      - checkout
      - run: "yarn install"
      - run: "yarn lint:ci"
      - run: "yarn build"
      - run: "./scripts/pr-parser-preview.sh"
      - run: "yarn test:node --maxWorkers=4"

      - store_artifacts:
          path: tmp/artifacts

  test-web:
    docker:
      - image: circleci/node:8.10-browsers
    steps:
      - checkout
      - run: "yarn install"
      # For some reason phantomjs-prebuild is failing w/yarn, but npm installing works
      - run: "yarn add karma-cli --dev"
      - run: "yarn test:web --maxWorkers=4"
      - run: "yarn build:web --maxWorkers=4"

  update-fixtures:
    docker:
      - image: circleci/node:8.10
    steps:
      - checkout
      - run: "yarn install"
      - run: "node ./scripts/update-fixtures.js"


workflows:
  version: 2
  build_and_test:
    jobs:
      - test-node
      - test-web
  # UNCOMMENT WHEN READY TO AUTOMATE THIS TASK
  # scheduled_tasks:
  #   triggers:
  #     # run once per hour
  #     - schedule:
  #       cron: "0 * * * *"
  #       filters:
  #         branches:
  #           only:
  #             - master
  #   jobs:
  #     - update-fixtures
