text: version: 2.1
  jobs:
    test:
      docker:
        - image: circleci/node:14
      steps:
        - checkout
        - run: npm ci
        - run:
            name: test
            command: npm run test:ci
            environment:
              JEST_JUNIT_OUTPUT_DIR: "./reports"
              JEST_JUNIT_OUTPUT_NAME: "test-results.xml"
        - store_test_results:
            path: ./reports
        - run:
            name: lint
            command: npm run lint
        - run:
            name: codecov
            command: bash <(curl -s https://codecov.io/bash)
        - store_test_results:
            path: jest
    release:
      docker:
        - image: circleci/node:14
      steps:
        - checkout
        - run: npm ci
        - run: npx semantic-release
  
  workflows:
    version: 2
    test_and_release:
      # Run the test jobs first, then the release only when all the test jobs are successful
      jobs:
        - test
        - release:
            filters:
              branches:
                only:
                  - master
            requires:
              - test
  