summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoel Challis <git@zvecr.com>2019-10-14 17:57:53 +0100
committerGitHub <noreply@github.com>2019-10-14 17:57:53 +0100
commite1de0d74a6f6c4bdc762b32fb78e449aed0fcecb (patch)
tree677c27ec4e19b5a2c398ce66fa7885765377f957
parent6560dffc05131c05655f8e0d74cc65c5918894fa (diff)
Move running pytest to travis_test (#7005)
-rwxr-xr-xutil/travis_build.sh10
-rw-r--r--util/travis_test.sh36
2 files changed, 27 insertions, 19 deletions
diff --git a/util/travis_build.sh b/util/travis_build.sh
index 2bc1ccd62f..225c8548f5 100755
--- a/util/travis_build.sh
+++ b/util/travis_build.sh
@@ -1,6 +1,6 @@
#!/bin/bash
-# if docker is installed - call make within the qmk docker image
+# if docker is installed - patch calls to within the qmk docker image
if command -v docker >/dev/null; then
function make() {
docker run --rm -e MAKEFLAGS="$MAKEFLAGS" -w /qmk_firmware/ -v "$PWD":/qmk_firmware --user $(id -u):$(id -g) qmkfm/base_container make "$@"
@@ -52,14 +52,6 @@ if [[ "$TRAVIS_COMMIT_MESSAGE" != *"[skip build]"* ]] ; then
fi
done
fi
- # Check and run python tests if necessary
- PFM=$(git diff --name-only -n 1 ${TRAVIS_COMMIT_RANGE} | grep -E -e '^(lib/python/)' -e '^(bin/qmk)' | wc -l)
- if [ $PFM -gt 0 -o "$BRANCH" = "master" ]; then
- echo
- echo "Running python tests."
- docker run --rm -w /qmk_firmware/ -v "$PWD":/qmk_firmware --user $(id -u):$(id -g) qmkfm/base_container 'bin/qmk pytest'
- : $((exit_code = $exit_code + $?))
- fi
fi
exit $exit_code
fi
diff --git a/util/travis_test.sh b/util/travis_test.sh
index e6a50ac165..9b7402c282 100644
--- a/util/travis_test.sh
+++ b/util/travis_test.sh
@@ -1,29 +1,45 @@
#!/bin/bash
+# if docker is installed - patch calls to within the qmk docker image
+if command -v docker >/dev/null; then
+ function make() {
+ docker run --rm -e MAKEFLAGS="$MAKEFLAGS" -w /qmk_firmware/ -v "$PWD":/qmk_firmware --user $(id -u):$(id -g) qmkfm/base_container make "$@"
+ }
+ function qmk() {
+ docker run --rm -w /qmk_firmware/ -v "$PWD":/qmk_firmware --user $(id -u):$(id -g) qmkfm/base_container bin/qmk "$@"
+ }
+fi
+
TRAVIS_COMMIT_MESSAGE="${TRAVIS_COMMIT_MESSAGE:-none}"
TRAVIS_COMMIT_RANGE="${TRAVIS_COMMIT_RANGE:-HEAD~1..HEAD}"
# test force push
#TRAVIS_COMMIT_RANGE="c287f1bfc5c8...81f62atc4c1d"
-NUM_IMPACTING_CHANGES=$(git diff --name-only -n 1 ${TRAVIS_COMMIT_RANGE} | grep -Ecv '^(docs/)')
BRANCH=$(git rev-parse --abbrev-ref HEAD)
+CHANGES=$(git diff --name-only -n 1 ${TRAVIS_COMMIT_RANGE})
+
+NUM_CORE_CHANGES=$(echo "$CHANGES" | grep -Ecv -e '^(docs/)' -e '^(keyboards/)' -e '^(layouts/)')
+NUM_PY_CHANGES=$(echo "$CHANGES" | grep -Ec -e '^(lib/python/)' -e '^(bin/qmk)')
if [[ "$TRAVIS_COMMIT_MESSAGE" == *"[skip test]"* ]]; then
echo "Skipping due to commit message"
exit 0
fi
-if [ "$BRANCH" != "master" ] && [ "$NUM_IMPACTING_CHANGES" == "0" ]; then
- echo "Skipping due to changes not impacting tests"
- exit 0
+exit_code=0
+
+if [ "$BRANCH" == "master" ] || [ "$NUM_CORE_CHANGES" != "0" ]; then
+ echo "Running tests."
+ make test:all
+ : $((exit_code = $exit_code + $?))
+
fi
-# if docker is installed - call make within the qmk docker image
-if command -v docker >/dev/null; then
- function make() {
- docker run --rm -e MAKEFLAGS="$MAKEFLAGS" -w /qmk_firmware/ -v "$PWD":/qmk_firmware --user $(id -u):$(id -g) qmkfm/base_container make "$@"
- }
+if [ "$BRANCH" == "master" ] || [ "$NUM_PY_CHANGES" != "0" ]; then
+ echo "Running python tests."
+ qmk pytest
+ : $((exit_code = $exit_code + $?))
fi
-make test:all
+exit $exit_code