2017-04-06 22:59:41 +00:00
|
|
|
#!/usr/bin/env bash
|
2016-03-18 03:18:16 +00:00
|
|
|
set -e
|
|
|
|
|
2018-06-07 13:34:47 +00:00
|
|
|
# Brings in _ROOT, _DIR, _DIRS globals.
|
2016-10-02 08:18:37 +00:00
|
|
|
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
2017-07-29 04:34:59 +00:00
|
|
|
source "${SCRIPT_DIR}/config.sh"
|
2016-03-18 03:18:16 +00:00
|
|
|
|
2016-08-07 03:59:51 +00:00
|
|
|
# Add Cargo to PATH.
|
|
|
|
export PATH=${HOME}/.cargo/bin:${PATH}
|
|
|
|
|
2016-09-30 03:50:06 +00:00
|
|
|
# Checks that the versions for Cargo projects $@ all match
|
|
|
|
function check_versions_match() {
|
|
|
|
local last_version=""
|
2017-07-29 04:34:59 +00:00
|
|
|
for dir in "${@}"; do
|
2016-09-30 03:50:06 +00:00
|
|
|
local cargo_toml="${dir}/Cargo.toml"
|
|
|
|
if ! [ -f "${cargo_toml}" ]; then
|
|
|
|
echo "Cargo configuration file '${cargo_toml}' does not exist."
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2017-07-29 04:34:59 +00:00
|
|
|
local version=$(grep version "${cargo_toml}" | head -n 1 | cut -d' ' -f3)
|
2016-09-30 03:50:06 +00:00
|
|
|
if [ -z "${last_version}" ]; then
|
|
|
|
last_version="${version}"
|
|
|
|
elif ! [ "${version}" = "${last_version}" ]; then
|
|
|
|
echo "Versions differ in '${cargo_toml}'. ${version} != ${last_version}"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
}
|
|
|
|
|
2017-03-16 02:26:15 +00:00
|
|
|
# Ensures there are no tabs in any file.
|
2016-12-29 04:33:56 +00:00
|
|
|
function ensure_tab_free() {
|
2016-12-29 04:47:15 +00:00
|
|
|
local tab=$(printf '\t')
|
2018-06-07 13:34:47 +00:00
|
|
|
local matches=$(git grep -E -I "${tab}" "${PROJECT_ROOT}" | grep -v 'LICENSE')
|
2016-12-29 04:33:56 +00:00
|
|
|
if ! [ -z "${matches}" ]; then
|
|
|
|
echo "Tab characters were found in the following:"
|
|
|
|
echo "${matches}"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2017-03-16 02:26:15 +00:00
|
|
|
# Ensures there are no files with trailing whitespace.
|
|
|
|
function ensure_trailing_whitespace_free() {
|
2018-06-07 13:34:47 +00:00
|
|
|
local matches=$(git grep -E -I "\s+$" "${PROJECT_ROOT}")
|
2017-03-16 02:26:15 +00:00
|
|
|
if ! [ -z "${matches}" ]; then
|
|
|
|
echo "Trailing whitespace was found in the following:"
|
|
|
|
echo "${matches}"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2017-02-02 08:41:47 +00:00
|
|
|
function bootstrap_examples() {
|
2017-07-29 04:34:59 +00:00
|
|
|
while read -r file; do
|
|
|
|
bootstrap_script="${file}/bootstrap.sh"
|
|
|
|
if [ -x "${bootstrap_script}" ]; then
|
|
|
|
echo " Bootstrapping ${file}..."
|
2017-02-02 08:41:47 +00:00
|
|
|
|
2017-07-29 04:34:59 +00:00
|
|
|
env_vars=$(bash "${bootstrap_script}")
|
|
|
|
bootstrap_result=$?
|
|
|
|
if [ $bootstrap_result -ne 0 ]; then
|
|
|
|
echo " Running bootstrap script (${bootstrap_script}) failed!"
|
|
|
|
exit 1
|
|
|
|
else
|
|
|
|
eval $env_vars
|
2017-02-02 08:41:47 +00:00
|
|
|
fi
|
|
|
|
fi
|
2017-07-29 04:34:59 +00:00
|
|
|
done < <(find "${EXAMPLES_DIR}" -maxdepth 1 -type d)
|
2017-02-02 08:41:47 +00:00
|
|
|
}
|
|
|
|
|
2016-12-29 04:33:56 +00:00
|
|
|
echo ":: Ensuring all crate versions match..."
|
2018-06-07 13:34:47 +00:00
|
|
|
check_versions_match "${ALL_PROJECT_DIRS[@]}"
|
2016-12-12 06:15:15 +00:00
|
|
|
|
2016-12-29 04:33:56 +00:00
|
|
|
echo ":: Checking for tabs..."
|
|
|
|
ensure_tab_free
|
|
|
|
|
2017-03-16 02:26:15 +00:00
|
|
|
echo ":: Checking for trailing whitespace..."
|
|
|
|
ensure_trailing_whitespace_free
|
|
|
|
|
2016-12-12 06:15:15 +00:00
|
|
|
echo ":: Updating dependencies..."
|
2016-09-30 22:39:55 +00:00
|
|
|
cargo update
|
|
|
|
|
2018-08-18 23:52:45 +00:00
|
|
|
if [ "$1" = "--contrib" ]; then
|
|
|
|
FEATURES=(
|
|
|
|
json
|
|
|
|
msgpack
|
|
|
|
tera_templates
|
|
|
|
handlebars_templates
|
2018-10-07 00:24:11 +00:00
|
|
|
serve
|
2018-11-08 17:01:58 +00:00
|
|
|
helmet
|
2018-08-18 23:52:45 +00:00
|
|
|
diesel_postgres_pool
|
|
|
|
diesel_sqlite_pool
|
|
|
|
diesel_mysql_pool
|
|
|
|
postgres_pool
|
2018-10-27 20:04:52 +00:00
|
|
|
mysql_pool
|
2018-08-18 23:52:45 +00:00
|
|
|
sqlite_pool
|
|
|
|
cypher_pool
|
|
|
|
redis_pool
|
2018-11-28 20:01:21 +00:00
|
|
|
mongodb_pool
|
2019-01-04 16:19:09 +00:00
|
|
|
memcache_pool
|
2018-08-18 23:52:45 +00:00
|
|
|
)
|
2017-01-15 10:33:45 +00:00
|
|
|
|
2018-08-18 23:52:45 +00:00
|
|
|
pushd "${CONTRIB_LIB_ROOT}" > /dev/null 2>&1
|
|
|
|
|
|
|
|
echo ":: Building and testing contrib [default]..."
|
|
|
|
CARGO_INCREMENTAL=0 cargo test
|
|
|
|
|
|
|
|
for feature in "${FEATURES[@]}"; do
|
|
|
|
echo ":: Building and testing contrib [${feature}]..."
|
|
|
|
CARGO_INCREMENTAL=0 cargo test --no-default-features --features "${feature}"
|
|
|
|
done
|
|
|
|
|
2018-11-05 20:29:03 +00:00
|
|
|
popd > /dev/null 2>&1
|
|
|
|
elif [ "$1" = "--core" ]; then
|
|
|
|
FEATURES=(
|
2018-11-09 07:37:37 +00:00
|
|
|
private-cookies # this is already tested since it's the default feature
|
2018-11-05 20:29:03 +00:00
|
|
|
tls
|
|
|
|
)
|
|
|
|
|
2018-11-09 07:37:37 +00:00
|
|
|
pushd "${CORE_LIB_ROOT}" > /dev/null 2>&1
|
2018-11-05 20:29:03 +00:00
|
|
|
|
|
|
|
echo ":: Building and testing core [no features]..."
|
|
|
|
CARGO_INCREMENTAL=0 cargo test --no-default-features
|
|
|
|
|
|
|
|
for feature in "${FEATURES[@]}"; do
|
|
|
|
echo ":: Building and testing core [${feature}]..."
|
|
|
|
CARGO_INCREMENTAL=0 cargo test --no-default-features --features "${feature}"
|
|
|
|
done
|
|
|
|
|
2018-08-18 23:52:45 +00:00
|
|
|
popd > /dev/null 2>&1
|
|
|
|
else
|
|
|
|
echo ":: Bootstrapping examples..."
|
|
|
|
bootstrap_examples
|
|
|
|
|
|
|
|
echo ":: Building and testing libraries..."
|
|
|
|
CARGO_INCREMENTAL=0 cargo test --all-features --all $@
|
|
|
|
fi
|