Add .zuul.yaml testing

This moves our testing in-tree for zuul.

Change-Id: If91ba558bc9741341df689b3927cda916beebb5d
Depends-On: https://review.openstack.org/623119/
Signed-off-by: Paul Belanger <pabelanger@redhat.com>
This commit is contained in:
Paul Belanger 2018-12-05 16:41:56 -05:00
parent e96777e9ae
commit b0112d6fae
7 changed files with 115 additions and 57 deletions

61
.zuul.yaml Normal file
View File

@ -0,0 +1,61 @@
- job:
name: ansible-role-virtualenv-base
parent: unittests
pre-run: tests/playbooks/pre.yaml
run: tests/playbooks/run.yaml
roles:
- zuul: openstack/ansible-role-virtualenv
# Testing for virtualenv_install_method: pip
- job:
name: ansible-role-virtualenv
parent: ansible-role-virtualenv-base
vars:
virtualenv_install_method: pip
- job:
name: ansible-role-virtualenv-fedora-latest
parent: ansible-role-virtualenv
nodeset: fedora-latest
- job:
name: ansible-role-virtualenv-ubuntu-bionic
parent: ansible-role-virtualenv
nodeset: ubuntu-bionic
# Testing for virtualenv_install_method: git
- job:
name: ansible-role-virtualenv-src
parent: ansible-role-virtualenv-base
vars:
virtualenv_git_update: false
virtualenv_install_method: git
- job:
name: ansible-role-virtualenv-src-fedora-latest
parent: ansible-role-virtualenv-src
nodeset: fedora-latest
- job:
name: ansible-role-virtualenv-src-ubuntu-bionic
parent: ansible-role-virtualenv-src
nodeset: ubuntu-bionic
- project:
templates:
- windmill-jobs-fedora-latest
- windmill-jobs-bionic
check:
jobs:
- ansible-role-virtualenv-fedora-latest
- ansible-role-virtualenv-ubuntu-bionic
- ansible-role-virtualenv-src-fedora-latest
- ansible-role-virtualenv-src-ubuntu-bionic
- tox-linters
gate:
jobs:
- ansible-role-virtualenv-fedora-latest
- ansible-role-virtualenv-ubuntu-bionic
- ansible-role-virtualenv-src-fedora-latest
- ansible-role-virtualenv-src-ubuntu-bionic
- tox-linters

View File

@ -1,2 +0,0 @@
[defaults]
roles_path = ../..

View File

@ -1,2 +1,2 @@
[all]
localhost
[test]
test01 ansible_host=127.0.0.1

28
tests/playbooks/pre.yaml Normal file
View File

@ -0,0 +1,28 @@
# 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.
# 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.
---
- hosts: all
tasks:
# TODO(pabelanger): Remove once this lands in our base job in
# project-config.
- name: Execute ensure-output-dirs role
include_role:
name: ensure-output-dirs
- name: Disable extra wheels mirror
become: yes
lineinfile:
dest: /etc/pip.conf
regexp: ^extra-index-url
state: absent

20
tests/playbooks/run.yaml Normal file
View File

@ -0,0 +1,20 @@
# 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.
# 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.
---
- hosts: all
vars:
rolename: ansible-role-virtualenv
roles:
- "{{ rolename }}"

View File

@ -1,39 +0,0 @@
# Copyright 2015 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.
# 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.
---
- hosts: localhost
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'
roles:
- "{{ rolename }}"
post_tasks:
- name: Register virtualenv_git_dest_stat.
stat:
path: /opt/ansible-role-virtualenv/git/pypa/virtualenv
register: virtualenv_git_dest_stat
- name: Assert virtualenv_git_dest tests.
assert:
that:
- virtualenv_git_dest_stat.stat.exists
- virtualenv_git_dest_stat.stat.isdir

18
tox.ini
View File

@ -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 \