Commit a6c2e7db authored by GuessWhoSamFoo's avatar GuessWhoSamFoo
Browse files

Selectively run tests depending on location of code change

Signed-off-by: default avatarGuessWhoSamFoo <foos@vmware.com>
parent 15ad0fa9
Showing with 42 additions and 11 deletions
+42 -11
......@@ -39,21 +39,11 @@ addons:
apt:
packages:
- rpm
# TODO: Update goreleaser.yml and add when open sourced
# - snapd
#
# TODO: Enable for snapd
#env:
#- PATH=/snap/bin:$PATH
#
#install:
#- sudo snap install snapcraft --classic
before_script:
- nvm install $(cat .nvmrc)
- make go-install
script:
- make ci
- $TRAVIS_BUILD_DIR/hacks/test-runner.sh
# choco install scripts points to private GH repo but windows cannot have secure env
# - if [[ $TRAVIS_OS_NAME == 'windows' ]]; then ./ci/travis-choco.sh; fi
#!/bin/bash
set -euxo pipefail
FRONTEND="web" # Specify multiple directory names separated by space
BUILD_FRONTEND=0
IGNORE_FILES=$(ls -p | grep -v /)
is_updated() {
GIT_DIFF=$(git --no-pager diff --name-only HEAD~1 | sort -u | awk 'BEGIN {FS="/"} {print $1}' | uniq);
export CHANGED=$GIT_DIFF
}
should_build() {
WATCH=($(echo "$FRONTEND" | tr ' ' '\n'))
is_updated
MODIFIED=($(echo "$CHANGED"))
for j in "${WATCH[@]}"
do
for k in "${MODIFIED[@]}"
do
if [[ $j = $k ]]; then
BUILD_FRONTEND=1
fi
done
done
}
if [[ $TRAVIS_BRANCH == 'master' ]]; then
make ci
else
should_build
if [[ $BUILD_FRONTEND == 0 ]]; then
# Backend tests only
make test vet sugarloaf-dev
else
make web-test web-build
fi
fi
exit $?
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment