fix: validation system

This commit is contained in:
Ludovic Fernandez 2019-04-01 15:30:07 +02:00 committed by Traefiker Bot
parent d6c9f51082
commit da20db862d
18 changed files with 235 additions and 324 deletions

View file

@ -1,24 +0,0 @@
#!/usr/bin/env 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/containous/traefik.git'
## FIXME wrong assumption
VALIDATE_BRANCH='master'
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
}
fi

View file

@ -1,9 +1,7 @@
#!/usr/bin/env bash
source "$(dirname "$BASH_SOURCE")/.validate"
IFS=$'\n'
files=( $(validate_diff --diff-filter=ACMR --name-only -- 'docs/*.md') )
files=( $( git ls-files 'docs/*.md' *.md ) )
unset IFS
errors=()

View file

@ -4,31 +4,26 @@ set -o pipefail
set -o nounset
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"; export SCRIPT_DIR
source "${SCRIPT_DIR}/.validate"
vendor_dir="./vendor/"
IFS=$'\n' files=( $(validate_diff --diff-filter=ACMR --name-only -- ${vendor_dir} || true) )
if [[ ${#files[@]} -gt 0 ]]; then
# We run dep install to and see if we have a diff afterwards
echo "checking ${vendor_dir} for unintentional changes..."
# We run dep install to and see if we have a diff afterwards
echo "checking ${vendor_dir} for unintentional changes..."
dep ensure -v
(${SCRIPT_DIR}/prune-dep.sh)
dep ensure -v
(${SCRIPT_DIR}/prune-dep.sh)
# Let see if the working directory is clean
diffs="$(git status --porcelain -- ${vendor_dir} 2>/dev/null)"
if [[ "$diffs" ]]; then
{
echo "The result of 'dep ensure' for vendor directory '${vendor_dir}' differs"
echo
echo "$diffs"
echo
echo 'Please vendor your package(s) with dep.'
echo
} >&2
exit 2
fi
# Let see if the working directory is clean
diffs="$(git status --porcelain -- ${vendor_dir} 2>/dev/null)"
if [[ "$diffs" ]]; then
{
echo "The result of 'dep ensure' for vendor directory '${vendor_dir}' differs"
echo
echo "$diffs"
echo
echo 'Please vendor your package(s) with dep.'
echo
} >&2
exit 2
fi
echo 'Congratulations! All vendoring changes are done the right way.'