Skip to content

Update tools #269

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Feb 6, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions push-images
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ IMAGES=$(make images)
IMAGE_TAG=$(./tools/image-tag)

for image in ${IMAGES}; do
if [[ "$image" == *"build"* ]]; then
continue
fi
docker push ${image}:${IMAGE_TAG}
docker tag ${image}:${IMAGE_TAG} ${QUAY_PREFIX}${image}:${IMAGE_TAG}
docker push ${QUAY_PREFIX}${image}:${IMAGE_TAG}
if [[ "$image" == *"build"* ]]; then
continue
fi
docker push ${image}:${IMAGE_TAG}
docker tag ${image}:${IMAGE_TAG} ${QUAY_PREFIX}${image}:${IMAGE_TAG}
docker push ${QUAY_PREFIX}${image}:${IMAGE_TAG}
done
49 changes: 45 additions & 4 deletions tools/lint
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,11 @@

set -e

LINT_IGNORE_FILE=${LINT_IGNORE_FILE:-".lintignore"}

IGNORE_LINT_COMMENT=
IGNORE_SPELLINGS=
PARALLEL=
while true; do
case "$1" in
-nocomment)
Expand All @@ -33,6 +36,10 @@ while true; do
IGNORE_SPELLINGS="$2,$IGNORE_SPELLINGS"
shift 2
;;
-p)
PARALLEL=1
shift 1
;;
*)
break
;;
Expand Down Expand Up @@ -142,10 +149,11 @@ lint() {
return
fi

# Don't lint static.go
# Don't lint specific files
case "$(basename "${filename}")" in
static.go) return ;;
coverage.html) return ;;
*.pb.go) return ;;
esac

if [[ "$(file --mime-type "${filename}" | awk '{print $2}')" == "text/x-shellscript" ]]; then
Expand All @@ -171,12 +179,45 @@ lint_files() {
exit $lint_result
}

matches_any() {
local filename="$1"
local patterns="$2"
while read -r pattern; do
# shellcheck disable=SC2053
# Use the [[ operator without quotes on $pattern
# in order to "glob" the provided filename:
[[ "$filename" == $pattern ]] && return 0
done <<<"$patterns"
return 1
}

filter_out() {
local patterns_file="$1"
if [ -n "$patterns_file" ] && [ -r "$patterns_file" ]; then
local patterns=$(sed '/^#.*$/d ; /^\s*$/d' "$patterns_file") # Remove blank lines and comments before we start iterating.
[ -n "$DEBUG" ] && echo >&2 "> Filters:" && echo >&2 "$patterns"
local filtered_out=()
while read -r filename; do
matches_any "$filename" "$patterns" && filtered_out+=("$filename") || echo "$filename"
done
[ -n "$DEBUG" ] && echo >&2 "> Files filtered out (i.e. NOT linted):" && printf >&2 '%s\n' "${filtered_out[@]}"
else
cat # No patterns provided: simply propagate stdin to stdout.
fi
}

list_files() {
if [ $# -gt 0 ]; then
git ls-files --exclude-standard | grep -vE '(^|/)vendor/'
find "$@" | grep -vE '(^|/)vendor/'
else
git diff --cached --name-only
git ls-files --exclude-standard | grep -vE '(^|/)vendor/'
fi
}

list_files "$@" | lint_files
if [ $# = 1 ] && [ -f "$1" ]; then
lint "$1"
elif [ -n "$PARALLEL" ]; then
list_files "$@" | filter_out "$LINT_IGNORE_FILE" | xargs -n1 -P16 $0
else
list_files "$@" | filter_out "$LINT_IGNORE_FILE" | lint_files
fi
2 changes: 1 addition & 1 deletion tools/runner/runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import (
"time"

"github.com/mgutz/ansi"
"github.com/weaveworks/docker/pkg/mflag"
"github.com/weaveworks/common/mflag"
)

const (
Expand Down
4 changes: 2 additions & 2 deletions tools/socks/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import (
"text/template"

socks5 "github.com/armon/go-socks5"
"github.com/weaveworks/docker/pkg/mflag"
"github.com/weaveworks/weave/common/mflagext"
"github.com/weaveworks/common/mflag"
"github.com/weaveworks/common/mflagext"
"golang.org/x/net/context"
)

Expand Down
11 changes: 8 additions & 3 deletions tools/test
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@ SLOW=
NO_GO_GET=true
TAGS=
PARALLEL=
TIMEOUT=1m

usage() {
echo "$0 [-slow] [-in-container foo] [-netgo] [-(no-)go-get]"
echo "$0 [-slow] [-in-container foo] [-netgo] [-(no-)go-get] [-timeout 1m]"
}

while [ $# -gt 0 ]; do
Expand All @@ -34,14 +35,18 @@ while [ $# -gt 0 ]; do
PARALLEL=true
shift 1
;;
"-timeout")
TIMEOUT=$2
shift 2
;;
*)
usage
exit 2
;;
esac
done

GO_TEST_ARGS=($TAGS -cpu 4 -timeout 8m)
GO_TEST_ARGS=($TAGS -cpu 4 -timeout $TIMEOUT)

if [ -n "$SLOW" ] || [ -n "$CIRCLECI" ]; then
SLOW=true
Expand Down Expand Up @@ -87,7 +92,7 @@ go test -i "${GO_TEST_ARGS[@]}" "${TESTDIRS[@]}"
run_test() {
local dir=$1
if [ -z "$NO_GO_GET" ]; then
go get -t $TAGS "$dir"
go get -t "$TAGS" "$dir"
fi

local GO_TEST_ARGS_RUN=("${GO_TEST_ARGS[@]}")
Expand Down