This repository has been archived by the owner on Feb 9, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 92
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Automatic merge from submit-queue Gazellify the build `bin/gazelle` should automatically correct `BUILD` files **Release note**: ```release-note NONe ```
- Loading branch information
1 parent
88aee08
commit 35cbd5d
Showing
54 changed files
with
287 additions
and
315 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,96 +1,84 @@ | ||
#!/bin/bash | ||
|
||
# Runs all requisite linters over the whole mixer code base. | ||
set -e | ||
SCRIPTPATH=$( cd "$(dirname "$0")" ; pwd -P ) | ||
source $SCRIPTPATH/use_bazel_go.sh | ||
|
||
ROOTDIR=$SCRIPTPATH/.. | ||
cd $ROOTDIR | ||
set -o errexit | ||
set -o nounset | ||
set -o pipefail | ||
set -x | ||
|
||
prep_linters() { | ||
bin/bazel_to_go.py | ||
} | ||
bin/bazel_to_go.py | ||
|
||
go_metalinter() { | ||
LINTER_SHA="bfcc1d6942136fd86eb6f1a6fb328de8398fbd80" | ||
echo Running buildifier... | ||
bazel build @com_github_bazelbuild_buildtools//buildifier | ||
buildifier=$(bazel info bazel-bin)/external/com_github_bazelbuild_buildtools/buildifier/buildifier | ||
$buildifier -showlog -mode=check \ | ||
$(find . -type f \( -name 'BUILD*' -or -name 'WORKSPACE' -or -wholename '.*bazel$' -or -wholename '.*bzl$' \) -print ) | ||
|
||
if [[ "$OSTYPE" == "darwin"* ]]; then | ||
gometalinter=$(which gometalinter) | ||
if [[ -z $gometalinter ]]; then | ||
cat << EOF | ||
echo Running linters... | ||
LINTER_SHA="bfcc1d6942136fd86eb6f1a6fb328de8398fbd80" | ||
if [[ "$OSTYPE" == "darwin"* ]]; then | ||
gometalinter=$(which gometalinter) | ||
if [[ -z $gometalinter ]]; then | ||
cat << EOF | ||
# Please install gometalinter: | ||
go get -d github.com/alecthomas/gometalinter && \ | ||
pushd $HOME/go/src/github.com/alecthomas/gometalinter && \ | ||
git checkout -q "${LINTER_SHA}" && \ | ||
go build -v -o $HOME/bin/gometalinter . && \ | ||
gometalinter --install && \ | ||
popd | ||
pushd $HOME/go/src/github.com/alecthomas/gometalinter && \ | ||
git checkout -q "${LINTER_SHA}" && \ | ||
go build -v -o $HOME/bin/gometalinter . && \ | ||
gometalinter --install && \ | ||
popd | ||
EOF | ||
exit 1 | ||
fi | ||
else | ||
# Note: WriteHeaderAndJson excluded because the interface is defined in a 3rd party library. | ||
gometalinter="docker run \ | ||
-v $(bazel info output_base):$(bazel info output_base) \ | ||
-v $(pwd):/go/src/istio.io/mixer \ | ||
-w /go/src/istio.io/mixer \ | ||
gcr.io/istio-testing/linter:${LINTER_SHA}" | ||
fi | ||
exit 1 | ||
fi | ||
else | ||
# Note: WriteHeaderAndJson excluded because the interface is defined in a 3rd party library. | ||
gometalinter="docker run \ | ||
-v $(bazel info output_base):$(bazel info output_base) \ | ||
-v $(pwd):/go/src/istio.io/mixer \ | ||
-w /go/src/istio.io/mixer \ | ||
gcr.io/istio-testing/linter:${LINTER_SHA}" | ||
fi | ||
|
||
NUM_CPU=$(getconf _NPROCESSORS_ONLN) | ||
echo Running linters... | ||
$gometalinter \ | ||
--concurrency=${NUM_CPU}\ | ||
--enable-gc\ | ||
--vendored-linters\ | ||
--deadline=1200s --disable-all\ | ||
--enable=aligncheck\ | ||
--enable=deadcode\ | ||
--enable=errcheck\ | ||
--enable=gas\ | ||
--enable=goconst\ | ||
--enable=gofmt\ | ||
--enable=goimports\ | ||
--enable=golint --min-confidence=0\ | ||
--enable=gotype\ | ||
--exclude=vendor\ | ||
--exclude=.pb.go\ | ||
--exclude=pkg/config/proto/combined.go\ | ||
--exclude=.*.gen.go\ | ||
--exclude="should have a package comment"\ | ||
--exclude=".*pkg/config/apiserver_test.go:.* method WriteHeaderAndJson should be WriteHeaderAndJSON"\ | ||
--enable=ineffassign\ | ||
--enable=interfacer\ | ||
--enable=lll --line-length=160\ | ||
--enable=megacheck\ | ||
--enable=misspell\ | ||
--enable=structcheck\ | ||
--enable=unconvert\ | ||
--enable=unparam\ | ||
--enable=varcheck\ | ||
--enable=vet\ | ||
--enable=vetshadow\ | ||
--skip=testdata\ | ||
--skip=vendor\ | ||
--vendor\ | ||
./... | ||
} | ||
NUM_CPU=$(getconf _NPROCESSORS_ONLN) | ||
$gometalinter \ | ||
--concurrency=${NUM_CPU}\ | ||
--enable-gc\ | ||
--vendored-linters\ | ||
--deadline=1200s --disable-all\ | ||
--enable=aligncheck\ | ||
--enable=deadcode\ | ||
--enable=errcheck\ | ||
--enable=gas\ | ||
--enable=goconst\ | ||
--enable=gofmt\ | ||
--enable=goimports\ | ||
--enable=golint --min-confidence=0\ | ||
--enable=gotype\ | ||
--exclude=vendor\ | ||
--exclude=.pb.go\ | ||
--exclude=pkg/config/proto/combined.go\ | ||
--exclude=.*.gen.go\ | ||
--exclude="should have a package comment"\ | ||
--exclude=".*pkg/config/apiserver_test.go:.* method WriteHeaderAndJson should be WriteHeaderAndJSON"\ | ||
--enable=ineffassign\ | ||
--enable=interfacer\ | ||
--enable=lll --line-length=160\ | ||
--enable=megacheck\ | ||
--enable=misspell\ | ||
--enable=structcheck\ | ||
--enable=unconvert\ | ||
--enable=unparam\ | ||
--enable=varcheck\ | ||
--enable=vet\ | ||
--enable=vetshadow\ | ||
--skip=testdata\ | ||
--skip=vendor\ | ||
--vendor\ | ||
./... | ||
|
||
run_linters() { | ||
echo Running buildifier... | ||
bazel build @com_github_bazelbuild_buildtools//buildifier | ||
buildifier=$(bazel info bazel-bin)/external/com_github_bazelbuild_buildtools/buildifier/buildifier | ||
$buildifier -showlog -mode=check $(find . -name BUILD -type f) | ||
$buildifier -showlog -mode=check $(find . -name BUILD.bazel -type f) | ||
$buildifier -showlog -mode=check ./BUILD.ubuntu | ||
$buildifier -showlog -mode=check ./WORKSPACE | ||
go_metalinter | ||
$SCRIPTPATH/check_license.sh | ||
$SCRIPTPATH/check_workspace.sh | ||
} | ||
echo Check license... | ||
bin/check_license.sh | ||
|
||
prep_linters | ||
run_linters | ||
echo Check workspace... | ||
bin/check_workspace.sh | ||
|
||
echo Done running linters |
Oops, something went wrong.