version: 2.1

aliases:
  # Variables
  - &project_working_directory ~/project
  - &yarn_cache_version v1

orbs:
  eq: equisoft/build-tools@0.0.7

executors:
  node:
    working_directory: *project_working_directory
    docker:
      - image: node:10

commands:
  attach-project-directory:
    steps:
      - attach_workspace:
          at: *project_working_directory

  yarn-install:
    steps:
      - eq/with-yarn-cache:
          cache-version: *yarn_cache_version
          yarn-legacy: true

jobs:
  init-workspace:
    executor: node
    steps:
      - checkout
      - persist_to_workspace:
          root: '.'
          paths: '.'

  yarn-install:
    executor: node
    steps:
      - attach-project-directory
      - yarn-install

  build:
    executor: node
    steps:
      - attach-project-directory
      - yarn-install
      - run: yarn grunt build
      - persist_to_workspace:
          root: .
          paths:
            - js/dist

  eslint:
    executor: node
    steps:
      - attach-project-directory
      - yarn-install
      - run: yarn eslint:ci

  test:
    executor: node
    steps:
      - attach-project-directory
      - yarn-install
      - run: yarn test:ci

workflows:
  version: 2
  build_and_test:
    jobs:
      - init-workspace
      - yarn-install:
          requires:
            - init-workspace
      - test:
          requires:
            - yarn-install
      - build:
          requires:
            - yarn-install

version: 2.1

aliases:
  # Variables
  - &project_working_directory ~/project
  - &yarn_cache_version v1

orbs:
  eq: equisoft/build-tools@0.0.7

executors:
  node:
    working_directory: *project_working_directory
    docker:
      - image: node:10

commands:
  attach-project-directory:
    steps:
      - attach_workspace:
          at: *project_working_directory

  yarn-install:
    steps:
      - eq/with-yarn-cache:
          cache-version: *yarn_cache_version

jobs:
  init-workspace:
    executor: node
    steps:
      - checkout
      - persist_to_workspace:
          root: '.'
          paths: '.'

  yarn-install:
    executor: node
    steps:
      - attach-project-directory
      - yarn-install

  build:
    executor: node
    steps:
      - attach-project-directory
      - yarn-install
      - run: yarn build
      - persist_to_workspace:
          root: .
          paths:
            - js/dist

  eslint:
    executor: node
    steps:
      - attach-project-directory
      - yarn-install
      - run: yarn eslint:ci

  test:
    executor: node
    steps:
      - attach-project-directory
      - yarn-install
      - run: yarn test:ci

workflows:
  version: 2
  build_and_test:
    jobs:
      - init-workspace
      - yarn-install:
          requires:
            - init-workspace
      - test:
          requires:
            - yarn-install
      - build:
          requires:
            - yarn-install

Fix yarn install in ci
Fix yarn install in ci
