-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathfabfile.py
78 lines (61 loc) · 1.83 KB
/
fabfile.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
# vim: fileencoding=utf-8
__author__ = 'mirko'
import logging
import subprocess
import nose
from fabric.api import *
import jenkins_support
import hooks
require("jenkins_shell_user", used_for="accessing the host with sudo-rights.")
env.hosts = ["huschteguzzel.de"]
env.user = env.jenkins_shell_user
logging.basicConfig(level=logging.INFO, format="%(asctime)s:%(levelname)s:%(name)s:%(message)s")
logging.getLogger("dicttoxml").setLevel(logging.WARNING)
logging.getLogger("requests").setLevel(logging.WARNING)
logging.getLogger("paramiko").setLevel(logging.WARNING)
def revision():
if revision.rev is None:
revision.rev = subprocess.check_output(("git", "rev-parse", "--short", "--porcelain", "HEAD")).strip()
return revision.rev
revision.rev = None
def loggit(phase):
rev = revision()
def f():
logging.info("%s: '%s' on '%s' (%s)", phase, env.command, env.host, rev)
return f
myhook = hooks.add_hooks(pre=loggit("pre"), post=loggit("post"))
@task
@myhook
def apt_get_update():
"""
apt-get update -qq
"""
run("sudo /usr/bin/apt-get update -q")
@task
@myhook
def apt_get_upgrade():
"""
apt-get upgrade -q -y
"""
run("sudo /usr/bin/apt-get upgrade -q -y")
@task
@myhook
def upgrade():
"""
apt-get -q update && apt-get -q -y upgrade
"""
execute(apt_get_update)
execute(apt_get_upgrade)
@task
@myhook
def test(args=None):
"""
Run all unit tests and doctests.
Specify string argument ``args`` for additional args to ``nosetests``.
"""
# Default to explicitly targeting the 'tests' folder, but only if nothing
# is being overridden.
tests = "" if args else " tests"
default_args = "-sv --with-doctest --nologcapture --with-xunit %s" % tests
default_args += (" " + args) if args else ""
nose.core.run_exit(argv=[''] + default_args.split())