Skip to content

Commit

Permalink
Merge pull request #4487 from jvaidya/build_tests_options
Browse files Browse the repository at this point in the history
Added the ability to build without tests
  • Loading branch information
sougou authored Dec 24, 2018
2 parents dfc0bb9 + 157ebf5 commit 4060706
Show file tree
Hide file tree
Showing 3 changed files with 113 additions and 65 deletions.
123 changes: 73 additions & 50 deletions bootstrap.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
# 3. Detection of installed MySQL and setting MYSQL_FLAVOR.
# 4. Installation of development related steps e.g. creating Git hooks.

BUILD_TESTS=${BUILD_TESTS:-1}

#
# 0. Initialization and helper methods.
Expand All @@ -48,23 +49,33 @@ go version &>/dev/null || fail "Go is not installed or is not on \$PATH"
[[ "$(go version 2>&1)" =~ go1\.[1-9][1-9] ]] || fail "Go is not version 1.11+"

# Set up the proper GOPATH for go get below.
source ./dev.env
if [ "$BUILD_TESTS" == 1 ] ; then
source ./dev.env
else
source ./build.env
fi

# Create main directories.
mkdir -p "$VTROOT/dist"
mkdir -p "$VTROOT/bin"
mkdir -p "$VTROOT/lib"
mkdir -p "$VTROOT/vthook"

# Set up required soft links.
# TODO(mberlin): Which of these can be deleted?
ln -snf "$VTTOP/config" "$VTROOT/config"
ln -snf "$VTTOP/data" "$VTROOT/data"
ln -snf "$VTTOP/py" "$VTROOT/py-vtdb"
ln -snf "$VTTOP/go/vt/zkctl/zksrv.sh" "$VTROOT/bin/zksrv.sh"
ln -snf "$VTTOP/test/vthook-test.sh" "$VTROOT/vthook/test.sh"
ln -snf "$VTTOP/test/vthook-test_backup_error" "$VTROOT/vthook/test_backup_error"
ln -snf "$VTTOP/test/vthook-test_backup_transform" "$VTROOT/vthook/test_backup_transform"
if [ "$BUILD_TESTS" == 1 ] ; then
# Set up required soft links.
# TODO(mberlin): Which of these can be deleted?
ln -snf "$VTTOP/config" "$VTROOT/config"
ln -snf "$VTTOP/data" "$VTROOT/data"
ln -snf "$VTTOP/py" "$VTROOT/py-vtdb"
ln -snf "$VTTOP/go/vt/zkctl/zksrv.sh" "$VTROOT/bin/zksrv.sh"
ln -snf "$VTTOP/test/vthook-test.sh" "$VTROOT/vthook/test.sh"
ln -snf "$VTTOP/test/vthook-test_backup_error" "$VTROOT/vthook/test_backup_error"
ln -snf "$VTTOP/test/vthook-test_backup_transform" "$VTROOT/vthook/test_backup_transform"
else
ln -snf "$VTTOP/config" "$VTROOT/config"
ln -snf "$VTTOP/data" "$VTROOT/data"
ln -snf "$VTTOP/go/vt/zkctl/zksrv.sh" "$VTROOT/bin/zksrv.sh"
fi

# install_dep is a helper function to generalize the download and installation of dependencies.
#
Expand Down Expand Up @@ -137,8 +148,10 @@ function install_grpc() {
grpcio_ver=$version
$PIP install --upgrade grpcio=="$grpcio_ver" grpcio-tools=="$grpcio_ver"
}
install_dep "gRPC" "1.16.0" "$VTROOT/dist/grpc" install_grpc

if [ "$BUILD_TESTS" == 1 ] ; then
install_dep "gRPC" "1.16.0" "$VTROOT/dist/grpc" install_grpc
fi

