hack: validate tests for crioctl deprecation

Signed-off-by: Antonio Murdaca <runcom@redhat.com>
This commit is contained in:
Antonio Murdaca 2017-11-13 16:26:10 +01:00
parent 25ac83196f
commit 8ae0aee7e5
No known key found for this signature in database
GPG key ID: B2BEAD150DE936B9
4 changed files with 67 additions and 0 deletions

View file

@ -32,6 +32,7 @@ jobs:
- make .gitvalidation - make .gitvalidation
- make gofmt - make gofmt
- make lint - make lint
- make verify
- make testunit - make testunit
- make docs - make docs
- make - make
@ -41,12 +42,14 @@ jobs:
- make .gitvalidation - make .gitvalidation
- make gofmt - make gofmt
- make lint - make lint
- make verify
- make testunit - make testunit
- make docs - make docs
- make - make
go: 1.9.x go: 1.9.x
- script: - script:
- make .gitvalidation - make .gitvalidation
- make verify
- make testunit - make testunit
- make docs - make docs
- make - make

View file

@ -66,6 +66,9 @@ lint: .gopathok
gofmt: gofmt:
@./hack/verify-gofmt.sh @./hack/verify-gofmt.sh
verify:
@./hack/validate/deprecate-crioctl
conmon: conmon:
$(MAKE) -C $@ $(MAKE) -C $@

30
hack/validate/.validate Normal file
View file

@ -0,0 +1,30 @@
#!/usr/bin/env 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
VALIDATE_REPO='https://github.com/kubernetes-incubator/cri-o.git'
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
}
validate_log() {
if [ "$VALIDATE_UPSTREAM" != "$VALIDATE_HEAD" ]; then
git log "$VALIDATE_COMMIT_LOG" "$@"
fi
}
fi

31
hack/validate/deprecate-crioctl Executable file
View file

@ -0,0 +1,31 @@
#!/usr/bin/env bash
# Check that no new tests are being added using crioctl
export SCRIPTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
source "${SCRIPTDIR}/.validate"
IFS=$'\n'
files=( $(validate_diff --diff-filter=ACMR --name-only -- 'test/*.bats' || true) )
unset IFS
badFiles=()
for f in "${files[@]}"; do
# we use "git show" here to validate that what's committed doesn't contain crioctl calls
if git show "$VALIDATE_HEAD:$f" | grep -q crioctl; then
badFiles+=( "$f" )
fi
done
if [ ${#badFiles[@]} -eq 0 ]; then
echo 'Congratulations! No new tests have been added using crioctl.'
else
{
echo "These files use crioctl instead of crictl:"
echo ""
for f in "${badFiles[@]}"; do
echo " - $f"
done
echo
} >&2
false
fi