version: 2.1

workflows:
  version: 2.1
  main:
    jobs:
      - lint
      - test-v8
      - test-v9
      - release:
          requires:
            - lint
            - test-v8
            - test-v9
          filters:
            branches:
              only:
                - master

jobs:
  lint:
    docker:
      - image: cimg/node:22.11.0
    steps:
      - checkout
      - run:
          name: Install dependencies
          command: npm ci
      - run:
          name: Show ESLint version
          command: npx eslint --version
      - run:
          name: Lint code
          command: npm run lint

  test-v8:
    docker:
      - image: cimg/node:22.11.0
    steps:
      - checkout
      - run:
          name: Install dependencies
          command: npm ci
      - run:
          name: Install ESLint 8
          command: npm install eslint@8
      - run:
          name: Show ESLint version
          command: npx eslint --version
      - run:
          name: Test ESLint 8
          command: npm run test:legacy

  test-v9:
    docker:
      - image: cimg/node:22.11.0
    steps:
      - checkout
      - run:
          name: Install dependencies
          command: npm ci
      - run:
          name: Install ESLint 9
          command: npm install eslint@9
      - run:
          name: Show ESLint version
          command: npx eslint --version
      - run:
          name: Test ESLint 9
          command: npm test

  release:
    docker:
      - image: cimg/node:22.11.0
    steps:
      - checkout
      - run:
          name: Install dependencies
          command: npm ci
      - run:
          name: Run semantic release
          command: npm run semantic-release
