<commit_before>version: 2.1

ignore_ghpages: &ignore_ghpages
  filters:
    branches:
      ignore:
        - gh-pages

jobs:
  lint:
    machine:
      docker_layer_caching: true
    steps:
      - checkout
      - run_make:
          label: Run linter
          target: lint
      - store_test_results:
          path: reports
      - store_artifacts:
          path: reports

  unit_tests:
    machine:
      docker_layer_caching: true
    steps:
      - checkout
      - run_make:
          label: Run unit tests
          target: unit-tests
      - store_test_results:
          path: junit
      - store_artifacts:
          path: junit
      - store_test_results:
          path: coverage
      - store_artifacts:
          path: coverage
      - run:
          name: Prepare coverage report
          command: |
            mkdir -p unit-coverage
            cp coverage/coverage-final.json unit-coverage/unit-coverage.json
      - persist_to_workspace:
          root: ~/
          paths:
            - 'project/unit-coverage/*'

  unit_client_tests:
    machine:
      docker_layer_caching: true
    steps:
      - checkout
      - run_make:
          label: Run unit tests
          target: unit-client-tests
      - store_test_results:
          path: junit
      - store_artifacts:
          path: junit
      - store_test_results:
          path: coverage
      - store_artifacts:
          path: coverage

  functional_tests:
    machine:
      docker_layer_caching: true
    parallelism: 7
    resource_class: xlarge
    steps:
      - checkout
      - run_make:
          label: Run functional tests
          target: start-mock functional-tests
      - store_cypress_artifacts
      - run:
          name: Prepare coverage report
          command: |
            mkdir -p partial-coverage
            touch partial-coverage/.placeholder
            cp cypress-coverage/coverage-final.json partial-coverage/cypress-coverage-$CIRCLE_WORKFLOW_JOB_ID-index-$CIRCLE_NODE_INDEX.json
      - persist_to_workspace:
          root: ~/
          paths:
            - 'project/partial-coverage/*'

  visual_tests:
    machine:
      docker_layer_caching: true
    steps:
      - checkout
      - run_make:
          label: Run visual tests
          target: start-mock visual-tests
      - store_artifacts:
          path: visual-screenshots
      - store_artifacts:
          path: visual-report

  visual_component_tests:
    machine:
      docker_layer_caching: true
    steps:
      - checkout
      - run_make:
          label: Run visual tests
          target: start-storybook visual-component-tests
      - store_artifacts:
          path: cypress-visual-screenshots
      - store_artifacts:
          path: cypress-visual-report

  e2e_tests_dit:
    machine:
      docker_layer_caching: true
    parallelism: 3
    resource_class: xlarge
    parameters:
      staff:
        type: string
    steps:
      - checkout
      - run_make:
          label: Run e2e tests
          target: start-e2e-<< parameters.staff >> e2e-tests-<< parameters.staff >>
      - store_cypress_artifacts

  e2e_tests:
    machine:
      docker_layer_caching: true
    parallelism: 1
    resource_class: xlarge
    parameters:
      staff:
        type: string
    steps:
      - checkout
      - run_make:
          label: Run e2e tests
          target: start-e2e-<< parameters.staff >> e2e-tests-<< parameters.staff >>
      - store_cypress_artifacts

  release-storybook:
    docker:
      - image: node
    steps:
      - checkout
      - run: npm ci
      - run:
          name: Release storybook
          command: npm run storybook:release
    

  merge-and-publish-coverage:
    docker:
      - image: node
    steps:
      - checkout
      - attach_workspace:
          at: ~/
      - run: npm i -g add nyc
      - run: cp unit-coverage/unit-coverage.json partial-coverage
      - run: nyc merge partial-coverage
      - run: mkdir .nyc_output || true
      - run: mv coverage.json .nyc_output/out.json
      - run:
          command: |
            nyc report \
            --reporter lcov --reporter text \
            --reporter=html --report-dir coverage<commit_msg>Configure CircleCI CPU/RAM for failing visual_component_tests<commit_after>version: 2.1

ignore_ghpages: &ignore_ghpages
  filters:
    branches:
      ignore:
        - gh-pages

