Skip to content

Commit

Permalink
Add --branch argument and make it easier to update osf repo
Browse files Browse the repository at this point in the history
Typical workflow will be to run

    inv test --update

In order to get up to date with the feature/postgres branch
  • Loading branch information
sloria committed Aug 4, 2016
1 parent 8b36d1b commit bcc4241
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 24 deletions.
34 changes: 17 additions & 17 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -18,44 +18,44 @@ First setup the tests. This only needs to be run once: ::

Run the tests: ::

inv tests
inv test

To update the osf.io repo used for testing: ::
To update the osf.io repo before testing: ::

inv setup_tests --update
inv test --update


Running Migrations
==================

To create/reset your database: ::

python manage.py reset_db --noinput
python manage.py reset_db --noinput

To migrate the defined schema to your database: ::

python manage.py migrate
python manage.py migrate

To migrate all models leaving their relationships empty: ::

python manage.py migrate_bare_objects
python manage.py migrate_bare_objects

To create foreign keys: ::
python manage.py migrate_foreign_keys

python manage.py migrate_foreign_keys

To create many to many relationships: ::

python manage.py migrate_m2m
python manage.py migrate_m2m

To verify nodes and users: ::

python manage.py verify_nodes_users
python manage.py verify_nodes_users

To create nodelogs: ::

python manage.py migrate_nodelogs
python manage.py migrate_nodelogs

To verify nodelogs: ::

python manage.py verify_nodelogs
python manage.py verify_nodelogs
17 changes: 10 additions & 7 deletions tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,20 @@
POSTGRES_BRANCH = 'feature/postgres'

@task
def setup_tests(ctx, update=False, requirements=True):
def setup_tests(ctx, update=False, requirements=True, branch=POSTGRES_BRANCH):
if update and os.path.exists('osf.io'):
ctx.run('rm -rf osf.io/', echo=True)
print('Cleaned up.')
first_run = False
if not os.path.exists('osf.io'):
first_run = True
# '--depth 1' excludes the history (for faster cloning)
ctx.run('git clone --branch={} {} --depth 1'.format(POSTGRES_BRANCH, OSF_GIT_URL), echo=True)
ctx.run('git clone --branch={} {} --depth 1'.format(branch, OSF_GIT_URL), echo=True)

os.chdir('osf.io')
if update and not first_run:
print('Updating osf.io ({})'.format(POSTGRES_BRANCH))
ctx.run('git pull origin {}'.format(POSTGRES_BRANCH), echo=True)
print('Updating osf.io ({})'.format(branch))
ctx.run('git pull origin {}'.format(branch), echo=True)
# Copy necessary local.py files
try:
copyfile(
Expand All @@ -45,10 +48,10 @@ def setup_tests(ctx, update=False, requirements=True):


@task
def test(ctx, setup=False):
def test(ctx, setup=False, update=False, requirements=True, branch=POSTGRES_BRANCH):
import pytest
if setup:
setup_tests(ctx)
if setup or update:
setup_tests(ctx, update=update, requirements=requirements, branch=branch)
if not os.path.exists('osf.io'):
print('Must run "inv setup_tests" before running tests.')
sys.exit(1)
Expand Down

0 comments on commit bcc4241

Please sign in to comment.