Skip to content

Commit 6f0298a

Browse files
committed
Merge pull request #55 from vrutkovs/travis-ci
Use Travis CI
2 parents cf68e65 + d77600e commit 6f0298a

9 files changed

+93
-61
lines changed

.travis.yml

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
sudo: false
2+
3+
language: python
4+
5+
python:
6+
- "2.7"
7+
8+
env:
9+
- TESTS="pyflakes"
10+
- TESTS="pep8"
11+
- TESTS="behave"
12+
13+
matrix:
14+
allow_failures:
15+
- env: TESTS="pep8"
16+
17+
before_install:
18+
- pip install pep8 pyflakes behave PyHamcrest python-coveralls nose --upgrade
19+
- python setup.py -q install
20+
- git clean -fdx
21+
22+
script:
23+
- case $TESTS in
24+
pep8) pep8 ctf-cli.py ctf_cli/* --ignore=E501,E225,E265,E402 --show-source --show-pep8 ;;
25+
pyflakes) pyflakes ctf-cli.py ctf_cli/* ;;
26+
behave) behave -t ~@xfail ;;
27+
esac
28+
29+
notifications:
30+
webhooks:
31+
urls:
32+
- https://webhooks.gitter.im/e/92b168ffacdc38a6facd
33+
on_success: change
34+
on_failure: always
35+
on_start: never
36+
37+
after_success:
38+
coveralls

circle.yml

-24
This file was deleted.

ctf-cli.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,4 @@
1919

2020
from ctf_cli.cli_runner import CliRunner
2121

22-
CliRunner.run()
22+
CliRunner.run()

ctf_cli/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,4 @@
1414
# GNU General Public License for more details.
1515
#
1616
# You should have received a copy of the GNU General Public License
17-
# along with this program. If not, see <http://www.gnu.org/licenses/>.
17+
# along with this program. If not, see <http://www.gnu.org/licenses/>.

ctf_cli/application.py

+9-5
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ def init(self):
100100
with open(steps_py_file, "w") as f:
101101
f.write(common_steps_py_content)
102102
check_call("git add %s" % steps_py_file, shell=True)
103-
103+
104104
# Copy sample configuration
105105
ctf_conf_file = os.path.join(self._execution_dir_path, "ctf.conf")
106106
if os.path.exists(ctf_conf_file):
@@ -113,21 +113,24 @@ def init(self):
113113
check_call("git add %s" % ctf_conf_file, shell=True)
114114

115115
def add_remote(self):
116-
if 'feature' in self._cli_conf.get(CTFCliConfig.GLOBAL_SECTION_NAME, CTFCliConfig.CONFIG_REMOTE_TYPE):
116+
if 'feature' in self._cli_conf.get(
117+
CTFCliConfig.GLOBAL_SECTION_NAME, CTFCliConfig.CONFIG_REMOTE_TYPE):
117118
self.add_remote_feature()
118119
else:
119120
self.add_remote_step()
120121

121122
def add_remote_feature(self):
122-
project = self._cli_conf.get(CTFCliConfig.GLOBAL_SECTION_NAME, CTFCliConfig.CONFIG_REMOTE_PROJECT)
123+
project = self._cli_conf.get(
124+
CTFCliConfig.GLOBAL_SECTION_NAME, CTFCliConfig.CONFIG_REMOTE_PROJECT)
123125
if project is None:
124126
path = "tests/features/"
125127
else:
126128
path = "tests/features/" + project
127129
self.add_submodule(path)
128130

129131
def add_remote_step(self):
130-
project = self._cli_conf.get(CTFCliConfig.GLOBAL_SECTION_NAME, CTFCliConfig.CONFIG_REMOTE_PROJECT)
132+
project = self._cli_conf.get(
133+
CTFCliConfig.GLOBAL_SECTION_NAME, CTFCliConfig.CONFIG_REMOTE_PROJECT)
131134
if project is None:
132135
path = "tests/steps/"
133136
else:
@@ -159,7 +162,8 @@ def run(self):
159162
check_call("git submodule update --init", shell=True)
160163

161164
# TODO: Remove this or rework, once more types are implemented
162-
if self._cli_conf.get(CTFCliConfig.GLOBAL_SECTION_NAME, CTFCliConfig.CONFIG_EXEC_TYPE) != 'ansible':
165+
if self._cli_conf.get(
166+
CTFCliConfig.GLOBAL_SECTION_NAME, CTFCliConfig.CONFIG_EXEC_TYPE) != 'ansible':
163167
raise CTFCliError("Wrong ExecType configured. Currently only 'ansible' is supported!")
164168

165169
self._working_dir = BehaveWorkingDirectory(self._working_dir_path, self._cli_conf)

ctf_cli/arguments_parser.py

+18-15
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@ class ArgumentsParser(object):
2424

2525
def __init__(self, args=None):
2626
""" parse arguments """
27-
self.parser = argparse.ArgumentParser(description='CLI for running Containers Testing Framework')
27+
self.parser = argparse.ArgumentParser(
28+
description='CLI for running Containers Testing Framework')
2829
self.subparsers = self.parser.add_subparsers(dest="cli_action")
2930
self.add_args()
3031
self.add_remote_subparser()
@@ -36,39 +37,42 @@ def __init__(self, args=None):
3637
def add_remote_add_subparser(self, subparser):
3738
subparser.add_argument(
3839
dest='remote_type',
39-
choices=['steps', 'features'],
40-
)
40+
choices=['steps', 'features'])
4141

4242
subparser.add_argument(
4343
dest='url',
44-
help='module url'
45-
)
46-
44+
help='module url')
45+
4746
subparser.add_argument(
4847
"--project",
4948
dest='project',
5049
help="name of test project")
5150

5251
def add_remote_remove_subparser(self, subparser):
5352
subparser.add_argument(
54-
dest='name'
55-
)
53+
dest='name')
5654

5755
def add_remote_subparser(self):
58-
remote_subparser=self.subparsers.add_parser('remote', help='addidng/removing test suites')
59-
remote_oper_subparser=remote_subparser.add_subparsers(dest='remote_action')
60-
self.add_remote_add_subparser(remote_oper_subparser.add_parser('add', help='add remote repository'))
61-
self.add_remote_remove_subparser(remote_oper_subparser.add_parser('remove', help='remove remote repository'))
56+
remote_subparser = self.subparsers.add_parser(
57+
'remote', help='addidng/removing test suites')
58+
remote_oper_subparser = remote_subparser.add_subparsers(
59+
dest='remote_action')
60+
self.add_remote_add_subparser(remote_oper_subparser.add_parser(
61+
'add', help='add remote repository'))
62+
self.add_remote_remove_subparser(remote_oper_subparser.add_parser(
63+
'remove', help='remove remote repository'))
6264
remote_oper_subparser.add_parser('list', help='list remote repositories')
6365

6466
def add_run_subparser(self):
65-
run_subparser=self.subparsers.add_parser('run', help="run test suite - default")
67+
run_subparser = self.subparsers.add_parser(
68+
'run', help="run test suite - default")
6669
run_subparser.add_argument(
6770
"-c",
6871
"--cli-config",
6972
default=None,
7073
dest='cli_config_path',
71-
help="Path to CLI configuration file (By default use only CLI arguments and default values)"
74+
help="Path to CLI configuration file" +
75+
"(By default use only CLI arguments and default values)"
7276
)
7377
run_subparser.add_argument(
7478
"-t",
@@ -116,7 +120,6 @@ def add_args(self):
116120
help="Output is more verbose (recommended)"
117121
)
118122

119-
120123
def __getattr__(self, name):
121124
try:
122125
return getattr(self.args, name)

ctf_cli/behave.py

+24-14
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,8 @@ def setup(self):
121121
"""
122122
self._check_working_dir()
123123

124-
if self._cli_conf.get(CTFCliConfig.GLOBAL_SECTION_NAME, CTFCliConfig.CONFIG_EXEC_TYPE) == 'ansible':
124+
if self._cli_conf.get(CTFCliConfig.GLOBAL_SECTION_NAME,
125+
CTFCliConfig.CONFIG_EXEC_TYPE) == 'ansible':
125126
self._create_ansible_config()
126127

127128
self._add_project_specific_features()
@@ -163,26 +164,31 @@ def _create_ansible_config(self):
163164
user = None
164165

165166
try:
166-
script = self._cli_conf.get(CTFCliConfig.ANSIBLE_SECTION_NAME, CTFCliConfig.CONFIG_ANSIBLE_DYNAMIC_SCRIPT)
167-
except NoSectionError as e:
167+
script = self._cli_conf.get(CTFCliConfig.ANSIBLE_SECTION_NAME,
168+
CTFCliConfig.CONFIG_ANSIBLE_DYNAMIC_SCRIPT)
169+
except NoSectionError:
168170
raise CTFCliError("No configuration for 'ansible' provided!")
169-
except NoOptionError as e:
171+
except NoOptionError:
170172
logger.debug("No dynamic provision script found")
171173
script = None
172174

173175
if not script:
174176
try:
175-
method = self._cli_conf.get(CTFCliConfig.ANSIBLE_SECTION_NAME, CTFCliConfig.CONFIG_ANSIBLE_METHOD)
176-
host = self._cli_conf.get(CTFCliConfig.ANSIBLE_SECTION_NAME, CTFCliConfig.CONFIG_ANSIBLE_HOST)
177-
user = self._cli_conf.get(CTFCliConfig.ANSIBLE_SECTION_NAME, CTFCliConfig.CONFIG_ANSIBLE_USER)
178-
179-
except NoOptionError as e:
177+
method = self._cli_conf.get(CTFCliConfig.ANSIBLE_SECTION_NAME,
178+
CTFCliConfig.CONFIG_ANSIBLE_METHOD)
179+
host = self._cli_conf.get(CTFCliConfig.ANSIBLE_SECTION_NAME,
180+
CTFCliConfig.CONFIG_ANSIBLE_HOST)
181+
user = self._cli_conf.get(CTFCliConfig.ANSIBLE_SECTION_NAME,
182+
CTFCliConfig.CONFIG_ANSIBLE_USER)
183+
184+
except NoOptionError:
180185
logger.debug("No dynamic provision script found")
181186

182187
# Optional parameters
183188
try:
184-
sudo = self._cli_conf.get(CTFCliConfig.ANSIBLE_SECTION_NAME, CTFCliConfig.CONFIG_ANSIBLE_SUDO)
185-
except NoOptionError as e:
189+
sudo = self._cli_conf.get(CTFCliConfig.ANSIBLE_SECTION_NAME,
190+
CTFCliConfig.CONFIG_ANSIBLE_SUDO)
191+
except NoOptionError:
186192
sudo = False
187193

188194
ansible_conf_path = None
@@ -196,15 +202,18 @@ def _create_ansible_config(self):
196202
host=host, method=method, user=user, sudo=sudo
197203
)
198204

199-
logger.debug("Writing ansible configuration to '%s'\n%s", ansible_conf_path, ansible_conf_content)
205+
logger.debug("Writing ansible configuration to '%s'\n%s",
206+
ansible_conf_path, ansible_conf_content)
200207
with open(ansible_conf_path, 'w') as f:
201208
f.write(ansible_conf_content)
202209

203210
self._exec_type_conf_path = ansible_conf_path
204211

205212
def _check_working_dir(self):
206213
"""
207-
Check if working directory exists. Remove it if it exists and then recreate. Create it if it does not exist
214+
Check if working directory exists.
215+
Remove it if it exists and then recreate.
216+
Create it if it does not exist
208217
"""
209218
if os.path.exists(self._working_dir):
210219
logger.debug("Working directory '%s' exists. Removing it!", self._working_dir)
@@ -227,7 +236,8 @@ def _add_project_specific_steps(self):
227236
shutil.copytree(project_steps_dir, self._steps_dir)
228237

229238
else:
230-
logger.warning("Not using project specific Steps. '%s' does not exist!", project_steps_dir)
239+
logger.warning("Not using project specific Steps. '%s' does not exist!",
240+
project_steps_dir)
231241

232242
def _add_project_specific_features(self):
233243
"""

ctf_cli/cli_runner.py

+1
Original file line numberDiff line numberDiff line change
@@ -70,5 +70,6 @@ def run():
7070
finally:
7171
logger.debug('Exiting...')
7272

73+
7374
def run():
7475
CliRunner.run()

ctf_cli/settings.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,4 @@
1717
# along with this program. If not, see <http://www.gnu.org/licenses/>.
1818

1919
DEFAULT_CONFIG_NAME = 'ctf.conf'
20-
DEBUG_LOG_FILE_NAME = 'ctf-debug.log'
20+
DEBUG_LOG_FILE_NAME = 'ctf-debug.log'

0 commit comments

Comments
 (0)