From dd0403a2eb3687db99ac27322e44efff0382dd00 Mon Sep 17 00:00:00 2001 From: Daniel Nephin Date: Wed, 12 Oct 2016 15:25:49 -0400 Subject: [PATCH] Move validation out of hack/make Allow each script to run directly without the hack/make.sh wrapper. These scripts do not produce artifacts and do not benefit from the "bundles" framework. Signed-off-by: Daniel Nephin Upstream-commit: 22033e10034884734621f185b60ddaa119014480 Component: engine --- components/engine/Makefile | 4 ++-- components/engine/hack/make.sh | 9 --------- .../engine/hack/{make => validate}/.validate | 7 ++----- components/engine/hack/validate/all | 8 ++++++++ .../hack/{make/validate-dco => validate/dco} | 3 ++- components/engine/hack/validate/default | 14 ++++++++++++++ .../default-seccomp} | 5 +++-- .../hack/{make/validate-gofmt => validate/gofmt} | 3 ++- .../hack/{make/validate-lint => validate/lint} | 3 ++- .../{make/validate-pkg => validate/pkg-imports} | 5 +++-- .../{make/validate-test => validate/test-imports} | 6 +++--- .../hack/{make/validate-toml => validate/toml} | 3 ++- .../hack/{make/validate-vendor => validate/vendor} | 5 ++++- .../hack/{make/validate-vet => validate/vet} | 3 ++- 14 files changed, 49 insertions(+), 29 deletions(-) rename components/engine/hack/{make => validate}/.validate (82%) create mode 100755 components/engine/hack/validate/all rename components/engine/hack/{make/validate-dco => validate/dco} (94%) mode change 100644 => 100755 create mode 100755 components/engine/hack/validate/default rename components/engine/hack/{make/validate-default-seccomp => validate/default-seccomp} (78%) mode change 100644 => 100755 rename components/engine/hack/{make/validate-gofmt => validate/gofmt} (86%) mode change 100644 => 100755 rename components/engine/hack/{make/validate-lint => validate/lint} (85%) mode change 100644 => 100755 rename components/engine/hack/{make/validate-pkg => validate/pkg-imports} (77%) mode change 100644 => 100755 rename components/engine/hack/{make/validate-test => validate/test-imports} (85%) mode change 100644 => 100755 rename components/engine/hack/{make/validate-toml => validate/toml} (86%) mode change 100644 => 100755 rename components/engine/hack/{make/validate-vendor => validate/vendor} (82%) mode change 100644 => 100755 rename components/engine/hack/{make/validate-vet => validate/vet} (84%) mode change 100644 => 100755 diff --git a/components/engine/Makefile b/components/engine/Makefile index f35265311a..a3dc91bcae 100644 --- a/components/engine/Makefile +++ b/components/engine/Makefile @@ -75,7 +75,7 @@ DOCKER_RUN_DOCKER := $(DOCKER_FLAGS) "$(DOCKER_IMAGE)" default: binary all: build ## validate all checks, build linux binaries, run all tests\ncross build non-linux binaries and generate archives - $(DOCKER_RUN_DOCKER) hack/make.sh + $(DOCKER_RUN_DOCKER) bash -c 'hack/validate/default && hack/make.sh' binary: build ## build the linux binaries $(DOCKER_RUN_DOCKER) hack/make.sh binary @@ -133,7 +133,7 @@ tgz: build ## build the archives (.zip on windows and .tgz\notherwise) containin $(DOCKER_RUN_DOCKER) hack/make.sh dynbinary binary cross tgz validate: build ## validate DCO, Seccomp profile generation, gofmt,\n./pkg/ isolation, golint, tests, tomls, go vet and vendor - $(DOCKER_RUN_DOCKER) hack/make.sh validate-dco validate-default-seccomp validate-gofmt validate-pkg validate-lint validate-test validate-toml validate-vet validate-vendor + $(DOCKER_RUN_DOCKER) hack/validate/all win: build ## cross build the binary for windows $(DOCKER_RUN_DOCKER) hack/make.sh win diff --git a/components/engine/hack/make.sh b/components/engine/hack/make.sh index ee93b8ee3d..b88582de69 100755 --- a/components/engine/hack/make.sh +++ b/components/engine/hack/make.sh @@ -56,15 +56,6 @@ echo # List of bundles to create when no argument is passed DEFAULT_BUNDLES=( - validate-dco - validate-default-seccomp - validate-gofmt - validate-lint - validate-pkg - validate-test - validate-toml - validate-vet - binary-client binary-daemon dynbinary diff --git a/components/engine/hack/make/.validate b/components/engine/hack/validate/.validate similarity index 82% rename from components/engine/hack/make/.validate rename to components/engine/hack/validate/.validate index 7397d0fa11..defa981865 100644 --- a/components/engine/hack/make/.validate +++ b/components/engine/hack/validate/.validate @@ -1,5 +1,7 @@ #!/bin/bash +set -e -o pipefail + if [ -z "$VALIDATE_UPSTREAM" ]; then # this is kind of an expensive check, so let's not do this twice if we # are running more than one validate bundlescript @@ -7,11 +9,6 @@ if [ -z "$VALIDATE_UPSTREAM" ]; then VALIDATE_REPO='https://github.com/docker/docker.git' VALIDATE_BRANCH='master' - if [ "$TRAVIS" = 'true' -a "$TRAVIS_PULL_REQUEST" != 'false' ]; then - VALIDATE_REPO="https://github.com/${TRAVIS_REPO_SLUG}.git" - VALIDATE_BRANCH="${TRAVIS_BRANCH}" - fi - VALIDATE_HEAD="$(git rev-parse --verify HEAD)" git fetch -q "$VALIDATE_REPO" "refs/heads/$VALIDATE_BRANCH" diff --git a/components/engine/hack/validate/all b/components/engine/hack/validate/all new file mode 100755 index 0000000000..308af47263 --- /dev/null +++ b/components/engine/hack/validate/all @@ -0,0 +1,8 @@ +#!/bin/bash +# +# Run all validation + +export SCRIPTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" + +. $SCRIPTDIR/default +. $SCRIPTDIR/vendor diff --git a/components/engine/hack/make/validate-dco b/components/engine/hack/validate/dco old mode 100644 new mode 100755 similarity index 94% rename from components/engine/hack/make/validate-dco rename to components/engine/hack/validate/dco index 5ac98728f3..754ce8faec --- a/components/engine/hack/make/validate-dco +++ b/components/engine/hack/validate/dco @@ -1,6 +1,7 @@ #!/bin/bash -source "${MAKEDIR}/.validate" +export SCRIPTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" +source "${SCRIPTDIR}/.validate" adds=$(validate_diff --numstat | awk '{ s += $1 } END { print s }') dels=$(validate_diff --numstat | awk '{ s += $2 } END { print s }') diff --git a/components/engine/hack/validate/default b/components/engine/hack/validate/default new file mode 100755 index 0000000000..3ae5f5c03b --- /dev/null +++ b/components/engine/hack/validate/default @@ -0,0 +1,14 @@ +#!/bin/bash +# +# Run default validation, exclude vendor because it's slow + +export SCRIPTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" + +. $SCRIPTDIR/dco +. $SCRIPTDIR/default-seccomp +. $SCRIPTDIR/gofmt +. $SCRIPTDIR/lint +. $SCRIPTDIR/pkg-imports +. $SCRIPTDIR/test-imports +. $SCRIPTDIR/toml +. $SCRIPTDIR/vet diff --git a/components/engine/hack/make/validate-default-seccomp b/components/engine/hack/validate/default-seccomp old mode 100644 new mode 100755 similarity index 78% rename from components/engine/hack/make/validate-default-seccomp rename to components/engine/hack/validate/default-seccomp index 4facec743d..8fe8435618 --- a/components/engine/hack/make/validate-default-seccomp +++ b/components/engine/hack/validate/default-seccomp @@ -1,13 +1,14 @@ #!/bin/bash -source "${MAKEDIR}/.validate" +export SCRIPTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" +source "${SCRIPTDIR}/.validate" IFS=$'\n' files=( $(validate_diff --diff-filter=ACMR --name-only -- 'profiles/seccomp' || true) ) unset IFS if [ ${#files[@]} -gt 0 ]; then - # We run vendor.sh to and see if we have a diff afterwards + # We run 'go generate' and see if we have a diff afterwards go generate ./profiles/seccomp/ >/dev/null # Let see if the working directory is clean diffs="$(git status --porcelain -- profiles/seccomp 2>/dev/null)" diff --git a/components/engine/hack/make/validate-gofmt b/components/engine/hack/validate/gofmt old mode 100644 new mode 100755 similarity index 86% rename from components/engine/hack/make/validate-gofmt rename to components/engine/hack/validate/gofmt index 7ad9e85576..f3c6a848de --- a/components/engine/hack/make/validate-gofmt +++ b/components/engine/hack/validate/gofmt @@ -1,6 +1,7 @@ #!/bin/bash -source "${MAKEDIR}/.validate" +export SCRIPTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" +source "${SCRIPTDIR}/.validate" IFS=$'\n' files=( $(validate_diff --diff-filter=ACMR --name-only -- '*.go' | grep -v '^vendor/' || true) ) diff --git a/components/engine/hack/make/validate-lint b/components/engine/hack/validate/lint old mode 100644 new mode 100755 similarity index 85% rename from components/engine/hack/make/validate-lint rename to components/engine/hack/validate/lint index 09b6599f52..41517e2127 --- a/components/engine/hack/make/validate-lint +++ b/components/engine/hack/validate/lint @@ -1,6 +1,7 @@ #!/bin/bash -source "${MAKEDIR}/.validate" +export SCRIPTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" +source "${SCRIPTDIR}/.validate" IFS=$'\n' files=( $(validate_diff --diff-filter=ACMR --name-only -- '*.go' | grep -v '^vendor/' | grep -v '^api/types/' || true) ) diff --git a/components/engine/hack/make/validate-pkg b/components/engine/hack/validate/pkg-imports old mode 100644 new mode 100755 similarity index 77% rename from components/engine/hack/make/validate-pkg rename to components/engine/hack/validate/pkg-imports index d5843417e0..1da3403b86 --- a/components/engine/hack/make/validate-pkg +++ b/components/engine/hack/validate/pkg-imports @@ -1,7 +1,8 @@ #!/bin/bash set -e -source "${MAKEDIR}/.validate" +export SCRIPTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" +source "${SCRIPTDIR}/.validate" IFS=$'\n' files=( $(validate_diff --diff-filter=ACMR --name-only -- 'pkg/*.go' || true) ) @@ -19,7 +20,7 @@ for f in "${files[@]}"; do done if [ ${#badFiles[@]} -eq 0 ]; then - echo 'Congratulations! "./pkg/..." is safely isolated from internal code.' + echo 'Congratulations! "./pkg/..." is safely isolated from internal code.' else { echo 'These files import internal code: (either directly or indirectly)' diff --git a/components/engine/hack/make/validate-test b/components/engine/hack/validate/test-imports old mode 100644 new mode 100755 similarity index 85% rename from components/engine/hack/make/validate-test rename to components/engine/hack/validate/test-imports index 84c5e26ba9..373caa2f29 --- a/components/engine/hack/make/validate-test +++ b/components/engine/hack/validate/test-imports @@ -1,8 +1,8 @@ #!/bin/bash - # Make sure we're not using gos' Testing package any more in integration-cli -source "${MAKEDIR}/.validate" +export SCRIPTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" +source "${SCRIPTDIR}/.validate" IFS=$'\n' files=( $(validate_diff --diff-filter=ACMR --name-only -- 'integration-cli/*.go' || true) ) @@ -25,7 +25,7 @@ for f in "${files[@]}"; do done if [ ${#badFiles[@]} -eq 0 ]; then - echo 'Congratulations! No testing.T found.' + echo 'Congratulations! No testing.T found.' else { echo "These files use the wrong testing infrastructure:" diff --git a/components/engine/hack/make/validate-toml b/components/engine/hack/validate/toml old mode 100644 new mode 100755 similarity index 86% rename from components/engine/hack/make/validate-toml rename to components/engine/hack/validate/toml index f6393c854d..a0cb158dbd --- a/components/engine/hack/make/validate-toml +++ b/components/engine/hack/validate/toml @@ -1,6 +1,7 @@ #!/bin/bash -source "${MAKEDIR}/.validate" +export SCRIPTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" +source "${SCRIPTDIR}/.validate" IFS=$'\n' files=( $(validate_diff --diff-filter=ACMR --name-only -- 'MAINTAINERS' || true) ) diff --git a/components/engine/hack/make/validate-vendor b/components/engine/hack/validate/vendor old mode 100644 new mode 100755 similarity index 82% rename from components/engine/hack/make/validate-vendor rename to components/engine/hack/validate/vendor index 7c2cf33c66..076a8e07a1 --- a/components/engine/hack/make/validate-vendor +++ b/components/engine/hack/validate/vendor @@ -1,6 +1,7 @@ #!/bin/bash -source "${MAKEDIR}/.validate" +export SCRIPTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" +source "${SCRIPTDIR}/.validate" IFS=$'\n' files=( $(validate_diff --diff-filter=ACMR --name-only -- 'hack/vendor.sh' 'hack/.vendor-helpers.sh' 'vendor/' || true) ) @@ -24,4 +25,6 @@ if [ ${#files[@]} -gt 0 ]; then else echo 'Congratulations! All vendoring changes are done the right way.' fi +else + echo 'No vendor changes in diff.' fi diff --git a/components/engine/hack/make/validate-vet b/components/engine/hack/validate/vet old mode 100644 new mode 100755 similarity index 84% rename from components/engine/hack/make/validate-vet rename to components/engine/hack/validate/vet index d543509a53..7ab25fee86 --- a/components/engine/hack/make/validate-vet +++ b/components/engine/hack/validate/vet @@ -1,6 +1,7 @@ #!/bin/bash -source "${MAKEDIR}/.validate" +export SCRIPTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" +source "${SCRIPTDIR}/.validate" IFS=$'\n' files=( $(validate_diff --diff-filter=ACMR --name-only -- '*.go' | grep -v '^vendor/' || true) )