From e2b2669fdc225cf5041384a9986024b7cec1d0c0 Mon Sep 17 00:00:00 2001 From: Paul Belanger Date: Mon, 9 Jan 2017 14:27:46 -0500 Subject: [PATCH] Update tox.ini for openstack gate Also add missing .gitreview file. Change-Id: I25a115b8c03dc154905ab92262c736f6edbe6e72 Signed-off-by: Paul Belanger --- .gitreview | 4 ++++ bindep.txt | 9 +++++++++ tests/ansible.cfg | 2 +- tests/test.yaml | 2 +- tox.ini | 48 +++++++++++++++++++++++++++++------------------ 5 files changed, 45 insertions(+), 20 deletions(-) create mode 100644 .gitreview create mode 100644 bindep.txt diff --git a/.gitreview b/.gitreview new file mode 100644 index 0000000..fa701ed --- /dev/null +++ b/.gitreview @@ -0,0 +1,4 @@ +[gerrit] +host=review.openstack.org +port=29418 +project=openstack/ansible-role-sudoers.git diff --git a/bindep.txt b/bindep.txt new file mode 100644 index 0000000..0265648 --- /dev/null +++ b/bindep.txt @@ -0,0 +1,9 @@ +# This is a cross-platform list tracking distribution packages needed by tests; +# see http://docs.openstack.org/infra/bindep/ for additional information. + +libffi-devel [platform:rpm] +libffi-dev [platform:dpkg] +libselinux-python [platform:rpm] +libssl-dev [platform:dpkg] +openssl-devel [platform:rpm] +python2-dnf [platform:fedora] diff --git a/tests/ansible.cfg b/tests/ansible.cfg index 2d4c5f9..6c8a344 100644 --- a/tests/ansible.cfg +++ b/tests/ansible.cfg @@ -1,2 +1,2 @@ [defaults] -roles_path = .. +roles_path = ../.. diff --git a/tests/test.yaml b/tests/test.yaml index 5fa16b8..62d6636 100644 --- a/tests/test.yaml +++ b/tests/test.yaml @@ -13,12 +13,12 @@ # under the License. --- - hosts: localhost - sudo: yes vars: rolename: "{{ lookup('pipe', 'pwd') | dirname | basename }}" pre_tasks: # Make sure OS does not have a stale package cache. - name: Update apt cache. + become: yes apt: update_cache: yes when: ansible_os_family == 'Debian' diff --git a/tox.ini b/tox.ini index 23d78a3..60b7f91 100644 --- a/tox.ini +++ b/tox.ini @@ -1,27 +1,19 @@ [tox] minversion = 1.4.2 -envlist = ansible-lint,docs,pep8 +envlist = docs,linters skipsdist = True [testenv] deps = -r{toxinidir}/requirements.txt -r{toxinidir}/test-requirements.txt -[testenv:ansible-lint] -setenv = - ANSIBLE_CONFIG = tests/ansible.cfg -whitelist_externals = bash +[testenv:functional] commands = - bash -c "find . -type f -regex '.*.y[a]?ml' -print0 | xargs -t -n1 -0 \ - ansible-lint" - bash -c "find tests -type f -regex '.*.y[a]?ml' -print | xargs -t -n1 \ - ansible-playbook --syntax-check -i tests/inventory \ - -e rolename=$(basename $(pwd)) > /dev/null" - -[testenv:ansible-functional] -commands = - ansible-playbook -i tests/inventory tests/test.yaml -passenv = HOME + # NOTE(pabelanger): Because ansible default ansible_user to null now, we need to pass it via CLI. + ansible-playbook -i tests/inventory tests/test.yaml -e ansible_user={env:USER} +passenv = + HOME + USER setenv = ANSIBLE_CONFIG = {toxinidir}/tests/ansible.cfg PYTHONUNBUFFERED = 1 @@ -29,8 +21,28 @@ setenv = [testenv:docs] commands = python setup.py build_sphinx -[testenv:pep8] -commands = flake8 - [testenv:venv] commands = {posargs} + +[flake8] +# E123, E125 skipped as they are invalid PEP-8. + +show-source = True +ignore = E123,E125 +builtins = _ +exclude=.venv,.git,.tox,dist,doc,*openstack/common*,*lib/python*,*egg,build + +[testenv:linters] +setenv = + ANSIBLE_CONFIG = tests/ansible.cfg +whitelist_externals = bash +commands = + # PEP8 Lint Check + flake8 + # Ansible Lint Check + bash -c "find . -type f -regex '.*.y[a]?ml' -print0 | xargs -t -n1 -0 \ + ansible-lint" + # Ansible Syntax Check + bash -c "find tests -type f -regex '.*.y[a]?ml' -print | xargs -t -n1 \ + ansible-playbook --syntax-check -i tests/inventory \ + -e rolename=$(basename $(pwd)) > /dev/null"