language: golang

go:
- "1.14"

before_script:
- go install golang.org/x/tools/cmd/goimports

script:
- go test -v ./...
- >
  echo "Checking goimports..." && (
    if [[ -n $(goimports -l internal cmd) ]]; then
      goimports -d internal cmd
      echo 'Please run `goimports -w cmd internal`.'
      false
    fi
  )
- >
  echo "Checking go mod..." && (
    go mod tidy
    git diff --quiet || (
      git diff go.mod go.sum
      echo 'Please run `go mod tidy`.'
      false
    )
  )
- >
  echo "Checking for license headers..." && (
    FILES=$(grep -rL 'https://www.apache.org/licenses/LICENSE-2.0' internal cmd)
    if [[ -n ${FILES} ]]; then
      echo "The following files are missing the Apache header:\n${FILES}"
      false
    fi
  )

language: golang

go:
- "1.14"

before_script:
- go install golang.org/x/tools/cmd/goimports

script:
- go test -v ./...
- >
  echo "Checking goimports..." && (
    if [[ -n $(goimports -l internal cmd) ]]; then
      goimports -d internal cmd
      echo 'Please run `goimports -w cmd internal`.'
      false
    fi
  )
- >
  echo "Checking go mod..." && (
    go mod tidy
    git diff --quiet || (
      git diff go.mod go.sum
      echo 'Please run `go mod tidy`.'
      false
    )
  )
- >
  echo "Checking for license headers..." && (
    FILES=$(grep -rL 'https://www.apache.org/licenses/LICENSE-2.0' internal cmd | grep -v ".json")
    if [[ -n ${FILES} ]]; then
      echo "The following files are missing the Apache header:"
      echo ${FILES}
      false
    fi
  )

Correct formatting of message, exclude JSON.
Correct formatting of message, exclude JSON.
