mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-24 20:36:49 +00:00
Merge branch 'master' into single-order-patches
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
[](http://ci.openfood.com.au:8080/job/openfoodweb%20-%20tests/)
|
||||
[](https://buildkite.com/open-food-foundation/open-food-network)
|
||||
[](https://codeclimate.com/github/openfoodfoundation/openfoodnetwork)
|
||||
|
||||
# Open Food Network
|
||||
|
||||
@@ -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
13
script/ci/includes.sh
Normal 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
|
||||
}
|
||||
26
script/ci/load_staging_baseline.sh
Executable file
26
script/ci/load_staging_baseline.sh
Executable 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!"
|
||||
10
script/ci/merge_branch_to_master.sh
Executable file
10
script/ci/merge_branch_to_master.sh
Executable 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
|
||||
@@ -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
19
script/ci/push_to_staging.sh
Executable 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
16
script/ci/run_js_tests.sh
Executable 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
19
script/ci/run_tests.sh
Executable 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
|
||||
0
script/save_staging_baseline.sh → script/ci/save_staging_baseline.sh
Normal file → Executable file
0
script/save_staging_baseline.sh → script/ci/save_staging_baseline.sh
Normal file → Executable file
0
script/delayed_job.sh
Normal file → Executable file
0
script/delayed_job.sh
Normal file → Executable file
0
script/prepare_imported_db.rb
Normal file → Executable file
0
script/prepare_imported_db.rb
Normal file → Executable 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" ]]
|
||||
@@ -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
|
||||
Reference in New Issue
Block a user