# Install protoc.
function install_protoc() {
Expand Down Expand Up @@ -226,8 +239,9 @@ function install_pymock() {
popd >/dev/null
}
pymock_version=1.0.1
install_dep "py-mock" "$pymock_version" "$VTROOT/dist/py-mock-$pymock_version" install_pymock

if [ "$BUILD_TESTS" == 1 ] ; then
install_dep "py-mock" "$pymock_version" "$VTROOT/dist/py-mock-$pymock_version" install_pymock
fi

# Download Selenium (necessary to run test/vtctld_web_test.py).
function install_selenium() {
Expand All @@ -240,7 +254,9 @@ function install_selenium() {
# instead of go/dist/selenium/lib/python3.5/site-packages and then can't find module 'pip._vendor.requests'
PYTHONPATH='' $PIP install selenium
}
install_dep "Selenium" "latest" "$VTROOT/dist/selenium" install_selenium
if [ "$BUILD_TESTS" == 1 ] ; then
install_dep "Selenium" "latest" "$VTROOT/dist/selenium" install_selenium
fi


# Download chromedriver (necessary to run test/vtctld_web_test.py).
Expand All @@ -252,7 +268,9 @@ function install_chromedriver() {
unzip -o -q chromedriver_linux64.zip -d "$dist"
rm chromedriver_linux64.zip
}
install_dep "chromedriver" "2.44" "$VTROOT/dist/chromedriver" install_chromedriver
if [ "$BUILD_TESTS" == 1 ] ; then
install_dep "chromedriver" "2.44" "$VTROOT/dist/chromedriver" install_chromedriver
fi


#
Expand Down Expand Up @@ -301,47 +319,52 @@ govendor sync || fail "Failed to download/update dependencies with govendor. Ple


# find mysql and prepare to use libmysqlclient
if [ -z "$MYSQL_FLAVOR" ]; then
export MYSQL_FLAVOR=MySQL56
echo "MYSQL_FLAVOR environment variable not set. Using default: $MYSQL_FLAVOR"
fi
case "$MYSQL_FLAVOR" in
"MySQL56")
myversion="$("$VT_MYSQL_ROOT/bin/mysql" --version)"
[[ "$myversion" =~ Distrib\ 5\.[67] || "$myversion" =~ Ver\ 8\. ]] || fail "Couldn't find MySQL 5.6+ in $VT_MYSQL_ROOT. Set VT_MYSQL_ROOT to override search location."
echo "Found MySQL 5.6+ installation in $VT_MYSQL_ROOT."
;;

"MariaDB")
myversion="$("$VT_MYSQL_ROOT/bin/mysql" --version)"
[[ "$myversion" =~ MariaDB ]] || fail "Couldn't find MariaDB in $VT_MYSQL_ROOT. Set VT_MYSQL_ROOT to override search location."
echo "Found MariaDB installation in $VT_MYSQL_ROOT."
;;

*)
fail "Unsupported MYSQL_FLAVOR $MYSQL_FLAVOR"
;;

esac

# save the flavor that was used in bootstrap, so it can be restored
# every time dev.env is sourced.
echo "$MYSQL_FLAVOR" > "$VTROOT/dist/MYSQL_FLAVOR"
if [ "$BUILD_TESTS" == 1 ] ; then
if [ -z "$MYSQL_FLAVOR" ]; then
export MYSQL_FLAVOR=MySQL56
echo "MYSQL_FLAVOR environment variable not set. Using default: $MYSQL_FLAVOR"
fi
case "$MYSQL_FLAVOR" in
"MySQL56")
myversion="$("$VT_MYSQL_ROOT/bin/mysql" --version)"
[[ "$myversion" =~ Distrib\ 5\.[67] || "$myversion" =~ Ver\ 8\. ]] || fail "Couldn't find MySQL 5.6+ in $VT_MYSQL_ROOT. Set VT_MYSQL_ROOT to override search location."
echo "Found MySQL 5.6+ installation in $VT_MYSQL_ROOT."
;;

"MariaDB")
myversion="$("$VT_MYSQL_ROOT/bin/mysql" --version)"
[[ "$myversion" =~ MariaDB ]] || fail "Couldn't find MariaDB in $VT_MYSQL_ROOT. Set VT_MYSQL_ROOT to override search location."
echo "Found MariaDB installation in $VT_MYSQL_ROOT."
;;

