#!/bin/sh
# Usage: script/cibuild
# CI build script
#
set -e

# GC customizations
export RUBY_GC_MALLOC_LIMIT=79000000
export RUBY_GC_HEAP_INIT_SLOTS=800000
export RUBY_HEAP_FREE_MIN=100000
export RUBY_HEAP_SLOTS_INCREMENT=400000
export RUBY_HEAP_SLOTS_GROWTH_FACTOR=1

export PATH="/usr/share/rbenv/shims:$PATH"
export RACK_ROOT=$(cd "$(dirname $0)"/.. && pwd)
export RACK_ENV="test"
export RAILS_ENV="test"
export RBENV_VERSION="2.2.3"

# clean out the ruby environment
export RUBYLIB=
export RUBYOPT=

export CI="true"

if [ -d /usr/local/share/nodenv ]; then
  export NODENV_ROOT=/usr/local/share/nodenv
  export PATH=/usr/local/share/nodenv/bin:/usr/local/share/nodenv/shims:$PATH
  export NODENV_VERSION="v0.10.21"
  export NPM_VERSION="2.8.3"
fi

echo "==> Fetching config..."
echo "NodeJS version:    ${NODENV_VERSION}"
echo "NPM version:       ${NPM_VERSION}"
echo "PATH:              ${PATH}"
echo ""

script/test
