2019-04-19 20:20:02 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
2019-10-14 16:57:53 +00:00
|
|
|
# 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
|
|
|
|
|
2019-04-19 20:20:02 +00:00
|
|
|
TRAVIS_COMMIT_MESSAGE="${TRAVIS_COMMIT_MESSAGE:-none}"
|
|
|
|
TRAVIS_COMMIT_RANGE="${TRAVIS_COMMIT_RANGE:-HEAD~1..HEAD}"
|
|
|
|
|
|
|
|
# test force push
|
|
|
|
#TRAVIS_COMMIT_RANGE="c287f1bfc5c8...81f62atc4c1d"
|
|
|
|
|
|
|
|
BRANCH=$(git rev-parse --abbrev-ref HEAD)
|
2019-10-14 16:57:53 +00:00
|
|
|
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)')
|
2019-04-19 20:20:02 +00:00
|
|
|
|
|
|
|
if [[ "$TRAVIS_COMMIT_MESSAGE" == *"[skip test]"* ]]; then
|
|
|
|
echo "Skipping due to commit message"
|
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
2019-10-14 16:57:53 +00:00
|
|
|
exit_code=0
|
|
|
|
|
|
|
|
if [ "$BRANCH" == "master" ] || [ "$NUM_CORE_CHANGES" != "0" ]; then
|
|
|
|
echo "Running tests."
|
|
|
|
make test:all
|
|
|
|
: $((exit_code = $exit_code + $?))
|
|
|
|
|
2019-04-19 20:20:02 +00:00
|
|
|
fi
|
|
|
|
|
2019-10-14 16:57:53 +00:00
|
|
|
if [ "$BRANCH" == "master" ] || [ "$NUM_PY_CHANGES" != "0" ]; then
|
|
|
|
echo "Running python tests."
|
|
|
|
qmk pytest
|
|
|
|
: $((exit_code = $exit_code + $?))
|
2019-01-17 17:08:23 +00:00
|
|
|
fi
|
|
|
|
|
2019-10-14 16:57:53 +00:00
|
|
|
exit $exit_code
|