From 3881934fdc7e6ea644288432ce910e4ee73b2fa8 Mon Sep 17 00:00:00 2001 From: Jonathan Lange Date: Fri, 15 Jul 2016 11:36:18 +0100 Subject: [PATCH] Squashed 'tools/' changes from 0620e58..e9e7e6b e9e7e6b Merge pull request #26 from weaveworks/this-time-for-sure df494d6 Remove dependencies c045d16 Properly exclude vendor from lint 2cfcf08 Add blacklist to wcloud client ca6ebfb Merge pull request #25 from weaveworks/fix-brokenness bfb1747 Test directories need ./ prefixes, obviously. 5b9b314 Merge pull request #24 from weaveworks/find-files 8786427 Remove spurious debugging code from test 8b7ec6e Speed up test by using git ls-files cf53dc1 Exclude vendor from shell linting b2ab380 Fix field name c86fd3d Add notification config for wcloud f643920 Merge pull request #23 from weaveworks/only-lint-git-files 47a0152 Only lint git files 50d47f9 Merge pull request #22 from weaveworks/shell-lint git-subtree-dir: tools git-subtree-split: e9e7e6b0f042eb38bd2d45591f3f5c8364bdc7ce --- cmd/wcloud/types.go | 11 +++++++++++ files-with-type | 4 +--- lint | 2 +- test | 5 +++-- 4 files changed, 16 insertions(+), 6 deletions(-) diff --git a/cmd/wcloud/types.go b/cmd/wcloud/types.go index 16e6b2622..b02ee4c14 100644 --- a/cmd/wcloud/types.go +++ b/cmd/wcloud/types.go @@ -21,4 +21,15 @@ type Config struct { RepoPath string `json:"repo_path" yaml:"repo_path"` RepoKey string `json:"repo_key" yaml:"repo_key"` KubeconfigPath string `json:"kubeconfig_path" yaml:"kubeconfig_path"` + + Notifications []NotificationConfig `json:"notifications" yaml:"notifications"` + + // Globs of files not to change, relative to the route of the repo + ConfigFileBlackList []string `json:"config_file_black_list" yaml:"config_file_black_list"` +} + +// NotificationConfig describes how to send notifications +type NotificationConfig struct { + SlackWebhookURL string `json:"slack_webhook_url" yaml:"slack_webhook_url"` + SlackUsername string `json:"slack_username" yaml:"slack_username"` } diff --git a/files-with-type b/files-with-type index d969f4405..8238980c6 100755 --- a/files-with-type +++ b/files-with-type @@ -4,10 +4,8 @@ # # e.g. # $ files-with-type text/x-shellscript k8s infra -# -# Assumes `find`, `xargs`, and `file` are all installed. mime_type=$1 shift -find "$@" -print0 -type f |xargs -0 file --mime-type | grep "${mime_type}" | sed -e 's/:.*$//' +git ls-files "$@" | grep -vE '^vendor/' | xargs file --mime-type | grep "${mime_type}" | sed -e 's/:.*$//' diff --git a/lint b/lint index e807f8824..994d4c321 100755 --- a/lint +++ b/lint @@ -166,7 +166,7 @@ function lint_files { function list_files { if [ $# -gt 0 ]; then - find "$@" -type f | grep -vE '(^\./\.git|^\./\.pkg|/vendor/|/node_modules/|\.codecgen\.go$|\.generated\.go$)' + git ls-files --exclude-standard | grep -vE '(^|/)vendor/' else git diff --cached --name-only fi diff --git a/test b/test index 61791772b..f8d76c56b 100755 --- a/test +++ b/test @@ -1,6 +1,6 @@ #!/bin/bash -set -ex +set -e DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" GO_TEST_ARGS=( -tags netgo -cpu 4 -timeout 8m ) @@ -47,7 +47,8 @@ fi fail=0 -TESTDIRS=( $(find . -type f -name '*_test.go' -print0 | xargs -0 -n1 dirname | grep -vE '^\./(\.git|vendor|prog|experimental)/' | sort -u) ) +# NB: Relies on paths being prefixed with './'. +TESTDIRS=( $(git ls-files -- '*_test.go' | grep -vE '^(vendor|prog|experimental)/' | xargs -n1 dirname | sort -u | sed -e 's|^|./|') ) # If running on circle, use the scheduler to work out what tests to run on what shard if [ -n "$CIRCLECI" ] && [ -z "$NO_SCHEDULER" ] && [ -x "$DIR/sched" ]; then