<commit_before>version: 2
jobs:
  build:
    working_directory: /app
    docker:
      - image: docker:17.06.0-ce-git
    steps:
      - checkout
      - setup_remote_docker
      - run:
          name: Install dependencies
          command: |
            apk add --no-cache \
              py2-pip=9.0.1-r1 curl=7.54.0-r0
            pip install \
              docker-compose==1.14.0 \
              awscli==1.11.112 \
              httpie
      - run:
          name: Install Docker client
          command: |
            set -x
            VER="17.05.0-ce"
            curl -L -o /tmp/docker-$VER.tgz https://get.docker.com/builds/Linux/x86_64/docker-$VER.tgz
            tar -xz -C /tmp -f /tmp/docker-$VER.tgz
            mv /tmp/docker/* /usr/bin
      - restore_cache:
          keys:
            - v1-{{ .Branch }}
          paths:
            - /caches/app.tar
      - run:
          name: Load Docker image layer cache
          command: |
            set +o pipefail
            docker load -i /caches/app.tar | true
      - run:
          name: Build application Docker image
          command: |
            docker version
            cd 2.5
            docker build --cache-from=app -t app .
      - run:
          name: Get Docker image size
          command: |
            mkdir /tmp/artifacts;
            docker images --format "{{.Size}}" app > /tmp/artifacts/size;
      - store_artifacts:
          path: /tmp/artifacts
      - run:
          name: Save Docker image layer cache
          command: |
            mkdir -p /caches
            docker save -o /caches/app.tar app
      - save_cache:
          key: v1-{{ .Branch }}-{{ epoch }}
          paths:
            - /caches/app.tar
      - run:
          name: Run tests
          command: |
            set -x
            docker create -v /scripts --name scripts alpine:3.6 /bin/true
            docker cp scripts/local.bro scripts:/scripts
            docker create -v /pcap --name pcap alpine:3.6 /bin/true
            docker cp pcap/heartbleed.pcap pcap:/pcap
            docker run --rm app --version
            docker run -d --volumes-from scripts --volumes-from pcap app -r heartbleed.pcap local "Site::local_nets += { 192.168.11.0/24 }"
            docker cp app:/pcap/notice.log  pcap/notice.log
            ls -lah pcap
            cat pcap/notice.log | awk '{ print $11 }' | tail -n4
      # - deploy:
      #     name: Push application Docker image
      #     command: |
      #       if [ "${CIRCLE_BRANCH}" == "master" ]; then
      #         login="$(aws ecr get-login)"
      #         ${login}
      #         docker tag app "${ECR_ENDPOINT}/app:${CIRCLE_SHA1}"
      #         docker push "${ECR_ENDPOINT}/app:${CIRCLE_SHA1}"
      #       fi<commit_msg>one more time<commit_after>version: 2
jobs:
  build:
    working_directory: /app
    docker:
      - image: docker:17.06.0-ce-git
    steps:
      - checkout
      - setup_remote_docker
      - run:
          name: Install dependencies
          command: |
            apk add --no-cache \
              py2-pip=9.0.1-r1 curl=7.54.0-r0
            pip install \
              docker-compose==1.14.0 \
              awscli==1.11.112 \
              httpie
      - run:
          name: Install Docker client
          command: |
            set -x
            VER="17.05.0-ce"
            curl -L -o /tmp/docker-$VER.tgz https://get.docker.com/builds/Linux/x86_64/docker-$VER.tgz
            tar -xz -C /tmp -f /tmp/docker-$VER.tgz
            mv /tmp/docker/* /usr/bin
      - restore_cache:
          keys:
            - v1-{{ .Branch }}
          paths:
            - /caches/app.tar
      - run:
          name: Load Docker image layer cache
          command: |
            set +o pipefail
            docker load -i /caches/app.tar | true
      - run:
          name: Build application Docker image
          command: |
            docker version
            cd 2.5
            docker build --cache-from=app -t app .
      - run:
          name: Get Docker image size
          command: |
            mkdir /tmp/artifacts;
            docker images --format "{{.Size}}" app > /tmp/artifacts/size;
      - store_artifacts:
          path: /tmp/artifacts
      - run:
          name: Save Docker image layer cache
          command: |
            mkdir -p /caches
            docker save -o /caches/app.tar app
      - save_cache:
          key: v1-{{ .Branch }}-{{ epoch }}
          paths:
            - /caches/app.tar
      - run:
          name: Run tests
          command: |
            set -x
            docker create -v /scripts --name scripts alpine:3.6 /bin/true
            docker cp scripts/local.bro scripts:/scripts
            docker create -v /pcap --name pcap alpine:3.6 /bin/true
            docker cp pcap/heartbleed.pcap pcap:/pcap
            docker run --rm app --version
            docker run --name bro --volumes-from scripts --volumes-from pcap app -r heartbleed.pcap local "Site::local_nets += { 192.168.11.0/24 }"
            docker cp bro:/pcap/notice.log  pcap/notice.log
            ls -lah pcap
            cat pcap/notice.log | awk '{ print $11 }' | tail -n4
      # - deploy:
      #     name: Push application Docker image
      #     command: |
      #       if [ "${CIRCLE_BRANCH}" == "master" ]; then
      #         login="$(aws ecr get-login)"
      #         ${login}
      #         docker tag app "${ECR_ENDPOINT}/app:${CIRCLE_SHA1}"
      #         docker push "${ECR_ENDPOINT}/app:${CIRCLE_SHA1}"
      #       fi
{'fraction_non_alphanumeric': 0.11548223350253807, 'fraction_numerical': 0.02139231327048586, 'mean_word_length': 1.2527562270314414, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 2, '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': '1314782', 'n_tokens_mistral': 1798, 'n_tokens_neox': 1659, 'n_words': 432}