<commit_before>version: 2.1

orbs:
  browser-tools: circleci/browser-tools@1.2.1
  node: circleci/node@4.7.0

push_and_pr_builds: &push_and_pr_builds
  filters:
    branches:
      ignore:
        - nightly

push_builds_only: &push_builds_only
  filters:
    branches:
      only:
        - main
        - /^amp-release-.*$/

pr_builds_only: &pr_builds_only
  filters:
    branches:
      ignore:
        - main
        - /^amp-release-.*$/
        - nightly

experiment_job: &experiment_job
  parameters:
    exp:
      description: 'Which of the three (A/B/C) experiments to use'
      type: enum
      enum: ['A', 'B', 'C']
  environment:
    EXP: << parameters.exp >>

executors:
  base-docker-small:
    docker:
      - image: cimg/base:stable
    resource_class: small
  node-docker-medium:
    docker:
      - image: cimg/node:lts-browsers
    resource_class: medium
  node-docker-large:
    docker:
      - image: cimg/node:lts-browsers
    resource_class: large
  node-docker-xlarge:
    docker:
      - image: cimg/node:lts-browsers
    resource_class: xlarge
  jdk-docker-xlarge:
    docker:
      - image: cimg/openjdk:16.0-node
    resource_class: xlarge
  macos-medium:
    macos:
      xcode: 12.4.0
    resource_class: medium

commands:
  checkout_repo:
    parameters:
      save-git-cache:
        type: boolean
        default: false
    steps:
      - restore_cache:
          name: 'Restore Git Cache'
          keys:
            - git-cache-{{ arch }}-v2-{{ .Branch }}-{{ .Revision }}
            - git-cache-{{ arch }}-v2-{{ .Branch }}-
            - git-cache-{{ arch }}-v2-
      - checkout
      - when:
          condition: << parameters.save-git-cache >>
          steps:
            - save_cache:
                name: 'Save Git Cache'
                key: git-cache-{{ arch }}-v2-{{ .Branch }}-{{ .Revision }}
                paths:
                  - .git
  setup_node_environment:
    steps:
      - node/install:
          lts: true
          install-npm: false
      - node/install-packages
  setup_vm:
    steps:
      - attach_workspace:
          at: /tmp
      - run:
          name: 'Configure Temporary Workspace'
          command: |
            mv /tmp/workspace /tmp/restored-workspace
            mkdir -p /tmp/workspace
      - run:
          name: 'Maybe Gracefully Halt'
          command: /tmp/restored-workspace/maybe_gracefully_halt.sh
      - checkout_repo
      - run:
          name: 'Configure Development Environment'
          command: |
            ./.circleci/fetch_merge_commit.sh
            ./.circleci/restore_build_output.sh
            cat ./build-system/test-configs/hosts | sudo tee -a /etc/hosts
      - setup_node_environment
  teardown_vm:
    steps:
      - persist_to_workspace:
          root: /tmp
          paths:
            - workspace
  install_chrome:
    steps:
      - browser-tools/install-chrome:
          replace-existing: true
      - browser-tools/install-chromedriver
  install_firefox:
    steps:
      - browser-tools/install-firefox
  install_edge:
    steps:
      - run:
          name: 'Install Microsoft Edge'
          command: ./.circleci/install_microsoft_edge.sh
  enable_safari_automation:
    steps:
      - run:
          name: 'Enable Safari Automation'
          command: |
            defaults write com.apple.Safari AllowRemoteAutomation 1
            defaults write com.apple.Safari IncludeDevelopMenu 1
            sudo safaridriver --enable
  store_test_output:
    steps:
      - store_artifacts:
          path: result-reports
      - store_test_results:
          path: result-reports
  skip_on_push_builds:<commit_msg>Pin CircleCI's Chrome version (#35916)<commit_after>version: 2.1

orbs:
  browser-tools: circleci/browser-tools@1.2.1
  node: circleci/node@4.7.0

