From da91ffc0227d4b2405d3e3a8e1baec2712f6bc8c Mon Sep 17 00:00:00 2001 From: Paul Belanger Date: Tue, 4 Dec 2018 11:29:54 -0500 Subject: [PATCH] Add zuul tests in-tree This allows us to gate properly with windmill-jobs. Change-Id: I23a072da89791666bc711d785344ba88d206710c Signed-off-by: Paul Belanger --- .zuul.yaml | 39 +++++++++++++++++++++++++ tests/ansible.cfg | 2 -- tests/inventory | 3 +- tests/{test.yaml => playbooks/run.yaml} | 13 ++------- tox.ini | 18 +++--------- 5 files changed, 47 insertions(+), 28 deletions(-) create mode 100644 .zuul.yaml delete mode 100644 tests/ansible.cfg rename tests/{test.yaml => playbooks/run.yaml} (65%) diff --git a/.zuul.yaml b/.zuul.yaml new file mode 100644 index 0000000..11f455a --- /dev/null +++ b/.zuul.yaml @@ -0,0 +1,39 @@ +--- +- job: + name: ansible-role-sudoers + run: tests/playbooks/run.yaml + roles: + - zuul: openstack/ansible-role-sudoers + +- job: + name: ansible-role-sudoers-fedora-latest + parent: ansible-role-sudoers + nodeset: fedora-latest + +- job: + name: ansible-role-sudoers-ubuntu-bionic + parent: ansible-role-sudoers + nodeset: ubuntu-bionic + +- job: + name: ansible-role-sudoers-ubuntu-xenial + parent: ansible-role-sudoers + nodeset: ubuntu-xenial + +- project: + templates: + - windmill-jobs-fedora-latest + - windmill-jobs-bionic + - windmill-jobs-xenial + check: + jobs: + - ansible-role-sudoers-fedora-latest + - ansible-role-sudoers-ubuntu-bionic + - ansible-role-sudoers-ubuntu-xenial + - tox-linters + gate: + jobs: + - ansible-role-sudoers-fedora-latest + - ansible-role-sudoers-ubuntu-bionic + - ansible-role-sudoers-ubuntu-xenial + - tox-linters diff --git a/tests/ansible.cfg b/tests/ansible.cfg deleted file mode 100644 index 6c8a344..0000000 --- a/tests/ansible.cfg +++ /dev/null @@ -1,2 +0,0 @@ -[defaults] -roles_path = ../.. diff --git a/tests/inventory b/tests/inventory index df8b5f6..2fbb50c 100644 --- a/tests/inventory +++ b/tests/inventory @@ -1,2 +1 @@ -[all] -localhost ansible_connection=local +localhost diff --git a/tests/test.yaml b/tests/playbooks/run.yaml similarity index 65% rename from tests/test.yaml rename to tests/playbooks/run.yaml index 62d6636..11c5316 100644 --- a/tests/test.yaml +++ b/tests/playbooks/run.yaml @@ -1,4 +1,4 @@ -# Copyright 2015 Red Hat, Inc. +# Copyright 2018 Red Hat, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -12,16 +12,9 @@ # License for the specific language governing permissions and limitations # under the License. --- -- hosts: localhost +- hosts: all 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' + rolename: ansible-role-sudoers roles: - "{{ rolename }}" diff --git a/tox.ini b/tox.ini index 60b7f91..33fa54c 100644 --- a/tox.ini +++ b/tox.ini @@ -4,20 +4,10 @@ envlist = docs,linters skipsdist = True [testenv] +basepython = python3 deps = -r{toxinidir}/requirements.txt -r{toxinidir}/test-requirements.txt -[testenv:functional] -commands = - # 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 - [testenv:docs] commands = python setup.py build_sphinx @@ -34,14 +24,14 @@ exclude=.venv,.git,.tox,dist,doc,*openstack/common*,*lib/python*,*egg,build [testenv:linters] setenv = - ANSIBLE_CONFIG = tests/ansible.cfg + ANSIBLE_ROLES_PATH = .. 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" + bash -c "find . -not -path '*/\.*' -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 \