provision: Don't run migrations on `zulip` db in CircleCI.

The automated tests running in CircleCI don't actually use the `zulip`
db, so we can skip running migrations on it in some CircleCI shards to
save time.

NOTE: This only effects build jobs that run provision, except the
`production-build` job where we skip building the dbs altogether.
Migrations still run on `focal-backend` build job to ensure
we are testing all our development setup code.
This commit is contained in:
Aman Agrawal 2020-05-18 20:49:15 +05:30
parent c7e39ef090
commit 6950d8d769
4 changed files with 27 additions and 4 deletions

View File

@ -45,7 +45,7 @@ aliases:
rm -f /home/circleci/.gitconfig
# This is the main setup job for the test suite
mispipe "tools/ci/setup-backend 2>&1" ts
mispipe "tools/ci/setup-backend --skip-dev-db-build" ts
# Cleaning caches is mostly unnecessary in Circle, because
# most builds don't get to write to the cache.
@ -236,6 +236,9 @@ jobs:
- *save_cache_requirements
- *save_emoji_cache
- *run_backend_tests
- run:
name: Check development database build
command: mispipe "tools/ci/setup-backend" ts
- *notify_failure_status
"xenial-legacy":

View File

@ -6,7 +6,7 @@ set -x
# Provisioning may fail due to many issues but most of the times a network
# connection issue is the reason. So we are going to retry entire provisioning
# once again if that fixes our problem.
tools/provision || {
tools/provision "$@" 2>&1 || {
ret=$?
if [ "$ret" = 1 ]; then
echo "\`provision\`: Something went wrong with the provisioning, might be a network issue, Retrying to provision..."

View File

@ -425,6 +425,7 @@ def main(options: argparse.Namespace) -> "NoReturn":
provision_inner,
*(["--force"] if options.is_force else []),
*(["--build-release-tarball-only"] if options.is_build_release_tarball_only else []),
*(["--skip-dev-db-build"] if options.skip_dev_db_build else []),
],
)
@ -440,5 +441,10 @@ if __name__ == "__main__":
default=False,
help="Provision needed to build release tarball.")
parser.add_argument('--skip-dev-db-build', action='store_true',
dest='skip_dev_db_build',
default=False,
help="Don't run migrations on dev database.")
options = parser.parse_args()
main(options)

View File

@ -253,8 +253,17 @@ def main(options: argparse.Namespace) -> int:
dev_template_db_status = DEV_DATABASE.template_status()
if options.is_force or dev_template_db_status == 'needs_rebuild':
run(["tools/setup/postgres-init-dev-db"])
run(["tools/rebuild-dev-database"])
DEV_DATABASE.write_new_db_digest()
if options.skip_dev_db_build:
# We don't need to build the manual development
# database on CircleCI for running tests, so we can
# just leave it as a template db and save a minute.
#
# Important: We don't write a digest as that would
# incorrectly claim that we ran migrations.
pass
else:
run(["tools/rebuild-dev-database"])
DEV_DATABASE.write_new_db_digest()
elif dev_template_db_status == 'run_migrations':
DEV_DATABASE.run_db_migrations()
elif dev_template_db_status == 'current':
@ -327,5 +336,10 @@ if __name__ == "__main__":
default=False,
help="Provision for test suite with production settings.")
parser.add_argument('--skip-dev-db-build', action='store_true',
dest='skip_dev_db_build',
default=False,
help="Don't run migrations on dev database.")
options = parser.parse_args()
sys.exit(main(options))