push_and_pr_builds: &push_and_pr_builds
  filters:
    branches:
      ignore:
        - nightly

push_builds_only: &push_builds_only
  filters:
    branches:
      only:
        - main
        - /^amp-release-.*$/

pr_builds_only: &pr_builds_only
  filters:
    branches:
      ignore:
        - main
        - /^amp-release-.*$/
        - nightly

experiment_job: &experiment_job
  parameters:
    exp:
      description: 'Which of the three (A/B/C) experiments to use'
      type: enum
      enum: ['A', 'B', 'C']
  environment:
    EXP: << parameters.exp >>

executors:
  base-docker-small:
    docker:
      - image: cimg/base:stable
    resource_class: small
  node-docker-medium:
    docker:
      - image: cimg/node:lts-browsers
    resource_class: medium
  node-docker-large:
    docker:
      - image: cimg/node:lts-browsers
    resource_class: large
  node-docker-xlarge:
    docker:
      - image: cimg/node:lts-browsers
    resource_class: xlarge
  jdk-docker-xlarge:
    docker:
      - image: cimg/openjdk:16.0-node
    resource_class: xlarge
  macos-medium:
    macos:
      xcode: 12.4.0
    resource_class: medium

commands:
  checkout_repo:
    parameters:
      save-git-cache:
        type: boolean
        default: false
    steps:
      - restore_cache:
          name: 'Restore Git Cache'
          keys:
            - git-cache-{{ arch }}-v2-{{ .Branch }}-{{ .Revision }}
            - git-cache-{{ arch }}-v2-{{ .Branch }}-
            - git-cache-{{ arch }}-v2-
      - checkout
      - when:
          condition: << parameters.save-git-cache >>
          steps:
            - save_cache:
                name: 'Save Git Cache'
                key: git-cache-{{ arch }}-v2-{{ .Branch }}-{{ .Revision }}
                paths:
                  - .git
  setup_node_environment:
    steps:
      - node/install:
          lts: true
          install-npm: false
      - node/install-packages
  setup_vm:
    steps:
      - attach_workspace:
          at: /tmp
      - run:
          name: 'Configure Temporary Workspace'
          command: |
            mv /tmp/workspace /tmp/restored-workspace
            mkdir -p /tmp/workspace
      - run:
          name: 'Maybe Gracefully Halt'
          command: /tmp/restored-workspace/maybe_gracefully_halt.sh
      - checkout_repo
      - run:
          name: 'Configure Development Environment'
          command: |
            ./.circleci/fetch_merge_commit.sh
            ./.circleci/restore_build_output.sh
            cat ./build-system/test-configs/hosts | sudo tee -a /etc/hosts
      - setup_node_environment
  teardown_vm:
    steps:
      - persist_to_workspace:
          root: /tmp
          paths:
            - workspace
  install_chrome:
    steps:
      - browser-tools/install-chrome:
          replace-existing: true
          chrome-version: 93.0.4577.63
      - browser-tools/install-chromedriver
  install_firefox:
    steps:
      - browser-tools/install-firefox
  install_edge:
    steps:
      - run:
          name: 'Install Microsoft Edge'
          command: ./.circleci/install_microsoft_edge.sh
  enable_safari_automation:
    steps:
      - run:
          name: 'Enable Safari Automation'
          command: |
            defaults write com.apple.Safari AllowRemoteAutomation 1
            defaults write com.apple.Safari IncludeDevelopMenu 1
            sudo safaridriver --enable
  store_test_output:
    steps:
      - store_artifacts:
          path: result-reports
      - store_test_results:
          path: result-reports
  skip_on_push_builds:
{'fraction_non_alphanumeric': 0.10496860496860497, 'fraction_numerical': 0.007644007644007644, 'mean_word_length': 1.7659494148735373, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '726216', 'n_tokens_mistral': 2423, 'n_tokens_neox': 2334, 'n_words': 475}