<commit_before>orbs:
  win: circleci/windows@1.0.0
  codecov: codecov/codecov@1.0.5

version: 2.1

executors:
  golang:
    docker:
      - image: circleci/golang:1.13
  darwin:
    macos:
      xcode: "9.0"

commands:
  install-go-run-tests-unix:
    parameters:
      GOOS:
        type: string
      GOVERSION:
        type: string
    steps:
      - checkout
      - run: curl https://dl.google.com/go/go<< parameters.GOVERSION >>.<< parameters.GOOS >>-amd64.tar.gz | tar -C ~/ -xz
      - run: ~/go/bin/go test ./... -coverprofile=coverage.txt  -covermode=atomic
  install-go-run-tests-windows:
    parameters:
      GOVERSION:
        type: string
    steps:
      - checkout
      - run: curl https://dl.google.com/go/go<< parameters.GOVERSION >>.windows-amd64.zip --output ~/go<< parameters.GOVERSION >>.windows-amd64.zip
      - run: unzip ~/go<< parameters.GOVERSION >>.windows-amd64.zip -d ~/
      - run: ~/go/bin/go test ./... -coverprofile=coverage.txt  -covermode=atomic
  build-and-persist-packer-binary:
    parameters:
      GOOS:
        type: string
    steps:
      - checkout
      - run: GOOS=<< parameters.GOOS >> go build -ldflags="-s -w -X github.com/hashicorp/packer/version.GitCommit=${CIRCLE_SHA1}" -o ./pkg/packer_<< parameters.GOOS >>_$(go env GOARCH) .
      - run: zip ./pkg/packer_<< parameters.GOOS >>_$(go env GOARCH).zip ./pkg/packer_<< parameters.GOOS >>_$(go env GOARCH)
      - run: rm ./pkg/packer_<< parameters.GOOS >>_$(go env GOARCH)
      - persist_to_workspace:
          root: .
          paths:
            - ./pkg/
