version: 2.1

workflows:
  version: 2.1
  main:
    jobs:
      - lint
      - test-v4
      - test-v5
      - test-v6
      - release:
          requires:
            - lint
            - test-v4
            - test-v5
            - test-v6
          filters:
            branches:
              only:
                - master

jobs:
  lint:
    docker:
      - image: circleci/node:8
    steps:
      - checkout
      - run:
          name: Install dependencies
          command: npm install
      - run:
          name: Lint code
          command: npm run lint

  test-v4:
    docker:
      - image: circleci/node:8
    steps:
      - checkout
      - run:
          name: Install dependencies
          command: npm install
      - run:
          name: Test ESLint 4
          command: npm run test:v4

  test-v5:
    docker:
      - image: circleci/node:8
    steps:
      - checkout
      - run:
          name: Install dependencies
          command: npm install
      - run:
          name: Test ESLint 5
          command: npm run test

  test-v6:
    docker:
      - image: circleci/node:8
    steps:
      - checkout
      - run:
          name: Install dependencies
          command: npm install
      - run:
          name: Test ESLint 6
          command: npm run test:v6

  release:
    docker:
      - image: circleci/node:8
    steps:
      - checkout
      - run:
          name: Install dependencies
          command: npm install
      - run:
          name: Run semantic release
          command: npm run semantic-release