Skip to content

Commit

Permalink
Merge pull request bazelbuild#3 from damienmg/master
Browse files Browse the repository at this point in the history
Add CI scripts to test the tutorial
  • Loading branch information
kchodorow committed Sep 2, 2015
2 parents bc18e96 + 2f2d527 commit 621a58e
Show file tree
Hide file tree
Showing 3 changed files with 87 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
*~
bazel-*
.idea
.bazelrc
5 changes: 5 additions & 0 deletions tutorial/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,3 +77,8 @@ Bazel will generate some output files, most notably `bazel-bin/ios-app/ios-app.x

Open this file in xcode and run the application on your target device
(or device simulator).

Continuous integration
----------------------
The script in ci/build.sh is used by [http://ci.bazel.io] to test that this workspace
still build against Bazel at head.
81 changes: 81 additions & 0 deletions tutorial/ci/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
# Copyright 2015 Google Inc. All rights reserved.
#
# 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.

# Scripts to compile the tutorial on the CI system
# This script expect the following environment variable:
# $BAZEL_INSTALLER set to the path to the bazel installer
# $ANDROID_SDK_PATH, $ANDROID_SDK_API_LEVEL,
# $ANDROID_SDK_BUILD_TOOLS_VERSION are respectively the
# path to the Android SDK, the API Level of the SDK and
# the version of the build tools. If the path isn't defined
# the android build won't be tested. The 2 other one are defaulted
# to, respectively, "22" and "22.0.1".
# $IOS_SDK_VERSION set the SDK version of ios (defaulted to 8.4)


# Go to the workspace root
cd "$(dirname "$(dirname "${BASH_SOURCE[0]}")")"

echo "Workspace directory: ${PWD}"

if [ -z "${BAZEL_INSTALLER}" ]; then
echo "BAZEL_INSTALLER environment variable not provided," >&2
echo "Please set it to the path of the Bazel's installer." >&2
exit 1
fi

set -eux
# Set-up android tooling if provided
if [ -n "${ANDROID_SDK_PATH-}" ]; then
cat >>WORKSPACE <<EOF
android_sdk_repository(
name = "androidsdk",
path = "${ANDROID_SDK_PATH}",
api_level = ${ANDROID_SDK_API_LEVEL:-22},
build_tools_version = "${ANDROID_SDK_BUILD_TOOLS_VERSION:-22.0.1}",
)
EOF
# Revert change to workspace
trap 'git checkout HEAD WORKSPACE' EXIT
fi

# Install bazel
BASE="$(dirname "${PWD}")/bazel-install"
bash "${BAZEL_INSTALLER}" \
--base="${BASE}" \
--bazelrc="$PWD/.bazelrc" \
--bin="${BASE}/binary"

BAZEL="${BASE}/binary/bazel"

# Cleanup
"${BAZEL}" clean --expunge

# bazel info
"${BAZEL}" info

# Test building the backend
"${BAZEL}" build //backend

# Test the android application
if [ -n "${ANDROID_SDK_PATH-}" ]; then
"${BAZEL}" build //android
fi

# Under darwin, test the ios application
if [ "$(uname -s | tr 'A-Z' 'a-z')" = "darwin" ]; then
"${BAZEL}" build //ios-app --ios_sdk_version=${IOS_SDK_VERSION:-8.4}
fi

echo "Yay!"

0 comments on commit 621a58e

Please sign in to comment.