jobs:
  lint:
    machine:
      docker_layer_caching: true
    steps:
      - checkout
      - run_make:
          label: Run linter
          target: lint
      - store_test_results:
          path: reports
      - store_artifacts:
          path: reports

  unit_tests:
    machine:
      docker_layer_caching: true
    steps:
      - checkout
      - run_make:
          label: Run unit tests
          target: unit-tests
      - store_test_results:
          path: junit
      - store_artifacts:
          path: junit
      - store_test_results:
          path: coverage
      - store_artifacts:
          path: coverage
      - run:
          name: Prepare coverage report
          command: |
            mkdir -p unit-coverage
            cp coverage/coverage-final.json unit-coverage/unit-coverage.json
      - persist_to_workspace:
          root: ~/
          paths:
            - 'project/unit-coverage/*'

  unit_client_tests:
    machine:
      docker_layer_caching: true
    steps:
      - checkout
      - run_make:
          label: Run unit tests
          target: unit-client-tests
      - store_test_results:
          path: junit
      - store_artifacts:
          path: junit
      - store_test_results:
          path: coverage
      - store_artifacts:
          path: coverage

  functional_tests:
    machine:
      docker_layer_caching: true
    parallelism: 7
    resource_class: xlarge
    steps:
      - checkout
      - run_make:
          label: Run functional tests
          target: start-mock functional-tests
      - store_cypress_artifacts
      - run:
          name: Prepare coverage report
          command: |
            mkdir -p partial-coverage
            touch partial-coverage/.placeholder
            cp cypress-coverage/coverage-final.json partial-coverage/cypress-coverage-$CIRCLE_WORKFLOW_JOB_ID-index-$CIRCLE_NODE_INDEX.json
      - persist_to_workspace:
          root: ~/
          paths:
            - 'project/partial-coverage/*'

  visual_tests:
    machine:
      docker_layer_caching: true
    steps:
      - checkout
      - run_make:
          label: Run visual tests
          target: start-mock visual-tests
      - store_artifacts:
          path: visual-screenshots
      - store_artifacts:
          path: visual-report

  visual_component_tests:
    machine:
      docker_layer_caching: true
    resource_class: large
    steps:
      - checkout
      - run_make:
          label: Run visual tests
          target: start-storybook visual-component-tests
      - store_artifacts:
          path: cypress-visual-screenshots
      - store_artifacts:
          path: cypress-visual-report

  e2e_tests_dit:
    machine:
      docker_layer_caching: true
    parallelism: 3
    resource_class: xlarge
    parameters:
      staff:
        type: string
    steps:
      - checkout
      - run_make:
          label: Run e2e tests
          target: start-e2e-<< parameters.staff >> e2e-tests-<< parameters.staff >>
      - store_cypress_artifacts

  e2e_tests:
    machine:
      docker_layer_caching: true
    parallelism: 1
    resource_class: xlarge
    parameters:
      staff:
        type: string
    steps:
      - checkout
      - run_make:
          label: Run e2e tests
          target: start-e2e-<< parameters.staff >> e2e-tests-<< parameters.staff >>
      - store_cypress_artifacts

  release-storybook:
    docker:
      - image: node
    steps:
      - checkout
      - run: npm ci
      - run:
          name: Release storybook
          command: npm run storybook:release


  merge-and-publish-coverage:
    docker:
      - image: node
    steps:
      - checkout
      - attach_workspace:
          at: ~/
      - run: npm i -g add nyc
      - run: cp unit-coverage/unit-coverage.json partial-coverage
      - run: nyc merge partial-coverage
      - run: mkdir .nyc_output || true
      - run: mv coverage.json .nyc_output/out.json
      - run:
          command: |
            nyc report \
            --reporter lcov --reporter text \
            --reporter=html --report-dir coverage
{'fraction_non_alphanumeric': 0.0755883052056097, 'fraction_numerical': 0.0030900879486570002, 'mean_word_length': 1.6705807680101554, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 19, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3057070', 'n_tokens_mistral': 2565, 'n_tokens_neox': 2470, 'n_words': 562}