From c449c4c41a4068ceef1e041950e2326fab56db75 Mon Sep 17 00:00:00 2001 From: Alan Rominger Date: Fri, 6 Jun 2025 16:06:55 -0400 Subject: [PATCH] Combine Django bump with other fixes to github checks (#16015) * Add no cov on fail flag to fix CI * Bump django to 4.2.21 * Coverage args * Try cov equals awx * Run migration test in parallel * Ignore error and clean up commands * Try to make schema check not hang --------- Co-authored-by: Satoe Imaishi --- Makefile | 18 +++++++++++------- pytest.ini | 3 +++ requirements/requirements.in | 2 +- requirements/requirements.txt | 2 +- tools/docker-compose/start_tests.sh | 6 +++--- 5 files changed, 19 insertions(+), 12 deletions(-) diff --git a/Makefile b/Makefile index 036d0be1cc..83b4d2401c 100644 --- a/Makefile +++ b/Makefile @@ -19,6 +19,12 @@ COLLECTION_VERSION ?= $(shell $(PYTHON) tools/scripts/scm_version.py | cut -d . COLLECTION_SANITY_ARGS ?= --docker # collection unit testing directories COLLECTION_TEST_DIRS ?= awx_collection/test/awx +# pytest added args to collect coverage +COVERAGE_ARGS ?= --cov=awx --cov-report=xml --junitxml=reports/junit.xml --no-cov-on-fail +# pytest test directories +TEST_DIRS ?= awx/main/tests/unit awx/main/tests/functional awx/conf/tests +# pytest args to run tests in parallel +PARALLEL_TESTS ?= -n auto # collection integration test directories (defaults to all) COLLECTION_TEST_TARGET ?= # args for collection install @@ -316,7 +322,7 @@ swagger: reports @if [ "$(VENV_BASE)" ]; then \ . $(VENV_BASE)/awx/bin/activate; \ fi; \ - (set -o pipefail && py.test --cov --cov-report=xml --junitxml=reports/junit.xml $(PYTEST_ARGS) awx/conf/tests/functional awx/main/tests/functional/api awx/main/tests/docs | tee reports/$@.report) + (set -o pipefail && py.test $(COVERAGE_ARGS) $(PARALLEL_TESTS) awx/conf/tests/functional awx/main/tests/functional/api awx/main/tests/docs | tee reports/$@.report) @if [ "${GITHUB_ACTIONS}" = "true" ]; \ then \ echo 'cov-report-files=reports/coverage.xml' >> "${GITHUB_OUTPUT}"; \ @@ -334,14 +340,12 @@ api-lint: awx-link: [ -d "/awx_devel/awx.egg-info" ] || $(PYTHON) /awx_devel/tools/scripts/egg_info_dev -TEST_DIRS ?= awx/main/tests/unit awx/main/tests/functional awx/conf/tests -PYTEST_ARGS ?= -n auto ## Run all API unit tests. test: if [ "$(VENV_BASE)" ]; then \ . $(VENV_BASE)/awx/bin/activate; \ fi; \ - PYTHONDONTWRITEBYTECODE=1 py.test -p no:cacheprovider $(PYTEST_ARGS) $(TEST_DIRS) + PYTHONDONTWRITEBYTECODE=1 py.test -p no:cacheprovider $(PARALLEL_TESTS) $(TEST_DIRS) cd awxkit && $(VENV_BASE)/awx/bin/tox -re py3 awx-manage check_migrations --dry-run --check -n 'missing_migration_file' @@ -350,7 +354,7 @@ live_test: ## Run all API unit tests with coverage enabled. test_coverage: - $(MAKE) test PYTEST_ARGS="--create-db --cov --cov-report=xml --junitxml=reports/junit.xml" + $(MAKE) test PYTEST_ARGS="--create-db $(COVERAGE_ARGS)" @if [ "${GITHUB_ACTIONS}" = "true" ]; \ then \ echo 'cov-report-files=awxkit/coverage.xml,reports/coverage.xml' >> "${GITHUB_OUTPUT}"; \ @@ -358,7 +362,7 @@ test_coverage: fi test_migrations: - PYTHONDONTWRITEBYTECODE=1 py.test -p no:cacheprovider --migrations -m migration_test --create-db --cov=awx --cov-report=xml --junitxml=reports/junit.xml $(PYTEST_ARGS) $(TEST_DIRS) + PYTHONDONTWRITEBYTECODE=1 py.test -p no:cacheprovider --migrations -m migration_test --create-db $(PARALLEL_TESTS) $(COVERAGE_ARGS) $(TEST_DIRS) @if [ "${GITHUB_ACTIONS}" = "true" ]; \ then \ echo 'cov-report-files=reports/coverage.xml' >> "${GITHUB_OUTPUT}"; \ @@ -376,7 +380,7 @@ test_collection: fi && \ if ! [ -x "$(shell command -v ansible-playbook)" ]; then pip install ansible-core; fi ansible --version - py.test $(COLLECTION_TEST_DIRS) --cov --cov-report=xml --junitxml=reports/junit.xml -v + py.test $(COLLECTION_TEST_DIRS) $(COVERAGE_ARGS) -v @if [ "${GITHUB_ACTIONS}" = "true" ]; \ then \ echo 'cov-report-files=reports/coverage.xml' >> "${GITHUB_OUTPUT}"; \ diff --git a/pytest.ini b/pytest.ini index 5e4bf72dd5..512da67f81 100644 --- a/pytest.ini +++ b/pytest.ini @@ -15,6 +15,9 @@ markers = filterwarnings = error + # Breaks coverage combined with pytest-mp, surfacing as an unhandled error outside of test scope + ignore:Module awx was previously imported, but not measured:coverage.exceptions.CoverageWarning + # FIXME: Upgrade protobuf https://github.com/protocolbuffers/protobuf/issues/15077 once:Type google._upb._message.* uses PyType_Spec with a metaclass that has custom tp_new:DeprecationWarning diff --git a/requirements/requirements.in b/requirements/requirements.in index 838926747c..3afb0fef06 100644 --- a/requirements/requirements.in +++ b/requirements/requirements.in @@ -14,7 +14,7 @@ cryptography<42.0.0 # investigation is needed for 42+ to work with OpenSSL v3.0 Cython daphne distro -django==4.2.20 # CVE-2025-26699 +django==4.2.21 # CVE-2025-32873 django-cors-headers django-crum django-extensions diff --git a/requirements/requirements.txt b/requirements/requirements.txt index 327e3a8d12..eedef91c1a 100644 --- a/requirements/requirements.txt +++ b/requirements/requirements.txt @@ -132,7 +132,7 @@ dispatcherd==2025.5.21 # via -r /awx_devel/requirements/requirements.in distro==1.9.0 # via -r /awx_devel/requirements/requirements.in -django==4.2.20 +django==4.2.21 # via # -r /awx_devel/requirements/requirements.in # channels diff --git a/tools/docker-compose/start_tests.sh b/tools/docker-compose/start_tests.sh index 67f2e644a6..ff19d027e4 100755 --- a/tools/docker-compose/start_tests.sh +++ b/tools/docker-compose/start_tests.sh @@ -1,12 +1,12 @@ #!/bin/bash -set +x +set -euo pipefail cd /awx_devel make clean make awx-link -if [[ ! $@ ]]; then +if [[ $# -eq 0 ]]; then make test else - make $@ + make "$@" fi