From d968b648deaff425dfa755df297b0ae52dfa2992 Mon Sep 17 00:00:00 2001 From: Rick Elrod Date: Tue, 20 Dec 2022 17:40:08 -0600 Subject: [PATCH 1/3] Run sanity tests outside of our container Also just ignore one sanity test for the export module, instead of ignoring all of them. Also use latest ansible-test, and make it work on GHA (by using podman instead of docker). Signed-off-by: Rick Elrod --- .github/workflows/ci.yml | 21 ++++- .github/workflows/e2e_test.yml | 4 +- Makefile | 2 +- awx_collection/tests/config.yml | 3 + awx_collection/tests/sanity/ignore-2.13.txt | 88 --------------------- awx_collection/tests/sanity/ignore-2.14.txt | 1 + 6 files changed, 24 insertions(+), 95 deletions(-) create mode 100644 awx_collection/tests/config.yml delete mode 100644 awx_collection/tests/sanity/ignore-2.13.txt create mode 100644 awx_collection/tests/sanity/ignore-2.14.txt diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5e9a72392f..97df2050cd 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -28,9 +28,6 @@ jobs: - name: awx-collection command: /start_tests.sh test_collection_all label: Run Collection Tests - - name: awx-collection-sanity - command: /start_tests.sh test_collection_sanity - label: Run Ansible core Collection Sanity tests - name: api-schema label: Check API Schema command: /start_tests.sh detect-schema-change SCHEMA_DIFF_BASE_BRANCH=${{ github.event.pull_request.base.ref }} @@ -148,3 +145,21 @@ jobs: env: AWX_TEST_IMAGE: awx AWX_TEST_VERSION: ci + + collection-sanity: + name: awx_collection sanity + runs-on: ubuntu-latest + strategy: + fail-fast: false + steps: + - uses: actions/checkout@v2 + + - name: Upgrade ansible-core + run: python3 -m pip install --upgrade ansible-core + + - name: Run sanity tests + run: make test_collection_sanity + env: + # needed due to cgroupsv2. This is fixed, but a stable release + # with the fix has not been made yet. + ANSIBLE_TEST_PREFER_PODMAN: 1 diff --git a/.github/workflows/e2e_test.yml b/.github/workflows/e2e_test.yml index 22890fcf53..788042baed 100644 --- a/.github/workflows/e2e_test.yml +++ b/.github/workflows/e2e_test.yml @@ -6,7 +6,7 @@ env: on: pull_request_target: types: [labeled] -jobs: +jobs: e2e-test: if: contains(github.event.pull_request.labels.*.name, 'qe:e2e') runs-on: ubuntu-latest @@ -107,5 +107,3 @@ jobs: with: name: AWX-logs-${{ matrix.job }} path: make-docker-compose-output.log - - diff --git a/Makefile b/Makefile index 3a85428e93..d86e9779a4 100644 --- a/Makefile +++ b/Makefile @@ -339,7 +339,7 @@ test_collection_sanity: if ! [ -x "$(shell command -v ansible-test)" ]; then pip install ansible-core; fi ansible --version COLLECTION_VERSION=1.0.0 make install_collection - cd $(COLLECTION_INSTALL) && ansible-test sanity --exclude=plugins/modules/export.py + cd $(COLLECTION_INSTALL) && ansible-test sanity --docker test_collection_integration: install_collection cd $(COLLECTION_INSTALL) && ansible-test integration $(COLLECTION_TEST_TARGET) diff --git a/awx_collection/tests/config.yml b/awx_collection/tests/config.yml new file mode 100644 index 0000000000..fdb7c5055c --- /dev/null +++ b/awx_collection/tests/config.yml @@ -0,0 +1,3 @@ +--- +modules: + python_requires: '>3' diff --git a/awx_collection/tests/sanity/ignore-2.13.txt b/awx_collection/tests/sanity/ignore-2.13.txt deleted file mode 100644 index cd98399548..0000000000 --- a/awx_collection/tests/sanity/ignore-2.13.txt +++ /dev/null @@ -1,88 +0,0 @@ -plugins/module_utils/awxkit.py import-3.9 -plugins/module_utils/controller_api.py import-3.9 -plugins/modules/ad_hoc_command.py import-3.9 -plugins/modules/ad_hoc_command_cancel.py import-3.9 -plugins/modules/ad_hoc_command_wait.py import-3.9 -plugins/modules/application.py import-3.9 -plugins/modules/controller_meta.py import-3.9 -plugins/modules/credential.py import-3.92 -plugins/modules/credential_input_source.py import-3.9 -plugins/modules/credential_type.py import-3.9 -plugins/modules/execution_environment.py import-3.9 -plugins/modules/export.py import-3.9 -plugins/modules/group.py import-3.9 -plugins/modules/host.py import-3.9 -plugins/modules/import.py import-3.9 -plugins/modules/instance.py import-3.9 -plugins/modules/instance_group.py import-3.9 -plugins/modules/inventory.py import-3.9 -plugins/modules/inventory_source.py import-3.9 -plugins/modules/inventory_source_update.py import-3.9 -plugins/modules/job_cancel.py import-3.9 -plugins/modules/job_launch.py import-3.9 -plugins/modules/job_list.py import-3.9 -plugins/modules/job_template.py import-3.93 -plugins/modules/job_wait.py import-3.9 -plugins/modules/label.py import-3.9 -plugins/modules/license.py import-3.9 -plugins/modules/notification_template.py import-3.9 -plugins/modules/organization.py import-3.9 -plugins/modules/project.py import-3.92 -plugins/modules/project_update.py import-3.9 -plugins/modules/role.py import-3.9 -plugins/modules/schedule.py import-3.9 -plugins/modules/settings.py import-3.9 -plugins/modules/subscriptions.py import-3.9 -plugins/modules/team.py import-3.9 -plugins/modules/token.py import-3.9 -plugins/modules/user.py import-3.9 -plugins/modules/workflow_approval.py import-3.9 -plugins/modules/workflow_job_template.py import-3.9 -plugins/modules/workflow_job_template_node.py import-3.9 -plugins/modules/workflow_launch.py import-3.9 -plugins/modules/workflow_node_wait.py import-3.9 -plugins/inventory/controller.py import-3.10 -plugins/lookup/controller_api.py import-3.10 -plugins/module_utils/awxkit.py import-3.10 -plugins/module_utils/controller_api.py import-3.10 -plugins/modules/ad_hoc_command.py import-3.10 -plugins/modules/ad_hoc_command_cancel.py import-3.10 -plugins/modules/ad_hoc_command_wait.py import-3.10 -plugins/modules/application.py import-3.10 -plugins/modules/controller_meta.py import-3.10 -plugins/modules/credential.py import-3.10 -plugins/modules/credential_input_source.py import-3.10 -plugins/modules/credential_type.py import-3.10 -plugins/modules/execution_environment.py import-3.10 -plugins/modules/export.py import-3.10 -plugins/modules/group.py import-3.10 -plugins/modules/host.py import-3.10 -plugins/modules/import.py import-3.10 -plugins/modules/instance.py import-3.10 -plugins/modules/instance_group.py import-3.10 -plugins/modules/inventory.py import-3.10 -plugins/modules/inventory_source.py import-3.10 -plugins/modules/inventory_source_update.py import-3.10 -plugins/modules/job_cancel.py import-3.10 -plugins/modules/job_launch.py import-3.10 -plugins/modules/job_list.py import-3.10 -plugins/modules/job_template.py import-3.10 -plugins/modules/job_wait.py import-3.10 -plugins/modules/label.py import-3.10 -plugins/modules/license.py import-3.10 -plugins/modules/notification_template.py import-3.10 -plugins/modules/organization.py import-3.10 -plugins/modules/project.py import-3.10 -plugins/modules/project_update.py import-3.10 -plugins/modules/role.py import-3.10 -plugins/modules/schedule.py import-3.10 -plugins/modules/settings.py import-3.10 -plugins/modules/subscriptions.py import-3.10 -plugins/modules/team.py import-3.10 -plugins/modules/token.py import-3.10 -plugins/modules/user.py import-3.10 -plugins/modules/workflow_approval.py import-3.10 -plugins/modules/workflow_job_template.py import-3.10 -plugins/modules/workflow_job_template_node.py import-3.10 -plugins/modules/workflow_launch.py import-3.10 -plugins/modules/workflow_node_wait.py import-3.10 diff --git a/awx_collection/tests/sanity/ignore-2.14.txt b/awx_collection/tests/sanity/ignore-2.14.txt new file mode 100644 index 0000000000..19512ea0c1 --- /dev/null +++ b/awx_collection/tests/sanity/ignore-2.14.txt @@ -0,0 +1 @@ +plugins/modules/export.py validate-modules:nonexistent-parameter-documented # needs awxkit to construct argspec From cf1ec07eabbc6f64895e1896668dd97d2843acb2 Mon Sep 17 00:00:00 2001 From: Alan Rominger Date: Wed, 21 Dec 2022 09:53:18 -0500 Subject: [PATCH 2/3] Changes to run sanity tests locally Use a Makefile arg for the ansible-test sanity CLI args defaults to --docker in the future we probably need to customize python versions Copy the rule exception for Ansible 2.15 this helps people who are running from Ansible devel --- Makefile | 20 ++++++++++++-------- awx_collection/tests/sanity/ignore-2.15.txt | 1 + 2 files changed, 13 insertions(+), 8 deletions(-) create mode 100644 awx_collection/tests/sanity/ignore-2.15.txt diff --git a/Makefile b/Makefile index d86e9779a4..1185666e76 100644 --- a/Makefile +++ b/Makefile @@ -9,6 +9,17 @@ VERSION := $(shell $(PYTHON) tools/scripts/scm_version.py) # ansible-test requires semver compatable version, so we allow overrides to hack it COLLECTION_VERSION ?= $(shell $(PYTHON) tools/scripts/scm_version.py | cut -d . -f 1-3) +# args for the ansible-test sanity command +COLLECTION_SANITY_ARGS ?= --docker +# collection unit testing directories +COLLECTION_TEST_DIRS ?= awx_collection/test/awx +# collection integration test directories (defaults to all) +COLLECTION_TEST_TARGET ?= +# args for collection install +COLLECTION_PACKAGE ?= awx +COLLECTION_NAMESPACE ?= awx +COLLECTION_INSTALL = ~/.ansible/collections/ansible_collections/$(COLLECTION_NAMESPACE)/$(COLLECTION_PACKAGE) +COLLECTION_TEMPLATE_VERSION ?= false # NOTE: This defaults the container image version to the branch that's active COMPOSE_TAG ?= $(GIT_BRANCH) @@ -290,13 +301,6 @@ test: cd awxkit && $(VENV_BASE)/awx/bin/tox -re py3 awx-manage check_migrations --dry-run --check -n 'missing_migration_file' -COLLECTION_TEST_DIRS ?= awx_collection/test/awx -COLLECTION_TEST_TARGET ?= -COLLECTION_PACKAGE ?= awx -COLLECTION_NAMESPACE ?= awx -COLLECTION_INSTALL = ~/.ansible/collections/ansible_collections/$(COLLECTION_NAMESPACE)/$(COLLECTION_PACKAGE) -COLLECTION_TEMPLATE_VERSION ?= false - test_collection: rm -f $(shell ls -d $(VENV_BASE)/awx/lib/python* | head -n 1)/no-global-site-packages.txt if [ "$(VENV_BASE)" ]; then \ @@ -339,7 +343,7 @@ test_collection_sanity: if ! [ -x "$(shell command -v ansible-test)" ]; then pip install ansible-core; fi ansible --version COLLECTION_VERSION=1.0.0 make install_collection - cd $(COLLECTION_INSTALL) && ansible-test sanity --docker + cd $(COLLECTION_INSTALL) && ansible-test sanity $(COLLECTION_SANITY_ARGS) test_collection_integration: install_collection cd $(COLLECTION_INSTALL) && ansible-test integration $(COLLECTION_TEST_TARGET) diff --git a/awx_collection/tests/sanity/ignore-2.15.txt b/awx_collection/tests/sanity/ignore-2.15.txt new file mode 100644 index 0000000000..19512ea0c1 --- /dev/null +++ b/awx_collection/tests/sanity/ignore-2.15.txt @@ -0,0 +1 @@ +plugins/modules/export.py validate-modules:nonexistent-parameter-documented # needs awxkit to construct argspec From f739908ccf8c897321b3f70981eba7527fc10cb7 Mon Sep 17 00:00:00 2001 From: Alan Rominger Date: Wed, 21 Dec 2022 09:57:00 -0500 Subject: [PATCH 3/3] Add comment about Ansible-core being installed by default Co-authored-by: John R Barker --- .github/workflows/ci.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 97df2050cd..faa2b02192 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -154,6 +154,7 @@ jobs: steps: - uses: actions/checkout@v2 + # The containers that GitHub Actions use have Ansible installed, so upgrade to make sure we have the latest version. - name: Upgrade ansible-core run: python3 -m pip install --upgrade ansible-core