File tree Expand file tree Collapse file tree 5 files changed +43
-3
lines changed
Expand file tree Collapse file tree 5 files changed +43
-3
lines changed Original file line number Diff line number Diff line change @@ -34,6 +34,10 @@ branches:
3434 - master
3535
3636before_install :
37+ # Travis does shallow clones, so there is no master branch present.
38+ # But test-no-outdated-migrations.sh needs to check diffs against master.
39+ # Fetch just the master branch from origin.
40+ - git fetch origin master
3741 # Github-PR-Status secret
3842 - openssl aes-256-cbc -K $encrypted_53b2630f0fb4_key -iv $encrypted_53b2630f0fb4_iv -in test/github-secret.json.enc -out test/github-secret.json -d || true
3943
Original file line number Diff line number Diff line change @@ -178,6 +178,10 @@ check_gofmt() {
178178run_and_comment check_gofmt
179179end_context # test/gofmt
180180
181+ start_context " test/migrations"
182+ run_and_comment ./test/test-no-outdated-migrations.sh
183+ end_context " test/migrations"
184+
181185if [ " ${TRAVIS} " == " true" ]; then
182186 ./test/create_db.sh || die " unable to create the boulder database with test/create_db.sh"
183187fi
Original file line number Diff line number Diff line change 11# Common variables used by Goose-related scripts.
2- set -o errexit
3- set -o xtrace
4-
52function die() {
63 if [ ! -z " $1 " ]; then
74 echo $1 > /dev/stderr
Original file line number Diff line number Diff line change 33# Run this script after pulling changes that have migrations, to migrate your
44# local DB.
55#
6+ set -o errexit
7+ set -o xtrace
68cd $( dirname $0 ) /..
79
810source test/db-common.sh
Original file line number Diff line number Diff line change 1+ #! /bin/bash
2+ cd $( dirname $0 ) /..
3+ if [ ! -d .git ]; then
4+ echo " Not in a git repository, skipping out-of-order migration test."
5+ fi
6+
7+ source test/db-common.sh
8+
9+ NEW_FILES_LIST=$( mktemp)
10+ trap ' rm ${NEW_FILES_LIST}' EXIT
11+
12+ for svc in $SERVICES ; do
13+ for dbenv in $DBENVS ; do
14+ DB_DIR=$svc /_db/
15+ git diff --name-only master -- ${DB_DIR} > ${NEW_FILES_LIST}
16+ # Search for files in the migrations directory match the new files or come
17+ # lexically after them, then filter out the new files.
18+ GREP_OUT=" $( ls ${DB_DIR} migrations/* | sort | \
19+ grep -A 1 -xf ${NEW_FILES_LIST} | \
20+ grep -vxf ${NEW_FILES_LIST} ) "
21+ if [ -n " ${GREP_OUT} " ] ; then
22+ echo " --- New migrations on this branch: ---"
23+ cat $NEW_FILES_LIST
24+ echo " --- Existing migrations on master: ---"
25+ echo " ${GREP_OUT} "
26+ echo
27+ echo " All migrations on a branch must be timestamped newer than"
28+ echo " migrations on master before they can be merged. Please"
29+ echo " rename migrations as appropriate."
30+ exit 1
31+ fi
32+ done
33+ done
You can’t perform that action at this time.
0 commit comments