From 4158663e9a653ced8db76541beaad333a3590268 Mon Sep 17 00:00:00 2001 From: Rohan Mitchell Date: Thu, 16 Apr 2015 16:18:42 +1000 Subject: [PATCH 1/2] Pushing to production saves staging baseline data --- script/push_to_production.sh | 5 +++++ script/save_staging_baseline.sh | 20 ++++++++++++++++++++ 2 files changed, 25 insertions(+) create mode 100644 script/save_staging_baseline.sh diff --git a/script/push_to_production.sh b/script/push_to_production.sh index b4e374d744..72fa2a5edc 100755 --- a/script/push_to_production.sh +++ b/script/push_to_production.sh @@ -2,9 +2,14 @@ set -e +# Add production git remote if required PROD_TEST=`git remote | grep -s 'production' || true` if [[ "$PROD_TEST" != *production* ]]; then git remote add production ubuntu@ofn-prod:apps/openfoodweb/current fi +echo "--- Saving baseline data for staging" +ssh ofn-staging2 "/home/openfoodweb/apps/openfoodweb/current/script/save_staging_baseline.sh $BUILDKITE_COMMIT" + +echo "--- Pushing to production" [[ $(git push production $BUILDKITE_COMMIT:master --force 2>&1) =~ "Done" ]] diff --git a/script/save_staging_baseline.sh b/script/save_staging_baseline.sh new file mode 100644 index 0000000000..9fcc6c373b --- /dev/null +++ b/script/save_staging_baseline.sh @@ -0,0 +1,20 @@ +#!/bin/bash + +# Every time staging is deployed, we load a baseline data set before running the new code's +# migrations. This script saves a new baseline data set for that purpose. + +# This script is called remotely on a push to production. We only want to save a new baseline +# if the code in staging is identical to that in production. To accomplish that, we take the +# production commit SHA as a parameter ($1) and only perform the save if the SHA matches the +# current code checked out. + +set -e + +cd /home/openfoodweb/apps/openfoodweb/current +if [[ `git rev-parse HEAD` == $1 ]]; then + mkdir -p db/backup + pg_dump -h localhost -U openfoodweb openfoodweb_production |gzip > db/backup/staging-baseline.sql.gz + echo "Staging baseline data saved." +else + echo "Staging SHA does not match production, we will not save staging baseline data." +fi From 692e58e8f74b59d6e1df9bd67955a800c1cab2bc Mon Sep 17 00:00:00 2001 From: Rohan Mitchell Date: Tue, 21 Apr 2015 10:52:14 +1000 Subject: [PATCH 2/2] Output spec-by-spec results to track specs-hanging-at-90-percent issue --- script/run_tests.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/script/run_tests.sh b/script/run_tests.sh index 9082a79190..72d895c04e 100755 --- a/script/run_tests.sh +++ b/script/run_tests.sh @@ -15,4 +15,4 @@ echo "--- Preparing test database" bundle exec rake db:test:prepare echo "--- Running tests" -bundle exec rspec spec +bundle exec rspec spec -f d