<commit_before>version: 2.1

references:
  images:
    go-1.13: &GOLANG_1_13_IMAGE docker.mirror.hashicorp.services/circleci/golang:1.13
    go-1.14: &GOLANG_1_14_IMAGE docker.mirror.hashicorp.services/circleci/golang:1.14

  environment: &ENVIRONMENT
    TEST_RESULTS_DIR: &TEST_RESULTS_DIR /tmp/test-results # path to where test results are saved
    GOTRACEBACK: "all"
    GO111MODULE: "on"
    GOMAXPROCS: 2

jobs:
  go-fmt-and-vet:
    docker:
      - image: *GOLANG_1_14_IMAGE
    steps:
      - checkout

      # Restore go module cache if there is one
      - restore_cache:
          keys:
            - raft-modcache-v1-{{ checksum "go.mod" }}

      - run: go mod download

      # Save go module cache if the go.mod file has changed
      - save_cache:
          key: raft-modcache-v1-{{ checksum "go.mod" }}
          paths:
            - "/go/pkg/mod"

      # check go fmt output because it does not report non-zero when there are fmt changes
      - run:
          name: check go fmt
          command: |
            files=$(go fmt ./...)
            if [ -n "$files" ]; then
              echo "The following file(s) do not conform to go fmt:"
              echo "$files"
              exit 1
            fi
      - run: |
          PACKAGE_NAMES=$(go list ./... | grep -v github.com/hashicorp/raft/fuzzy)
          go vet $PACKAGE_NAMES

  go-test:
    description: Runs go tests
    parameters:
      go-version:
        description: what go version to use
        type: string
    docker:
      - image: << parameters.go-version >>
    environment: *ENVIRONMENT
    steps:
      - checkout
      - run: mkdir -p $TEST_RESULTS_DIR

      - restore_cache: # restore cache
          keys:
            - raft-modcache-v1-{{ checksum "go.mod" }}

      # run go tests with gotestsum
      - run: make ci.integ
      - store_test_results:
          path: /tmp/test-results
      - store_artifacts:
          path: /tmp/test-results

  go-test-32bit:
    description: Runs go tests - 32 bit
    parameters:
      go-version:
        description: what go version to use
        type: string
    docker:
      - image: << parameters.go-version >>
    environment:
      <<: *ENVIRONMENT
      GOARCH: "386"
    steps:
      - checkout
      - run: mkdir -p $TEST_RESULTS_DIR

      - restore_cache: # restore cache
          keys:
            - raft-modcache-v1-{{ checksum "go.mod" }}

      # run go tests with gotestsum
      - run: make ci.test-norace
      - store_test_results:
          path: /tmp/test-results
      - store_artifacts:
          path: /tmp/test-results

workflows:
  version: 2
  test-and-build:
    jobs:
      - go-fmt-and-vet
      - go-test:
          name: test go1.13
          go-version: *GOLANG_1_13_IMAGE
          requires:
            - go-fmt-and-vet
      - go-test:
          name: test go1.14
          go-version: *GOLANG_1_14_IMAGE
          requires:
            - go-fmt-and-vet
      - go-test-32bit:
          name: test go1.13 - 32bit
          go-version: *GOLANG_1_13_IMAGE
          requires:
            - go-fmt-and-vet
      - go-test-32bit:<commit_msg>Add circle tests for Go 1.15 and 1.16<commit_after>version: 2.1

references:
  images:
    go-1.13: &GOLANG_1_13_IMAGE docker.mirror.hashicorp.services/circleci/golang:1.13
    go-1.14: &GOLANG_1_14_IMAGE docker.mirror.hashicorp.services/circleci/golang:1.14
    go-1.15: &GOLANG_1_15_IMAGE docker.mirror.hashicorp.services/circleci/golang:1.15
    go-1.16: &GOLANG_1_16_IMAGE docker.mirror.hashicorp.services/circleci/golang:1.16

  environment: &ENVIRONMENT
    TEST_RESULTS_DIR: &TEST_RESULTS_DIR /tmp/test-results # path to where test results are saved
    GOTRACEBACK: "all"
    GO111MODULE: "on"
    GOMAXPROCS: 2

jobs:
  go-fmt-and-vet:
    docker:
      - image: *GOLANG_1_14_IMAGE
    steps:
      - checkout

      # Restore go module cache if there is one
      - restore_cache:
          keys:
            - raft-modcache-v1-{{ checksum "go.mod" }}

      - run: go mod download

      # Save go module cache if the go.mod file has changed
      - save_cache:
          key: raft-modcache-v1-{{ checksum "go.mod" }}
          paths:
            - "/go/pkg/mod"

      # check go fmt output because it does not report non-zero when there are fmt changes
      - run:
          name: check go fmt
          command: |
            files=$(go fmt ./...)
            if [ -n "$files" ]; then
              echo "The following file(s) do not conform to go fmt:"
              echo "$files"
              exit 1
            fi
      - run: |
          PACKAGE_NAMES=$(go list ./... | grep -v github.com/hashicorp/raft/fuzzy)
          go vet $PACKAGE_NAMES

  go-test:
    description: Runs go tests
    parameters:
      go-version:
        description: what go version to use
        type: string
    docker:
      - image: << parameters.go-version >>
    environment: *ENVIRONMENT
    steps:
      - checkout
      - run: mkdir -p $TEST_RESULTS_DIR

      - restore_cache: # restore cache
          keys:
            - raft-modcache-v1-{{ checksum "go.mod" }}

      # run go tests with gotestsum
      - run: make ci.integ
      - store_test_results:
          path: /tmp/test-results
      - store_artifacts:
          path: /tmp/test-results

  go-test-32bit:
    description: Runs go tests - 32 bit
    parameters:
      go-version:
        description: what go version to use
        type: string
    docker:
      - image: << parameters.go-version >>
    environment:
      <<: *ENVIRONMENT
      GOARCH: "386"
    steps:
      - checkout
      - run: mkdir -p $TEST_RESULTS_DIR

      - restore_cache: # restore cache
          keys:
            - raft-modcache-v1-{{ checksum "go.mod" }}

      # run go tests with gotestsum
      - run: make ci.test-norace
      - store_test_results:
          path: /tmp/test-results
      - store_artifacts:
          path: /tmp/test-results

workflows:
  version: 2
  test-and-build:
    jobs:
      - go-fmt-and-vet
      - go-test:
          name: test go1.13
          go-version: *GOLANG_1_13_IMAGE
          requires:
            - go-fmt-and-vet
      - go-test:
          name: test go1.14
          go-version: *GOLANG_1_14_IMAGE
          requires:
            - go-fmt-and-vet
      - go-test:
          name: test go1.15
          go-version: *GOLANG_1_15_IMAGE
          requires:
            - go-fmt-and-vet
      - go-test:
          name: test go1.16
          go-version: *GOLANG_1_16_IMAGE
          requires:
            - go-fmt-and-vet
      - go-test-32bit:
          name: test go1.13 - 32bit
          go-version: *GOLANG_1_13_IMAGE
          requires:
            - go-fmt-and-vet
      - go-test-32bit:
{'fraction_non_alphanumeric': 0.10298507462686567, 'fraction_numerical': 0.02447761194029851, 'mean_word_length': 1.64026792750197, 'pattern_counts': {'":': 0, '<': 15, '<?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': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6095471', 'n_tokens_mistral': 2326, 'n_tokens_neox': 2183, 'n_words': 528}