Exemplo n.º 1
0
def fetch_remote():
    step('Updating git remote...')
    env.box_idx = '' if len(
        env.hosts) < 2 else '-%d' % (env.hosts.index(env.host_string) + 1)

    with settings(warn_only=True):
        run_local('git fetch %(box_remote)s%(box_idx)s')
Exemplo n.º 2
0
def fetch_remote():
    step("Updating git remote...")
    env.box_idx = ("" if len(env.hosts) < 2 else "-%d" %
                   (env.hosts.index(env.host_string) + 1))

    with settings(warn_only=True):
        run_local("git fetch %(box_remote)s%(box_idx)s")
Exemplo n.º 3
0
def deploy():
    """Checks whether everything is ready for deployment"""

    step("Checking whether we are on the expected branch...")
    with settings(warn_only=True), hide("everything"):
        branch = run_local("git symbolic-ref -q --short HEAD", capture=True)

    if not branch:
        abort(red("No branch checked out, cannot continue.", bold=True))

    if branch != env.box_branch:
        puts(
            red("Warning: The currently checked out branch is '%s', but"
                " the environment '%s' runs on '%s'." %
                (branch, env.box_environment, env.box_branch)))

        if not confirm("Continue deployment?", default=False):
            abort("Aborting.")

    execute("check.check")
    execute("check.test")

    with cd("%(box_domain)s"):
        step("\nChecking for uncommitted changes on the server...")
        result = run("git status --porcelain")
        if result:
            abort(red("Uncommitted changes detected, aborting deployment."))
Exemplo n.º 4
0
def _do_deploy(args=()):
    with cd("%(box_domain)s"):
        run('find . -name "*.pyc" -delete')
        run("venv/bin/pip install -U pip wheel setuptools")
        run("venv/bin/pip install -r requirements.txt")
        run("venv/bin/python manage.py migrate --noinput")

    step("\nUploading static files...")
    rsync_project(
        local_dir="static/",
        remote_dir="%(box_domain)s/static/" % env,
        delete=("clear" in args),
    )

    step("\nCollecting static files...")
    with cd("%(box_domain)s"):
        run("venv/bin/python manage.py collectstatic --noinput")

    step("\nRunning system checks on server...")
    with cd("%(box_domain)s"):
        run("venv/bin/python manage.py check --deploy")

    step("\nRestarting server process...")
    execute("server.restart")

    execute("git.fetch_remote")
Exemplo n.º 5
0
def deploy():
    """Checks whether everything is ready for deployment"""

    step('Checking whether we are on the expected branch...')
    with settings(warn_only=True), hide('everything'):
        branch = run_local('git symbolic-ref -q --short HEAD', capture=True)

    if not branch:
        abort(red('No branch checked out, cannot continue.', bold=True))

    if branch != env.box_branch:
        puts(
            red('Warning: The currently checked out branch is \'%s\', but'
                ' the environment \'%s\' runs on \'%s\'.' %
                (branch, env.box_environment, env.box_branch)))

        if not confirm('Continue deployment?', default=False):
            abort('Aborting.')

    step('\nChecking whether we are up to date...')
    run_local('git push --dry-run origin %(box_branch)s')

    execute('check.check')
    execute('check.test')

    with cd('%(box_domain)s'):
        step('\nChecking for uncommitted changes on the server...')
        result = run('git status --porcelain')
        if result:
            abort(red('Uncommitted changes detected, aborting deployment.'))
Exemplo n.º 6
0
def direct():
    """Deploys code directly, most useful when Bitbucket is down"""
    execute("check.deploy")

    step("\nCompiling static sources...")
    run_local("yarn run prod")

    step("\nPushing changes...")
    run_local("git push %(box_remote)s %(box_branch)s:refs/heads/DIRECTDEPLOY")

    step("\nDeploying new code on server...")
    with cd("%(box_domain)s"):
        run("git merge --ff-only DIRECTDEPLOY")

    _do_deploy()

    run_local("git push %(box_remote)s :refs/heads/DIRECTDEPLOY")
    step("\nPLEASE do not forget to push to the source repository anyway!")
Exemplo n.º 7
0
def deploy(*args):
    """Deploys frontend and backend code to the server if the checking step
    did not report any problems"""
    step("\nChecking whether we are up to date...")
    run_local("git push --dry-run origin %(box_branch)s")

    execute("check.deploy")

    step("\nCompiling static sources...")
    run_local("yarn run prod")

    step("\nPushing changes...")
    run_local("git push --all origin %(box_branch)s")

    step("\nDeploying new code on server...")
    with cd("%(box_domain)s"):
        run("git fetch")
        run("git merge --ff-only origin/%(box_branch)s")

    _do_deploy(args)
Exemplo n.º 8
0
def test():
    step("\nRunning the test suite...")
    for cmd in env["box_test"]:
        run_local(cmd)
Exemplo n.º 9
0
def check():
    """Runs coding style checks, and Django's checking framework"""
    step("\nRunning coding style checks...")
    for cmd in env["box_check"]:
        run_local(cmd)
Exemplo n.º 10
0
def deploy(*args):
    """Deploys frontend and backend code to the server if the checking step
    did not report any problems"""
    execute('check.deploy')

    step('\nCompiling static sources...')
    run_local('yarn run prod')

    step('\nPushing changes...')
    run_local('git push origin %(box_branch)s')

    step('\nDeploying new code on server...')
    with cd('%(box_domain)s'):
        run('git fetch')
        run('git reset --hard origin/%(box_branch)s')
        run('find . -name "*.pyc" -delete')
        run('venv/bin/pip install -r requirements.txt')
        run('venv/bin/python manage.py migrate --noinput')

    step('\nUploading static files...')
    rsync_project(
        local_dir='static/',
        remote_dir='%(box_domain)s/static/' % env,
        delete=('clear' in args),
    )

    step('\nCollecting static files...')
    with cd('%(box_domain)s'):
        run('venv/bin/python manage.py collectstatic --noinput')

    step('\nRunning system checks on server...')
    with cd('%(box_domain)s'):
        run('venv/bin/python manage.py check --deploy')

    step('\nRestarting server process...')
    for line in env['box_restart']:
        run(line)

    execute('git.fetch_remote')