2018-01-10 04:38:50 +01:00
|
|
|
#!/bin/bash
|
|
|
|
#ARGUMENT test for RUST, JS, COVERAGE or JS_RELEASE
|
|
|
|
set -e # fail on any error
|
|
|
|
set -u # treat unset variables as error
|
2018-01-10 05:33:46 +01:00
|
|
|
export JS_FILES_MODIFIED="$(git --no-pager diff --name-only master...$CI_BUILD_REF | grep ^js/ | wc -l)"
|
|
|
|
export JS_OLD_FILES_MODIFIED="$(git --no-pager diff --name-only master...$CI_BUILD_REF | grep ^js-old/ | wc -l)"
|
|
|
|
export RUST_FILES_MODIFIED="$(git --no-pager diff --name-only master...$CI_BUILD_REF | grep -v -e ^js -e ^\\. -e ^LICENSE -e ^README.md -e ^test.sh -e ^windows/ -e ^scripts/ -e^mac/ -e ^nsis/ | wc -l)"
|
2018-01-10 04:38:50 +01:00
|
|
|
export RUST_BACKTRACE=1
|
2018-01-10 05:33:46 +01:00
|
|
|
TEST_SWITCH=$1
|
2018-01-10 04:38:50 +01:00
|
|
|
rust_test () {
|
|
|
|
git submodule update --init --recursive
|
|
|
|
rustup show
|
2018-01-10 05:33:46 +01:00
|
|
|
if [ "${RUST_FILES_MODIFIED}" -eq 0 ];
|
2018-01-10 04:38:50 +01:00
|
|
|
then echo "Skipping Rust tests since no Rust files modified.";
|
2018-01-10 05:33:46 +01:00
|
|
|
else ./test.sh;
|
2018-01-10 04:38:50 +01:00
|
|
|
fi
|
|
|
|
if [ "$CI_BUILD_REF_NAME" == "nightly" ];
|
|
|
|
then sh scripts/aura-test.sh;
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
js_test () {
|
|
|
|
git submodule update --init --recursive
|
2018-01-10 05:33:46 +01:00
|
|
|
if [ "${JS_FILES_MODIFIED}" -eq 0 ];
|
2018-01-10 04:38:50 +01:00
|
|
|
then echo "Skipping JS deps install since no JS files modified.";
|
|
|
|
else ./js/scripts/install-deps.sh;
|
|
|
|
fi
|
2018-01-10 05:33:46 +01:00
|
|
|
if [ "${JS_OLD_FILES_MODIFIED}" -eq 0 ];
|
2018-01-10 04:38:50 +01:00
|
|
|
then echo "Skipping JS (old) deps install since no JS files modified.";
|
|
|
|
else ./js-old/scripts/install-deps.sh;
|
|
|
|
fi
|
2018-01-10 05:33:46 +01:00
|
|
|
if [ "${JS_FILES_MODIFIED}" -eq 0 ];
|
2018-01-10 04:38:50 +01:00
|
|
|
then echo "Skipping JS lint since no JS files modified.";
|
|
|
|
else ./js/scripts/lint.sh && ./js/scripts/test.sh && ./js/scripts/build.sh;
|
|
|
|
fi
|
2018-01-10 05:33:46 +01:00
|
|
|
if [ "${JS_OLD_FILES_MODIFIED}" -eq 0 ];
|
2018-01-10 04:38:50 +01:00
|
|
|
then echo "Skipping JS (old) lint since no JS files modified.";
|
|
|
|
else ./js-old/scripts/lint.sh && ./js-old/scripts/test.sh && ./js-old/scripts/build.sh;
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
js_release () {
|
|
|
|
rustup default stable
|
2018-01-10 05:33:46 +01:00
|
|
|
echo "${JS_FILES_MODIFIED}"
|
|
|
|
if [ "${JS_FILES_MODIFIED}" -eq 0 ];
|
2018-01-10 04:38:50 +01:00
|
|
|
then echo "Skipping JS deps install since no JS files modified.";
|
|
|
|
else ./js/scripts/install-deps.sh;
|
|
|
|
fi
|
2018-01-10 05:33:46 +01:00
|
|
|
if [ "${JS_FILES_MODIFIED}" -eq 0 ];
|
2018-01-10 04:38:50 +01:00
|
|
|
then echo "Skipping JS rebuild since no JS files modified.";
|
|
|
|
else ./js/scripts/build.sh && ./js/scripts/push-precompiled.sh;
|
|
|
|
fi
|
2018-01-10 05:33:46 +01:00
|
|
|
echo "${JS_OLD_FILES_MODIFIED}"
|
|
|
|
if [ "${JS_OLD_FILES_MODIFIED}" -eq 0 ];
|
2018-01-10 04:38:50 +01:00
|
|
|
then echo "Skipping JS (old) deps install since no JS files modified.";
|
|
|
|
else ./js-old/scripts/install-deps.sh;
|
|
|
|
fi
|
2018-01-10 05:33:46 +01:00
|
|
|
if [ "${JS_OLD_FILES_MODIFIED}" -eq 0 ];
|
2018-01-10 04:38:50 +01:00
|
|
|
then echo "Skipping JS (old) rebuild since no JS files modified.";
|
|
|
|
else ./js-old/scripts/build.sh && ./js-old/scripts/push-precompiled.sh;
|
|
|
|
fi
|
2018-01-10 05:33:46 +01:00
|
|
|
if [ "${JS_FILES_MODIFIED}" -eq 0 ] && [ "${JS_OLD_FILES_MODIFIED}" -eq 0 ];
|
2018-01-10 04:38:50 +01:00
|
|
|
then echo "Skipping Cargo update since no JS files modified.";
|
|
|
|
else ./js/scripts/push-cargo.sh;
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
coverage_test () {
|
|
|
|
git submodule update --init --recursive
|
|
|
|
rm -rf target/*
|
|
|
|
rm -rf js/.coverage
|
|
|
|
scripts/cov.sh
|
|
|
|
}
|
2018-01-10 05:33:46 +01:00
|
|
|
case $TEST_SWITCH in
|
|
|
|
stable )
|
2018-01-10 04:38:50 +01:00
|
|
|
rustup default stable
|
|
|
|
rust_test
|
|
|
|
;;
|
|
|
|
beta)
|
|
|
|
rustup default beta
|
|
|
|
rust_test
|
|
|
|
;;
|
|
|
|
nightly)
|
|
|
|
rustup default nightly
|
|
|
|
rust_test
|
|
|
|
;;
|
|
|
|
js-test)
|
|
|
|
js_test
|
|
|
|
;;
|
|
|
|
js-release)
|
|
|
|
js_release
|
|
|
|
;;
|
|
|
|
test-coverage)
|
|
|
|
coverage_test
|
|
|
|
;;
|
|
|
|
esac
|