forked from yadt/yadtshell
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.py
149 lines (118 loc) · 5.58 KB
/
build.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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
# YADT - an Augmented Deployment Tool
# Copyright (C) 2010-2014 Immobilien Scout GmbH
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
import glob
import os
import shutil
from pybuilder.core import use_plugin, init, Author, task
from pybuilder.utils import assert_can_execute
use_plugin('python.core')
use_plugin('python.integrationtest')
use_plugin('python.install_dependencies')
use_plugin('python.unittest')
use_plugin('python.coverage')
use_plugin('python.flake8')
use_plugin('python.frosted')
use_plugin('pypi:pybuilder_jedi_plugin')
use_plugin('python.distutils')
use_plugin('copy_resources')
use_plugin('filter_resources')
authors = [Author('Arne Hilmann', '[email protected]'),
Author('Marcel Wolf', '[email protected]'),
Author('Maximilien Riehl', '[email protected]')]
description = """YADT - an Augmented Deployment Tool - The Shell Part
- regards the dependencies between services, over different hosts
- updates artefacts in a safe manner
- issues multiple commands in parallel on several hosts
for more documentation, visit http://www.yadt-project.org/
"""
name = 'yadtshell'
license = 'GNU GPL v3'
summary = 'YADT - an Augmented Deployment Tool - The Shell Part'
url = 'https://github.com/yadt/yadtshell'
version = '1.9.1'
default_task = ['clean', 'analyze', 'publish']
@init
def set_properties(project):
project.depends_on('hostexpand')
project.depends_on('Twisted')
project.depends_on('PyYAML')
project.depends_on('simplejson')
project.depends_on('docopt')
project.build_depends_on('shtub')
project.build_depends_on('mock')
project.set_property('integrationtest_parallel', True)
project.set_property('integrationtest_cpu_scaling_factor', 8)
project.set_property('integrationtest_inherit_environment', True)
project.set_property('flake8_verbose_output', True)
project.set_property('flake8_include_test_sources', True)
project.set_property('flake8_ignore', 'E501')
project.set_property('flake8_break_build', True)
FROSTED_BARE_EXCEPT_WARNING = 'W101'
project.set_property('frosted_ignore', [FROSTED_BARE_EXCEPT_WARNING])
project.set_property('verbose', True)
project.set_property('coverage_threshold_warn', 50)
project.set_property('coverage_break_build', False)
project.rpm_release = '0'
project.install_file('share/man/man1/', 'docs/man/yadtshell.1.man.gz')
project.set_property('copy_resources_target', '$dir_dist')
project.get_property('copy_resources_glob').extend(['setup.cfg', 'docs/man/yadtshell.1.man.gz'])
project.get_property('filter_resources_glob').extend(['**/yadtshell/__init__.py',
'**/scripts/yadtshell',
'**/setup.cfg'])
project.set_property('dir_dist_scripts', 'scripts')
project.get_property('distutils_commands').append('bdist_egg')
project.set_property('distutils_classifiers', [
'Development Status :: 4 - Beta',
'Environment :: Console',
'Intended Audience :: Developers',
'Intended Audience :: System Administrators',
'License :: OSI Approved :: GNU General Public License (GPL)',
'Programming Language :: Python',
'Topic :: System :: Networking',
'Topic :: System :: Software Distribution',
'Topic :: System :: Systems Administration'
])
@init(environments='teamcity')
def set_properties_for_teamcity_builds(project):
import os
project.set_property('teamcity_output', True)
project.version = '%s-%s' % (project.version, os.environ.get('BUILD_NUMBER', 0))
project.default_task = ['clean', 'install_build_dependencies', 'publish']
project.set_property('install_dependencies_index_url', os.environ.get('PYPIPROXY_URL'))
project.set_property('install_dependencies_use_mirrors', False)
project.rpm_release = os.environ.get('RPM_RELEASE', 0)
@task
def clean(project, logger):
clean_up("/tmp/logs/yadtshell/*", "yadtshell log", logger)
clean_up("/tmp/integration-test*", "yadtshell integration test", logger)
clean_up("/tmp/yadtshell-it", "yadtshell integration test stubs", logger)
clean_up("~/.yadtshell", "yadtshell state", logger)
def clean_up(path_or_glob, name, logger):
if "*" in path_or_glob:
directories_to_clean = glob.glob(path_or_glob)
else:
directories_to_clean = [os.path.expanduser(path_or_glob)]
for directory_to_clean in directories_to_clean:
if not os.path.exists(directory_to_clean):
continue
logger.info("Removing {0} directory: {1}".format(name, directory_to_clean))
shutil.rmtree(directory_to_clean)
@task
def generate_manpage_with_pandoc(project, logger):
assert_can_execute(['pandoc', '-v'], 'pandoc', 'generate_manpage_with_pandoc')
import subprocess
subprocess.check_output('pandoc -s -t man man-yadtshell.md -o docs/man/yadtshell.1.man', shell=True)
subprocess.check_output('rm -f docs/man/yadtshell.1.man.gz && gzip -9 docs/man/yadtshell.1.man', shell=True)