From 3dee29cd124f72b7ce802c4cbfa10aea041be7ec Mon Sep 17 00:00:00 2001 From: Rohan Mitchell Date: Wed, 6 May 2015 19:37:21 +1000 Subject: [PATCH 1/6] Remove build badge - master branch is always green --- README.markdown | 1 - 1 file changed, 1 deletion(-) diff --git a/README.markdown b/README.markdown index f43856daf6..b9aaf8193c 100644 --- a/README.markdown +++ b/README.markdown @@ -1,4 +1,3 @@ -[![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 From d109e898d281d5add8882d88e0988298cfbed3ae Mon Sep 17 00:00:00 2001 From: Rohan Mitchell Date: Wed, 6 May 2015 19:38:20 +1000 Subject: [PATCH 2/6] Preserve newlines when displaying deploy script output --- script/ci/push_to_production.sh | 2 +- script/ci/push_to_staging.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/script/ci/push_to_production.sh b/script/ci/push_to_production.sh index 8a8d4bf318..1666368e08 100755 --- a/script/ci/push_to_production.sh +++ b/script/ci/push_to_production.sh @@ -13,5 +13,5 @@ ssh ofn-staging2 "/home/openfoodweb/apps/openfoodweb/current/script/ci/save_stag echo "--- Pushing to production" output=$(git push production $BUILDKITE_COMMIT:master --force 2>&1) -echo $output +echo "$output" [[ $output =~ "Done" ]] diff --git a/script/ci/push_to_staging.sh b/script/ci/push_to_staging.sh index 0a5a11235a..a38cda0c1b 100755 --- a/script/ci/push_to_staging.sh +++ b/script/ci/push_to_staging.sh @@ -17,5 +17,5 @@ ssh ofn-staging2 "/home/openfoodweb/apps/openfoodweb/current/script/ci/load_stag echo "--- Pushing to staging" output=$(git push staging2 $BUILDKITE_COMMIT:master --force 2>&1) -echo $output +echo "$output" [[ $output =~ "Done" ]] From 6d33dc5070db0f20d205e8ffcc4158741986f2a7 Mon Sep 17 00:00:00 2001 From: Rohan Mitchell Date: Wed, 6 May 2015 19:41:36 +1000 Subject: [PATCH 3/6] Add script to merge master into the current branch if required before running specs --- script/ci/includes.sh | 7 +++++++ script/ci/merge_master_into_branch.sh | 12 ++++++++++++ 2 files changed, 19 insertions(+) create mode 100755 script/ci/merge_master_into_branch.sh diff --git a/script/ci/includes.sh b/script/ci/includes.sh index ee59a732d7..d7619f7d23 100644 --- a/script/ci/includes.sh +++ b/script/ci/includes.sh @@ -12,6 +12,13 @@ function exit_unless_master_merged { fi } +function succeed_if_master_merged { + if [[ `git branch -a --merged origin/$BUILDKITE_BRANCH` == *origin/master* ]]; then + echo "This branch already has the current master merged." + exit 0 + fi +} + function drop_and_recreate_database { # Adapted from: http://stackoverflow.com/questions/12924466/capistrano-with-postgresql-error-database-is-being-accessed-by-other-users psql -U openfoodweb postgres < Date: Wed, 6 May 2015 19:50:06 +1000 Subject: [PATCH 4/6] Add debugging to merge script --- script/ci/merge_branch_to_master.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/script/ci/merge_branch_to_master.sh b/script/ci/merge_branch_to_master.sh index 6e40ed4ef9..3eaae17d56 100755 --- a/script/ci/merge_branch_to_master.sh +++ b/script/ci/merge_branch_to_master.sh @@ -1,6 +1,6 @@ #!/bin/bash -set -e +set -ex source ./script/ci/includes.sh echo "--- Verifying branch is based on current master" From 50d2ddc05f68c3965793a21c64a30a4ce664c4fd Mon Sep 17 00:00:00 2001 From: Rohan Mitchell Date: Wed, 6 May 2015 20:00:50 +1000 Subject: [PATCH 5/6] Add progress comments --- script/ci/merge_master_into_branch.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/script/ci/merge_master_into_branch.sh b/script/ci/merge_master_into_branch.sh index ebbafd865c..a5e05c7759 100755 --- a/script/ci/merge_master_into_branch.sh +++ b/script/ci/merge_master_into_branch.sh @@ -3,8 +3,10 @@ set -e source ./script/ci/includes.sh +echo "--- Checking if master has already been merged" succeed_if_master_merged +echo "--- Merging master into this branch" git checkout $BUILDKITE_BRANCH git merge origin/$BUILDKITE_BRANCH git merge origin/master -m "Auto-merge from CI [skip ci]" From bd6bac887455b30545e610e306739be545d8ebd0 Mon Sep 17 00:00:00 2001 From: Rohan Mitchell Date: Wed, 6 May 2015 20:02:03 +1000 Subject: [PATCH 6/6] Display deployment output in real time This reverts commit 485eee4bddae4d4f9251eba618b913d11945f75a. --- script/ci/push_to_production.sh | 6 ++---- script/ci/push_to_staging.sh | 6 ++---- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/script/ci/push_to_production.sh b/script/ci/push_to_production.sh index 1666368e08..00ade0af07 100755 --- a/script/ci/push_to_production.sh +++ b/script/ci/push_to_production.sh @@ -1,6 +1,6 @@ #!/bin/bash -set -e +set -ex # Add production git remote if required PROD_TEST=`git remote | grep -s 'production' || true` @@ -12,6 +12,4 @@ echo "--- Saving baseline data for staging" ssh ofn-staging2 "/home/openfoodweb/apps/openfoodweb/current/script/ci/save_staging_baseline.sh $BUILDKITE_COMMIT" echo "--- Pushing to production" -output=$(git push production $BUILDKITE_COMMIT:master --force 2>&1) -echo "$output" -[[ $output =~ "Done" ]] +[[ $(git push production $BUILDKITE_COMMIT:master --force 2>&1) =~ "Done" ]] diff --git a/script/ci/push_to_staging.sh b/script/ci/push_to_staging.sh index a38cda0c1b..c634ca53a4 100755 --- a/script/ci/push_to_staging.sh +++ b/script/ci/push_to_staging.sh @@ -1,6 +1,6 @@ #!/bin/bash -set -e +set -ex source ./script/ci/includes.sh # Add staging git remote if required @@ -16,6 +16,4 @@ echo "--- Loading baseline data" ssh ofn-staging2 "/home/openfoodweb/apps/openfoodweb/current/script/ci/load_staging_baseline.sh" echo "--- Pushing to staging" -output=$(git push staging2 $BUILDKITE_COMMIT:master --force 2>&1) -echo "$output" -[[ $output =~ "Done" ]] +[[ $(git push staging2 $BUILDKITE_COMMIT:master --force 2>&1) =~ "Done" ]]