mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
commit
4ad8bd9299
72
test
72
test
@ -274,24 +274,23 @@ function release_pass {
|
|||||||
mv /tmp/etcd ./bin/etcd-last-release
|
mv /tmp/etcd ./bin/etcd-last-release
|
||||||
}
|
}
|
||||||
|
|
||||||
function fmt_pass {
|
function gofmt_pass {
|
||||||
toggle_failpoints disable
|
|
||||||
|
|
||||||
echo "Checking gofmt..."
|
|
||||||
fmtRes=$(gofmt -l -s -d "${FMT[@]}")
|
fmtRes=$(gofmt -l -s -d "${FMT[@]}")
|
||||||
if [ -n "${fmtRes}" ]; then
|
if [ -n "${fmtRes}" ]; then
|
||||||
echo -e "gofmt checking failed:\n${fmtRes}"
|
echo -e "gofmt checking failed:\n${fmtRes}"
|
||||||
exit 255
|
exit 255
|
||||||
fi
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
echo "Checking govet..."
|
function govet_pass {
|
||||||
vetRes=$(go vet "${TEST[@]}")
|
vetRes=$(go vet "${TEST[@]}")
|
||||||
if [ -n "${vetRes}" ]; then
|
if [ -n "${vetRes}" ]; then
|
||||||
echo -e "govet checking failed:\n${vetRes}"
|
echo -e "govet checking failed:\n${vetRes}"
|
||||||
exit 255
|
exit 255
|
||||||
fi
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
echo "Checking 'go tool vet -all -shadow'..."
|
function govet_shadow_pass {
|
||||||
fmtpkgs=$(for a in "${FMT[@]}"; do dirname "$a"; done | sort | uniq | grep -v "\\.")
|
fmtpkgs=$(for a in "${FMT[@]}"; do dirname "$a"; done | sort | uniq | grep -v "\\.")
|
||||||
fmtpkgs=($fmtpkgs)
|
fmtpkgs=($fmtpkgs)
|
||||||
vetRes=$(go tool vet -all -shadow "${fmtpkgs[@]}" 2>&1 | grep -v '/gw/' || true)
|
vetRes=$(go tool vet -all -shadow "${fmtpkgs[@]}" 2>&1 | grep -v '/gw/' || true)
|
||||||
@ -299,27 +298,30 @@ function fmt_pass {
|
|||||||
echo -e "govet -all -shadow checking failed:\n${vetRes}"
|
echo -e "govet -all -shadow checking failed:\n${vetRes}"
|
||||||
exit 255
|
exit 255
|
||||||
fi
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
function shellcheck_pass {
|
||||||
if which shellcheck >/dev/null; then
|
if which shellcheck >/dev/null; then
|
||||||
echo "Checking shellcheck..."
|
|
||||||
shellcheckResult=$(shellcheck -fgcc build test scripts/* 2>&1 || true)
|
shellcheckResult=$(shellcheck -fgcc build test scripts/* 2>&1 || true)
|
||||||
if [ -n "${shellcheckResult}" ]; then
|
if [ -n "${shellcheckResult}" ]; then
|
||||||
echo -e "shellcheck checking failed:\n${shellcheckResult}"
|
echo -e "shellcheck checking failed:\n${shellcheckResult}"
|
||||||
exit 255
|
exit 255
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
echo "Checking documentation style..."
|
function markdown_you_pass {
|
||||||
# eschew you
|
# eschew you
|
||||||
yous=$(find . -name \*.md -exec grep -E --color "[Yy]ou[r]?[ '.,;]" {} + | grep -v /v2/ || true)
|
yous=$(find . -name \*.md -exec grep -E --color "[Yy]ou[r]?[ '.,;]" {} + | grep -v /v2/ || true)
|
||||||
if [ ! -z "$yous" ]; then
|
if [ ! -z "$yous" ]; then
|
||||||
echo -e "found 'you' in documentation:\n${yous}"
|
echo -e "found 'you' in documentation:\n${yous}"
|
||||||
exit 255
|
exit 255
|
||||||
fi
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
function markdown_marker_pass {
|
||||||
# TODO: check other markdown files when marker handles headers with '[]'
|
# TODO: check other markdown files when marker handles headers with '[]'
|
||||||
if which marker >/dev/null; then
|
if which marker >/dev/null; then
|
||||||
echo "Checking marker to find broken links..."
|
|
||||||
markerResult=$(marker --skip-http --root ./Documentation 2>&1 || true)
|
markerResult=$(marker --skip-http --root ./Documentation 2>&1 || true)
|
||||||
if [ -n "${markerResult}" ]; then
|
if [ -n "${markerResult}" ]; then
|
||||||
echo -e "marker checking failed:\n${markerResult}"
|
echo -e "marker checking failed:\n${markerResult}"
|
||||||
@ -328,9 +330,10 @@ function fmt_pass {
|
|||||||
else
|
else
|
||||||
echo "Skipping marker..."
|
echo "Skipping marker..."
|
||||||
fi
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
function goword_pass {
|
||||||
if which goword >/dev/null; then
|
if which goword >/dev/null; then
|
||||||
echo "Checking goword..."
|
|
||||||
# get all go files to process
|
# get all go files to process
|
||||||
gofiles=$(find "${FMT[@]}" -iname '*.go' 2>/dev/null)
|
gofiles=$(find "${FMT[@]}" -iname '*.go' 2>/dev/null)
|
||||||
gofiles_all=($gofiles)
|
gofiles_all=($gofiles)
|
||||||
@ -352,9 +355,10 @@ function fmt_pass {
|
|||||||
else
|
else
|
||||||
echo "Skipping goword..."
|
echo "Skipping goword..."
|
||||||
fi
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
function gosimple_pass {
|
||||||
if which gosimple >/dev/null; then
|
if which gosimple >/dev/null; then
|
||||||
echo "Checking gosimple..."
|
|
||||||
gosimpleResult=$(gosimple "${STATIC_ANALYSIS_PATHS[@]}" 2>&1 || true)
|
gosimpleResult=$(gosimple "${STATIC_ANALYSIS_PATHS[@]}" 2>&1 || true)
|
||||||
if [ -n "${gosimpleResult}" ]; then
|
if [ -n "${gosimpleResult}" ]; then
|
||||||
echo -e "gosimple checking failed:\n${gosimpleResult}"
|
echo -e "gosimple checking failed:\n${gosimpleResult}"
|
||||||
@ -363,9 +367,10 @@ function fmt_pass {
|
|||||||
else
|
else
|
||||||
echo "Skipping gosimple..."
|
echo "Skipping gosimple..."
|
||||||
fi
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
function unused_pass {
|
||||||
if which unused >/dev/null; then
|
if which unused >/dev/null; then
|
||||||
echo "Checking unused..."
|
|
||||||
unusedResult=$(unused "${STATIC_ANALYSIS_PATHS[@]}" 2>&1 || true)
|
unusedResult=$(unused "${STATIC_ANALYSIS_PATHS[@]}" 2>&1 || true)
|
||||||
if [ -n "${unusedResult}" ]; then
|
if [ -n "${unusedResult}" ]; then
|
||||||
echo -e "unused checking failed:\n${unusedResult}"
|
echo -e "unused checking failed:\n${unusedResult}"
|
||||||
@ -374,9 +379,10 @@ function fmt_pass {
|
|||||||
else
|
else
|
||||||
echo "Skipping unused..."
|
echo "Skipping unused..."
|
||||||
fi
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
function staticcheck_pass {
|
||||||
if which staticcheck >/dev/null; then
|
if which staticcheck >/dev/null; then
|
||||||
echo "Checking staticcheck..."
|
|
||||||
staticcheckResult=$(staticcheck "${STATIC_ANALYSIS_PATHS[@]}" 2>&1 || true)
|
staticcheckResult=$(staticcheck "${STATIC_ANALYSIS_PATHS[@]}" 2>&1 || true)
|
||||||
if [ -n "${staticcheckResult}" ]; then
|
if [ -n "${staticcheckResult}" ]; then
|
||||||
# TODO: resolve these after go1.8 migration
|
# TODO: resolve these after go1.8 migration
|
||||||
@ -393,9 +399,10 @@ function fmt_pass {
|
|||||||
else
|
else
|
||||||
echo "Skipping staticcheck..."
|
echo "Skipping staticcheck..."
|
||||||
fi
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
function ineffassign_pass {
|
||||||
if which ineffassign >/dev/null; then
|
if which ineffassign >/dev/null; then
|
||||||
echo "Checking ineffassign..."
|
|
||||||
ineffassignResult=$(ineffassign "${STATIC_ANALYSIS_PATHS[@]}" 2>&1 || true)
|
ineffassignResult=$(ineffassign "${STATIC_ANALYSIS_PATHS[@]}" 2>&1 || true)
|
||||||
if [ -n "${ineffassignResult}" ]; then
|
if [ -n "${ineffassignResult}" ]; then
|
||||||
echo -e "ineffassign checking failed:\n${ineffassignResult}"
|
echo -e "ineffassign checking failed:\n${ineffassignResult}"
|
||||||
@ -404,9 +411,10 @@ function fmt_pass {
|
|||||||
else
|
else
|
||||||
echo "Skipping ineffassign..."
|
echo "Skipping ineffassign..."
|
||||||
fi
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
function nakedret_pass {
|
||||||
if which nakedret >/dev/null; then
|
if which nakedret >/dev/null; then
|
||||||
echo "Checking nakedret..."
|
|
||||||
nakedretResult=$(nakedret "${STATIC_ANALYSIS_PATHS[@]}" 2>&1 || true)
|
nakedretResult=$(nakedret "${STATIC_ANALYSIS_PATHS[@]}" 2>&1 || true)
|
||||||
if [ -n "${nakedretResult}" ]; then
|
if [ -n "${nakedretResult}" ]; then
|
||||||
echo -e "nakedret checking failed:\n${nakedretResult}"
|
echo -e "nakedret checking failed:\n${nakedretResult}"
|
||||||
@ -415,8 +423,9 @@ function fmt_pass {
|
|||||||
else
|
else
|
||||||
echo "Skipping nakedret..."
|
echo "Skipping nakedret..."
|
||||||
fi
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
echo "Checking for license header..."
|
function license_header_pass {
|
||||||
licRes=""
|
licRes=""
|
||||||
files=$(find . -type f -iname '*.go' ! -path './cmd/*' ! -path './gopath.proto/*')
|
files=$(find . -type f -iname '*.go' ! -path './cmd/*' ! -path './gopath.proto/*')
|
||||||
for file in $files; do
|
for file in $files; do
|
||||||
@ -428,8 +437,9 @@ function fmt_pass {
|
|||||||
echo -e "license header checking failed:\n${licRes}"
|
echo -e "license header checking failed:\n${licRes}"
|
||||||
exit 255
|
exit 255
|
||||||
fi
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
echo "Checking receiver names..."
|
function receiver_name_pass {
|
||||||
recvs=$(grep 'func ([^*]' {*,*/*,*/*/*}.go | grep -Ev "(generated|pb/)" | tr ':' ' ' | \
|
recvs=$(grep 'func ([^*]' {*,*/*,*/*/*}.go | grep -Ev "(generated|pb/)" | tr ':' ' ' | \
|
||||||
awk ' { print $2" "$3" "$4" "$1 }' | sed "s/[a-zA-Z\.]*go//g" | sort | uniq | \
|
awk ' { print $2" "$3" "$4" "$1 }' | sed "s/[a-zA-Z\.]*go//g" | sort | uniq | \
|
||||||
grep -Ev "(Descriptor|Proto|_)" | awk ' { print $3" "$4 } ' | sort | uniq -c | grep -v ' 1 ' | awk ' { print $2 } ')
|
grep -Ev "(Descriptor|Proto|_)" | awk ' { print $3" "$4 } ' | sort | uniq -c | grep -v ' 1 ' | awk ' { print $2 } ')
|
||||||
@ -441,8 +451,9 @@ function fmt_pass {
|
|||||||
done
|
done
|
||||||
exit 255
|
exit 255
|
||||||
fi
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
echo "Checking commit titles..."
|
function commit_title_pass {
|
||||||
git log --oneline "$(git merge-base HEAD master)"...HEAD | while read -r l; do
|
git log --oneline "$(git merge-base HEAD master)"...HEAD | while read -r l; do
|
||||||
commitMsg=$(echo "$l" | cut -f2- -d' ')
|
commitMsg=$(echo "$l" | cut -f2- -d' ')
|
||||||
if [[ "$commitMsg" == Merge* ]]; then
|
if [[ "$commitMsg" == Merge* ]]; then
|
||||||
@ -466,6 +477,31 @@ function fmt_pass {
|
|||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function fmt_pass {
|
||||||
|
toggle_failpoints disable
|
||||||
|
|
||||||
|
for p in gofmt \
|
||||||
|
govet \
|
||||||
|
govet_shadow \
|
||||||
|
shellcheck \
|
||||||
|
markdown_you \
|
||||||
|
markdown_marker \
|
||||||
|
goword \
|
||||||
|
gosimple \
|
||||||
|
unused \
|
||||||
|
staticcheck \
|
||||||
|
ineffassign \
|
||||||
|
nakedret \
|
||||||
|
license_header \
|
||||||
|
receiver_name \
|
||||||
|
commit_title \
|
||||||
|
; do
|
||||||
|
echo "Starting '$p' pass at $(date)"
|
||||||
|
"${p}"_pass "$@"
|
||||||
|
echo "Finished '$p' pass at $(date)"
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
function bom_pass {
|
function bom_pass {
|
||||||
if ! which license-bill-of-materials >/dev/null; then
|
if ! which license-bill-of-materials >/dev/null; then
|
||||||
return
|
return
|
||||||
|
Loading…
x
Reference in New Issue
Block a user