[feat] adding-tox-testing
- tox commands - docs update Change-Id: Ie6caa498d6017822e095ee5b001124074e2755aa
This commit is contained in:
parent
978ab7481b
commit
d17485f8b9
@ -109,7 +109,7 @@ class ChartBuilder(object):
|
||||
|
||||
try:
|
||||
chart_yaml = dotify(
|
||||
yaml.load(
|
||||
yaml.safe_load(
|
||||
open(os.path.join(self.source_directory, 'Chart.yaml'))
|
||||
.read()))
|
||||
except Exception:
|
||||
|
@ -1,10 +1,25 @@
|
||||
# Copyright 2017 The Armada Authors.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
from os import path
|
||||
import os
|
||||
import requests
|
||||
import shutil
|
||||
import tarfile
|
||||
import tempfile
|
||||
import shutil
|
||||
|
||||
from git import Repo
|
||||
from os import path
|
||||
|
||||
from ..exceptions import source_exceptions
|
||||
|
||||
@ -20,7 +35,7 @@ def git_clone(repo_url, branch='master'):
|
||||
raise source_exceptions.GitLocationException(repo_url)
|
||||
|
||||
os.environ['GIT_TERMINAL_PROMPT'] = '0'
|
||||
_tmp_dir = tempfile.mkdtemp(prefix='armada', dir='/tmp')
|
||||
_tmp_dir = tempfile.mkdtemp(prefix='armada')
|
||||
|
||||
try:
|
||||
Repo.clone_from(repo_url, _tmp_dir, **{'branch': branch})
|
||||
@ -38,7 +53,7 @@ def download_tarball(tarball_url):
|
||||
Downloads a tarball to /tmp and returns the path
|
||||
'''
|
||||
try:
|
||||
tarball_filename = tempfile.mkstemp(prefix='armada', dir='/tmp')[1]
|
||||
tarball_filename = tempfile.mkstemp(prefix='armada')[1]
|
||||
response = requests.get(tarball_url)
|
||||
with open(tarball_filename, 'wb') as f:
|
||||
f.write(response.content)
|
||||
@ -53,7 +68,7 @@ def extract_tarball(tarball_path):
|
||||
if not path.exists(tarball_path):
|
||||
raise source_exceptions.InvalidPathException(tarball_path)
|
||||
|
||||
_tmp_dir = tempfile.mkdtemp(prefix='armada', dir='/tmp')
|
||||
_tmp_dir = tempfile.mkdtemp(prefix='armada')
|
||||
|
||||
try:
|
||||
file = tarfile.open(tarball_path)
|
||||
|
@ -36,7 +36,17 @@ From the directory of the forked repository:
|
||||
|
||||
pip install -r requirements.txt
|
||||
pip install -r test-requirements.txt
|
||||
pip install -e .
|
||||
|
||||
pip install .
|
||||
|
||||
# Testing your armada code
|
||||
# The tox command will execute lint, bandit, cover
|
||||
tox
|
||||
|
||||
# For targeted test
|
||||
tox -e pep8
|
||||
tox -e bandit
|
||||
tox -e cover
|
||||
|
||||
.. note::
|
||||
|
||||
|
17
setup.py
17
setup.py
@ -1,22 +1,5 @@
|
||||
from setuptools.command.test import test as TestCommand
|
||||
import sys
|
||||
import setuptools
|
||||
|
||||
class Tox(TestCommand):
|
||||
"""Runs Tox comands"""
|
||||
def finalize_options(self):
|
||||
"""preps test suite"""
|
||||
TestCommand.finalize_options(self)
|
||||
self.test_args = []
|
||||
self.test_suite = True
|
||||
|
||||
def run_tests(self):
|
||||
"""runs test suite"""
|
||||
import tox
|
||||
errcode = tox.cmdline(self.test_args)
|
||||
sys.exit(errcode)
|
||||
|
||||
|
||||
try:
|
||||
import multiprocessing # noqa
|
||||
except ImportError:
|
||||
|
@ -10,3 +10,5 @@ nose==1.3.7
|
||||
testtools==2.3.0
|
||||
codecov
|
||||
mock
|
||||
bandit
|
||||
pytest==3.2.1
|
||||
|
41
tox.ini
41
tox.ini
@ -1,26 +1,47 @@
|
||||
[tox]
|
||||
envlist = py27
|
||||
skipsdist = True
|
||||
envlist = py27, pep8, coverage, bandit
|
||||
|
||||
[testenv]
|
||||
deps=
|
||||
-r{toxinidir}/requirements.txt
|
||||
-r{toxinidir}/test-requirements.txt
|
||||
setenv=
|
||||
PYTHONWARNINGS=all
|
||||
VIRTUAL_ENV={envdir}
|
||||
usedevelop = True
|
||||
commands =
|
||||
find . -type f -name "*.pyc" -delete
|
||||
python -V
|
||||
py.test -vvv -s --ignore=hapi
|
||||
|
||||
[testenv:docs]
|
||||
commands = python setup.py build_sphinx
|
||||
commands =
|
||||
python setup.py build_sphinx
|
||||
|
||||
[testenv:genconfig]
|
||||
commands = oslo-config-generator --config-file=etc/armada/config-generator.conf
|
||||
commands =
|
||||
oslo-config-generator --config-file=etc/armada/config-generator.conf
|
||||
|
||||
[testenv:lint]
|
||||
commands = flake8 .
|
||||
[testenv:pep8]
|
||||
deps=
|
||||
{[testenv]deps}
|
||||
commands =
|
||||
flake8 {posargs}
|
||||
|
||||
[testenv:testing]
|
||||
commands = nosetest -w armada
|
||||
[testenv:bandit]
|
||||
deps = .[bandit]
|
||||
commands =
|
||||
bandit -r armada -x armada/tests -n 5
|
||||
|
||||
[flake8] #TODO: Remove E402
|
||||
ignore=E302,H306,E402,W503
|
||||
[testenv:coverage]
|
||||
deps=
|
||||
{[testenv]deps}
|
||||
|
||||
commands =
|
||||
nosetests -w armada/tests/unit --cover-package=armada --with-coverage --cover-tests --exclude=.tox
|
||||
|
||||
[flake8]
|
||||
filename= *.py
|
||||
ignore = W503,E302
|
||||
exclude= .git, .idea, .tox, *.egg-info, *.eggs, bin, dist, hapi
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user