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 <dnephin@docker.com>
This commit is contained in:
Daniel Nephin 2016-10-12 15:25:49 -04:00
parent b2641bd9df
commit 22033e1003
14 changed files with 49 additions and 29 deletions

View file

@ -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

View file

@ -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

View file

@ -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"

8
hack/validate/all Executable file
View file

@ -0,0 +1,8 @@
#!/bin/bash
#
# Run all validation
export SCRIPTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
. $SCRIPTDIR/default
. $SCRIPTDIR/vendor

3
hack/make/validate-dco → hack/validate/dco Normal file → Executable file
View file

@ -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 }')

14
hack/validate/default Executable file
View file

@ -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

View file

@ -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)"

3
hack/make/validate-gofmt → hack/validate/gofmt Normal file → Executable file
View file

@ -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) )

3
hack/make/validate-lint → hack/validate/lint Normal file → Executable file
View file

@ -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) )

5
hack/make/validate-pkg → hack/validate/pkg-imports Normal file → Executable file
View file

@ -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)'

6
hack/make/validate-test → hack/validate/test-imports Normal file → Executable file
View file

@ -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:"

3
hack/make/validate-toml → hack/validate/toml Normal file → Executable file
View file

@ -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) )

5
hack/make/validate-vendor → hack/validate/vendor Normal file → Executable file
View file

@ -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

3
hack/make/validate-vet → hack/validate/vet Normal file → Executable file
View file

@ -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) )