-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfabfile.py
More file actions
59 lines (44 loc) · 1.59 KB
/
fabfile.py
File metadata and controls
59 lines (44 loc) · 1.59 KB
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
import os
import sys
from fabric.api import env, lcd, local, require, settings, task
# Build directory name
env.build_dir = '_build'
# Base path to the project
env.base_path = os.path.dirname(__file__)
# Base path of the django application
env.project_path = os.path.join(env.base_path, 'jadfr')
env.build_path = os.path.join(env.base_path, env.build_dir)
@task
def staging():
env.environment = 'staging'
@task
def production():
env.environment = 'production'
@task
def vagrant():
env.environment = 'local'
@task
def deploy():
require('environment')
@task
def test():
"""
Run the tests and create a coverage report
"""
with lcd(env.project_path):
pytest_xml_file = os.path.join(env.build_path, 'pytest.xml')
with settings(warn_only=True):
# Remove old coverage results
local('coverage erase')
# default directory for html test coverage report files
html_report_dir = os.path.join(env.build_path, 'htmlcov')
coverage_file = os.path.join(env.build_path, 'coverage.xml')
pytest_result = local('coverage run --source=\'.\' --rcfile=../coveragerc'
' -m py.test --junitxml=%s -x' % pytest_xml_file)
local('coverage html --rcfile=../coveragerc -d %s' % html_report_dir)
local('coverage xml --rcfile=../coveragerc -o %s' % coverage_file)
# Remove coverage results
local('coverage erase')
return_code = int(pytest_result.return_code)
if return_code > 0:
sys.exit(return_code)