Fix and improve flake8 test.
Previously the 'flake8' command was running but didn't seem to check out something in all cases. - This patch decouples the 'ansible-lint' and the 'flake8' sections into separated 'testenv'. - And this patch fixes all the 'flake8' issues. Change-Id: I30169598d086515121175ca322882ee00f05b913 Signed-off-by: Gael Chamoulaud <gchamoul@redhat.com>
This commit is contained in:
parent
e0df5f7108
commit
619c512594
|
@ -1,4 +1,16 @@
|
||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
|
# 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.
|
||||||
|
|
||||||
DOCUMENTATION = '''
|
DOCUMENTATION = '''
|
||||||
---
|
---
|
||||||
|
@ -40,8 +52,6 @@ EXAMPLES = '''
|
||||||
import json
|
import json
|
||||||
import logging
|
import logging
|
||||||
import re
|
import re
|
||||||
import sys
|
|
||||||
|
|
||||||
import requests
|
import requests
|
||||||
|
|
||||||
# we ignore any other host reference
|
# we ignore any other host reference
|
||||||
|
@ -131,7 +141,8 @@ def get_details(host, change_id, branch, revision):
|
||||||
|
|
||||||
|
|
||||||
def resolve_dep(host, change_id, branch, revision):
|
def resolve_dep(host, change_id, branch, revision):
|
||||||
'''
|
'''Dependency resolution.
|
||||||
|
|
||||||
Resolve the dependencies in the target commits until there are no more
|
Resolve the dependencies in the target commits until there are no more
|
||||||
dependent changes. If the branch or revision is None, it can still resolve
|
dependent changes. If the branch or revision is None, it can still resolve
|
||||||
the dependencies. It only uses the branch when the change_id is ambigiuous
|
the dependencies. It only uses the branch when the change_id is ambigiuous
|
||||||
|
@ -141,6 +152,7 @@ def resolve_dep(host, change_id, branch, revision):
|
||||||
project to be added to the output list.
|
project to be added to the output list.
|
||||||
|
|
||||||
Returns a list of dictionaries with the dependent changes.
|
Returns a list of dictionaries with the dependent changes.
|
||||||
|
|
||||||
'''
|
'''
|
||||||
resolved_ids = []
|
resolved_ids = []
|
||||||
deps = []
|
deps = []
|
||||||
|
|
|
@ -1,4 +1,16 @@
|
||||||
#!/usr/bin/env python
|
#!/usr/bin/python
|
||||||
|
# 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.
|
||||||
|
|
||||||
DOCUMENTATION = '''
|
DOCUMENTATION = '''
|
||||||
---
|
---
|
||||||
|
@ -24,7 +36,6 @@ EXAMPLES = '''
|
||||||
changes: "openstack/tripleo-heat-templates:master:refs/changes/88/296488/1^openstack/instack-undercloud:master:refs/changes/84/315184/5"
|
changes: "openstack/tripleo-heat-templates:master:refs/changes/88/296488/1^openstack/instack-undercloud:master:refs/changes/84/315184/5"
|
||||||
'''
|
'''
|
||||||
|
|
||||||
import sys
|
|
||||||
|
|
||||||
def process(host, changes):
|
def process(host, changes):
|
||||||
"""Process the changes from Zuul format"""
|
"""Process the changes from Zuul format"""
|
||||||
|
|
|
@ -1,4 +1,16 @@
|
||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
|
# 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.
|
||||||
|
|
||||||
DOCUMENTATION = '''
|
DOCUMENTATION = '''
|
||||||
---
|
---
|
||||||
|
@ -40,8 +52,6 @@ EXAMPLES = '''
|
||||||
import json
|
import json
|
||||||
import logging
|
import logging
|
||||||
import re
|
import re
|
||||||
import sys
|
|
||||||
|
|
||||||
import requests
|
import requests
|
||||||
|
|
||||||
# we ignore any other host reference
|
# we ignore any other host reference
|
||||||
|
@ -131,7 +141,8 @@ def get_details(host, change_id, branch, revision):
|
||||||
|
|
||||||
|
|
||||||
def resolve_dep(host, change_id, branch, revision):
|
def resolve_dep(host, change_id, branch, revision):
|
||||||
'''
|
'''Dependency resolution.
|
||||||
|
|
||||||
Resolve the dependencies in the target commits until there are no more
|
Resolve the dependencies in the target commits until there are no more
|
||||||
dependent changes. If the branch or revision is None, it can still resolve
|
dependent changes. If the branch or revision is None, it can still resolve
|
||||||
the dependencies. It only uses the branch when the change_id is ambigiuous
|
the dependencies. It only uses the branch when the change_id is ambigiuous
|
||||||
|
@ -142,6 +153,7 @@ def resolve_dep(host, change_id, branch, revision):
|
||||||
|
|
||||||
Returns a list of dictionaries with the dependent changes.
|
Returns a list of dictionaries with the dependent changes.
|
||||||
'''
|
'''
|
||||||
|
|
||||||
resolved_ids = []
|
resolved_ids = []
|
||||||
deps = []
|
deps = []
|
||||||
to_resolve = [{'host': host,
|
to_resolve = [{'host': host,
|
||||||
|
|
|
@ -1,23 +1,22 @@
|
||||||
#!/usr/bin/python
|
#!/usr/bin/python
|
||||||
#coding: utf-8 -*-
|
# coding: utf-8 -*-
|
||||||
|
#
|
||||||
# (c) 2016, Mathieu Bultel <mbultel@redhat.com>
|
# (c) 2016, Mathieu Bultel <mbultel@redhat.com>
|
||||||
# (c) 2016, Steve Baker <sbaker@redhat.com>
|
# (c) 2016, Steve Baker <sbaker@redhat.com>
|
||||||
#
|
#
|
||||||
# This module is free software: you can redistribute it and/or modify
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
# it under the terms of the GNU General Public License as published by
|
# you may not use this file except in compliance with the License.
|
||||||
# the Free Software Foundation, either version 3 of the License, or
|
# You may obtain a copy of the License at
|
||||||
# (at your option) any later version.
|
|
||||||
#
|
#
|
||||||
# This software is distributed in the hope that it will be useful,
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
# 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
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
# along with this software. If not, see <http://www.gnu.org/licenses/>.
|
# 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 time import sleep
|
|
||||||
from distutils.version import StrictVersion
|
from distutils.version import StrictVersion
|
||||||
try:
|
try:
|
||||||
import shade
|
import shade
|
||||||
|
@ -152,6 +151,7 @@ stack:
|
||||||
'updated_time': null}"
|
'updated_time': null}"
|
||||||
'''
|
'''
|
||||||
|
|
||||||
|
|
||||||
def _create_stack(module, stack, cloud):
|
def _create_stack(module, stack, cloud):
|
||||||
try:
|
try:
|
||||||
stack = cloud.create_stack(module.params['name'],
|
stack = cloud.create_stack(module.params['name'],
|
||||||
|
@ -167,10 +167,11 @@ def _create_stack(module, stack, cloud):
|
||||||
return stack
|
return stack
|
||||||
else:
|
else:
|
||||||
return False
|
return False
|
||||||
module.fail_json(msg = "Failure in creating stack: ".format(stack))
|
module.fail_json(msg="Failure in creating stack: ".format(stack))
|
||||||
except shade.OpenStackCloudException as e:
|
except shade.OpenStackCloudException as e:
|
||||||
module.fail_json(msg=str(e))
|
module.fail_json(msg=str(e))
|
||||||
|
|
||||||
|
|
||||||
def _update_stack(module, stack, cloud):
|
def _update_stack(module, stack, cloud):
|
||||||
try:
|
try:
|
||||||
stack = cloud.update_stack(
|
stack = cloud.update_stack(
|
||||||
|
@ -184,11 +185,12 @@ def _update_stack(module, stack, cloud):
|
||||||
if stack['stack_status'] == 'UPDATE_COMPLETE':
|
if stack['stack_status'] == 'UPDATE_COMPLETE':
|
||||||
return stack
|
return stack
|
||||||
else:
|
else:
|
||||||
module.fail_json(msg = "Failure in updating stack: %s" %
|
module.fail_json(msg="Failure in updating stack: %s" %
|
||||||
stack['stack_status_reason'])
|
stack['stack_status_reason'])
|
||||||
except shade.OpenStackCloudException as e:
|
except shade.OpenStackCloudException as e:
|
||||||
module.fail_json(msg=str(e))
|
module.fail_json(msg=str(e))
|
||||||
|
|
||||||
|
|
||||||
def _system_state_change(module, stack, cloud):
|
def _system_state_change(module, stack, cloud):
|
||||||
state = module.params['state']
|
state = module.params['state']
|
||||||
if state == 'present':
|
if state == 'present':
|
||||||
|
@ -198,6 +200,7 @@ def _system_state_change(module, stack, cloud):
|
||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
|
|
||||||
argument_spec = openstack_full_argument_spec(
|
argument_spec = openstack_full_argument_spec(
|
||||||
|
@ -255,8 +258,9 @@ def main():
|
||||||
except shade.OpenStackCloudException as e:
|
except shade.OpenStackCloudException as e:
|
||||||
module.fail_json(msg=str(e))
|
module.fail_json(msg=str(e))
|
||||||
|
|
||||||
|
|
||||||
from ansible.module_utils.basic import *
|
from ansible.module_utils.basic import *
|
||||||
from ansible.module_utils.openstack import *
|
from ansible.module_utils.openstack import *
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
main()
|
main()
|
||||||
|
|
||||||
|
|
|
@ -1,20 +1,20 @@
|
||||||
#!/usr/bin/python
|
#!/usr/bin/python
|
||||||
# coding: utf-8 -*-
|
# coding: utf-8 -*-
|
||||||
|
#
|
||||||
# (c) 2016, Adriano Petrich <apetrich@redhat.com>
|
# (c) 2016, Adriano Petrich <apetrich@redhat.com>
|
||||||
#
|
#
|
||||||
# This module is free software: you can redistribute it and/or modify
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
# it under the terms of the GNU General Public License as published by
|
# you may not use this file except in compliance with the License.
|
||||||
# the Free Software Foundation, either version 3 of the License, or
|
# You may obtain a copy of the License at
|
||||||
# (at your option) any later version.
|
|
||||||
#
|
#
|
||||||
# This software is distributed in the hope that it will be useful,
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
# 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
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
# along with this software. If not, see <http://www.gnu.org/licenses/>.
|
# 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.
|
||||||
|
|
||||||
DOCUMENTATION = '''
|
DOCUMENTATION = '''
|
||||||
---
|
---
|
||||||
|
|
37
tox.ini
37
tox.ini
|
@ -8,6 +8,7 @@ usedevelop = True
|
||||||
install_command = pip install -U {opts} {packages}
|
install_command = pip install -U {opts} {packages}
|
||||||
setenv = VIRTUAL_ENV={envdir}
|
setenv = VIRTUAL_ENV={envdir}
|
||||||
deps = -r{toxinidir}/test-requirements.txt
|
deps = -r{toxinidir}/test-requirements.txt
|
||||||
|
whitelist_externals = bash
|
||||||
|
|
||||||
[testenv:bindep]
|
[testenv:bindep]
|
||||||
# Do not install any requirements. We want this to be fast and work even if
|
# Do not install any requirements. We want this to be fast and work even if
|
||||||
|
@ -20,25 +21,45 @@ commands = bindep test
|
||||||
[testenv:docs]
|
[testenv:docs]
|
||||||
commands = python setup.py build_sphinx
|
commands = python setup.py build_sphinx
|
||||||
|
|
||||||
[testenv:linters]
|
[testenv:pep8]
|
||||||
basepython=python2
|
commands =
|
||||||
whitelist_externals = bash
|
# Run hacking/flake8 check for all python files
|
||||||
|
bash -c "grep --recursive --binary-files=without-match \
|
||||||
|
--files-with-match '^.!.*python$' \
|
||||||
|
--exclude-dir .tox \
|
||||||
|
--exclude-dir .git \
|
||||||
|
--exclude-dir .eggs \
|
||||||
|
--exclude-dir *.egg-info \
|
||||||
|
--exclude-dir dist \
|
||||||
|
--exclude-dir *lib/python* \
|
||||||
|
--exclude-dir doc \
|
||||||
|
{toxinidir} | xargs flake8 --verbose"
|
||||||
|
|
||||||
|
[testenv:ansible-lint]
|
||||||
|
basepython=python2
|
||||||
commands =
|
commands =
|
||||||
flake8
|
|
||||||
bash ci-scripts/ansible-lint.sh
|
bash ci-scripts/ansible-lint.sh
|
||||||
|
|
||||||
[testenv:releasenotes]
|
[testenv:releasenotes]
|
||||||
whitelist_externals = bash
|
whitelist_externals = bash
|
||||||
commands = bash -c ci-scripts/releasenotes_tox.sh
|
commands = bash -c ci-scripts/releasenotes_tox.sh
|
||||||
|
|
||||||
|
[testenv:linters]
|
||||||
|
commands =
|
||||||
|
{[testenv:pep8]commands}
|
||||||
|
{[testenv:ansible-lint]commands}
|
||||||
|
|
||||||
[testenv:venv]
|
[testenv:venv]
|
||||||
commands = {posargs}
|
commands = {posargs}
|
||||||
|
|
||||||
[flake8]
|
[flake8]
|
||||||
# E123, E125 skipped as they are invalid PEP-8.
|
# E123, E125 skipped as they are invalid PEP-8.
|
||||||
|
# E402 module level import not at top of file
|
||||||
|
# E501 line too long
|
||||||
|
# F403 'from ansible.module_utils.basic import *' used; unable to detect undefined names
|
||||||
|
# H303 No wildcard (*) import
|
||||||
|
# H301 one import per line
|
||||||
|
# F405 ... may be undefined, or defined from star imports:
|
||||||
show-source = True
|
show-source = True
|
||||||
ignore = E123,E125
|
ignore = E123,E125,E402,E501,F403,H303,H301,F405
|
||||||
builtins = _
|
builtins = _
|
||||||
# TODO(adarazs): reenable flake8 checks on roles after fixing them up
|
|
||||||
exclude=.venv,.git,.tox,dist,doc,*lib/python*,*egg,build,roles
|
|
||||||
|
|
Loading…
Reference in New Issue