From 6271268567fd6744141e2c7d3857b2982f694015 Mon Sep 17 00:00:00 2001 From: Monty Taylor Date: Mon, 11 May 2020 16:09:54 -0500 Subject: [PATCH] Run linters in a temp dir instead of an install We can't run linters in an install because installs expand symlinks to regular files so the ansible-test code that detects symlinks can't work so it looks at docs for symlink aliases as if they were real. Change-Id: I0a5659a1f693261a21a5b29528f950b846205f2e --- tests/unit/compat/mock.py | 2 +- tools/run-ansible-sanity.sh | 26 ++++++++++++++++++++++++++ tox.ini | 3 +-- 3 files changed, 28 insertions(+), 3 deletions(-) create mode 100644 tools/run-ansible-sanity.sh diff --git a/tests/unit/compat/mock.py b/tests/unit/compat/mock.py index 382ab2f4..b1afa9fa 100644 --- a/tests/unit/compat/mock.py +++ b/tests/unit/compat/mock.py @@ -50,7 +50,7 @@ if sys.version_info >= (3,) and sys.version_info < (3, 4, 4): # Retrieve lines from read_data via a generator so that separate calls to # readline, read, and readlines are properly interleaved sep = b'\n' if isinstance(read_data, bytes) else '\n' - data_as_list = [l + sep for l in read_data.split(sep)] + data_as_list = [li + sep for li in read_data.split(sep)] if data_as_list[-1] == sep: # If the last line ended in a newline, the list comprehension will have an diff --git a/tools/run-ansible-sanity.sh b/tools/run-ansible-sanity.sh new file mode 100644 index 00000000..c4357528 --- /dev/null +++ b/tools/run-ansible-sanity.sh @@ -0,0 +1,26 @@ +#!/bin/bash +# Copyright 2020 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. + +TOXDIR=${1:-.} +ANSIBLE_COLLECTIONS_PATH=$(mktemp -d) +echo "Executing ansible-test sanity checks in ${ANSIBLE_COLLECTIONS_PATH}" + +trap "rm -rf ${ANSIBLE_COLLECTIONS_PATH}" err exit + +rm -rf "${ANSIBLE_COLLECTIONS_PATH}" +mkdir -p ${ANSIBLE_COLLECTIONS_PATH}/ansible_collections/openstack/cloud +cp -a ${TOXDIR}/{plugins,meta,galaxy.yml} ${ANSIBLE_COLLECTIONS_PATH}/ansible_collections/openstack/cloud +cd ${ANSIBLE_COLLECTIONS_PATH}/ansible_collections/openstack/cloud/ +ansible-test sanity --skip-test metaclass-boilerplate --skip-test future-import-boilerplate diff --git a/tox.ini b/tox.ini index 7bf7031d..e48c58f9 100644 --- a/tox.ini +++ b/tox.ini @@ -37,8 +37,7 @@ passenv = * commands = {[testenv:build]commands} {[testenv:pep8]commands} - /bin/bash -c "ansible-galaxy collection install $(ls {toxinidir}/build_artifact/openstack-cloud-*) --force" - /bin/bash -c "cd ~/.ansible/collections/ansible_collections/openstack/cloud && ansible-test sanity --skip-test metaclass-boilerplate --skip-test future-import-boilerplate" + /bin/bash {toxinidir}/tools/run-ansible-sanity.sh {toxinidir} [testenv:venv] deps =