Skip to content

Commit

Permalink
Merge pull request #401 from ToyotaResearchInstitute/apojomovsky/use_…
Browse files Browse the repository at this point in the history
…drake_binary_in_ci

Use a drake binary in CI instead of compiling it from source
  • Loading branch information
Alexis Pojomovsky authored May 11, 2018
2 parents 89ba0f9 + a167a94 commit 3617cc2
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 6 deletions.
54 changes: 48 additions & 6 deletions tools/continuous_integration/jenkins/build
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,56 @@ set -euo pipefail
JOBS=$( getconf _NPROCESSORS_ONLN )
COMPILER_PATH="/usr/bin/g++-5"

pushd workspace
mkdir -p install

pushd drake
bazel run --compiler=gcc-5 //:install `pwd`/../../install
bazel build --compiler=gcc-5 //automotive:*
popd # drake
# The date that forms part of the build URL is automatically parsed from the
# drake respository's last commit date, avoiding us from doing it by hand.

popd # workspace
pushd workspace/drake
COMMIT_DATE="$(git log -n 1 --pretty='format:%cd' --date=format:'%Y%m%d')"
popd

BINARY_URL="https://drake-packages.csail.mit.edu/drake/nightly/drake-YYYYMMDD-xenial.tar.gz"

VALID_URL=false

url_exists () {
echo Testing URL: $1
# Sends an http request against the test URL, will return false if whether the
# request specifically fails or if it takes more than 5 seconds to respond.
if curl --output /dev/null --silent --head --max-time 5 --fail "$1"; then
VALID_URL=true
fi
}

TEST_URL="${BINARY_URL//YYYYMMDD/$COMMIT_DATE}"
url_exists $TEST_URL

# In case the initial URL for downloading the binary is not valid,
# the script will attempt to generate new ones based on the dates of up
# to 5 days after the commit date.
if ! $VALID_URL; then
TEST_DATE=$COMMIT_DATE
NUM_ATTEMPTS=1
while ! $VALID_URL; do
if [ "$NUM_ATTEMPTS" -le "5" ] ; then
# Adds one day to the current date to test.
TEST_DATE=$(date +%Y%m%d -d "$TEST_DATE + 1 day")
# Updates binary's URL with new date.
TEST_URL="${BINARY_URL//YYYYMMDD/$TEST_DATE}"
# Checks availability.
url_exists $TEST_URL
NUM_ATTEMPTS=$((NUM_ATTEMPTS+1))
# If couldn't find a valid URL between the tested dates, fails.
else
echo "ERROR: Couldn't find a valid URL to download drake binaries."
exit 1
fi
done
fi

# Downloads drake binary and untars it into the install directory.
curl $TEST_URL | tar xvz -C `pwd`/install --strip 1

mkdir -p build

Expand Down
1 change: 1 addition & 0 deletions tools/continuous_integration/jenkins/setup_early
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ sudo apt-key adv --keyserver hkp://ha.pool.sks-keyservers.net:80 --recv-key 421C
sudo apt-get update -qq
sudo apt-get install -y --no-install-recommends $(tr '\n' ' ' <<EOF
awscli
curl
git
libignition-cmake-dev
mercurial
Expand Down

0 comments on commit 3617cc2

Please sign in to comment.