Comply with ansible lint
Adds openstack-tox-linters job and edits the source code so that it complies with the ansible and yaml lint. Also creates requirements files, setup.* files and tox.ini one according the other ansible-role-* projects. Change-Id: If538c081a9f0f462714381baab002de5b403fde0
This commit is contained in:
parent
0427e4a64f
commit
b2bd953ec2
9
.ansible-lint
Normal file
9
.ansible-lint
Normal file
@ -0,0 +1,9 @@
|
||||
---
|
||||
parseable: true
|
||||
skip_list:
|
||||
# Add skips here only as last resort, like:
|
||||
# https://github.com/ansible/ansible-lint/issues/557
|
||||
- 302 # [E302] mkdir used in place of argument state=directory to file module
|
||||
- 303 # [E303] ... used in place of ... module
|
||||
- 208 # [E208]
|
||||
- 106 # [E106]
|
74
.gitignore
vendored
74
.gitignore
vendored
@ -1 +1,75 @@
|
||||
# Byte-compiled / optimized / DLL files
|
||||
__pycache__/
|
||||
*.py[cod]
|
||||
|
||||
# C extensions
|
||||
*.so
|
||||
|
||||
# Distribution / packaging
|
||||
.Python
|
||||
env/
|
||||
develop-eggs/
|
||||
dist/
|
||||
downloads/
|
||||
eggs/
|
||||
.eggs/
|
||||
lib/
|
||||
lib64/
|
||||
sdist/
|
||||
var/
|
||||
container_registry.egg-info/
|
||||
.installed.cfg
|
||||
*.egg
|
||||
|
||||
# PyInstaller
|
||||
# Usually these files are written by a python script from a template
|
||||
# before PyInstaller builds the exe, so as to inject date/other infos into it.
|
||||
*.manifest
|
||||
*.spec
|
||||
!infrared_plugin/plugin.spec
|
||||
|
||||
# Installer logs
|
||||
pip-log.txt
|
||||
pip-delete-this-directory.txt
|
||||
|
||||
# Unit test / coverage reports
|
||||
htmlcov/
|
||||
.tox/
|
||||
.coverage
|
||||
.coverage.*
|
||||
.cache
|
||||
nosetests.xml
|
||||
coverage.xml
|
||||
*,cover
|
||||
|
||||
# Translations
|
||||
*.mo
|
||||
*.pot
|
||||
|
||||
# Django stuff:
|
||||
*.log
|
||||
|
||||
# Sphinx documentation
|
||||
doc/build/
|
||||
|
||||
# PyBuilder
|
||||
target/
|
||||
|
||||
# virtualenv
|
||||
.venv/
|
||||
|
||||
# jenkins config
|
||||
jenkins/config.ini
|
||||
playbooks/debug.yml
|
||||
|
||||
# Files created by releasenotes build
|
||||
releasenotes/build
|
||||
|
||||
# Editors
|
||||
.*.sw[klmnop]
|
||||
|
||||
# ansible retry files
|
||||
*.retry
|
||||
|
||||
# ansible
|
||||
roles
|
||||
|
44
.pre-commit-config.yaml
Normal file
44
.pre-commit-config.yaml
Normal file
@ -0,0 +1,44 @@
|
||||
---
|
||||
repos:
|
||||
- repo: https://github.com/pre-commit/pre-commit-hooks
|
||||
rev: v2.4.0
|
||||
hooks:
|
||||
- id: end-of-file-fixer
|
||||
- id: trailing-whitespace
|
||||
- id: mixed-line-ending
|
||||
- id: check-byte-order-marker
|
||||
- id: check-executables-have-shebangs
|
||||
- id: check-merge-conflict
|
||||
- id: debug-statements
|
||||
- id: flake8
|
||||
- id: check-yaml
|
||||
files: .*\.(yaml|yml)$
|
||||
- repo: https://github.com/adrienverge/yamllint.git
|
||||
rev: v1.18.0
|
||||
hooks:
|
||||
- id: yamllint
|
||||
files: \.(yaml|yml)$
|
||||
types: [file, yaml]
|
||||
entry: yamllint --strict -f parsable
|
||||
- repo: https://github.com/ansible/ansible-lint.git
|
||||
rev: 9da220ae3a11c10c10ee43284ad6cad6d8ba52b7
|
||||
hooks:
|
||||
- id: ansible-lint
|
||||
always_run: true
|
||||
# do not add file filters here as ansible-lint does not give reliable
|
||||
# results when called with individual files.
|
||||
# https://github.com/ansible/ansible-lint/issues/611
|
||||
verbose: true
|
||||
entry: env ANSIBLE_LIBRARY=./library ansible-lint --force-color -v .
|
||||
- repo: https://github.com/openstack-dev/bashate.git
|
||||
rev: 0.6.0
|
||||
hooks:
|
||||
- id: bashate
|
||||
entry: bashate --error . --verbose --ignore=E006,E040
|
||||
# Run bashate check for all bash scripts
|
||||
# Ignores the following rules:
|
||||
# E006: Line longer than 79 columns (as many scripts use jinja
|
||||
# templating, this is very difficult)
|
||||
# E040: Syntax error determined using `bash -n` (as many scripts
|
||||
# use jinja templating, this will often fail and the syntax
|
||||
# error will be discovered in execution anyway)
|
7
.yamllint
Normal file
7
.yamllint
Normal file
@ -0,0 +1,7 @@
|
||||
---
|
||||
extends: default
|
||||
|
||||
rules:
|
||||
line-length:
|
||||
# matches hardcoded 160 value from ansible-lint
|
||||
max: 160
|
@ -1,3 +1,8 @@
|
||||
---
|
||||
- project:
|
||||
templates:
|
||||
- noop-jobs
|
||||
check:
|
||||
jobs:
|
||||
- openstack-tox-linters
|
||||
gate:
|
||||
jobs:
|
||||
- openstack-tox-linters
|
||||
|
27
LICENSE
27
LICENSE
@ -172,30 +172,3 @@
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
APPENDIX: How to apply the Apache License to your work.
|
||||
|
||||
To apply the Apache License to your work, attach the following
|
||||
boilerplate notice, with the fields enclosed by brackets "[]"
|
||||
replaced with your own identifying information. (Don't include
|
||||
the brackets!) The text should be enclosed in the appropriate
|
||||
comment syntax for the file format. We also recommend that a
|
||||
file or class name and description of purpose be included on the
|
||||
same "printed page" as the copyright notice for easier
|
||||
identification within third-party archives.
|
||||
|
||||
Copyright [yyyy] [name of copyright owner]
|
||||
|
||||
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.
|
||||
|
@ -26,6 +26,7 @@ deployment is working by passing refstack tests.
|
||||
| guideline | False | 2020.06 | String | Specific guideline |
|
||||
| private_key_path_src * | False | None | String | If defined, the key defined by the param is copied to the targeted machine to private_key_path location.|
|
||||
| refstack_client_source | False | ~/.refstack-client | String | Destination where refstack-client will be cloned. |
|
||||
| refstack_client_version | False | HEAD | String | Version of refstack-client cloned from git. |
|
||||
| server | False | https://refstack.openstack.org/api | String | Server url where results will be uploaded. |
|
||||
| tempest_config_path | False | None | String | Destination of tempest configuration file to be used for running refstack tests. |
|
||||
| tempest_tag | False | refstack-client's default | String | Tempest will be cloned and checkouted to this specific tag. |
|
||||
|
@ -1,10 +1,13 @@
|
||||
---
|
||||
server: "https://refstack.openstack.org/api"
|
||||
refstack_client_source: "~/.refstack-client"
|
||||
upload_results: True
|
||||
download_artifacts: True
|
||||
upload_results: true
|
||||
download_artifacts: true
|
||||
url_cirros_image: "http://download.cirros-cloud.net/0.4.0/cirros-0.4.0-x86_64-disk.img"
|
||||
|
||||
# Local directory where the files will be stored
|
||||
dest_dir: "{{ lookup('env', 'PWD') }}"
|
||||
# the latest guideline by default
|
||||
guideline: "2020.06"
|
||||
# default refstack version used is the HEAD
|
||||
refstack_client_version: "HEAD"
|
||||
|
@ -12,4 +12,3 @@
|
||||
- name: ansible-role-refstack-client
|
||||
include_role:
|
||||
name: ansible-role-refstack-client
|
||||
|
||||
|
2
requirements.txt
Normal file
2
requirements.txt
Normal file
@ -0,0 +1,2 @@
|
||||
pbr>=1.6
|
||||
ansible>=2.5,<2.10
|
43
setup.cfg
Normal file
43
setup.cfg
Normal file
@ -0,0 +1,43 @@
|
||||
[metadata]
|
||||
name = ansible-role-refstack-client
|
||||
summary = ansible-role-refstack-client - An Ansible role to manage refstack-client.
|
||||
description-file =
|
||||
README.md
|
||||
author = author = OpenStack
|
||||
author-email = openstack-discuss@lists.openstack.org
|
||||
home-page = https://refstack.openstack.org
|
||||
classifier =
|
||||
Environment :: OpenStack
|
||||
Intended Audience :: Developers
|
||||
Intended Audience :: Information Technology
|
||||
License :: OSI Approved :: Apache Software License
|
||||
Operating System :: POSIX :: Linux
|
||||
Programming Language :: Python
|
||||
Programming Language :: Python :: 3
|
||||
Programming Language :: Python :: 3.5
|
||||
Programming Language :: Python :: 3.6
|
||||
Programming Language :: Python :: 3.7
|
||||
Programming Language :: Python :: 3.8
|
||||
|
||||
[global]
|
||||
setup-hooks =
|
||||
pbr.hooks.setup_hook
|
||||
|
||||
[files]
|
||||
data_files =
|
||||
usr/local/share/ansible/roles/ansible-role-refstack-client/defaults = defaults/*
|
||||
usr/local/share/ansible/roles/ansible-role-refstack-client/tasks = tasks/*
|
||||
|
||||
[wheel]
|
||||
universal = 1
|
||||
|
||||
[pbr]
|
||||
skip_authors = True
|
||||
skip_changelog = True
|
||||
|
||||
[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 = _
|
19
setup.py
Normal file
19
setup.py
Normal 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)
|
@ -45,6 +45,7 @@
|
||||
args:
|
||||
executable: /bin/bash
|
||||
chdir: "{{ refstack_client_source }}"
|
||||
changed_when: accounts_path is not defined
|
||||
|
||||
- name: Cat generated accounts.yaml file
|
||||
shell: |
|
||||
@ -52,3 +53,4 @@
|
||||
args:
|
||||
executable: /bin/bash
|
||||
chdir: "{{ refstack_client_source }}"
|
||||
changed_when: false
|
||||
|
@ -6,18 +6,18 @@
|
||||
changed_when: false
|
||||
|
||||
- name: Install git
|
||||
become: yes
|
||||
become: true
|
||||
package:
|
||||
name: git
|
||||
|
||||
- name: Install virtualenv
|
||||
become: yes
|
||||
become: true
|
||||
package:
|
||||
name: python-virtualenv
|
||||
when: python_is_available.rc == 0
|
||||
|
||||
- name: Install virtualenv
|
||||
become: yes
|
||||
become: true
|
||||
package:
|
||||
name: python3-virtualenv
|
||||
when: python_is_available.rc != 0
|
||||
@ -42,7 +42,7 @@
|
||||
get_url: url=https://bootstrap.pypa.io/get-pip.py dest=/tmp
|
||||
|
||||
- name: install pip
|
||||
become: yes
|
||||
become: true
|
||||
command: "python /tmp/get-pip.py"
|
||||
|
||||
- name: delete get-pip.py
|
||||
|
@ -6,10 +6,11 @@
|
||||
git:
|
||||
repo: 'https://github.com/openstack/refstack-client.git'
|
||||
dest: "{{ refstack_client_source }}"
|
||||
version: "{{ refstack_client_version }}"
|
||||
|
||||
- name: Look for python3
|
||||
command: "python3 --version"
|
||||
ignore_errors: yes
|
||||
ignore_errors: true
|
||||
register: python3_is_available
|
||||
changed_when: false
|
||||
|
||||
@ -80,6 +81,7 @@
|
||||
args:
|
||||
chdir: "{{ refstack_client_source }}"
|
||||
executable: /bin/bash
|
||||
changed_when: false
|
||||
|
||||
- name: Run tests with the defined test list
|
||||
shell: |
|
||||
@ -95,7 +97,7 @@
|
||||
chdir: "{{ refstack_client_source }}"
|
||||
executable: /bin/bash
|
||||
register: refstack_result
|
||||
ignore_errors: yes
|
||||
ignore_errors: true
|
||||
when: test_list is defined
|
||||
|
||||
- name: Run tests with the default test list
|
||||
@ -112,22 +114,24 @@
|
||||
chdir: "{{ refstack_client_source }}"
|
||||
executable: /bin/bash
|
||||
register: refstack_result
|
||||
ignore_errors: yes
|
||||
ignore_errors: true
|
||||
when: test_list is not defined
|
||||
|
||||
- name: Find the test result json file
|
||||
shell: |
|
||||
set -ex
|
||||
set -o pipefail -ex
|
||||
ls | grep "\.json" | tail -1
|
||||
register: ls_out
|
||||
args:
|
||||
chdir: "{{ refstack_client_source }}/.tempest/.stestr"
|
||||
executable: /bin/bash
|
||||
changed_when: false
|
||||
|
||||
- name: Copy private key
|
||||
copy:
|
||||
src: "{{ private_key_path_src }}"
|
||||
dest: "{{ private_key_path }}"
|
||||
mode: '0600'
|
||||
when:
|
||||
- upload_results | bool
|
||||
- private_key_path is defined
|
||||
@ -135,7 +139,7 @@
|
||||
|
||||
- name: Upload results with signature
|
||||
shell: |
|
||||
set -ex
|
||||
set -o pipefail -ex
|
||||
source .venv/bin/activate
|
||||
yes | refstack-client upload ".tempest/.stestr/{{ ls_out.stdout }}" \
|
||||
--url {{ server }} \
|
||||
@ -148,18 +152,19 @@
|
||||
- upload_results | bool
|
||||
- private_key_path is defined
|
||||
|
||||
- block:
|
||||
- when: download_artifacts | bool
|
||||
block:
|
||||
- name: Download results file in .json
|
||||
fetch:
|
||||
src: "{{ refstack_client_source }}/.tempest/.stestr/{{ ls_out.stdout }}"
|
||||
dest: "{{ dest_dir }}/test_results.json"
|
||||
flat: yes
|
||||
flat: true
|
||||
|
||||
- name: Download results file in subunit
|
||||
fetch:
|
||||
src: "{{ refstack_client_source }}/.tempest/.stestr/{{ ls_out.stdout | splitext | first }}"
|
||||
dest: "{{ dest_dir }}/test_results_subunit"
|
||||
flat: yes
|
||||
flat: true
|
||||
|
||||
- debug:
|
||||
msg: "{{ upload_out.stdout }}"
|
||||
@ -168,13 +173,14 @@
|
||||
copy:
|
||||
content: "{{ upload_out.stdout }}"
|
||||
dest: "{{ dest_dir }}/upload_output.txt"
|
||||
mode: '0644'
|
||||
delegate_to: localhost
|
||||
|
||||
- name: Download tempest.conf file
|
||||
fetch:
|
||||
src: "{{ path_to_tempest_config }}"
|
||||
dest: "{{ dest_dir }}/tempest.conf"
|
||||
flat: yes
|
||||
flat: true
|
||||
args:
|
||||
chdir: "{{ refstack_client_source }}"
|
||||
|
||||
@ -182,10 +188,9 @@
|
||||
fetch:
|
||||
src: "{{ path_to_accounts_file }}"
|
||||
dest: "{{ dest_dir }}/accounts.yaml"
|
||||
flat: yes
|
||||
flat: true
|
||||
args:
|
||||
chdir: "{{ refstack_client_source }}"
|
||||
when: download_artifacts | bool
|
||||
|
||||
- name: Check if we passed refstack tests
|
||||
fail:
|
||||
|
5
test-requirements.txt
Normal file
5
test-requirements.txt
Normal file
@ -0,0 +1,5 @@
|
||||
mock
|
||||
pre-commit>=1.20.0 # MIT
|
||||
pytest
|
||||
pytest-mock
|
||||
pyyaml
|
32
tox.ini
Normal file
32
tox.ini
Normal file
@ -0,0 +1,32 @@
|
||||
[tox]
|
||||
minversion = 3.4.0
|
||||
envlist = docs, linters
|
||||
skipsdist = True
|
||||
|
||||
[testenv]
|
||||
usedevelop = True
|
||||
install_command = pip install -c{env:UPPER_CONSTRAINTS_FILE:https://opendev.org/openstack/requirements/raw/branch/master/upper-constraints.txt} {opts} {packages}
|
||||
passenv =
|
||||
ANSIBLE_*
|
||||
CURL_CA_BUNDLE
|
||||
DOCKER_*
|
||||
HOME
|
||||
REQUESTS_CA_BUNDLE
|
||||
SSH_AUTH_SOCK
|
||||
SSL_CERT_FILE
|
||||
TERM
|
||||
setenv = VIRTUAL_ENV={envdir}
|
||||
deps = -r{toxinidir}/test-requirements.txt
|
||||
whitelist_externals = bash
|
||||
|
||||
[testenv:linters]
|
||||
basepython = python3
|
||||
setenv =
|
||||
ANSIBLE_LIBRARY=./library
|
||||
commands =
|
||||
# check only modified files:
|
||||
python -m pre_commit run -a
|
||||
|
||||
[testenv:venv]
|
||||
basepython = python3
|
||||
commands = {posargs}
|
Loading…
Reference in New Issue
Block a user