From e097bc61c82732916d38df3b5b12e2cf1198a5c9 Mon Sep 17 00:00:00 2001 From: AlanCoding Date: Thu, 3 Oct 2019 12:04:59 -0400 Subject: [PATCH] New target for sanity testing of the collection Do not run in Zuul --- .gitignore | 1 + Makefile | 8 ++++++++ awx_collection/make_imports_absolute.yml | 17 +++++++++++++++++ 3 files changed, 26 insertions(+) create mode 100644 awx_collection/make_imports_absolute.yml diff --git a/.gitignore b/.gitignore index be22f947ae..60d960b66e 100644 --- a/.gitignore +++ b/.gitignore @@ -138,6 +138,7 @@ use_dev_supervisor.txt awx_collection_test_venv/ awx_collection/*.tar.gz awx_collection/galaxy.yml +sanity/ .idea/* *.unison.tmp diff --git a/Makefile b/Makefile index 0a93a8696b..55b65fa2c5 100644 --- a/Makefile +++ b/Makefile @@ -399,6 +399,14 @@ flake8_collection: test_collection_all: prepare_collection_venv test_collection flake8_collection +test_collection_sanity: + rm -rf sanity + mkdir -p sanity/ansible_collections/awx + cp -Ra awx_collection sanity/ansible_collections/awx/awx # symlinks do not work + cd sanity/ansible_collections/awx/awx && ansible-playbook -i localhost, make_imports_absolute.yml # hack because sanity tests do not fully work + cd sanity/ansible_collections/awx/awx && git init && git add . # requires both this file structure and a git repo, so there you go + cd sanity/ansible_collections/awx/awx && ansible-test sanity --test validate-modules + build_collection: ansible-playbook -i localhost, awx_collection/template_galaxy.yml -e collection_package=$(COLLECTION_PACKAGE) -e collection_namespace=$(COLLECTION_NAMESPACE) -e collection_version=$(VERSION) ansible-galaxy collection build awx_collection --output-path=awx_collection diff --git a/awx_collection/make_imports_absolute.yml b/awx_collection/make_imports_absolute.yml new file mode 100644 index 0000000000..184019ea2b --- /dev/null +++ b/awx_collection/make_imports_absolute.yml @@ -0,0 +1,17 @@ +- hosts: localhost + gather_facts: false + connection: local + + tasks: + - name: Find all module files + find: + paths: "{{ playbook_dir }}/plugins/modules" + patterns: "*.py" + register: module_files + + - name: Change module_utils imports to absolute namespace and package names + replace: + path: "{{ item.path }}" + regexp: '^from ..module_utils.ansible_tower' + replace: 'from ansible_collections.awx.awx.plugins.module_utils.ansible_tower' + with_items: "{{ module_files.files }}"