-
Notifications
You must be signed in to change notification settings - Fork 70
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add the install and basic-checks subcommand in the makefile
install subcommand will install binary to GOBIN path Signed-off-by: wuxu <wuxu1103@163.com>
- Loading branch information
Showing
9 changed files
with
162 additions
and
9 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,29 @@ | ||
# Copyright IBM Corp All Rights Reserved. | ||
# Copyright London Stock Exchange Group All Rights Reserved. | ||
# | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
GOTOOLS = goimports golint staticcheck | ||
BUILD_DIR ?= build | ||
GOTOOLS_BINDIR ?= $(shell go env GOBIN) | ||
|
||
# go tool->path mapping | ||
go.fqp.goimports := golang.org/x/tools/cmd/goimports | ||
go.fqp.golint := golang.org/x/lint/golint | ||
go.fqp.staticcheck := honnef.co/go/tools/cmd/staticcheck | ||
|
||
.PHONY: gotools-install | ||
gotools-install: $(patsubst %,$(GOTOOLS_BINDIR)/%, $(GOTOOLS)) | ||
|
||
.PHONY: gotools-clean | ||
gotools-clean: | ||
|
||
# Default rule for gotools uses the name->path map for a generic 'go get' style build | ||
gotool.%: | ||
$(eval TOOL = ${subst gotool.,,${@}}) | ||
@echo "Building ${go.fqp.${TOOL}} -> $(TOOL)" | ||
go install ${go.fqp.${TOOL}} | ||
|
||
$(GOTOOLS_BINDIR)/%: | ||
$(eval TOOL = ${subst $(GOTOOLS_BINDIR)/,,${@}}) | ||
@$(MAKE) -f gotools.mk gotool.$(TOOL) |
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,50 @@ | ||
#!/bin/bash | ||
# | ||
# Copyright IBM Corp. All Rights Reserved. | ||
# | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
function filterExcludedAndGeneratedFiles { | ||
local excluded_files | ||
excluded_files=( | ||
'\.block$' | ||
'^\.build/' | ||
'^build/' | ||
'(^|/)ci\.properties$' | ||
'(^|/)\.git/' | ||
'\.gen\.go$' | ||
'(^|/)go.mod$' | ||
'(^|/)go.sum$' | ||
'(^|/)Gopkg\.lock$' | ||
'\.html$' | ||
'\.json$' | ||
'\.key$' | ||
'(^|/)LICENSE$' | ||
'\.md$' | ||
'\.pb\.go$' | ||
'\.pem$' | ||
'\.png$' | ||
'\.pptx$' | ||
'\.rst$' | ||
'_sk$' | ||
'\.tx$' | ||
'\.txt$' | ||
'^NOTICE$' | ||
'(^|/)testdata\/' | ||
'(^|/)vendor\/' | ||
'(^|/)Pipfile$' | ||
'(^|/)Pipfile\.lock$' | ||
'(^|/)tox\.ini$' | ||
) | ||
|
||
local filter | ||
filter=$(local IFS='|' ; echo "${excluded_files[*]}") | ||
|
||
read -ra files <<<"$@" | ||
for f in "${files[@]}"; do | ||
file=$(echo "$f" | grep -Ev "$filter" | sort -u) | ||
if [ -n "$file" ]; then | ||
head -n2 "$file" | grep -qE '// Code generated by' || echo "$file" | ||
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,53 @@ | ||
#!/bin/bash | ||
|
||
# Copyright Greg Haskins All Rights Reserved. | ||
# | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
set -e | ||
|
||
# shellcheck source=/dev/null | ||
source "$(cd "$(dirname "$0")" && pwd)/functions.sh" | ||
|
||
fabric_dir="$(cd "$(dirname "$0")/.." && pwd)" | ||
source_dirs=() | ||
while IFS=$'\n' read -r source_dir; do | ||
source_dirs+=("$source_dir") | ||
done < <(go list -f '{{.Dir}}' ./... | sed s,"${fabric_dir}".,,g | cut -f 1 -d / | sort -u) | ||
|
||
echo "Checking with gofmt" | ||
OUTPUT="$(gofmt -l -s "${source_dirs[@]}")" | ||
OUTPUT="$(filterExcludedAndGeneratedFiles "$OUTPUT")" | ||
if [ -n "$OUTPUT" ]; then | ||
echo "The following files contain gofmt errors" | ||
echo "$OUTPUT" | ||
echo "The gofmt command 'gofmt -l -s -w' must be run for these files" | ||
exit 1 | ||
fi | ||
|
||
echo "Checking with goimports" | ||
OUTPUT="$(goimports -l "${source_dirs[@]}")" | ||
OUTPUT="$(filterExcludedAndGeneratedFiles "$OUTPUT")" | ||
if [ -n "$OUTPUT" ]; then | ||
echo "The following files contain goimports errors" | ||
echo "$OUTPUT" | ||
echo "The goimports command 'goimports -l -w' must be run for these files" | ||
exit 1 | ||
fi | ||
|
||
echo "Checking with go vet" | ||
PRINTFUNCS="Debug,Debugf,Print,Printf,Info,Infof,Warning,Warningf,Error,Errorf,Critical,Criticalf,Sprint,Sprintf,Log,Logf,Panic,Panicf,Fatal,Fatalf,Notice,Noticef,Wrap,Wrapf,WithMessage" | ||
OUTPUT="$(go vet -all -printfuncs "$PRINTFUNCS" ./...)" | ||
if [ -n "$OUTPUT" ]; then | ||
echo "The following files contain go vet errors" | ||
echo "$OUTPUT" | ||
exit 1 | ||
fi | ||
|
||
#echo "Checking with staticcheck" | ||
#OUTPUT="$(staticcheck ./... || true)" | ||
#if [ -n "$OUTPUT" ]; then | ||
# echo "The following staticcheck issues were flagged" | ||
# echo "$OUTPUT" | ||
# exit 1 | ||
#fi |