Merge branch 'master' into single-order-patches

This commit is contained in:
Maikel Linke
2015-04-23 12:11:44 +10:00
14 changed files with 106 additions and 31 deletions

View File

@@ -1,4 +1,4 @@
[![Build Status](http://ci.openfood.com.au:8080/buildStatus/icon?job=openfoodweb - tests)](http://ci.openfood.com.au:8080/job/openfoodweb%20-%20tests/)
[![Build status](https://badge.buildkite.com/e18473fffac95ed2735ca75700673bd301cac5cffc64de821a.svg?branch=master)](https://buildkite.com/open-food-foundation/open-food-network)
[![Code Climate](https://codeclimate.com/github/openfoodfoundation/openfoodnetwork.png)](https://codeclimate.com/github/openfoodfoundation/openfoodnetwork)
# Open Food Network

View File

@@ -42,7 +42,7 @@ module.exports = function(config) {
autoWatch: true,
browsers: ['Chrome'],
browsers: ['PhantomJS'],
junitReporter: {
outputFile: 'log/testacular-unit.xml',

13
script/ci/includes.sh Normal file
View File

@@ -0,0 +1,13 @@
function load_environment {
source /var/lib/jenkins/.rvm/environments/ruby-1.9.3-p392
if [ ! -f config/application.yml ]; then
ln -s application.yml.example config/application.yml
fi
}
function exit_unless_master_merged {
if [[ `git branch -a --merged origin/$BUILDKITE_BRANCH` != *origin/master* ]]; then
echo "This branch does not have the current master merged. Please merge master and push again."
exit 1
fi
}

View File

@@ -0,0 +1,26 @@
#!/bin/bash
# Every time staging is deployed, we load a baseline data set before running the new code's
# migrations. This script loads the baseline data set, after first taking a backup of the
# current database.
set -e
cd /home/openfoodweb/apps/openfoodweb/current
echo "Stopping unicorn..."
service unicorn_openfoodweb stop
echo "Backing up current data..."
mkdir -p db/backup
pg_dump -h localhost -U openfoodweb openfoodweb_production |gzip > db/backup/staging-`date +%Y%m%d%H%M%S`.sql.gz
echo "Loading baseline data..."
dropdb -U openfoodweb -w openfoodweb_production
createdb -U openfoodweb -w openfoodweb_production
gunzip -c db/backup/staging-baseline.sql.gz |psql -h localhost -U openfoodweb openfoodweb_production
echo "Restarting unicorn..."
service unicorn_openfoodweb start
echo "Done!"

View File

@@ -0,0 +1,10 @@
#!/bin/bash
set -e
source ./script/ci/includes.sh
echo "--- Verifying branch is based on current master"
exit_unless_master_merged
echo "--- Pushing branch"
echo git push origin $BUILDKITE_COMMIT:master

View File

@@ -9,7 +9,7 @@ if [[ "$PROD_TEST" != *production* ]]; then
fi
echo "--- Saving baseline data for staging"
ssh ofn-staging2 "/home/openfoodweb/apps/openfoodweb/current/script/save_staging_baseline.sh $BUILDKITE_COMMIT"
ssh ofn-staging2 "/home/openfoodweb/apps/openfoodweb/current/script/ci/save_staging_baseline.sh $BUILDKITE_COMMIT"
echo "--- Pushing to production"
[[ $(git push production $BUILDKITE_COMMIT:master --force 2>&1) =~ "Done" ]]

19
script/ci/push_to_staging.sh Executable file
View File

@@ -0,0 +1,19 @@
#!/bin/bash
set -e
source ./script/ci/includes.sh
# Add staging git remote if required
ST2_TEST=`git remote | grep -s 'staging2' || true`
if [[ "$ST2_TEST" != *staging2* ]]; then
git remote add staging2 openfoodweb@ofn-staging2:apps/openfoodweb/current
fi
echo "--- Verifying branch is based on current master"
exit_unless_master_merged
echo "--- Loading baseline data"
ssh ofn-staging2 "/home/openfoodweb/apps/openfoodweb/current/script/ci/load_staging_baseline.sh"
echo "--- Pushing to staging"
[[ $(git push staging2 $BUILDKITE_COMMIT:master --force 2>&1) =~ "Done" ]]

16
script/ci/run_js_tests.sh Executable file
View File

@@ -0,0 +1,16 @@
#!/bin/bash
set -e
echo "--- Loading environment"
source ./script/ci/includes.sh
load_environment
echo "--- Verifying branch is based on current master"
exit_unless_master_merged
echo "--- Bundling"
bundle install
echo "--- Running tests"
bundle exec rake karma:run

19
script/ci/run_tests.sh Executable file
View File

@@ -0,0 +1,19 @@
#!/bin/bash
set -e
echo "--- Loading environment"
source ./script/ci/includes.sh
load_environment
echo "--- Verifying branch is based on current master"
exit_unless_master_merged
echo "--- Bundling"
bundle install
echo "--- Loading test database"
bundle exec rake db:test:load
echo "--- Running tests"
bundle exec rspec spec --format progress

View File

0
script/delayed_job.sh Normal file → Executable file
View File

0
script/prepare_imported_db.rb Normal file → Executable file
View File

View File

@@ -1,10 +0,0 @@
#!/bin/bash
set -e
ST2_TEST=`git remote | grep -s 'staging2' || true`
if [[ "$ST2_TEST" != *staging2* ]]; then
git remote add staging2 openfoodweb@ofn-staging2:apps/openfoodweb/current
fi
[[ $(git push staging2 $BUILDKITE_COMMIT:master --force 2>&1) =~ "Done" ]]

View File

@@ -1,18 +0,0 @@
#!/bin/bash
set -e
echo "--- Loading environment"
source /var/lib/jenkins/.rvm/environments/ruby-1.9.3-p392
if [ ! -f config/application.yml ]; then
ln -s application.yml.example config/application.yml
fi
echo "--- Bundling"
bundle install
echo "--- Preparing test database"
bundle exec rake db:test:prepare
echo "--- Running tests"
bundle exec rspec spec -f d