-
Notifications
You must be signed in to change notification settings - Fork 510
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This change introduces lint checking to the build process. Minor lint fixes are also included in this patch. Change-Id: I1615909db05a20c07e1188b82e40830a162ece58 Signed-off-by: Troy Ronda <troy@troyronda.com>
- Loading branch information
Showing
6 changed files
with
66 additions
and
8 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
#!/bin/bash | ||
# This script runs Go linting and vetting tools | ||
# Original script from Hyperledger Fabric and Fabric CA projects | ||
|
||
set -e | ||
|
||
declare -a arr=( | ||
"./config" | ||
"./fabric-ca-client" | ||
"./fabric-client" | ||
"./test" | ||
) | ||
|
||
echo "Running linters..." | ||
for i in "${arr[@]}" | ||
do | ||
echo "Checking $i" | ||
OUTPUT="$(golint $i/...)" | ||
if [[ $OUTPUT ]]; then | ||
echo "You should check the following golint suggestions:" | ||
printf "$OUTPUT\n" | ||
echo "end golint suggestions" | ||
fi | ||
|
||
OUTPUT="$(go vet $i/...)" | ||
if [[ $OUTPUT ]]; then | ||
echo "You should check the following govet suggestions:" | ||
printf "$OUTPUT\n" | ||
echo "end govet suggestions" | ||
fi | ||
|
||
found=`gofmt -l \`find $i -name "*.go" |grep -v "./vendor"\` 2>&1` | ||
if [ $? -ne 0 ]; then | ||
echo "The following files need reformatting with 'gofmt -w <file>':" | ||
printf "$badformat\n" | ||
exit 1 | ||
fi | ||
|
||
OUTPUT="$(goimports -srcdir $GOPATH/src/github.com/hyperledger/fabric-sdk-go -l $i)" | ||
if [[ $OUTPUT ]]; then | ||
echo "YOU MUST FIX THE FOLLOWING GOIMPORTS ERRORS:" | ||
printf "$OUTPUT\n" | ||
echo "END GOIMPORTS ERRORS" | ||
exit 1 | ||
fi | ||
done |
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 |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#!/bin/bash | ||
# This script installs dependencies for testing tools | ||
|
||
echo "Installing dependencies..." | ||
go get -u github.com/axw/gocov/... | ||
go get -u github.com/AlekSi/gocov-xml | ||
go get -u github.com/client9/misspell/cmd/misspell | ||
go get -u github.com/golang/lint/golint | ||
go get -u golang.org/x/tools/cmd/goimports |