From e2d2da2670c79c5f852dde5ec97815c5a130b471 Mon Sep 17 00:00:00 2001 From: Felix Matouschek Date: Thu, 11 Apr 2024 14:50:51 +0200 Subject: [PATCH 1/3] chore: Add tox configuration Add tox configuration that allows to build a venv for development and to format source files. To make use of it add appropriate Makefile targets. Drop unneeded requirements from requirements.txt and test-requirements.txt and add needed requirements. Signed-off-by: Felix Matouschek --- .gitignore | 3 +++ Makefile | 9 +++++++++ galaxy.yml | 1 + test-requirements.txt | 9 ++------- tests/requirements.txt | 2 ++ tests/unit/requirements.txt | 5 ----- tox.ini | 22 ++++++++++++++++++++++ 7 files changed, 39 insertions(+), 12 deletions(-) create mode 100644 tests/requirements.txt delete mode 100644 tests/unit/requirements.txt create mode 100644 tox.ini diff --git a/.gitignore b/.gitignore index 1a097c1..3d59881 100644 --- a/.gitignore +++ b/.gitignore @@ -136,6 +136,9 @@ bin/ *.tar.gz *.zip +# pytest-ansible +collections/ + # Collection specific ignores /changelogs/.plugin-cache.yaml /tests/output/ diff --git a/Makefile b/Makefile index 12945d1..bf8c961 100644 --- a/Makefile +++ b/Makefile @@ -7,3 +7,12 @@ cluster-up: .PHONY: cluster-down cluster-down: hack/e2e-setup.sh --cleanup + +.PHONY: build-venv +build-venv: + tox run -e venv + ln -sf .tox/venv .venv + +.PHONY: format +format: + tox run -e format diff --git a/galaxy.yml b/galaxy.yml index 5859945..fa54fde 100644 --- a/galaxy.yml +++ b/galaxy.yml @@ -35,6 +35,7 @@ build_ignore: - Makefile - OWNERS - REVIEW_CHECKLIST.md + - tox.ini - '*.tar.gz' - '*.zip' - docs/_gh_include diff --git a/test-requirements.txt b/test-requirements.txt index 47283a2..f90b181 100644 --- a/test-requirements.txt +++ b/test-requirements.txt @@ -1,9 +1,4 @@ -kubernetes-validate -coverage==4.5.4 -mock pytest -pytest-xdist -pytest-mock -pytest-forked -virtualenv pytest-ansible +pytest-xdist +tox-ansible diff --git a/tests/requirements.txt b/tests/requirements.txt new file mode 100644 index 0000000..89812bf --- /dev/null +++ b/tests/requirements.txt @@ -0,0 +1,2 @@ +# No additional requirements at this moment +# Have a look at /requirements.txt and /test-requirements.txt diff --git a/tests/unit/requirements.txt b/tests/unit/requirements.txt deleted file mode 100644 index 7f955e9..0000000 --- a/tests/unit/requirements.txt +++ /dev/null @@ -1,5 +0,0 @@ -jinja2 -jsonpatch -kubernetes>=28.1.0 -PyYAML>=3.11 -pytest diff --git a/tox.ini b/tox.ini new file mode 100644 index 0000000..4879a8f --- /dev/null +++ b/tox.ini @@ -0,0 +1,22 @@ +[tox] +env_list = venv + +[testenv:venv] +download = True +deps = + -r requirements.txt + -r test-requirements.txt + -r tests/requirements.txt +allowlist_externals = + mkdir + ln +commands = + mkdir -p "{env_site_packages_dir}/ansible_collections/kubevirt" + ln -sf "{tox_root}" "{env_site_packages_dir}/ansible_collections/kubevirt/core" + ansible-galaxy collection install -r requirements.yml -p "{env_site_packages_dir}/ansible_collections" --force + +[testenv:format] +deps = + black +commands = black . + From 55a6acef5d1931419058a3a0d395badcbfd8295e Mon Sep 17 00:00:00 2001 From: Felix Matouschek Date: Thu, 11 Apr 2024 15:02:51 +0200 Subject: [PATCH 2/3] chore: Add tox-ansible configuration Add tox-ansible configuration that allows to run tests with all required ansible and python versions. Add Makefile targets to make use of it. Signed-off-by: Felix Matouschek --- .gitignore | 3 ++- Makefile | 12 ++++++++++++ tox-ansible.ini | 0 3 files changed, 14 insertions(+), 1 deletion(-) create mode 100644 tox-ansible.ini diff --git a/.gitignore b/.gitignore index 3d59881..4cf02ec 100644 --- a/.gitignore +++ b/.gitignore @@ -136,8 +136,9 @@ bin/ *.tar.gz *.zip -# pytest-ansible +# pytest-ansible and tox-ansible collections/ +kubevirt.core # Collection specific ignores /changelogs/.plugin-cache.yaml diff --git a/Makefile b/Makefile index bf8c961..5ddb50d 100644 --- a/Makefile +++ b/Makefile @@ -16,3 +16,15 @@ build-venv: .PHONY: format format: tox run -e format + +.PHONY: test-sanity +test-sanity: + tox -f sanity --ansible -p auto --conf tox-ansible.ini + +.PHONY: test-unit +test-unit: + tox -f unit --ansible -p auto --conf tox-ansible.ini + +.PHONY: test-integration +test-integration: + tox -f integration --ansible --conf tox-ansible.ini diff --git a/tox-ansible.ini b/tox-ansible.ini new file mode 100644 index 0000000..e69de29 From ac589abf5ef9ca2789c0a502e6951ccbc9493901 Mon Sep 17 00:00:00 2001 From: Felix Matouschek Date: Thu, 11 Apr 2024 14:53:05 +0200 Subject: [PATCH 3/3] chore: Add vscode configuration Add vscode configuration that allows to develop, test and debug the collection. Signed-off-by: Felix Matouschek --- .gitignore | 7 ++++++- .vscode/extensions.json | 8 ++++++++ .vscode/settings.json | 7 +++++++ galaxy.yml | 1 + 4 files changed, 22 insertions(+), 1 deletion(-) create mode 100644 .vscode/extensions.json create mode 100644 .vscode/settings.json diff --git a/.gitignore b/.gitignore index 4cf02ec..10d32f0 100644 --- a/.gitignore +++ b/.gitignore @@ -130,7 +130,12 @@ dmypy.json # Pyre type checker .pyre/ -.vscode/ +# Allow specific vscode configuration +.vscode/* +!.vscode/extensions.json +!.vscode/settings.json + +# Local files .idea/ bin/ *.tar.gz diff --git a/.vscode/extensions.json b/.vscode/extensions.json new file mode 100644 index 0000000..b9ffe4a --- /dev/null +++ b/.vscode/extensions.json @@ -0,0 +1,8 @@ +{ + "recommendations": [ + "ms-python.python", + "ms-python.debugpy", + "ms-python.vscode-pylance", + "github.vscode-github-actions" + ] +} diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..a3a1838 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,7 @@ +{ + "python.testing.pytestArgs": [ + "tests" + ], + "python.testing.unittestEnabled": false, + "python.testing.pytestEnabled": true +} diff --git a/galaxy.yml b/galaxy.yml index fa54fde..c230928 100644 --- a/galaxy.yml +++ b/galaxy.yml @@ -26,6 +26,7 @@ build_ignore: - .git - .gitignore - .github + - .vscode - .yamllint - bin - changelogs