From 641bbea82142121d19b684f1491496e4cb7a9f90 Mon Sep 17 00:00:00 2001 From: Bikouo Aubin <79859644+abikouo@users.noreply.github.com> Date: Wed, 6 Dec 2023 15:38:07 +0100 Subject: [PATCH] Running tests locally (#207) * Running tests locally * create temporary directory to run tests in * clean for molecule target * Update Makefile Co-authored-by: Mike Graves --------- Co-authored-by: Mike Graves --- Makefile | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/Makefile b/Makefile index b897aed..4cbdd29 100644 --- a/Makefile +++ b/Makefile @@ -6,26 +6,29 @@ VERSION = 3.0.1 SANITY_TEST_ARGS ?= --docker --color UNITS_TEST_ARGS ?= --docker --color PYTHON_VERSION ?= `python3 -c 'import platform; print("{0}.{1}".format(platform.python_version_tuple()[0], platform.python_version_tuple()[1]))'` +# this expression compute the install path once for all the execution +# See: https://stackoverflow.com/questions/44114466/how-to-declare-a-deferred-variable-that-is-computed-only-once-for-all +INSTALL_PATH ?= $(eval INSTALL_PATH := $(shell mktemp -d))$(INSTALL_PATH) clean: rm -f community-okd-$(VERSION).tar.gz rm -f redhat-openshift-$(VERSION).tar.gz - rm -rf ansible_collections + rm -rf $(INSTALL_PATH) build: clean ansible-galaxy collection build install: build - ansible-galaxy collection install --force -p ansible_collections community-okd-$(VERSION).tar.gz + ansible-galaxy collection install --force -p $(INSTALL_PATH) community-okd-$(VERSION).tar.gz sanity: install - cd ansible_collections/community/okd && ansible-test sanity -v --python $(PYTHON_VERSION) $(SANITY_TEST_ARGS) + cd $(INSTALL_PATH)/ansible_collections/community/okd && ansible-test sanity -v --python $(PYTHON_VERSION) $(SANITY_TEST_ARGS) && rm -rf $(INSTALL_PATH) units: install - cd ansible_collections/community/okd && ansible-test units -v --python $(PYTHON_VERSION) $(UNITS_TEST_ARGS) + cd $(INSTALL_PATH)/ansible_collections/community/okd && ansible-test units -v --python $(PYTHON_VERSION) $(UNITS_TEST_ARGS) && rm -rf $(INSTALL_PATH) molecule: install - molecule test + cd $(INSTALL_PATH)/ansible_collections/community/okd && molecule test && rm -rf $(INSTALL_PATH) test-integration: upstream-test-integration downstream-test-integration