<commit_before>aliases:
  - &opam_env
    TERM: dumb
    OPAMYES: true

  - &docker_opam
    docker:
      - image: ocaml/opam:debian-8_ocaml-4.05.0
        environment:
          <<: *opam_env
    working_directory: ~/flow

  - &docker_node
    docker:
      - image: circleci/node:8
    working_directory: ~/flow

  - &opam_deps
    name: Install deps from opam
    command: |
      eval $(opam config env)
      opam pin add -n flowtype-ci . | cat
      opam depext flowtype-ci | cat
      opam install --deps-only flowtype-ci | cat

  - &restore_opam_cache
    keys:
      - opam-cache-{{ arch }}-opam_1_2_2-ocaml_4_05_0-{{ checksum "opam" }}
      - opam-cache-{{ arch }}-opam_1_2_2-ocaml_4_05_0
      - opam-cache-{{ arch }}-opam_1_2_2

  - &save_opam_cache
    key: opam-cache-{{ arch }}-opam_1_2_2-ocaml_4_05_0-{{ checksum "opam" }}
    paths:
      - ~/.opam

  - &run_on_tags
    filters:
      tags:
        only: /.*/

version: 2
jobs:
  checkout:
    <<: *docker_node
    steps:
      - checkout
      - run:
          # This job does a lot of setup to be able to access github, so
          # fetch the list of git tags that Try Flow uses here, instead of
          # hitting github again later.
          name: List versions
          command: .circleci/list_versions.sh
      - persist_to_workspace:
          root: .
          paths: .

  build_linux:
    <<: *docker_opam
    steps:
      - attach_workspace:
          at: ~/flow
      - run:
          # TODO: move this to a custom docker image
          name: Install deps
          command: sudo apt-get update && sudo apt-get install zip
      - restore_cache: *restore_opam_cache
      - run:
          name: Update opam repo
          command: |
            opam remote list -s | grep upstream >/dev/null || \
              opam remote add upstream https://opam.ocaml.org | cat
            opam update | cat
      - run: *opam_deps
      - run:
          name: Install extra deps from opam
          command: opam install js_of_ocaml.3.1.0 | cat
      - save_cache: *save_opam_cache
      - run:
          name: Build flow
          command: |
            opam config exec -- make bin/flow dist/flow.zip
            mkdir -p bin/linux && cp bin/flow bin/linux/flow
      - run:
          name: Build libflowparser
          command: opam config exec -- make -C src/parser dist/libflowparser.zip
      - run:
          name: Build flow.js
          command: opam config exec -- make js
      - run:
          name: Build flow_parser.js
          command: opam config exec -- make -C src/parser js
      - run:
          name: Create artifacts
          command: |
            cp dist/flow.zip dist/flow-linux64.zip
            cp src/parser/dist/libflowparser.zip dist/libflowparser-linux64.zip
            cp src/parser/flow_parser.js dist/flow_parser.js
      - persist_to_workspace:
          root: .
          paths:
            - bin/linux/flow
            - bin/flow.js
            - dist/flow-linux64.zip
            - dist/libflowparser-linux64.zip
            - dist/flow_parser.js
      - store_artifacts:
          path: dist/flow-linux64.zip
          destination: flow-linux64.zip
      - store_artifacts:
          path: dist/libflowparser-linux64.zip
          destination: libflowparser-linux64.zip
      - store_artifacts:
          path: bin/flow.js
          destination: flow.js
      - store_artifacts:
          path: dist/flow_parser.js
          destination: flow_parser.js

  build_macos:
    macos:
      xcode: "9.0"
    environment:
      <<: *opam_env
    working_directory: ~/flow
    steps:
      - attach_workspace:
          at: ~/flow
      - restore_cache:
          keys:
            - brew-cache-{{ arch }}-v2
      # https://github.com/Homebrew/homebrew-core/issues/26358
      - run:
          name: Fix homebrew python
          command: brew upgrade python
      - run:
          name: Install opam
          command: command -v opam || brew install opam aspcud
      - save_cache:
          key: brew-cache-{{ arch }}-v2
          paths:
            - /usr/local/bin/opam
            - /usr/local/bin/aspcud
      - restore_cache: *restore_opam_cache
      - run:
          name: Install ocaml
          command: opam init --comp 4.05.0 -yn | cat
      - save_cache:
          key: opam-cache-{{ arch }}-opam_1_2_2-ocaml_4_05_0
          paths:
            - ~/.opam
      - run:
          name: Update opam repo
          command: opam update | cat
      - run: *opam_deps
      - save_cache: *save_opam_cache
      - run:
          name: Build flow
          command: |
            opam config exec -- make bin/flow dist/flow.zip
            mkdir -p bin/macos && cp bin/flow bin/macos/flow
      - run:
          name: Build libflowparser
          command: opam config exec -- make -C src/parser dist/libflowparser.zip
      - run:
          name: Create artifacts
          command: |
            cp dist/flow.zip dist/flow-osx.zip<commit_msg>[PR] [circle] use actual opam version in cache key<commit_after>aliases:
  - &opam_env
    TERM: dumb
    OPAMYES: true

  - &docker_opam
    docker:
      - image: ocaml/opam:debian-8_ocaml-4.05.0
        environment:
          <<: *opam_env
    working_directory: ~/flow

  - &docker_node
    docker:
      - image: circleci/node:8
    working_directory: ~/flow

  # Saves the currently-installed opam version to a file, which we include
  # in cache keys.
  - &opam_version
    name: Calculate opam version
    command: opam --version > .circleci/opamversion

  - &opam_deps
    name: Install deps from opam
    command: |
      eval $(opam config env)
      opam pin add -n flowtype-ci . | cat
      opam depext flowtype-ci | cat
      opam install --deps-only flowtype-ci | cat

  - &restore_opam_cache
    keys:
      - opam-cache-{{ arch }}-opam_{{ checksum ".circleci/opamversion" }}-ocaml_4_05_0-{{ checksum "opam" }}
      - opam-cache-{{ arch }}-opam_{{ checksum ".circleci/opamversion" }}-ocaml_4_05_0
      - opam-cache-{{ arch }}-opam_{{ checksum ".circleci/opamversion" }}

  - &save_opam_cache
    key: opam-cache-{{ arch }}-opam_{{ checksum ".circleci/opamversion" }}-ocaml_4_05_0-{{ checksum "opam" }}
    paths:
      - ~/.opam

  - &run_on_tags
    filters:
      tags:
        only: /.*/

