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"