2017-03-07 19:44:40 +08:00
|
|
|
#!/bin/bash
|
|
|
|
|
2017-04-06 22:11:40 +08:00
|
|
|
function print_usage_and_exit {
|
2017-04-11 20:25:25 +08:00
|
|
|
echo "./init [-s] [--no-clone-dependencies] [--arc-diff DIFF_ID]"
|
|
|
|
echo -e "Prepare the environment for Memgraph QA.\n"
|
|
|
|
echo "Optional arguments:"
|
|
|
|
echo -e " -s\tuse sudo apt-get for installing required packages"
|
|
|
|
echo -e " -h\tdisplay this help and exit"
|
|
|
|
echo -e " --no-clone-dependencies\tskip cloning memgraph sources"
|
|
|
|
echo -e " --arc-diff\tcheckout the DIFF_ID from Phabricator"
|
2017-04-06 22:11:40 +08:00
|
|
|
exit 1
|
|
|
|
}
|
|
|
|
|
2017-03-17 17:27:01 +08:00
|
|
|
# read arguments
|
2017-04-06 22:11:40 +08:00
|
|
|
arcanist_diff_id=""
|
2017-03-17 17:27:01 +08:00
|
|
|
clone_dependencies=true
|
2017-04-11 20:25:25 +08:00
|
|
|
use_sudo=0
|
2017-04-06 22:11:40 +08:00
|
|
|
while [[ $# -gt 0 ]]; do
|
|
|
|
case $1 in
|
|
|
|
--no-clone-dependencies)
|
|
|
|
clone_dependencies=false
|
|
|
|
shift
|
|
|
|
;;
|
|
|
|
--arc-diff)
|
|
|
|
if [[ -z $2 ]]; then
|
|
|
|
print_usage_and_exit
|
|
|
|
fi
|
|
|
|
arcanist_diff_id=$2
|
|
|
|
shift 2
|
|
|
|
;;
|
2017-04-11 20:25:25 +08:00
|
|
|
-s)
|
|
|
|
use_sudo=1
|
|
|
|
shift
|
|
|
|
;;
|
2017-04-06 22:11:40 +08:00
|
|
|
*)
|
|
|
|
# unknown option
|
|
|
|
print_usage_and_exit
|
|
|
|
;;
|
|
|
|
esac
|
2017-03-17 17:27:01 +08:00
|
|
|
done
|
|
|
|
|
2017-03-07 19:44:40 +08:00
|
|
|
# exit if any subcommand returns a non-zero status
|
|
|
|
set -e
|
|
|
|
|
|
|
|
script_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
|
|
|
|
2017-04-11 20:25:25 +08:00
|
|
|
required_pkgs=(git arcanist # used to clone sources
|
|
|
|
python-virtualenv python3-pip # required by 'run' script
|
|
|
|
)
|
|
|
|
|
2017-03-07 19:44:40 +08:00
|
|
|
# install all dependencies on debian based operating systems
|
2017-04-11 20:25:25 +08:00
|
|
|
for pkg in ${required_pkgs[@]}; do
|
|
|
|
if dpkg -s $pkg 2>/dev/null >/dev/null; then
|
|
|
|
echo "Found $pkg"
|
|
|
|
elif (( $use_sudo )); then
|
|
|
|
echo "Installing $pkg"
|
|
|
|
if [[ ! `sudo apt-get -y install $pkg` ]]; then
|
|
|
|
echo "Didn't install $pkg [required]"
|
|
|
|
required_missing=1
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
echo "Missing $pkg [required]"
|
|
|
|
required_missing=1
|
|
|
|
fi
|
2017-03-07 19:44:40 +08:00
|
|
|
done
|
|
|
|
|
2017-04-11 20:25:25 +08:00
|
|
|
if (( $required_missing )); then
|
|
|
|
echo "Missing required packages. EXITING!"
|
|
|
|
echo "Please, install required packages and rerun $0 again."
|
|
|
|
exit 2
|
|
|
|
fi
|
|
|
|
|
2017-03-07 19:44:40 +08:00
|
|
|
# TODO: use pullbot and read a password from program arg or env var
|
|
|
|
# (in order to use this script inside CI infrastructure)
|
|
|
|
|
2017-04-06 22:11:40 +08:00
|
|
|
# create tests folder
|
2017-03-07 19:44:40 +08:00
|
|
|
tests_folder=${script_dir}/tests
|
2017-03-17 17:27:01 +08:00
|
|
|
mkdir -p ${tests_folder}
|
2017-03-07 19:44:40 +08:00
|
|
|
|
|
|
|
# clone dressipi's tests
|
|
|
|
cd ${tests_folder}
|
2017-04-06 22:11:40 +08:00
|
|
|
if ${clone_dependencies}; then
|
|
|
|
rm -rf ${tests_folder}/*
|
|
|
|
git clone https://phabricator.memgraph.io/source/pilot_dressipi.git
|
2017-03-17 17:27:01 +08:00
|
|
|
fi
|
2017-03-07 19:44:40 +08:00
|
|
|
|
|
|
|
# clean dbms folder
|
|
|
|
dbms_folder=${script_dir}/dbms
|
2017-03-17 17:27:01 +08:00
|
|
|
mkdir -p ${dbms_folder}
|
2017-03-07 19:44:40 +08:00
|
|
|
|
|
|
|
# clone memgraph & checkout right commit
|
|
|
|
cd ${dbms_folder}
|
2017-03-17 17:27:01 +08:00
|
|
|
if ${clone_dependencies} ; then
|
2017-04-06 22:11:40 +08:00
|
|
|
rm -rf ${dbms_folder}/*
|
|
|
|
git clone https://phabricator.memgraph.io/diffusion/MG/memgraph.git
|
2017-03-17 17:27:01 +08:00
|
|
|
fi
|
2017-03-07 19:44:40 +08:00
|
|
|
memgraph_folder=${dbms_folder}/memgraph
|
|
|
|
cd ${memgraph_folder}
|
|
|
|
git checkout dev
|
|
|
|
# optionally apply arcanist patch
|
|
|
|
if [[ ! -z ${arcanist_diff_id} ]]; then
|
|
|
|
# nocommit is here because arc tries to commit the patch
|
|
|
|
# and it fails if user isn't set (inside CI infrastructure the user
|
|
|
|
# probably won't be defined because CI infrastructure doesn't push
|
|
|
|
# any code back to the repository)
|
2017-04-06 22:11:40 +08:00
|
|
|
arc patch ${arcanist_diff_id} --nocommit
|
2017-03-07 19:44:40 +08:00
|
|
|
fi
|
|
|
|
./init
|
2017-04-06 22:11:40 +08:00
|
|
|
|
|
|
|
# compile memgraph
|
|
|
|
memgraph_build_dir=${script_dir}/dbms/memgraph/build
|
|
|
|
cd ${memgraph_build_dir}
|
|
|
|
cmake ..
|
|
|
|
make -j8
|
|
|
|
make copy_hardcoded_queries
|