# Golang CircleCI 2.0 configuration file
#
# Check https://circleci.com/docs/2.0/language-go/ for more details
jobs:
  test-linux:
    executor: golang
    resource_class: large
    working_directory: /go/src/github.com/hashicorp/packer
    steps:
      - checkout
      - run: TESTARGS="-coverprofile=coverage.txt  -covermode=atomic" make ci
      - codecov/upload:
          file: coverage.txt
  test-darwin:
    executor: darwin
    working_directory: ~/go/src/github.com/hashicorp/packer
    environment:
      GO111MODULE: "off"
    steps:
      - install-go-run-tests-unix:
          GOOS: darwin
          GOVERSION: "1.13"
      - codecov/upload:
          file: coverage.txt
  test-windows:
    executor:
      name: win/vs2019
      shell: bash.exe
    steps:
      - install-go-run-tests-windows:
          GOVERSION: "1.13"
      - codecov/upload:
          file: coverage.txt
  check-lint:
    executor: golang
    resource_class: large
    steps:
      - checkout
      - run: git fetch --all
      - run:
          command: make ci-lint
          no_output_timeout: 30m
  check-vendor-vs-mod:
    executor: golang
    working_directory: /go/src/github.com/hashicorp/packer
    environment:
      GO111MODULE: "off"
    steps:
      - checkout
      - run: GO111MODULE=on go run . --help
      - run: make check-vendor-vs-mod
  check-fmt:
    executor: golang
    steps:
      - checkout
      - run: make fmt-check
  check-generate:
    executor: golang
    working_directory: /go/src/github.com/hashicorp/packer
    steps:
      - checkout
      - run: make generate-check
  build_linux:
    executor: golang
    steps:
      - build-and-persist-packer-binary:
          GOOS: linux
  build_windows:
    executor: golang
    working_directory: /go/src/github.com/hashicorp/packer
    steps:
      - build-and-persist-packer-binary:
          GOOS: windows
  build_darwin:
    executor: golang
    working_directory: /go/src/github.com/hashicorp/packer
    steps:
      - build-and-persist-packer-binary:
          GOOS: darwin
  build_freebsd:
    executor: golang
    working_directory: /go/src/github.com/hashicorp/packer
    steps:
      - build-and-persist-packer-binary:
          GOOS: freebsd
  build_solaris:
    executor: golang
    working_directory: /go/src/github.com/hashicorp/packer
    steps:
      - build-and-persist-packer-binary:
          GOOS: solaris
  build_openbsd:
    executor: golang
    working_directory: /go/src/github.com/hashicorp/packer
    steps:
      - build-and-persist-packer-binary:
          GOOS: openbsd
  store_artifacts:
    executor: golang
    steps:
      - attach_workspace:
          at: .
      - store_artifacts:
          path: ./pkg/
          destination: /
  publish-github-tag-release:
    docker:
      - image: cibuilds/github:0.10
    working_directory: /go/src/github.com/hashicorp/packer
    steps:
      - attach_workspace:
          at: .
      - run: |
          ghr -prerelease -t ${GITHUB_TOKEN_AZR} -u ${CIRCLE_PROJECT_USERNAME} -r ${CIRCLE_PROJECT_REPONAME} -c ${CIRCLE_SHA1} -delete ${CIRCLE_TAG} ./pkg/
  build-website-docker-image:
    docker:
      - image: circleci/buildpack-deps
    shell: /usr/bin/env bash -euo pipefail -c
    steps:
      - checkout
      - setup_remote_docker
      - run:
          name: Build Docker Image if Necessary
          command: |
            IMAGE_TAG=$(cat website/Dockerfile website/package-lock.json | sha256sum | awk '{print $1;}')
            echo "Using $IMAGE_TAG"
            if curl https://hub.docker.com/v2/repositories/hashicorp/packer-website/tags/$IMAGE_TAG -fsL > /dev/null; then
                echo "Dependencies have not changed, not building a new website docker image."
            else<commit_msg>replace AZR token with a CI one (#9195)<commit_after>orbs:
  win: circleci/windows@1.0.0
  codecov: codecov/codecov@1.0.5

version: 2.1

executors:
  golang:
    docker:
      - image: circleci/golang:1.13
  darwin:
    macos:
      xcode: "9.0"

commands:
  install-go-run-tests-unix:
    parameters:
      GOOS:
        type: string
      GOVERSION:
        type: string
    steps:
      - checkout
      - run: curl https://dl.google.com/go/go<< parameters.GOVERSION >>.<< parameters.GOOS >>-amd64.tar.gz | tar -C ~/ -xz
      - run: ~/go/bin/go test ./... -coverprofile=coverage.txt  -covermode=atomic
  install-go-run-tests-windows:
    parameters:
      GOVERSION:
        type: string
    steps:
      - checkout
      - run: curl https://dl.google.com/go/go<< parameters.GOVERSION >>.windows-amd64.zip --output ~/go<< parameters.GOVERSION >>.windows-amd64.zip
      - run: unzip ~/go<< parameters.GOVERSION >>.windows-amd64.zip -d ~/
      - run: ~/go/bin/go test ./... -coverprofile=coverage.txt  -covermode=atomic
  build-and-persist-packer-binary:
    parameters:
      GOOS:
        type: string
    steps:
      - checkout
      - run: GOOS=<< parameters.GOOS >> go build -ldflags="-s -w -X github.com/hashicorp/packer/version.GitCommit=${CIRCLE_SHA1}" -o ./pkg/packer_<< parameters.GOOS >>_$(go env GOARCH) .
      - run: zip ./pkg/packer_<< parameters.GOOS >>_$(go env GOARCH).zip ./pkg/packer_<< parameters.GOOS >>_$(go env GOARCH)
      - run: rm ./pkg/packer_<< parameters.GOOS >>_$(go env GOARCH)
      - persist_to_workspace:
          root: .
          paths:
            - ./pkg/
# Golang CircleCI 2.0 configuration file
#
# Check https://circleci.com/docs/2.0/language-go/ for more details
jobs:
  test-linux:
    executor: golang
    resource_class: large
    working_directory: /go/src/github.com/hashicorp/packer
    steps:
      - checkout
      - run: TESTARGS="-coverprofile=coverage.txt  -covermode=atomic" make ci
      - codecov/upload:
          file: coverage.txt
  test-darwin:
    executor: darwin
    working_directory: ~/go/src/github.com/hashicorp/packer
    environment:
      GO111MODULE: "off"
    steps:
      - install-go-run-tests-unix:
          GOOS: darwin
          GOVERSION: "1.13"
      - codecov/upload:
          file: coverage.txt
  test-windows:
    executor:
      name: win/vs2019
      shell: bash.exe
    steps:
      - install-go-run-tests-windows:
          GOVERSION: "1.13"
      - codecov/upload:
          file: coverage.txt
  check-lint:
    executor: golang
    resource_class: large
    steps:
      - checkout
      - run: git fetch --all
      - run:
          command: make ci-lint
          no_output_timeout: 30m
  check-vendor-vs-mod:
    executor: golang
    working_directory: /go/src/github.com/hashicorp/packer
    environment:
      GO111MODULE: "off"
    steps:
      - checkout
      - run: GO111MODULE=on go run . --help
      - run: make check-vendor-vs-mod
  check-fmt:
    executor: golang
    steps:
      - checkout
      - run: make fmt-check
  check-generate:
    executor: golang
    working_directory: /go/src/github.com/hashicorp/packer
    steps:
      - checkout
      - run: make generate-check
  build_linux:
    executor: golang
    steps:
      - build-and-persist-packer-binary:
          GOOS: linux
  build_windows:
    executor: golang
    working_directory: /go/src/github.com/hashicorp/packer
    steps:
      - build-and-persist-packer-binary:
          GOOS: windows
  build_darwin:
    executor: golang
    working_directory: /go/src/github.com/hashicorp/packer
    steps:
      - build-and-persist-packer-binary:
          GOOS: darwin
  build_freebsd:
    executor: golang
    working_directory: /go/src/github.com/hashicorp/packer
    steps:
      - build-and-persist-packer-binary:
          GOOS: freebsd
  build_solaris:
    executor: golang
    working_directory: /go/src/github.com/hashicorp/packer
    steps:
      - build-and-persist-packer-binary:
          GOOS: solaris
  build_openbsd:
    executor: golang
    working_directory: /go/src/github.com/hashicorp/packer
    steps:
      - build-and-persist-packer-binary:
          GOOS: openbsd
  store_artifacts:
    executor: golang
    steps:
      - attach_workspace:
          at: .
      - store_artifacts:
          path: ./pkg/
          destination: /
  publish-github-tag-release:
    docker:
      - image: cibuilds/github:0.10
    working_directory: /go/src/github.com/hashicorp/packer
    steps:
      - attach_workspace:
          at: .
      - run: |
          ghr -prerelease -t ${CI_GITHUB_TOKEN} -u ${CIRCLE_PROJECT_USERNAME} -r ${CIRCLE_PROJECT_REPONAME} -c ${CIRCLE_SHA1} -delete ${CIRCLE_TAG} ./pkg/
  build-website-docker-image:
    docker:
      - image: circleci/buildpack-deps
    shell: /usr/bin/env bash -euo pipefail -c
    steps:
      - checkout
      - setup_remote_docker
      - run:
          name: Build Docker Image if Necessary
          command: |
            IMAGE_TAG=$(cat website/Dockerfile website/package-lock.json | sha256sum | awk '{print $1;}')
            echo "Using $IMAGE_TAG"
            if curl https://hub.docker.com/v2/repositories/hashicorp/packer-website/tags/$IMAGE_TAG -fsL > /dev/null; then
                echo "Dependencies have not changed, not building a new website docker image."
            else
{'fraction_non_alphanumeric': 0.12042869230046066, 'fraction_numerical': 0.010905330450314938, 'mean_word_length': 2.11234640140433, 'pattern_counts': {'":': 0, '<': 43, '<?xml version=': 0, '>': 45, 'https://': 8, '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': '4763165', 'n_tokens_mistral': 3741, 'n_tokens_neox': 3641, 'n_words': 724}