Add a CI job with ansible-lint
The implementation is copy-pasted with some tweaks from project-config CI jobs. A list of exclusions is currently huge and should be reduced. Change-Id: I7811884caa5d6c46e42bc4d1638ccaa4d17910b7
This commit is contained in:
parent
bd7dc08c71
commit
6f825b0241
18
.ansible-lint
Normal file
18
.ansible-lint
Normal file
@ -0,0 +1,18 @@
|
||||
skip_list:
|
||||
# FIXME: gradually fix and remove these exclusions:
|
||||
- '204' # Lines should be no longer than 160 chars
|
||||
- '206' # Variables should have spaces before and after: {{ var_name }}
|
||||
- '208' # File permissions not mentioned
|
||||
- '301' # Commands should not change things if nothing needs doing
|
||||
- '303' # Using command rather than module
|
||||
- '305' # Use shell only when shell functionality is required
|
||||
- '306' # Shells that use pipes should set the pipefail option
|
||||
- '502' # All tasks should be named
|
||||
- '504' # Do not use 'local_action', use 'delegate_to: localhost'
|
||||
- '601' # Don't compare to literal True/False
|
||||
- '602' # Don't compare to empty string
|
||||
- '701' # meta/main.yml should contain relevant info
|
||||
- '702' # Tags must contain lowercase letters and digits only
|
||||
# NOTE(dtantsur): the following rules should likely stay excluded:
|
||||
- '106' # Role name {} does not match ``^[a-z][a-z0-9_]+$`` pattern'
|
||||
- '503' # Tasks that run when changed should likely be handlers
|
25
tools/ansible-lint.sh
Normal file
25
tools/ansible-lint.sh
Normal file
@ -0,0 +1,25 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -eu
|
||||
|
||||
DEST="$(dirname $0)/../playbooks/collections"
|
||||
SOURCE="${ANSIBLE_COLLECTION_SOURCE_PATH:-../ansible-collections-openstack}"
|
||||
|
||||
if [ ! -d "$SOURCE" ]; then
|
||||
echo "Cannot find ansible-collections-openstack at $SOURCE"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
rm -f "$DEST" || true
|
||||
mkdir -p "$DEST/ansible_collections/openstack"
|
||||
rm -f "$DEST/ansible_collections/openstack/cloud"
|
||||
|
||||
ln -s "$(realpath $SOURCE)" "$DEST/ansible_collections/openstack/cloud"
|
||||
|
||||
export ANSIBLE_COLLECTIONS_PATHS="$DEST"
|
||||
export ANSIBLE_LIBRARY="$(dirname $0)/../playbooks/library"
|
||||
|
||||
find playbooks -maxdepth 1 -type f -regex '.*.ya?ml' -print0 | \
|
||||
xargs -t -n1 -0 ansible-lint -vv --nocolor
|
||||
find playbooks/roles -maxdepth 1 -mindepth 1 -type d -printf "%p/\n" | \
|
||||
xargs -t -n1 ansible-lint -vv --nocolor
|
8
tox.ini
8
tox.ini
@ -71,3 +71,11 @@ deps =
|
||||
-c{toxinidir}/lower-constraints.txt
|
||||
-r{toxinidir}/test-requirements.txt
|
||||
-r{toxinidir}/requirements.txt
|
||||
|
||||
[testenv:linters]
|
||||
whitelist_externals = bash
|
||||
deps =
|
||||
ansible>=2.9.0,<2.10
|
||||
ansible-lint>=4.3.0,<5
|
||||
commands =
|
||||
bash tools/ansible-lint.sh
|
||||
|
@ -125,3 +125,9 @@
|
||||
name: bifrost-integration-tinyipa-fedora-latest
|
||||
parent: bifrost-integration-tinyipa
|
||||
nodeset: fedora-latest
|
||||
|
||||
- job:
|
||||
name: bifrost-tox-linters
|
||||
parent: openstack-tox-linters
|
||||
required-projects:
|
||||
- openstack/ansible-collections-openstack
|
||||
|
@ -7,6 +7,7 @@
|
||||
- release-notes-jobs-python3
|
||||
check:
|
||||
jobs:
|
||||
- bifrost-tox-linters
|
||||
- bifrost-integration-tinyipa-ubuntu-bionic
|
||||
- bifrost-integration-tinyipa-centos-8
|
||||
- bifrost-integration-tinyipa-keystone-ubuntu-bionic
|
||||
@ -36,6 +37,7 @@
|
||||
voting: false
|
||||
gate:
|
||||
jobs:
|
||||
- bifrost-tox-linters
|
||||
- bifrost-integration-tinyipa-ubuntu-bionic
|
||||
- bifrost-integration-tinyipa-centos-8
|
||||
- bifrost-integration-tinyipa-keystone-ubuntu-bionic
|
||||
|
Loading…
x
Reference in New Issue
Block a user