version: 2
jobs:
  checkout:
    <<: *docker_node
    steps:
      - checkout
      - run:
          # This job does a lot of setup to be able to access github, so
          # fetch the list of git tags that Try Flow uses here, instead of
          # hitting github again later.
          name: List versions
          command: .circleci/list_versions.sh
      - persist_to_workspace:
          root: .
          paths: .

  build_linux:
    <<: *docker_opam
    steps:
      - attach_workspace:
          at: ~/flow
      - run:
          # TODO: move this to a custom docker image
          name: Install deps
          command: sudo apt-get update && sudo apt-get install zip
      - run: *opam_version
      - restore_cache: *restore_opam_cache
      - run:
          name: Update opam repo
          command: |
            opam remote list -s | grep upstream >/dev/null || \
              opam remote add upstream https://opam.ocaml.org | cat
            opam update | cat
      - run: *opam_deps
      - run:
          name: Install extra deps from opam
          command: opam install js_of_ocaml.3.1.0 | cat
      - save_cache: *save_opam_cache
      - run:
          name: Build flow
          command: |
            opam config exec -- make bin/flow dist/flow.zip
            mkdir -p bin/linux && cp bin/flow bin/linux/flow
      - run:
          name: Build libflowparser
          command: opam config exec -- make -C src/parser dist/libflowparser.zip
      - run:
          name: Build flow.js
          command: opam config exec -- make js
      - run:
          name: Build flow_parser.js
          command: opam config exec -- make -C src/parser js
      - run:
          name: Create artifacts
          command: |
            cp dist/flow.zip dist/flow-linux64.zip
            cp src/parser/dist/libflowparser.zip dist/libflowparser-linux64.zip
            cp src/parser/flow_parser.js dist/flow_parser.js
      - persist_to_workspace:
          root: .
          paths:
            - bin/linux/flow
            - bin/flow.js
            - dist/flow-linux64.zip
            - dist/libflowparser-linux64.zip
            - dist/flow_parser.js
      - store_artifacts:
          path: dist/flow-linux64.zip
          destination: flow-linux64.zip
      - store_artifacts:
          path: dist/libflowparser-linux64.zip
          destination: libflowparser-linux64.zip
      - store_artifacts:
          path: bin/flow.js
          destination: flow.js
      - store_artifacts:
          path: dist/flow_parser.js
          destination: flow_parser.js

  build_macos:
    macos:
      xcode: "9.0"
    environment:
      <<: *opam_env
    working_directory: ~/flow
    steps:
      - attach_workspace:
          at: ~/flow
      # https://github.com/Homebrew/homebrew-core/issues/26358
      - run:
          name: Fix homebrew python
          command: brew upgrade python
      - run:
          name: Install opam
          command: command -v opam || brew install opam aspcud
      - run: *opam_version
      - restore_cache: *restore_opam_cache
      - run:
          name: Install ocaml
          command: opam init --comp 4.05.0 -yn | cat
      - save_cache:
          key: opam-cache-{{ arch }}-opam_{{ checksum ".circleci/opamversion" }}-ocaml_4_05_0
          paths:
            - ~/.opam
      - run:
          name: Update opam repo
          command: opam update | cat
      - run: *opam_deps
      - save_cache: *save_opam_cache
      - run:
          name: Build flow
          command: |
            opam config exec -- make bin/flow dist/flow.zip
            mkdir -p bin/macos && cp bin/flow bin/macos/flow
      - run:
          name: Build libflowparser
          command: opam config exec -- make -C src/parser dist/libflowparser.zip
      - run:
          name: Create artifacts
          command: |
            cp dist/flow.zip dist/flow-osx.zip
{'fraction_non_alphanumeric': 0.09748892171344166, 'fraction_numerical': 0.012112259970457902, 'mean_word_length': 1.6121399176954732, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 6, 'https://': 4, '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': '6772966', 'n_tokens_mistral': 3312, 'n_tokens_neox': 3198, 'n_words': 825}