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>
| ... | ... |
@@ -75,7 +75,7 @@ DOCKER_RUN_DOCKER := $(DOCKER_FLAGS) "$(DOCKER_IMAGE)" |
| 75 | 75 |
default: binary |
| 76 | 76 |
|
| 77 | 77 |
all: build ## validate all checks, build linux binaries, run all tests\ncross build non-linux binaries and generate archives |
| 78 |
- $(DOCKER_RUN_DOCKER) hack/make.sh |
|
| 78 |
+ $(DOCKER_RUN_DOCKER) bash -c 'hack/validate/default && hack/make.sh' |
|
| 79 | 79 |
|
| 80 | 80 |
binary: build ## build the linux binaries |
| 81 | 81 |
$(DOCKER_RUN_DOCKER) hack/make.sh binary |
| ... | ... |
@@ -133,7 +133,7 @@ tgz: build ## build the archives (.zip on windows and .tgz\notherwise) containin |
| 133 | 133 |
$(DOCKER_RUN_DOCKER) hack/make.sh dynbinary binary cross tgz |
| 134 | 134 |
|
| 135 | 135 |
validate: build ## validate DCO, Seccomp profile generation, gofmt,\n./pkg/ isolation, golint, tests, tomls, go vet and vendor |
| 136 |
- $(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 |
|
| 136 |
+ $(DOCKER_RUN_DOCKER) hack/validate/all |
|
| 137 | 137 |
|
| 138 | 138 |
win: build ## cross build the binary for windows |
| 139 | 139 |
$(DOCKER_RUN_DOCKER) hack/make.sh win |
| ... | ... |
@@ -56,15 +56,6 @@ echo |
| 56 | 56 |
|
| 57 | 57 |
# List of bundles to create when no argument is passed |
| 58 | 58 |
DEFAULT_BUNDLES=( |
| 59 |
- validate-dco |
|
| 60 |
- validate-default-seccomp |
|
| 61 |
- validate-gofmt |
|
| 62 |
- validate-lint |
|
| 63 |
- validate-pkg |
|
| 64 |
- validate-test |
|
| 65 |
- validate-toml |
|
| 66 |
- validate-vet |
|
| 67 |
- |
|
| 68 | 59 |
binary-client |
| 69 | 60 |
binary-daemon |
| 70 | 61 |
dynbinary |
| 71 | 62 |
deleted file mode 100644 |
| ... | ... |
@@ -1,33 +0,0 @@ |
| 1 |
-#!/bin/bash |
|
| 2 |
- |
|
| 3 |
-if [ -z "$VALIDATE_UPSTREAM" ]; then |
|
| 4 |
- # this is kind of an expensive check, so let's not do this twice if we |
|
| 5 |
- # are running more than one validate bundlescript |
|
| 6 |
- |
|
| 7 |
- VALIDATE_REPO='https://github.com/docker/docker.git' |
|
| 8 |
- VALIDATE_BRANCH='master' |
|
| 9 |
- |
|
| 10 |
- if [ "$TRAVIS" = 'true' -a "$TRAVIS_PULL_REQUEST" != 'false' ]; then |
|
| 11 |
- VALIDATE_REPO="https://github.com/${TRAVIS_REPO_SLUG}.git"
|
|
| 12 |
- VALIDATE_BRANCH="${TRAVIS_BRANCH}"
|
|
| 13 |
- fi |
|
| 14 |
- |
|
| 15 |
- VALIDATE_HEAD="$(git rev-parse --verify HEAD)" |
|
| 16 |
- |
|
| 17 |
- git fetch -q "$VALIDATE_REPO" "refs/heads/$VALIDATE_BRANCH" |
|
| 18 |
- VALIDATE_UPSTREAM="$(git rev-parse --verify FETCH_HEAD)" |
|
| 19 |
- |
|
| 20 |
- VALIDATE_COMMIT_LOG="$VALIDATE_UPSTREAM..$VALIDATE_HEAD" |
|
| 21 |
- VALIDATE_COMMIT_DIFF="$VALIDATE_UPSTREAM...$VALIDATE_HEAD" |
|
| 22 |
- |
|
| 23 |
- validate_diff() {
|
|
| 24 |
- if [ "$VALIDATE_UPSTREAM" != "$VALIDATE_HEAD" ]; then |
|
| 25 |
- git diff "$VALIDATE_COMMIT_DIFF" "$@" |
|
| 26 |
- fi |
|
| 27 |
- } |
|
| 28 |
- validate_log() {
|
|
| 29 |
- if [ "$VALIDATE_UPSTREAM" != "$VALIDATE_HEAD" ]; then |
|
| 30 |
- git log "$VALIDATE_COMMIT_LOG" "$@" |
|
| 31 |
- fi |
|
| 32 |
- } |
|
| 33 |
-fi |
| 34 | 1 |
deleted file mode 100644 |
| ... | ... |
@@ -1,54 +0,0 @@ |
| 1 |
-#!/bin/bash |
|
| 2 |
- |
|
| 3 |
-source "${MAKEDIR}/.validate"
|
|
| 4 |
- |
|
| 5 |
-adds=$(validate_diff --numstat | awk '{ s += $1 } END { print s }')
|
|
| 6 |
-dels=$(validate_diff --numstat | awk '{ s += $2 } END { print s }')
|
|
| 7 |
-#notDocs="$(validate_diff --numstat | awk '$3 !~ /^docs\// { print $3 }')"
|
|
| 8 |
- |
|
| 9 |
-: ${adds:=0}
|
|
| 10 |
-: ${dels:=0}
|
|
| 11 |
- |
|
| 12 |
-# "Username may only contain alphanumeric characters or dashes and cannot begin with a dash" |
|
| 13 |
-githubUsernameRegex='[a-zA-Z0-9][a-zA-Z0-9-]+' |
|
| 14 |
- |
|
| 15 |
-# https://github.com/docker/docker/blob/master/CONTRIBUTING.md#sign-your-work |
|
| 16 |
-dcoPrefix='Signed-off-by:' |
|
| 17 |
-dcoRegex="^(Docker-DCO-1.1-)?$dcoPrefix ([^<]+) <([^<>@]+@[^<>]+)>( \\(github: ($githubUsernameRegex)\\))?$" |
|
| 18 |
- |
|
| 19 |
-check_dco() {
|
|
| 20 |
- grep -qE "$dcoRegex" |
|
| 21 |
-} |
|
| 22 |
- |
|
| 23 |
-if [ $adds -eq 0 -a $dels -eq 0 ]; then |
|
| 24 |
- echo '0 adds, 0 deletions; nothing to validate! :)' |
|
| 25 |
-else |
|
| 26 |
- commits=( $(validate_log --format='format:%H%n') ) |
|
| 27 |
- badCommits=() |
|
| 28 |
- for commit in "${commits[@]}"; do
|
|
| 29 |
- if [ -z "$(git log -1 --format='format:' --name-status "$commit")" ]; then |
|
| 30 |
- # no content (ie, Merge commit, etc) |
|
| 31 |
- continue |
|
| 32 |
- fi |
|
| 33 |
- if ! git log -1 --format='format:%B' "$commit" | check_dco; then |
|
| 34 |
- badCommits+=( "$commit" ) |
|
| 35 |
- fi |
|
| 36 |
- done |
|
| 37 |
- if [ ${#badCommits[@]} -eq 0 ]; then
|
|
| 38 |
- echo "Congratulations! All commits are properly signed with the DCO!" |
|
| 39 |
- else |
|
| 40 |
- {
|
|
| 41 |
- echo "These commits do not have a proper '$dcoPrefix' marker:" |
|
| 42 |
- for commit in "${badCommits[@]}"; do
|
|
| 43 |
- echo " - $commit" |
|
| 44 |
- done |
|
| 45 |
- echo |
|
| 46 |
- echo 'Please amend each commit to include a properly formatted DCO marker.' |
|
| 47 |
- echo |
|
| 48 |
- echo 'Visit the following URL for information about the Docker DCO:' |
|
| 49 |
- echo ' https://github.com/docker/docker/blob/master/CONTRIBUTING.md#sign-your-work' |
|
| 50 |
- echo |
|
| 51 |
- } >&2 |
|
| 52 |
- false |
|
| 53 |
- fi |
|
| 54 |
-fi |
| 55 | 1 |
deleted file mode 100644 |
| ... | ... |
@@ -1,27 +0,0 @@ |
| 1 |
-#!/bin/bash |
|
| 2 |
- |
|
| 3 |
-source "${MAKEDIR}/.validate"
|
|
| 4 |
- |
|
| 5 |
-IFS=$'\n' |
|
| 6 |
-files=( $(validate_diff --diff-filter=ACMR --name-only -- 'profiles/seccomp' || true) ) |
|
| 7 |
-unset IFS |
|
| 8 |
- |
|
| 9 |
-if [ ${#files[@]} -gt 0 ]; then
|
|
| 10 |
- # We run vendor.sh to and see if we have a diff afterwards |
|
| 11 |
- go generate ./profiles/seccomp/ >/dev/null |
|
| 12 |
- # Let see if the working directory is clean |
|
| 13 |
- diffs="$(git status --porcelain -- profiles/seccomp 2>/dev/null)" |
|
| 14 |
- if [ "$diffs" ]; then |
|
| 15 |
- {
|
|
| 16 |
- echo 'The result of go generate ./profiles/seccomp/ differs' |
|
| 17 |
- echo |
|
| 18 |
- echo "$diffs" |
|
| 19 |
- echo |
|
| 20 |
- echo 'Please re-run go generate ./profiles/seccomp/' |
|
| 21 |
- echo |
|
| 22 |
- } >&2 |
|
| 23 |
- false |
|
| 24 |
- else |
|
| 25 |
- echo 'Congratulations! Seccomp profile generation is done correctly.' |
|
| 26 |
- fi |
|
| 27 |
-fi |
| 28 | 1 |
deleted file mode 100644 |
| ... | ... |
@@ -1,30 +0,0 @@ |
| 1 |
-#!/bin/bash |
|
| 2 |
- |
|
| 3 |
-source "${MAKEDIR}/.validate"
|
|
| 4 |
- |
|
| 5 |
-IFS=$'\n' |
|
| 6 |
-files=( $(validate_diff --diff-filter=ACMR --name-only -- '*.go' | grep -v '^vendor/' || true) ) |
|
| 7 |
-unset IFS |
|
| 8 |
- |
|
| 9 |
-badFiles=() |
|
| 10 |
-for f in "${files[@]}"; do
|
|
| 11 |
- # we use "git show" here to validate that what's committed is formatted |
|
| 12 |
- if [ "$(git show "$VALIDATE_HEAD:$f" | gofmt -s -l)" ]; then |
|
| 13 |
- badFiles+=( "$f" ) |
|
| 14 |
- fi |
|
| 15 |
-done |
|
| 16 |
- |
|
| 17 |
-if [ ${#badFiles[@]} -eq 0 ]; then
|
|
| 18 |
- echo 'Congratulations! All Go source files are properly formatted.' |
|
| 19 |
-else |
|
| 20 |
- {
|
|
| 21 |
- echo "These files are not properly gofmt'd:" |
|
| 22 |
- for f in "${badFiles[@]}"; do
|
|
| 23 |
- echo " - $f" |
|
| 24 |
- done |
|
| 25 |
- echo |
|
| 26 |
- echo 'Please reformat the above files using "gofmt -s -w" and commit the result.' |
|
| 27 |
- echo |
|
| 28 |
- } >&2 |
|
| 29 |
- false |
|
| 30 |
-fi |
| 31 | 1 |
deleted file mode 100644 |
| ... | ... |
@@ -1,30 +0,0 @@ |
| 1 |
-#!/bin/bash |
|
| 2 |
- |
|
| 3 |
-source "${MAKEDIR}/.validate"
|
|
| 4 |
- |
|
| 5 |
-IFS=$'\n' |
|
| 6 |
-files=( $(validate_diff --diff-filter=ACMR --name-only -- '*.go' | grep -v '^vendor/' | grep -v '^api/types/' || true) ) |
|
| 7 |
-unset IFS |
|
| 8 |
- |
|
| 9 |
-errors=() |
|
| 10 |
-for f in "${files[@]}"; do
|
|
| 11 |
- failedLint=$(golint "$f") |
|
| 12 |
- if [ "$failedLint" ]; then |
|
| 13 |
- errors+=( "$failedLint" ) |
|
| 14 |
- fi |
|
| 15 |
-done |
|
| 16 |
- |
|
| 17 |
-if [ ${#errors[@]} -eq 0 ]; then
|
|
| 18 |
- echo 'Congratulations! All Go source files have been linted.' |
|
| 19 |
-else |
|
| 20 |
- {
|
|
| 21 |
- echo "Errors from golint:" |
|
| 22 |
- for err in "${errors[@]}"; do
|
|
| 23 |
- echo "$err" |
|
| 24 |
- done |
|
| 25 |
- echo |
|
| 26 |
- echo 'Please fix the above errors. You can test via "golint" and commit the result.' |
|
| 27 |
- echo |
|
| 28 |
- } >&2 |
|
| 29 |
- false |
|
| 30 |
-fi |
| 31 | 1 |
deleted file mode 100644 |
| ... | ... |
@@ -1,32 +0,0 @@ |
| 1 |
-#!/bin/bash |
|
| 2 |
-set -e |
|
| 3 |
- |
|
| 4 |
-source "${MAKEDIR}/.validate"
|
|
| 5 |
- |
|
| 6 |
-IFS=$'\n' |
|
| 7 |
-files=( $(validate_diff --diff-filter=ACMR --name-only -- 'pkg/*.go' || true) ) |
|
| 8 |
-unset IFS |
|
| 9 |
- |
|
| 10 |
-badFiles=() |
|
| 11 |
-for f in "${files[@]}"; do
|
|
| 12 |
- IFS=$'\n' |
|
| 13 |
- badImports=( $(go list -e -f '{{ join .Deps "\n" }}' "$f" | sort -u | grep -vE '^github.com/docker/docker/pkg/' | grep -E '^github.com/docker/docker' || true) )
|
|
| 14 |
- unset IFS |
|
| 15 |
- |
|
| 16 |
- for import in "${badImports[@]}"; do
|
|
| 17 |
- badFiles+=( "$f imports $import" ) |
|
| 18 |
- done |
|
| 19 |
-done |
|
| 20 |
- |
|
| 21 |
-if [ ${#badFiles[@]} -eq 0 ]; then
|
|
| 22 |
- echo 'Congratulations! "./pkg/..." is safely isolated from internal code.' |
|
| 23 |
-else |
|
| 24 |
- {
|
|
| 25 |
- echo 'These files import internal code: (either directly or indirectly)' |
|
| 26 |
- for f in "${badFiles[@]}"; do
|
|
| 27 |
- echo " - $f" |
|
| 28 |
- done |
|
| 29 |
- echo |
|
| 30 |
- } >&2 |
|
| 31 |
- false |
|
| 32 |
-fi |
| 33 | 1 |
deleted file mode 100644 |
| ... | ... |
@@ -1,38 +0,0 @@ |
| 1 |
-#!/bin/bash |
|
| 2 |
- |
|
| 3 |
-# Make sure we're not using gos' Testing package any more in integration-cli |
|
| 4 |
- |
|
| 5 |
-source "${MAKEDIR}/.validate"
|
|
| 6 |
- |
|
| 7 |
-IFS=$'\n' |
|
| 8 |
-files=( $(validate_diff --diff-filter=ACMR --name-only -- 'integration-cli/*.go' || true) ) |
|
| 9 |
-unset IFS |
|
| 10 |
- |
|
| 11 |
-badFiles=() |
|
| 12 |
-for f in "${files[@]}"; do
|
|
| 13 |
- # skip check_test.go since it *does* use the testing package |
|
| 14 |
- if [ "$f" = "integration-cli/check_test.go" ]; then |
|
| 15 |
- continue |
|
| 16 |
- fi |
|
| 17 |
- |
|
| 18 |
- # we use "git show" here to validate that what's committed doesn't contain golang built-in testing |
|
| 19 |
- if git show "$VALIDATE_HEAD:$f" | grep -q testing.T; then |
|
| 20 |
- if [ "$(echo $f | grep '_test')" ]; then |
|
| 21 |
- # allow testing.T for non- _test files |
|
| 22 |
- badFiles+=( "$f" ) |
|
| 23 |
- fi |
|
| 24 |
- fi |
|
| 25 |
-done |
|
| 26 |
- |
|
| 27 |
-if [ ${#badFiles[@]} -eq 0 ]; then
|
|
| 28 |
- echo 'Congratulations! No testing.T found.' |
|
| 29 |
-else |
|
| 30 |
- {
|
|
| 31 |
- echo "These files use the wrong testing infrastructure:" |
|
| 32 |
- for f in "${badFiles[@]}"; do
|
|
| 33 |
- echo " - $f" |
|
| 34 |
- done |
|
| 35 |
- echo |
|
| 36 |
- } >&2 |
|
| 37 |
- false |
|
| 38 |
-fi |
| 39 | 1 |
deleted file mode 100644 |
| ... | ... |
@@ -1,30 +0,0 @@ |
| 1 |
-#!/bin/bash |
|
| 2 |
- |
|
| 3 |
-source "${MAKEDIR}/.validate"
|
|
| 4 |
- |
|
| 5 |
-IFS=$'\n' |
|
| 6 |
-files=( $(validate_diff --diff-filter=ACMR --name-only -- 'MAINTAINERS' || true) ) |
|
| 7 |
-unset IFS |
|
| 8 |
- |
|
| 9 |
-badFiles=() |
|
| 10 |
-for f in "${files[@]}"; do
|
|
| 11 |
- # we use "git show" here to validate that what's committed has valid toml syntax |
|
| 12 |
- if ! git show "$VALIDATE_HEAD:$f" | tomlv /proc/self/fd/0 ; then |
|
| 13 |
- badFiles+=( "$f" ) |
|
| 14 |
- fi |
|
| 15 |
-done |
|
| 16 |
- |
|
| 17 |
-if [ ${#badFiles[@]} -eq 0 ]; then
|
|
| 18 |
- echo 'Congratulations! All toml source files changed here have valid syntax.' |
|
| 19 |
-else |
|
| 20 |
- {
|
|
| 21 |
- echo "These files are not valid toml:" |
|
| 22 |
- for f in "${badFiles[@]}"; do
|
|
| 23 |
- echo " - $f" |
|
| 24 |
- done |
|
| 25 |
- echo |
|
| 26 |
- echo 'Please reformat the above files as valid toml' |
|
| 27 |
- echo |
|
| 28 |
- } >&2 |
|
| 29 |
- false |
|
| 30 |
-fi |
| 31 | 1 |
deleted file mode 100644 |
| ... | ... |
@@ -1,27 +0,0 @@ |
| 1 |
-#!/bin/bash |
|
| 2 |
- |
|
| 3 |
-source "${MAKEDIR}/.validate"
|
|
| 4 |
- |
|
| 5 |
-IFS=$'\n' |
|
| 6 |
-files=( $(validate_diff --diff-filter=ACMR --name-only -- 'hack/vendor.sh' 'hack/.vendor-helpers.sh' 'vendor/' || true) ) |
|
| 7 |
-unset IFS |
|
| 8 |
- |
|
| 9 |
-if [ ${#files[@]} -gt 0 ]; then
|
|
| 10 |
- # We run vendor.sh to and see if we have a diff afterwards |
|
| 11 |
- ./hack/vendor.sh >/dev/null |
|
| 12 |
- # Let see if the working directory is clean |
|
| 13 |
- diffs="$(git status --porcelain -- vendor 2>/dev/null)" |
|
| 14 |
- if [ "$diffs" ]; then |
|
| 15 |
- {
|
|
| 16 |
- echo 'The result of ./hack/vendor.sh differs' |
|
| 17 |
- echo |
|
| 18 |
- echo "$diffs" |
|
| 19 |
- echo |
|
| 20 |
- echo 'Please vendor your package with ./hack/vendor.sh.' |
|
| 21 |
- echo |
|
| 22 |
- } >&2 |
|
| 23 |
- false |
|
| 24 |
- else |
|
| 25 |
- echo 'Congratulations! All vendoring changes are done the right way.' |
|
| 26 |
- fi |
|
| 27 |
-fi |
| 28 | 1 |
deleted file mode 100644 |
| ... | ... |
@@ -1,31 +0,0 @@ |
| 1 |
-#!/bin/bash |
|
| 2 |
- |
|
| 3 |
-source "${MAKEDIR}/.validate"
|
|
| 4 |
- |
|
| 5 |
-IFS=$'\n' |
|
| 6 |
-files=( $(validate_diff --diff-filter=ACMR --name-only -- '*.go' | grep -v '^vendor/' || true) ) |
|
| 7 |
-unset IFS |
|
| 8 |
- |
|
| 9 |
-errors=() |
|
| 10 |
-for f in "${files[@]}"; do
|
|
| 11 |
- failedVet=$(go vet "$f") |
|
| 12 |
- if [ "$failedVet" ]; then |
|
| 13 |
- errors+=( "$failedVet" ) |
|
| 14 |
- fi |
|
| 15 |
-done |
|
| 16 |
- |
|
| 17 |
- |
|
| 18 |
-if [ ${#errors[@]} -eq 0 ]; then
|
|
| 19 |
- echo 'Congratulations! All Go source files have been vetted.' |
|
| 20 |
-else |
|
| 21 |
- {
|
|
| 22 |
- echo "Errors from go vet:" |
|
| 23 |
- for err in "${errors[@]}"; do
|
|
| 24 |
- echo " - $err" |
|
| 25 |
- done |
|
| 26 |
- echo |
|
| 27 |
- echo 'Please fix the above errors. You can test via "go vet" and commit the result.' |
|
| 28 |
- echo |
|
| 29 |
- } >&2 |
|
| 30 |
- false |
|
| 31 |
-fi |
| 32 | 1 |
new file mode 100644 |
| ... | ... |
@@ -0,0 +1,30 @@ |
| 0 |
+#!/bin/bash |
|
| 1 |
+ |
|
| 2 |
+set -e -o pipefail |
|
| 3 |
+ |
|
| 4 |
+if [ -z "$VALIDATE_UPSTREAM" ]; then |
|
| 5 |
+ # this is kind of an expensive check, so let's not do this twice if we |
|
| 6 |
+ # are running more than one validate bundlescript |
|
| 7 |
+ |
|
| 8 |
+ VALIDATE_REPO='https://github.com/docker/docker.git' |
|
| 9 |
+ VALIDATE_BRANCH='master' |
|
| 10 |
+ |
|
| 11 |
+ VALIDATE_HEAD="$(git rev-parse --verify HEAD)" |
|
| 12 |
+ |
|
| 13 |
+ git fetch -q "$VALIDATE_REPO" "refs/heads/$VALIDATE_BRANCH" |
|
| 14 |
+ VALIDATE_UPSTREAM="$(git rev-parse --verify FETCH_HEAD)" |
|
| 15 |
+ |
|
| 16 |
+ VALIDATE_COMMIT_LOG="$VALIDATE_UPSTREAM..$VALIDATE_HEAD" |
|
| 17 |
+ VALIDATE_COMMIT_DIFF="$VALIDATE_UPSTREAM...$VALIDATE_HEAD" |
|
| 18 |
+ |
|
| 19 |
+ validate_diff() {
|
|
| 20 |
+ if [ "$VALIDATE_UPSTREAM" != "$VALIDATE_HEAD" ]; then |
|
| 21 |
+ git diff "$VALIDATE_COMMIT_DIFF" "$@" |
|
| 22 |
+ fi |
|
| 23 |
+ } |
|
| 24 |
+ validate_log() {
|
|
| 25 |
+ if [ "$VALIDATE_UPSTREAM" != "$VALIDATE_HEAD" ]; then |
|
| 26 |
+ git log "$VALIDATE_COMMIT_LOG" "$@" |
|
| 27 |
+ fi |
|
| 28 |
+ } |
|
| 29 |
+fi |
| 0 | 8 |
new file mode 100755 |
| ... | ... |
@@ -0,0 +1,55 @@ |
| 0 |
+#!/bin/bash |
|
| 1 |
+ |
|
| 2 |
+export SCRIPTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
|
| 3 |
+source "${SCRIPTDIR}/.validate"
|
|
| 4 |
+ |
|
| 5 |
+adds=$(validate_diff --numstat | awk '{ s += $1 } END { print s }')
|
|
| 6 |
+dels=$(validate_diff --numstat | awk '{ s += $2 } END { print s }')
|
|
| 7 |
+#notDocs="$(validate_diff --numstat | awk '$3 !~ /^docs\// { print $3 }')"
|
|
| 8 |
+ |
|
| 9 |
+: ${adds:=0}
|
|
| 10 |
+: ${dels:=0}
|
|
| 11 |
+ |
|
| 12 |
+# "Username may only contain alphanumeric characters or dashes and cannot begin with a dash" |
|
| 13 |
+githubUsernameRegex='[a-zA-Z0-9][a-zA-Z0-9-]+' |
|
| 14 |
+ |
|
| 15 |
+# https://github.com/docker/docker/blob/master/CONTRIBUTING.md#sign-your-work |
|
| 16 |
+dcoPrefix='Signed-off-by:' |
|
| 17 |
+dcoRegex="^(Docker-DCO-1.1-)?$dcoPrefix ([^<]+) <([^<>@]+@[^<>]+)>( \\(github: ($githubUsernameRegex)\\))?$" |
|
| 18 |
+ |
|
| 19 |
+check_dco() {
|
|
| 20 |
+ grep -qE "$dcoRegex" |
|
| 21 |
+} |
|
| 22 |
+ |
|
| 23 |
+if [ $adds -eq 0 -a $dels -eq 0 ]; then |
|
| 24 |
+ echo '0 adds, 0 deletions; nothing to validate! :)' |
|
| 25 |
+else |
|
| 26 |
+ commits=( $(validate_log --format='format:%H%n') ) |
|
| 27 |
+ badCommits=() |
|
| 28 |
+ for commit in "${commits[@]}"; do
|
|
| 29 |
+ if [ -z "$(git log -1 --format='format:' --name-status "$commit")" ]; then |
|
| 30 |
+ # no content (ie, Merge commit, etc) |
|
| 31 |
+ continue |
|
| 32 |
+ fi |
|
| 33 |
+ if ! git log -1 --format='format:%B' "$commit" | check_dco; then |
|
| 34 |
+ badCommits+=( "$commit" ) |
|
| 35 |
+ fi |
|
| 36 |
+ done |
|
| 37 |
+ if [ ${#badCommits[@]} -eq 0 ]; then
|
|
| 38 |
+ echo "Congratulations! All commits are properly signed with the DCO!" |
|
| 39 |
+ else |
|
| 40 |
+ {
|
|
| 41 |
+ echo "These commits do not have a proper '$dcoPrefix' marker:" |
|
| 42 |
+ for commit in "${badCommits[@]}"; do
|
|
| 43 |
+ echo " - $commit" |
|
| 44 |
+ done |
|
| 45 |
+ echo |
|
| 46 |
+ echo 'Please amend each commit to include a properly formatted DCO marker.' |
|
| 47 |
+ echo |
|
| 48 |
+ echo 'Visit the following URL for information about the Docker DCO:' |
|
| 49 |
+ echo ' https://github.com/docker/docker/blob/master/CONTRIBUTING.md#sign-your-work' |
|
| 50 |
+ echo |
|
| 51 |
+ } >&2 |
|
| 52 |
+ false |
|
| 53 |
+ fi |
|
| 54 |
+fi |
| 0 | 55 |
new file mode 100755 |
| ... | ... |
@@ -0,0 +1,14 @@ |
| 0 |
+#!/bin/bash |
|
| 1 |
+# |
|
| 2 |
+# Run default validation, exclude vendor because it's slow |
|
| 3 |
+ |
|
| 4 |
+export SCRIPTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
|
| 5 |
+ |
|
| 6 |
+. $SCRIPTDIR/dco |
|
| 7 |
+. $SCRIPTDIR/default-seccomp |
|
| 8 |
+. $SCRIPTDIR/gofmt |
|
| 9 |
+. $SCRIPTDIR/lint |
|
| 10 |
+. $SCRIPTDIR/pkg-imports |
|
| 11 |
+. $SCRIPTDIR/test-imports |
|
| 12 |
+. $SCRIPTDIR/toml |
|
| 13 |
+. $SCRIPTDIR/vet |
| 0 | 14 |
new file mode 100755 |
| ... | ... |
@@ -0,0 +1,28 @@ |
| 0 |
+#!/bin/bash |
|
| 1 |
+ |
|
| 2 |
+export SCRIPTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
|
| 3 |
+source "${SCRIPTDIR}/.validate"
|
|
| 4 |
+ |
|
| 5 |
+IFS=$'\n' |
|
| 6 |
+files=( $(validate_diff --diff-filter=ACMR --name-only -- 'profiles/seccomp' || true) ) |
|
| 7 |
+unset IFS |
|
| 8 |
+ |
|
| 9 |
+if [ ${#files[@]} -gt 0 ]; then
|
|
| 10 |
+ # We run 'go generate' and see if we have a diff afterwards |
|
| 11 |
+ go generate ./profiles/seccomp/ >/dev/null |
|
| 12 |
+ # Let see if the working directory is clean |
|
| 13 |
+ diffs="$(git status --porcelain -- profiles/seccomp 2>/dev/null)" |
|
| 14 |
+ if [ "$diffs" ]; then |
|
| 15 |
+ {
|
|
| 16 |
+ echo 'The result of go generate ./profiles/seccomp/ differs' |
|
| 17 |
+ echo |
|
| 18 |
+ echo "$diffs" |
|
| 19 |
+ echo |
|
| 20 |
+ echo 'Please re-run go generate ./profiles/seccomp/' |
|
| 21 |
+ echo |
|
| 22 |
+ } >&2 |
|
| 23 |
+ false |
|
| 24 |
+ else |
|
| 25 |
+ echo 'Congratulations! Seccomp profile generation is done correctly.' |
|
| 26 |
+ fi |
|
| 27 |
+fi |
| 0 | 28 |
new file mode 100755 |
| ... | ... |
@@ -0,0 +1,31 @@ |
| 0 |
+#!/bin/bash |
|
| 1 |
+ |
|
| 2 |
+export SCRIPTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
|
| 3 |
+source "${SCRIPTDIR}/.validate"
|
|
| 4 |
+ |
|
| 5 |
+IFS=$'\n' |
|
| 6 |
+files=( $(validate_diff --diff-filter=ACMR --name-only -- '*.go' | grep -v '^vendor/' || true) ) |
|
| 7 |
+unset IFS |
|
| 8 |
+ |
|
| 9 |
+badFiles=() |
|
| 10 |
+for f in "${files[@]}"; do
|
|
| 11 |
+ # we use "git show" here to validate that what's committed is formatted |
|
| 12 |
+ if [ "$(git show "$VALIDATE_HEAD:$f" | gofmt -s -l)" ]; then |
|
| 13 |
+ badFiles+=( "$f" ) |
|
| 14 |
+ fi |
|
| 15 |
+done |
|
| 16 |
+ |
|
| 17 |
+if [ ${#badFiles[@]} -eq 0 ]; then
|
|
| 18 |
+ echo 'Congratulations! All Go source files are properly formatted.' |
|
| 19 |
+else |
|
| 20 |
+ {
|
|
| 21 |
+ echo "These files are not properly gofmt'd:" |
|
| 22 |
+ for f in "${badFiles[@]}"; do
|
|
| 23 |
+ echo " - $f" |
|
| 24 |
+ done |
|
| 25 |
+ echo |
|
| 26 |
+ echo 'Please reformat the above files using "gofmt -s -w" and commit the result.' |
|
| 27 |
+ echo |
|
| 28 |
+ } >&2 |
|
| 29 |
+ false |
|
| 30 |
+fi |
| 0 | 31 |
new file mode 100755 |
| ... | ... |
@@ -0,0 +1,31 @@ |
| 0 |
+#!/bin/bash |
|
| 1 |
+ |
|
| 2 |
+export SCRIPTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
|
| 3 |
+source "${SCRIPTDIR}/.validate"
|
|
| 4 |
+ |
|
| 5 |
+IFS=$'\n' |
|
| 6 |
+files=( $(validate_diff --diff-filter=ACMR --name-only -- '*.go' | grep -v '^vendor/' | grep -v '^api/types/' || true) ) |
|
| 7 |
+unset IFS |
|
| 8 |
+ |
|
| 9 |
+errors=() |
|
| 10 |
+for f in "${files[@]}"; do
|
|
| 11 |
+ failedLint=$(golint "$f") |
|
| 12 |
+ if [ "$failedLint" ]; then |
|
| 13 |
+ errors+=( "$failedLint" ) |
|
| 14 |
+ fi |
|
| 15 |
+done |
|
| 16 |
+ |
|
| 17 |
+if [ ${#errors[@]} -eq 0 ]; then
|
|
| 18 |
+ echo 'Congratulations! All Go source files have been linted.' |
|
| 19 |
+else |
|
| 20 |
+ {
|
|
| 21 |
+ echo "Errors from golint:" |
|
| 22 |
+ for err in "${errors[@]}"; do
|
|
| 23 |
+ echo "$err" |
|
| 24 |
+ done |
|
| 25 |
+ echo |
|
| 26 |
+ echo 'Please fix the above errors. You can test via "golint" and commit the result.' |
|
| 27 |
+ echo |
|
| 28 |
+ } >&2 |
|
| 29 |
+ false |
|
| 30 |
+fi |
| 0 | 31 |
new file mode 100755 |
| ... | ... |
@@ -0,0 +1,33 @@ |
| 0 |
+#!/bin/bash |
|
| 1 |
+set -e |
|
| 2 |
+ |
|
| 3 |
+export SCRIPTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
|
| 4 |
+source "${SCRIPTDIR}/.validate"
|
|
| 5 |
+ |
|
| 6 |
+IFS=$'\n' |
|
| 7 |
+files=( $(validate_diff --diff-filter=ACMR --name-only -- 'pkg/*.go' || true) ) |
|
| 8 |
+unset IFS |
|
| 9 |
+ |
|
| 10 |
+badFiles=() |
|
| 11 |
+for f in "${files[@]}"; do
|
|
| 12 |
+ IFS=$'\n' |
|
| 13 |
+ badImports=( $(go list -e -f '{{ join .Deps "\n" }}' "$f" | sort -u | grep -vE '^github.com/docker/docker/pkg/' | grep -E '^github.com/docker/docker' || true) )
|
|
| 14 |
+ unset IFS |
|
| 15 |
+ |
|
| 16 |
+ for import in "${badImports[@]}"; do
|
|
| 17 |
+ badFiles+=( "$f imports $import" ) |
|
| 18 |
+ done |
|
| 19 |
+done |
|
| 20 |
+ |
|
| 21 |
+if [ ${#badFiles[@]} -eq 0 ]; then
|
|
| 22 |
+ echo 'Congratulations! "./pkg/..." is safely isolated from internal code.' |
|
| 23 |
+else |
|
| 24 |
+ {
|
|
| 25 |
+ echo 'These files import internal code: (either directly or indirectly)' |
|
| 26 |
+ for f in "${badFiles[@]}"; do
|
|
| 27 |
+ echo " - $f" |
|
| 28 |
+ done |
|
| 29 |
+ echo |
|
| 30 |
+ } >&2 |
|
| 31 |
+ false |
|
| 32 |
+fi |
| 0 | 33 |
new file mode 100755 |
| ... | ... |
@@ -0,0 +1,38 @@ |
| 0 |
+#!/bin/bash |
|
| 1 |
+# Make sure we're not using gos' Testing package any more in integration-cli |
|
| 2 |
+ |
|
| 3 |
+export SCRIPTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
|
| 4 |
+source "${SCRIPTDIR}/.validate"
|
|
| 5 |
+ |
|
| 6 |
+IFS=$'\n' |
|
| 7 |
+files=( $(validate_diff --diff-filter=ACMR --name-only -- 'integration-cli/*.go' || true) ) |
|
| 8 |
+unset IFS |
|
| 9 |
+ |
|
| 10 |
+badFiles=() |
|
| 11 |
+for f in "${files[@]}"; do
|
|
| 12 |
+ # skip check_test.go since it *does* use the testing package |
|
| 13 |
+ if [ "$f" = "integration-cli/check_test.go" ]; then |
|
| 14 |
+ continue |
|
| 15 |
+ fi |
|
| 16 |
+ |
|
| 17 |
+ # we use "git show" here to validate that what's committed doesn't contain golang built-in testing |
|
| 18 |
+ if git show "$VALIDATE_HEAD:$f" | grep -q testing.T; then |
|
| 19 |
+ if [ "$(echo $f | grep '_test')" ]; then |
|
| 20 |
+ # allow testing.T for non- _test files |
|
| 21 |
+ badFiles+=( "$f" ) |
|
| 22 |
+ fi |
|
| 23 |
+ fi |
|
| 24 |
+done |
|
| 25 |
+ |
|
| 26 |
+if [ ${#badFiles[@]} -eq 0 ]; then
|
|
| 27 |
+ echo 'Congratulations! No testing.T found.' |
|
| 28 |
+else |
|
| 29 |
+ {
|
|
| 30 |
+ echo "These files use the wrong testing infrastructure:" |
|
| 31 |
+ for f in "${badFiles[@]}"; do
|
|
| 32 |
+ echo " - $f" |
|
| 33 |
+ done |
|
| 34 |
+ echo |
|
| 35 |
+ } >&2 |
|
| 36 |
+ false |
|
| 37 |
+fi |
| 0 | 38 |
new file mode 100755 |
| ... | ... |
@@ -0,0 +1,31 @@ |
| 0 |
+#!/bin/bash |
|
| 1 |
+ |
|
| 2 |
+export SCRIPTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
|
| 3 |
+source "${SCRIPTDIR}/.validate"
|
|
| 4 |
+ |
|
| 5 |
+IFS=$'\n' |
|
| 6 |
+files=( $(validate_diff --diff-filter=ACMR --name-only -- 'MAINTAINERS' || true) ) |
|
| 7 |
+unset IFS |
|
| 8 |
+ |
|
| 9 |
+badFiles=() |
|
| 10 |
+for f in "${files[@]}"; do
|
|
| 11 |
+ # we use "git show" here to validate that what's committed has valid toml syntax |
|
| 12 |
+ if ! git show "$VALIDATE_HEAD:$f" | tomlv /proc/self/fd/0 ; then |
|
| 13 |
+ badFiles+=( "$f" ) |
|
| 14 |
+ fi |
|
| 15 |
+done |
|
| 16 |
+ |
|
| 17 |
+if [ ${#badFiles[@]} -eq 0 ]; then
|
|
| 18 |
+ echo 'Congratulations! All toml source files changed here have valid syntax.' |
|
| 19 |
+else |
|
| 20 |
+ {
|
|
| 21 |
+ echo "These files are not valid toml:" |
|
| 22 |
+ for f in "${badFiles[@]}"; do
|
|
| 23 |
+ echo " - $f" |
|
| 24 |
+ done |
|
| 25 |
+ echo |
|
| 26 |
+ echo 'Please reformat the above files as valid toml' |
|
| 27 |
+ echo |
|
| 28 |
+ } >&2 |
|
| 29 |
+ false |
|
| 30 |
+fi |
| 0 | 31 |
new file mode 100755 |
| ... | ... |
@@ -0,0 +1,30 @@ |
| 0 |
+#!/bin/bash |
|
| 1 |
+ |
|
| 2 |
+export SCRIPTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
|
| 3 |
+source "${SCRIPTDIR}/.validate"
|
|
| 4 |
+ |
|
| 5 |
+IFS=$'\n' |
|
| 6 |
+files=( $(validate_diff --diff-filter=ACMR --name-only -- 'hack/vendor.sh' 'hack/.vendor-helpers.sh' 'vendor/' || true) ) |
|
| 7 |
+unset IFS |
|
| 8 |
+ |
|
| 9 |
+if [ ${#files[@]} -gt 0 ]; then
|
|
| 10 |
+ # We run vendor.sh to and see if we have a diff afterwards |
|
| 11 |
+ ./hack/vendor.sh >/dev/null |
|
| 12 |
+ # Let see if the working directory is clean |
|
| 13 |
+ diffs="$(git status --porcelain -- vendor 2>/dev/null)" |
|
| 14 |
+ if [ "$diffs" ]; then |
|
| 15 |
+ {
|
|
| 16 |
+ echo 'The result of ./hack/vendor.sh differs' |
|
| 17 |
+ echo |
|
| 18 |
+ echo "$diffs" |
|
| 19 |
+ echo |
|
| 20 |
+ echo 'Please vendor your package with ./hack/vendor.sh.' |
|
| 21 |
+ echo |
|
| 22 |
+ } >&2 |
|
| 23 |
+ false |
|
| 24 |
+ else |
|
| 25 |
+ echo 'Congratulations! All vendoring changes are done the right way.' |
|
| 26 |
+ fi |
|
| 27 |
+else |
|
| 28 |
+ echo 'No vendor changes in diff.' |
|
| 29 |
+fi |
| 0 | 30 |
new file mode 100755 |
| ... | ... |
@@ -0,0 +1,32 @@ |
| 0 |
+#!/bin/bash |
|
| 1 |
+ |
|
| 2 |
+export SCRIPTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
|
| 3 |
+source "${SCRIPTDIR}/.validate"
|
|
| 4 |
+ |
|
| 5 |
+IFS=$'\n' |
|
| 6 |
+files=( $(validate_diff --diff-filter=ACMR --name-only -- '*.go' | grep -v '^vendor/' || true) ) |
|
| 7 |
+unset IFS |
|
| 8 |
+ |
|
| 9 |
+errors=() |
|
| 10 |
+for f in "${files[@]}"; do
|
|
| 11 |
+ failedVet=$(go vet "$f") |
|
| 12 |
+ if [ "$failedVet" ]; then |
|
| 13 |
+ errors+=( "$failedVet" ) |
|
| 14 |
+ fi |
|
| 15 |
+done |
|
| 16 |
+ |
|
| 17 |
+ |
|
| 18 |
+if [ ${#errors[@]} -eq 0 ]; then
|
|
| 19 |
+ echo 'Congratulations! All Go source files have been vetted.' |
|
| 20 |
+else |
|
| 21 |
+ {
|
|
| 22 |
+ echo "Errors from go vet:" |
|
| 23 |
+ for err in "${errors[@]}"; do
|
|
| 24 |
+ echo " - $err" |
|
| 25 |
+ done |
|
| 26 |
+ echo |
|
| 27 |
+ echo 'Please fix the above errors. You can test via "go vet" and commit the result.' |
|
| 28 |
+ echo |
|
| 29 |
+ } >&2 |
|
| 30 |
+ false |
|
| 31 |
+fi |