<commit_before># These environment variables must be set in CircleCI UI
#
# DOCKERHUB_REPO - docker hub repo, format: <username>/<repo>
# DOCKER_USER
# DOCKER_PASS
#
version: 2
jobs:
  lint-vet-fmt:
    docker:
      - image: golang:1.12-buster
    working_directory: /usr/local/go/src/go.mozilla.org/autograph
    steps:
      - checkout
      - run:
          name: run golint
          command: |
            make install-golint lint
            make show-lint
      - run:
          name: run gofmt
          command: |
            make -s fmt-diff | tee fmt.diff
            test -z "$(cat fmt.diff)"
      - run:
          name: install packages for crypto11 headers for go vet
          command: |
            apt-get update
            apt-get install -y libltdl-dev
      - run:
          name: run go vet
          command: make vet

  unit-test:
    docker:
      - image: circleci/golang:1.12-buster
      - image: circleci/postgres:11
        environment:
          POSTGRES_USER: root
          POSTGRES_DB: autograph
    working_directory: /go/src/go.mozilla.org/autograph
    environment:
      GOPATH: "/go"
    steps:
      - checkout
      - run:
          name: Install packages
          command: |
            sudo apt-get -y install libltdl-dev gpg postgresql-client
            make install-goveralls install-cover
      - run:
          name: Waiting for Postgres to be ready
          command: |
            for i in `seq 1 10`;
            do
              nc -z localhost 5432 && echo Success && exit 0
              echo -n .
              sleep 1
            done
            echo Failed waiting for Postgres && exit 1
      - run:
          name: Configure database
          command: |
            psql -U root -d autograph -h localhost -p 5432 -f database/schema.sql
      - run:
          name: Run a dummy statsd in the background
          command: make dummy-statsd
          background: true
      - run:
          name: Run unit tests
          command: |
            make generate test
      - run:
          name: Report coverage
          command: |
            cd $GOPATH/src/go.mozilla.org/autograph
            $GOPATH/bin/goveralls -coverprofile=coverage.out -service circle-ci

  build-integrationtest-verify:
    # based on the official golang image with more docker stuff
    docker:
      - image: circleci/golang:1.12-buster
    working_directory: /go/src/go.mozilla.org/autograph
    steps:
      - checkout
      - setup_remote_docker
      - run:
          name: create version.json and other autogenerated files then build docker images
          command: make generate build
      - run:
          name:
          command: make integration-test
      # save the built docker container to CircleCI's cache since
      # CircleCI Workflows do not have the same remote docker
      # instance.
      #
      # Use /go/src/app since we don't have permissions to make
      # directories in other locations
      - run:
          name: docker save built images
          no_output_timeout: 30m
          command: |
            mkdir -p /go/src/app/cache
            docker save "autograph-app" | gzip -c > /go/src/app/cache/docker.tgz
      - save_cache:
          key: v4-{{ .Branch }}-{{ epoch }}
          paths:
            - /go/src/app/cache/docker.tgz

  deploy:
    docker:
      - image: docker:18.02.0-ce
    steps:
      - setup_remote_docker
      - restore_cache:
          key: v4-{{.Branch}}
      - run:
          name: Restore Docker image cache
          command: gunzip -c /go/src/app/cache/docker.tgz | docker load

      - run:
          name: Deploy to Dockerhub
          command: |
            # deploy master
            if [ "${CIRCLE_BRANCH}" == "master" ]; then
              docker login -u $DOCKER_USER -p $DOCKER_PASS
              docker tag autograph-app ${DOCKERHUB_REPO}:latest
              docker push ${DOCKERHUB_REPO}:latest
            elif  [ ! -z "${CIRCLE_TAG}" ]; then
            # deploy a release tag...
              docker login -u $DOCKER_USER -p $DOCKER_PASS
              echo "${DOCKERHUB_REPO}:${CIRCLE_TAG}"
              docker tag autograph-app "${DOCKERHUB_REPO}:${CIRCLE_TAG}"
              docker images
              docker push "${DOCKERHUB_REPO}:${CIRCLE_TAG}"
            fi

workflows:
  version: 2
  check-code-quality:
    jobs:
      - lint-vet-fmt:
          filters:
            tags:
              only: /.*/

      - unit-test:
          filters:
            tags:
              only: /.*/

  build-integrationtest-verify-deploy:
    jobs:
      - build-integrationtest-verify:
          filters:
            tags:
              only: /.*/

      - deploy:
          requires:
            - build-integrationtest-verify
          filters:
            tags:
              # only upload the docker container on semver tags
              only: /[0-9]\.[0-9]\.[0-9]/
            branches:
              only: master
