forked from docker-archive/classicswarm
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request docker-archive#329 from aluzzardi/travis-test
Simplify travis configuration.
- Loading branch information
Showing
4 changed files
with
124 additions
and
59 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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/docker/swarm.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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
#!/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} | ||
|
||
# "Username may only contain alphanumeric characters or dashes and cannot begin with a dash" | ||
githubUsernameRegex='[a-zA-Z0-9][a-zA-Z0-9-]+' | ||
|
||
# https://github.com/docker/docker/blob/master/CONTRIBUTING.md#sign-your-work | ||
dcoPrefix='Signed-off-by:' | ||
dcoRegex="^(Docker-DCO-1.1-)?$dcoPrefix ([^<]+) <([^<>@]+@[^<>]+)>( \\(github: ($githubUsernameRegex)\\))?$" | ||
|
||
check_dco() { | ||
grep -qE "$dcoRegex" | ||
} | ||
|
||
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 | ||
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" | check_dco; 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/docker/docker/blob/master/CONTRIBUTING.md#sign-your-work' | ||
echo | ||
} >&2 | ||
false | ||
fi | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
#!/bin/bash | ||
|
||
source "$(dirname "$BASH_SOURCE")/.validate" | ||
|
||
IFS=$'\n' | ||
files=( $(validate_diff --diff-filter=ACMR --name-only -- '*.go' | grep -v '^Godeps/' || 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 |