Add tox checks, pbr packaging

This commit is contained in:
Steve Baker 2018-05-23 11:57:41 +12:00
parent 65ba913781
commit 1f31f485ba
9 changed files with 169 additions and 0 deletions

6
ansible-requirements.txt Normal file
View File

@ -0,0 +1,6 @@
# These are required here because ansible can't be in global-requirements due
# to licensing conflicts. But we sill need to be able to pull them in for
# lint checks and want to document these as ansible specific things that may
# be required for this repository.
ansible
ansible-lint

12
ansible.cfg Normal file
View File

@ -0,0 +1,12 @@
[defaults]
gathering = smart
command_warnings = False
retry_files_enabled = False
callback_whitelist = profile_tasks
# Attempt to load custom modules whether it's installed system-wide or from a virtual environment
roles_path = roles:$VIRTUAL_ENV/usr/share/ansible/roles/tripleo-modify-image:$VIRTUAL_ENV/usr/local/share/
[ssh_connection]
control_path = %(directory)s/%C

21
ci-scripts/ansible-lint.sh Executable file
View File

@ -0,0 +1,21 @@
#!/bin/bash
# ANSIBLE0006: Using command rather than module
# we have a few use cases where we need to use curl and rsync
# ANSIBLE0007: Using command rather than an argument to e.g file
# we have a lot of 'rm' command and we should use file module instead
# ANSIBLE0010: Package installs should not use latest.
# Sometimes we need to update some packages.
# ANSIBLE0012: Commands should not change things if nothing needs doing
# ANSIBLE0013: Use Shell only when shell functionality is required
# ANSIBLE0016: Tasks that run when changed should likely be handlers
# this requires refactoring roles, skipping for now
SKIPLIST="ANSIBLE0006,ANSIBLE0007,ANSIBLE0010,ANSIBLE0012,ANSIBLE0013,ANSIBLE0016"
# Lin the role.
ansible-lint -vvv -x $SKIPLIST ./ || lint_error=1
# exit with 1 if we had a least an error or warning.
if [[ -n "$lint_error" ]]; then
exit 1;
fi

View File

@ -1,4 +1,17 @@
#!/usr/bin/env python
# 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.
import json
import subprocess

2
requirements.txt Normal file
View File

@ -0,0 +1,2 @@
pbr>=1.6
ansible

35
setup.cfg Normal file
View File

@ -0,0 +1,35 @@
[metadata]
name = ansible-role-tripleo-modify-image
summary = ansible-tripleo-modify-image - Ansible role to allow modification to container images built for the TripleO project.
description-file =
README.md
author = TripleO Team
author-email = sbaker@redhat.com
home-page = https://git.openstack.org/cgit/openstack/ansible-role-tripleo-modify-image
classifier =
License :: OSI Approved :: Apache Software License
Development Status :: 4 - Beta
Intended Audience :: Developers
Intended Audience :: System Administrators
Intended Audience :: Information Technology
Topic :: Utilities
[global]
setup-hooks =
pbr.hooks.setup_hook
[files]
data_files =
/usr/share/ansible/roles/tripleo-modify-image/defaults = defaults/*
/usr/share/ansible/roles/tripleo-modify-image/meta = meta/*
/usr/share/ansible/roles/tripleo-modify-image/tasks = tasks/*
/usr/share/ansible/roles/tripleo-modify-image/templates = templates/*
/usr/share/ansible/roles/tripleo-modify-image/files = files/*
[wheel]
universal = 1
[pbr]
skip_authors = True
skip_changelog = True

19
setup.py Normal file
View File

@ -0,0 +1,19 @@
# Copyright Red Hat, Inc. All Rights Reserved.
#
# 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.
import setuptools
setuptools.setup(
setup_requires=['pbr'],
pbr=True)

1
test-requirements.txt Normal file
View File

@ -0,0 +1 @@
hacking!=0.13.0,<0.14,>=0.12.0 # Apache-2.0

60
tox.ini Normal file
View File

@ -0,0 +1,60 @@
[tox]
minversion = 1.6
envlist = docs, linters
skipdist = True
[testenv]
usedevelop = True
install_command = pip install -c{env:UPPER_CONSTRAINTS_FILE:https://git.openstack.org/cgit/openstack/requirements/plain/upper-constraints.txt} {opts} {packages}
setenv = VIRTUAL_ENV={envdir}
deps = -r{toxinidir}/test-requirements.txt
whitelist_externals = bash
[testenv:bindep]
# Do not install any requirements. We want this to be fast and work even if
# system dependencies are missing, since it's used to tell you what system
# dependencies are missing! This also means that bindep must be installed
# separately, outside of the requirements files.
deps = bindep
commands = bindep test
[testenv:pep8]
commands =
# Run hacking/flake8 check for all python files
bash -c "git ls-files | grep -v releasenotes | xargs grep --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 \
| xargs flake8 --verbose"
[testenv:ansible-lint]
basepython=python2
commands =
bash ci-scripts/ansible-lint.sh
[testenv:linters]
deps =
-r{toxinidir}/test-requirements.txt
-r{toxinidir}/ansible-requirements.txt
commands =
{[testenv:pep8]commands}
{[testenv:ansible-lint]commands}
[testenv:releasenotes]
whitelist_externals = bash
commands = bash -c ci-scripts/releasenotes_tox.sh
[testenv:venv]
commands = {posargs}
[flake8]
# E123, E125 skipped as they are invalid PEP-8.
# E265 deals with spaces inside of comments
show-source = True
ignore = E123,E125,E265
builtins = _