Files
Packer-Cn/scripts/lint.sh
T
Wilken Rivera c9c0ee65d3 circle-ci: update ci-lint steps (#9043)
* new-from-rev option is showing inconsistent results on circle and
locally. This change moves to a custom command `script/lint.sh` that gets a list of added
go files and pipes them to golangci-lint for testing.

* Add a git fetch as a step before retrieving merge-base changes to fix
the issue described at https://discuss.circleci.com/t/checkout-script-adds-commits-to-master-from-circle-branch/14194/2

* Moved source code out of GOPATH to ensure go mod support and reduce
the risk of having golangci-lint trying to scan all of the files within
GOPATH. This was an issue in the past, in changing it I found less OOM
issues on circle.
2020-04-14 12:03:22 +02:00

7 lines
233 B
Bash
Executable File

#!/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