*)
fail "Unsupported MYSQL_FLAVOR $MYSQL_FLAVOR"
;;

esac
# save the flavor that was used in bootstrap, so it can be restored
# every time dev.env is sourced.
echo "$MYSQL_FLAVOR" > "$VTROOT/dist/MYSQL_FLAVOR"
fi

#
# 4. Installation of development related steps e.g. creating Git hooks.
#


# Create the Git hooks.
echo "creating git hooks"
mkdir -p "$VTTOP/.git/hooks"
ln -sf "$VTTOP/misc/git/pre-commit" "$VTTOP/.git/hooks/pre-commit"
ln -sf "$VTTOP/misc/git/prepare-commit-msg.bugnumber" "$VTTOP/.git/hooks/prepare-commit-msg"
ln -sf "$VTTOP/misc/git/commit-msg" "$VTTOP/.git/hooks/commit-msg"
(cd "$VTTOP" && git config core.hooksPath "$VTTOP/.git/hooks")
if [ "$BUILD_TESTS" == 1 ] ; then
# Create the Git hooks.
echo "creating git hooks"
mkdir -p "$VTTOP/.git/hooks"
ln -sf "$VTTOP/misc/git/pre-commit" "$VTTOP/.git/hooks/pre-commit"
ln -sf "$VTTOP/misc/git/prepare-commit-msg.bugnumber" "$VTTOP/.git/hooks/prepare-commit-msg"
ln -sf "$VTTOP/misc/git/commit-msg" "$VTTOP/.git/hooks/commit-msg"
(cd "$VTTOP" && git config core.hooksPath "$VTTOP/.git/hooks")
echo
echo "bootstrap finished - run 'source dev.env' in your shell before building."
else
echo
echo "bootstrap finished - run 'source build.env' in your shell before building."
fi


echo
echo "bootstrap finished - run 'source dev.env' in your shell before building."
39 changes: 39 additions & 0 deletions build.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# No shebang line as this script is sourced from an external shell.

# Copyright 2017 Google Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# Plese ensure dev.env is written in a way which is POSIX (bourne)
# shell compatible.
# - Some build systems like rpm require the different scriptlets used
# to build a package to be run under a POSIX shell so non-POSIX
# syntax will break that as dev.env will not be sourced by bash..

# Import prepend_path function.
dir="$(dirname "${BASH_SOURCE[0]}")"
# shellcheck source=tools/shell_functions.inc
if ! source "${dir}/tools/shell_functions.inc"; then
echo "failed to load tools/shell_functions.inc"
return 1
fi

VTTOP=$(pwd)
export VTTOP
VTROOT="${VTROOT:-${VTTOP/\/src\/vitess.io\/vitess/}}"
export VTROOT
# VTTOP sanity check
if [[ "$VTTOP" == "${VTTOP/\/src\/vitess.io\/vitess/}" ]]; then
echo "WARNING: VTTOP($VTTOP) does not contain src/vitess.io/vitess"
fi

16 changes: 1 addition & 15 deletions dev.env
Original file line number Diff line number Diff line change
Expand Up @@ -20,22 +20,8 @@
# to build a package to be run under a POSIX shell so non-POSIX
# syntax will break that as dev.env will not be sourced by bash..

# Import prepend_path function.
dir="$(dirname "${BASH_SOURCE[0]}")"
# shellcheck source=tools/shell_functions.inc
if ! source "${dir}/tools/shell_functions.inc"; then
echo "failed to load tools/shell_functions.inc"
return 1
fi
source build.env

VTTOP=$(pwd)
export VTTOP
VTROOT="${VTROOT:-${VTTOP/\/src\/vitess.io\/vitess/}}"
export VTROOT
# VTTOP sanity check
if [[ "$VTTOP" == "${VTTOP/\/src\/vitess.io\/vitess/}" ]]; then
echo "WARNING: VTTOP($VTTOP) does not contain src/vitess.io/vitess"
fi
export GOTOP=$VTTOP/go
export PYTOP=$VTTOP/py

Expand Down

0 comments on commit 4060706

Please sign in to comment.