<commit_msg>circleci fixes for gomod<commit_after># These environment variables must be set in CircleCI UI
#
# DOCKERHUB_REPO - docker hub repo, format: <username>/<repo>
# DOCKER_USER
# DOCKER_PASS
#
version: 2
jobs:
  lint-vet-fmt:
    docker:
      - image: golang:1.12-buster
    steps:
      - checkout
      - run:
          name: run golint
          command: |
            make install-golint lint
            make show-lint
      - run:
          name: run gofmt
          command: |
            make -s fmt-diff | tee fmt.diff
            test -z "$(cat fmt.diff)"
      - run:
          name: install packages for crypto11 headers for go vet
          command: |
            apt-get update
            apt-get install -y libltdl-dev
      - run:
          name: run go vet
          command: make vet

  unit-test:
    docker:
      - image: circleci/golang:1.12-buster
      - image: circleci/postgres:11
        environment:
          POSTGRES_USER: root
          POSTGRES_DB: autograph
    environment:
      GOPATH: "/go"
    steps:
      - checkout
      - run:
          name: Install packages
          command: |
            sudo apt-get -y install libltdl-dev gpg postgresql-client
            make install-goveralls install-cover
      - run:
          name: Waiting for Postgres to be ready
          command: |
            for i in `seq 1 10`;
            do
              nc -z localhost 5432 && echo Success && exit 0
              echo -n .
              sleep 1
            done
            echo Failed waiting for Postgres && exit 1
      - run:
          name: Configure database
          command: |
            psql -U root -d autograph -h localhost -p 5432 -f database/schema.sql
      - run:
          name: Run a dummy statsd in the background
          command: make dummy-statsd
          background: true
      - run:
          name: Run unit tests
          command: |
            make generate test
      - run:
          name: Report coverage
          command: |
            $GOPATH/bin/goveralls -coverprofile=coverage.out -service circle-ci

  build-integrationtest-verify:
    # based on the official golang image with more docker stuff
    docker:
      - image: circleci/golang:1.12-buster
    steps:
      - checkout
      - setup_remote_docker
      - run:
          name: create version.json and other autogenerated files then build docker images
          command: make generate build
      - run:
          name:
          command: make integration-test
      # save the built docker container to CircleCI's cache since
      # CircleCI Workflows do not have the same remote docker
      # instance.
      #
      # Use /go/src/app since we don't have permissions to make
      # directories in other locations
      - run:
          name: docker save built images
          no_output_timeout: 30m
          command: |
            mkdir -p /go/src/app/cache
            docker save "autograph-app" | gzip -c > /go/src/app/cache/docker.tgz
      - save_cache:
          key: v4-{{ .Branch }}-{{ epoch }}
          paths:
            - /go/src/app/cache/docker.tgz

  deploy:
    docker:
      - image: docker:18.02.0-ce
    steps:
      - setup_remote_docker
      - restore_cache:
          key: v4-{{.Branch}}
      - run:
          name: Restore Docker image cache
          command: gunzip -c /go/src/app/cache/docker.tgz | docker load

      - run:
          name: Deploy to Dockerhub
          command: |
            # deploy master
            if [ "${CIRCLE_BRANCH}" == "master" ]; then
              docker login -u $DOCKER_USER -p $DOCKER_PASS
              docker tag autograph-app ${DOCKERHUB_REPO}:latest
              docker push ${DOCKERHUB_REPO}:latest
            elif  [ ! -z "${CIRCLE_TAG}" ]; then
            # deploy a release tag...
              docker login -u $DOCKER_USER -p $DOCKER_PASS
              echo "${DOCKERHUB_REPO}:${CIRCLE_TAG}"
              docker tag autograph-app "${DOCKERHUB_REPO}:${CIRCLE_TAG}"
              docker images
              docker push "${DOCKERHUB_REPO}:${CIRCLE_TAG}"
            fi

workflows:
  version: 2
  check-code-quality:
    jobs:
      - lint-vet-fmt:
          filters:
            tags:
              only: /.*/

      - unit-test:
          filters:
            tags:
              only: /.*/

  build-integrationtest-verify-deploy:
    jobs:
      - build-integrationtest-verify:
          filters:
            tags:
              only: /.*/

      - deploy:
          requires:
            - build-integrationtest-verify
          filters:
            tags:
              # only upload the docker container on semver tags
              only: /[0-9]\.[0-9]\.[0-9]/
            branches:
              only: master

{'fraction_non_alphanumeric': 0.08816537467700258, 'fraction_numerical': 0.00909560723514212, 'mean_word_length': 1.442817470335774, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 9, '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': '469241', 'n_tokens_mistral': 2939, 'n_tokens_neox': 2762, 'n_words': 801}