Files

77 lines
2.2 KiB
Python
Raw Permalink Normal View History

2017-11-07 09:23:57 +01:00
from invoke import run, task
2017-12-19 15:18:35 +01:00
import os
2017-11-07 09:23:57 +01:00
@task
def install(ctx):
run('pip install -r requirements.txt')
run('pip install -r requirements.test.txt')
run('bundle')
run('npm i')
@task
def test(ctx):
run('nosetests')
test_js_ci(ctx)
@task
def test_ci(ctx):
2017-11-21 17:11:29 +01:00
run('nosetests --nologcapture --with-xunit --xunit-file $CIRCLE_TEST_REPORTS/nosetests.xml')
test_js_ci(ctx)
2017-11-07 09:23:57 +01:00
def test_js_ci(ctx):
2017-11-21 17:11:29 +01:00
run('./node_modules/.bin/karma start spec/javascripts/karma.config.js')
2017-11-07 09:23:57 +01:00
@task
def test_js(ctx):
run('./node_modules/.bin/karma start spec/javascripts/karma.config.js')
@task
def update_version(ctx):
run('echo "import os\n\n\ndef version():\n if os.getenv(\'VERSION\'):\n return os.getenv(\'VERSION\')\n return \'$(git describe --tags)\'" > helix/constants/version.py')
2017-12-19 15:18:35 +01:00
2017-11-07 09:23:57 +01:00
@task
def serve(ctx):
2017-12-19 15:18:35 +01:00
run('SP_DOCGEN_API_KEY=DC97-20AF-567E gunicorn -c gunicorn_config.py --pythonpath helix main:app')
2017-11-07 09:23:57 +01:00
@task
def update_heroku_version(ctx, environment):
run('curl -n -X PATCH https://api.heroku.com/apps/sp-helix-%s/config-vars -d "{\\"VERSION\\": \\"$(git describe --tags)\\"}" -H "Content-Type: application/json" -H "Accept: application/vnd.heroku+json; version=3"' % environment)
@task
def db_migrate(ctx):
run('PYTHONPATH=.:$PYTHONPATH alembic upgrade head')
@task
def serve_debug(ctx):
run('PYTHONPATH=. FLASK_DEBUG=1 SP_DOCGEN_API_KEY=DC97-20AF-567E python helix/main.py')
2017-12-19 15:18:35 +01:00
@task
def db_diagram(ctx):
db_uri = os.getenv('DATABASE_URL', 'postgres://pivotal:@localhost:5432/pivotal')
run('eralchemy -i "{}" -o documentation/db_schema.png -x temp audit'.format(db_uri))
@task
def classes_diagrams(ctx):
run('pyreverse -k -o calculators-diagram.png helix/calculators')
run('pyreverse -k -o constants-diagram.png helix/constants')
run('pyreverse -k -o forms-diagram.png helix/forms')
run('pyreverse -k -o models-diagram.png helix/models')
run('pyreverse -k -o validators-diagram.png helix/validators')
run('rm -rf packages*.png ; mv classes.*-diagram.png documentation/')
@task
def serve_ssl(ctx):
run('FLASK_DEBUG_SSL=true PORT=8443 PYTHONPATH=. FLASK_DEBUG=1 SP_DOCGEN_API_KEY=DC97-20AF-567E python helix/main.py')