Created
May 16, 2017 09:34
-
-
Save carlosipe/bbafa0b1d8c4a3b5035f6b8b33f622d4 to your computer and use it in GitHub Desktop.
Hawkins config
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| setsid ./bin/hawkins-build.sh & | |
| sleep 1 | |
| BUILD_PID=`cat $HAWKINS_BUILD_PATH/hawkins-build.pid` | |
| BUILD_PGID=$(ps -o pgid= $BUILD_PID | grep -o '[0-9]*') | |
| echo "HAWKFILE PID: $$" | |
| echo "HAWKFILE PGID: $(ps -o pgid= $$ | grep -o '[0-9]*')" | |
| echo "BUILD_PID: $BUILD_PID" | |
| echo "BUILD_PGID: $BUILD_PGID" | |
| trap 'kill -15 -- -$BUILD_PGID; sleep 30; kill -9 -- -$BUILD_PGID; false' SIGINT SIGTERM | |
| wait $BUILD_PID |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash -e | |
| shopt -s globstar | |
| set -o pipefail | |
| echo "HAWKINS: Starting build" | |
| echo "HAWKINS: Path: $HAWKINS_BUILD_PATH" | |
| echo "HAWKINS: Host: $HOSTNAME" | |
| echo "HAWKINS: PID: $$" | |
| echo $$ > "$HAWKINS_BUILD_PATH/hawkins-build.pid" | |
| export TMPDIR=$PWD/tmp | |
| export PGPORT=$(($RANDOM+1024)) | |
| export PGDATA=$TMPDIR/pgdata | |
| # set environment | |
| export PATH=$PATH:/usr/lib/postgresql/9.3/bin/ | |
| export TZ=Europe/Madrid | |
| export RAILS_ENV=test | |
| export WORKER_COUNT=8 | |
| # This is the expected env var to contain the current build index in concurrent test builds, used by simplecov to correctly merge results | |
| export TEST_ENV_NUMBER=$PARALLEL_SEQ | |
| # Tune ruby to maximize memory usage and lower GC runs | |
| export RUBY_GC_MALLOC_LIMIT=90000000 | |
| export RUBY_GC_HEAP_INIT_SLOTS=15150000 | |
| # rspec profile path | |
| export PROFILE_PATH=$HAWKINS_CACHE_PATH/profiles | |
| mkdir -p $PROFILE_PATH | |
| # traps | |
| export HAWKINS_CLEANUP_SCRIPT='pg_ctl -s -m fast -w -D $PGDATA stop; sudo umount $TMPDIR; rm -fR $HAWKINS_BUILD_PATH' | |
| trap "echo 'HAWKINS: Signal received. Aborting, but cleaning up first.'; $HAWKINS_CLEANUP_SCRIPT; false" SIGINT SIGTERM | |
| trap "echo 'HAWKINS: Build finished. Cleaning up.'; $HAWKINS_CLEANUP_SCRIPT; true" EXIT | |
| # env info | |
| echo "HAWKINS: Ruby: `ruby --version`" | |
| echo "HAWKINS: PhantomJS: `phantomjs --version`" | |
| # create a tmp build dir | |
| mkdir -p $TMPDIR | |
| sudo mount -t tmpfs -o defaults,noatime,nosuid,nodev,noexec,size=2500m tmpfs $TMPDIR | |
| # copy configuration | |
| mv config/secrets_example.yml config/secrets.yml | |
| mv config/database_hawkins.yml config/database.yml | |
| # symlink upload paths to tmpfs | |
| mkdir -p $TMPDIR/system | |
| ln -nfs $TMPDIR/system $PWD/public/system | |
| mkdir -p $TMPDIR/uploads | |
| ln -nfs $TMPDIR/uploads $PWD/public/uploads | |
| # symlink phantomjs cache dir to tmpfs | |
| mkdir -p $TMPDIR/phantom_cache | |
| rm -rf ~/.qws/cache | |
| ln -nfs $TMPDIR/phantom_cache ~/.qws/cache | |
| # start an in-memory postgres instance | |
| mkdir -p $PGDATA | |
| pg_ctl -s -w init -D $PGDATA -o "-A trust" | |
| pg_ctl -s -w -D $PGDATA start -o '-c deadlock_timeout=15000 -c fsync=off -c synchronous_commit=off -c full_page_writes=off -c checkpoint_segments=16 -c unix_socket_directories=$TMPDIR -c max_connections=240' | |
| # bundle and run specs | |
| bundle install --quiet --jobs=8 --retry=3 --without development production | |
| mkdir -p $HAWKINS_CACHE_PATH/assets | |
| mkdir -p $HAWKINS_CACHE_PATH/sprockets_cache | |
| mkdir -p $PWD/tmp/cache | |
| ln -s $HAWKINS_CACHE_PATH/assets $PWD/public/assets | |
| ln -s $HAWKINS_CACHE_PATH/sprockets_cache $PWD/tmp/cache/assets | |
| RAILS_ENV=test RAILS_GROUPS=assets bundle exec rake db:create assets:precompile | |
| # ./bin/prepare-specs --report | |
| ./bin/prepare-specs | parallel -j $WORKER_COUNT --ctrlc -k --delay 10 -uX 'bundle exec rake db:create db:test:prepare && bundle exec rspec --color --tty --require rspec/instafail --format RSpec::Instafail --format json --out $PROFILE_PATH/$HAWKINS_BUILD-$PARALLEL_SEQ.json' | |
| FAILED_JOBS_COUNT=$? | |
| echo "HAWKINS: $FAILED_JOBS_COUNT jobs failed." | |
| if [ $FAILED_JOBS_COUNT != 0 ] || [ $HAWKINS_BRANCH != 'develop' ] ; then | |
| rm -r $PROFILE_PATH/$HAWKINS_BUILD* | |
| fi | |
| exit $FAILED_JOBS_COUNT |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment