Skip to content

Commit

Permalink
Require tests for feature/bugfix
Browse files Browse the repository at this point in the history
  • Loading branch information
fao89 committed Sep 9, 2020
1 parent a6eb0dd commit adb1f15
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
23 changes: 23 additions & 0 deletions .travis/pre_before_install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/usr/bin/env bash

set -mveuo pipefail

# skip this check for everything but PRs
if [ "$TRAVIS_PULL_REQUEST" = "false" ]; then
exit 0
fi

if [ "$TRAVIS_COMMIT_RANGE" != "" ]; then
RANGE=$TRAVIS_COMMIT_RANGE
elif [ "$TRAVIS_COMMIT" != "" ]; then
RANGE="$TRAVIS_COMMIT~...$TRAVIS_COMMIT"
fi


REQUIRES_TEST=$(git diff --name-only $RANGE | grep -E 'feature|bugfix')
CONTAINS_TEST=$(git diff --name-only $RANGE | grep -E '^test_')

if [ -n $REQUIRES_TEST ] && ![ -n $CONTAINS_TEST ]; then
echo "Test required for feature/bugfix."
exit 1
fi
1 change: 1 addition & 0 deletions CHANGES/7437.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Require tests for feature/bugfix

0 comments on commit adb1f15

Please sign in to comment.