mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Add new validate-dco and validate-gofmt bundlescripts for DCO and gofmt validation
Docker-DCO-1.1-Signed-off-by: Andrew Page <admwiggin@gmail.com> (github: tianon)
This commit is contained in:
parent
031e288075
commit
81370b5b0f
5 changed files with 118 additions and 10 deletions
12
.travis.yml
12
.travis.yml
|
@ -12,19 +12,11 @@ before_script:
|
||||||
- env | sort
|
- env | sort
|
||||||
- sudo apt-get update -qq
|
- sudo apt-get update -qq
|
||||||
- sudo apt-get install -qq python-yaml
|
- sudo apt-get install -qq python-yaml
|
||||||
- git remote add upstream git://github.com/dotcloud/docker.git
|
|
||||||
- upstream=master;
|
|
||||||
if [ "$TRAVIS_PULL_REQUEST" != false ]; then
|
|
||||||
upstream=$TRAVIS_BRANCH;
|
|
||||||
fi;
|
|
||||||
git fetch --append --no-tags upstream refs/heads/$upstream:refs/remotes/upstream/$upstream
|
|
||||||
# sometimes we have upstream master already as origin/master (PRs), but other times we don't, so let's just make sure we have a completely unambiguous way to specify "upstream master" from here out
|
|
||||||
# but if it's a PR against non-master, we need that upstream branch instead :)
|
|
||||||
- sudo pip install -r docs/requirements.txt
|
- sudo pip install -r docs/requirements.txt
|
||||||
|
|
||||||
script:
|
script:
|
||||||
- hack/travis/dco.py
|
- hack/make.sh validate-dco
|
||||||
- hack/travis/gofmt.py
|
- hack/make.sh validate-gofmt
|
||||||
- make -sC docs SPHINXOPTS=-qW docs man
|
- make -sC docs SPHINXOPTS=-qW docs man
|
||||||
|
|
||||||
# vim:set sw=2 ts=2:
|
# vim:set sw=2 ts=2:
|
||||||
|
|
|
@ -40,13 +40,19 @@ echo
|
||||||
|
|
||||||
# List of bundles to create when no argument is passed
|
# List of bundles to create when no argument is passed
|
||||||
DEFAULT_BUNDLES=(
|
DEFAULT_BUNDLES=(
|
||||||
|
validate-dco
|
||||||
|
validate-gofmt
|
||||||
|
|
||||||
binary
|
binary
|
||||||
|
|
||||||
test
|
test
|
||||||
test-integration
|
test-integration
|
||||||
test-integration-cli
|
test-integration-cli
|
||||||
|
|
||||||
dynbinary
|
dynbinary
|
||||||
dyntest
|
dyntest
|
||||||
dyntest-integration
|
dyntest-integration
|
||||||
|
|
||||||
cover
|
cover
|
||||||
cross
|
cross
|
||||||
tgz
|
tgz
|
||||||
|
|
33
hack/make/.validate
Normal file
33
hack/make/.validate
Normal file
|
@ -0,0 +1,33 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
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
|
||||||
|
|
||||||
|
VALIDATE_REPO='https://github.com/dotcloud/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"
|
||||||
|
VALIDATE_UPSTREAM="$(git rev-parse --verify FETCH_HEAD)"
|
||||||
|
|
||||||
|
VALIDATE_COMMIT_LOG="$VALIDATE_UPSTREAM..$VALIDATE_HEAD"
|
||||||
|
VALIDATE_COMMIT_DIFF="$VALIDATE_UPSTREAM...$VALIDATE_HEAD"
|
||||||
|
|
||||||
|
validate_diff() {
|
||||||
|
if [ "$VALIDATE_UPSTREAM" != "$VALIDATE_HEAD" ]; then
|
||||||
|
git diff "$VALIDATE_COMMIT_DIFF" "$@"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
validate_log() {
|
||||||
|
if [ "$VALIDATE_UPSTREAM" != "$VALIDATE_HEAD" ]; then
|
||||||
|
git log "$VALIDATE_COMMIT_LOG" "$@"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
fi
|
47
hack/make/validate-dco
Normal file
47
hack/make/validate-dco
Normal file
|
@ -0,0 +1,47 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
source "$(dirname "$BASH_SOURCE")/.validate"
|
||||||
|
|
||||||
|
adds=$(validate_diff --numstat | awk '{ s += $1 } END { print s }')
|
||||||
|
dels=$(validate_diff --numstat | awk '{ s += $2 } END { print s }')
|
||||||
|
notDocs="$(validate_diff --numstat | awk '$3 !~ /^docs\// { print $3 }')"
|
||||||
|
|
||||||
|
: ${adds:=0}
|
||||||
|
: ${dels:=0}
|
||||||
|
|
||||||
|
if [ $adds -eq 0 -a $dels -eq 0 ]; then
|
||||||
|
echo '0 adds, 0 deletions; nothing to validate! :)'
|
||||||
|
elif [ -z "$notDocs" -a $adds -le 1 -a $dels -le 1 ]; then
|
||||||
|
echo 'Congratulations! DCO small-patch-exception material!'
|
||||||
|
else
|
||||||
|
dcoPrefix='Docker-DCO-1.1-Signed-off-by:'
|
||||||
|
dcoRegex="^$dcoPrefix ([^<]+) <([^<>@]+@[^<>]+)> \\(github: (\S+)\\)$"
|
||||||
|
commits=( $(validate_log --format='format:%H%n') )
|
||||||
|
badCommits=()
|
||||||
|
for commit in "${commits[@]}"; do
|
||||||
|
if [ -z "$(git log -1 --format='format:' --name-status "$commit")" ]; then
|
||||||
|
# no content (ie, Merge commit, etc)
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
if ! git log -1 --format='format:%B' "$commit" | grep -qE "$dcoRegex"; then
|
||||||
|
badCommits+=( "$commit" )
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
if [ ${#badCommits[@]} -eq 0 ]; then
|
||||||
|
echo "Congratulations! All commits are properly signed with the DCO!"
|
||||||
|
else
|
||||||
|
{
|
||||||
|
echo "These commits do not have a proper '$dcoPrefix' marker:"
|
||||||
|
for commit in "${badCommits[@]}"; do
|
||||||
|
echo " - $commit"
|
||||||
|
done
|
||||||
|
echo
|
||||||
|
echo 'Please amend each commit to include a properly formatted DCO marker.'
|
||||||
|
echo
|
||||||
|
echo 'Visit the following URL for information about the Docker DCO:'
|
||||||
|
echo ' https://github.com/dotcloud/docker/blob/master/CONTRIBUTING.md#sign-your-work'
|
||||||
|
echo
|
||||||
|
} >&2
|
||||||
|
false
|
||||||
|
fi
|
||||||
|
fi
|
30
hack/make/validate-gofmt
Normal file
30
hack/make/validate-gofmt
Normal file
|
@ -0,0 +1,30 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
source "$(dirname "$BASH_SOURCE")/.validate"
|
||||||
|
|
||||||
|
IFS=$'\n'
|
||||||
|
files=( $(validate_diff --diff-filter=ACMR --name-only -- '*.go' | grep -v '^vendor/' || true) )
|
||||||
|
unset IFS
|
||||||
|
|
||||||
|
badFiles=()
|
||||||
|
for f in "${files[@]}"; do
|
||||||
|
# we use "git show" here to validate that what's committed is formatted
|
||||||
|
if [ "$(git show "$VALIDATE_HEAD:$f" | gofmt -s -l)" ]; then
|
||||||
|
badFiles+=( "$f" )
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
if [ ${#badFiles[@]} -eq 0 ]; then
|
||||||
|
echo 'Congratulations! All Go source files are properly formatted.'
|
||||||
|
else
|
||||||
|
{
|
||||||
|
echo "These files are not properly gofmt'd:"
|
||||||
|
for f in "${badFiles[@]}"; do
|
||||||
|
echo " - $f"
|
||||||
|
done
|
||||||
|
echo
|
||||||
|
echo 'Please reformat the above files using "gofmt -s -w" and commit the result.'
|
||||||
|
echo
|
||||||
|
} >&2
|
||||||
|
false
|
||||||
|
fi
|
Loading…
Reference in a new issue