forked from ARPA-SIMC/arkimaps
-
Notifications
You must be signed in to change notification settings - Fork 0
/
fabfile.py
72 lines (51 loc) · 1.6 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
from __future__ import print_function
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from fabric.api import local, run, cd, env, hosts
import git
import re
import os
from six.moves import shlex_quote
env.use_ssh_config = True
def cmd(*args):
return " ".join(shlex_quote(a) for a in args)
def push(host):
repo = git.Repo()
remote = repo.remote(host)
push_url = remote.config_reader.get("url")
remote_dir = re.sub(r"^ssh://[^/]+", "", push_url)
local(cmd("git", "push", host, "HEAD", "--force"))
with cd(remote_dir):
run(cmd("git", "reset", "--hard"))
run(cmd("git", "clean", "-fx"))
run(cmd("git", "checkout", "-B", "test_" + host, repo.head.commit.hexsha))
run(cmd("git", "clean", "-fx"))
def run_test(host):
push(host)
repo = git.Repo()
remote = repo.remote(host)
push_url = remote.config_reader.get("url")
remote_dir = re.sub(r"^ssh://[^/]+", "", push_url)
arkimet_run_local = os.path.join(remote_dir, "..", "arkimet", "run-local")
with cd(remote_dir):
run(cmd("mkdir", "-p", "testdata"))
run(cmd("tar", "-C", "testdata", "-axf", "../arkimaps-test-data.tar.xz"))
run(cmd(arkimet_run_local, "nose2-3.6"))
@hosts("trentuno")
def push_trentuno():
push("trentuno")
@hosts("trentadue")
def push_trentadue():
push("trentadue")
@hosts("otto")
def test_otto():
run_test("otto")
@hosts("trentuno")
def test_trentuno():
run_test("trentuno")
@hosts("trentadue")
def test_trentadue():
run_test("trentadue")
def test():
test_otto()