diff --git a/.circleci/config.yml b/.circleci/config.yml index ed11fcc5a..27884d8cb 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -80,9 +80,9 @@ jobs: check-lint: executor: golang resource_class: large - working_directory: /go/src/github.com/hashicorp/packer steps: - checkout + - run: git fetch --all - run: command: make ci-lint no_output_timeout: 30m diff --git a/Makefile b/Makefile index 96494ebf6..23872ac41 100644 --- a/Makefile +++ b/Makefile @@ -84,8 +84,7 @@ lint: install-lint-deps ## Lint Go code ci-lint: install-lint-deps ## On ci only lint newly added Go source files @echo "==> Running linter on newly added Go source files..." - GO111MODULE=on golangci-lint run --new-from-rev=`git merge-base master HEAD` ./... - + @GO111MODULE=on sh -c "$(CURDIR)/scripts/lint.sh" fmt: ## Format Go code @go fmt ./... diff --git a/scripts/lint.sh b/scripts/lint.sh new file mode 100755 index 000000000..cfe0e6baa --- /dev/null +++ b/scripts/lint.sh @@ -0,0 +1,6 @@ +#!/usr/bin/env bash + +CHANGED_FILES=$(git diff --name-status `git merge-base origin/master HEAD`...HEAD | grep '^A.*\.go$'| awk '{print $2}') +if [ ! -z "${CHANGED_FILES}" ]; then + echo $CHANGED_FILES | xargs -n1 golangci-lint run +fi