summaryrefslogtreecommitdiffstats
path: root/ansible_collections/cisco/meraki/scripts
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-13 12:04:41 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-13 12:04:41 +0000
commit975f66f2eebe9dadba04f275774d4ab83f74cf25 (patch)
tree89bd26a93aaae6a25749145b7e4bca4a1e75b2be /ansible_collections/cisco/meraki/scripts
parentInitial commit. (diff)
downloadansible-975f66f2eebe9dadba04f275774d4ab83f74cf25.tar.xz
ansible-975f66f2eebe9dadba04f275774d4ab83f74cf25.zip
Adding upstream version 7.7.0+dfsg.upstream/7.7.0+dfsg
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'ansible_collections/cisco/meraki/scripts')
-rw-r--r--ansible_collections/cisco/meraki/scripts/sublime-build/build.py76
-rwxr-xr-xansible_collections/cisco/meraki/scripts/sublime-build/build.py.generic76
-rw-r--r--ansible_collections/cisco/meraki/scripts/sublime-build/requirements.txt1
3 files changed, 153 insertions, 0 deletions
diff --git a/ansible_collections/cisco/meraki/scripts/sublime-build/build.py b/ansible_collections/cisco/meraki/scripts/sublime-build/build.py
new file mode 100644
index 000000000..53acd432b
--- /dev/null
+++ b/ansible_collections/cisco/meraki/scripts/sublime-build/build.py
@@ -0,0 +1,76 @@
+#!/usr/bin/env python
+
+import subprocess
+import sys
+import pathlib
+
+
+def is_path_module(path) -> bool:
+ path = pathlib.Path(path)
+ parts = path.parts
+ if "plugins" in parts and "modules" in parts:
+ # print(f"This is module {str(parts[-1])}")
+ return True
+ return False
+
+
+def is_path_integration_test(path) -> bool:
+ path = pathlib.Path(path)
+ parts = path.parts
+ if "integration" in parts and "tests" in parts:
+ return True
+ return False
+
+
+def get_module_name_from_module(path) -> str:
+ path = pathlib.Path(path)
+ parts = path.parts
+ return parts[-1].split(".")[0]
+
+
+def get_module_name_from_test(path) -> str:
+ path = pathlib.Path(path)
+ parts = path.parts
+ return parts[-3]
+
+
+def execute_tests(module_name, ansible_test_path=None) -> None:
+ if ansible_test_path is not None:
+ if ansible_test_path[-1] != "/":
+ ansible_test_path = f"{ansible_test_path}/"
+ with subprocess.Popen(
+ [
+ f"{ansible_test_path}ansible-test",
+ "network-integration",
+ "--allow-unsupported",
+ module_name,
+ ],
+ ) as process:
+ process.communicate()
+ else:
+ with subprocess.Popen(
+ [
+ "ansible-test",
+ "network-integration",
+ "--allow-unsupported",
+ module_name,
+ ],
+ ) as process:
+ process.communicate()
+
+
+def main():
+ if len(sys.argv) == 1:
+ sys.exit("File path must be passed as an argument.")
+ if is_path_module(sys.argv[1]) is True:
+ module_name = get_module_name_from_module(sys.argv[1])
+ if is_path_integration_test(sys.argv[1]) is True:
+ module_name = get_module_name_from_test(sys.argv[1])
+ if len(sys.argv) == 3: # Specify ansible-test path
+ execute_tests(module_name, sys.argv[2])
+ else:
+ execute_tests(module_name)
+
+
+if __name__ == "__main__":
+ main()
diff --git a/ansible_collections/cisco/meraki/scripts/sublime-build/build.py.generic b/ansible_collections/cisco/meraki/scripts/sublime-build/build.py.generic
new file mode 100755
index 000000000..53acd432b
--- /dev/null
+++ b/ansible_collections/cisco/meraki/scripts/sublime-build/build.py.generic
@@ -0,0 +1,76 @@
+#!/usr/bin/env python
+
+import subprocess
+import sys
+import pathlib
+
+
+def is_path_module(path) -> bool:
+ path = pathlib.Path(path)
+ parts = path.parts
+ if "plugins" in parts and "modules" in parts:
+ # print(f"This is module {str(parts[-1])}")
+ return True
+ return False
+
+
+def is_path_integration_test(path) -> bool:
+ path = pathlib.Path(path)
+ parts = path.parts
+ if "integration" in parts and "tests" in parts:
+ return True
+ return False
+
+
+def get_module_name_from_module(path) -> str:
+ path = pathlib.Path(path)
+ parts = path.parts
+ return parts[-1].split(".")[0]
+
+
+def get_module_name_from_test(path) -> str:
+ path = pathlib.Path(path)
+ parts = path.parts
+ return parts[-3]
+
+
+def execute_tests(module_name, ansible_test_path=None) -> None:
+ if ansible_test_path is not None:
+ if ansible_test_path[-1] != "/":
+ ansible_test_path = f"{ansible_test_path}/"
+ with subprocess.Popen(
+ [
+ f"{ansible_test_path}ansible-test",
+ "network-integration",
+ "--allow-unsupported",
+ module_name,
+ ],
+ ) as process:
+ process.communicate()
+ else:
+ with subprocess.Popen(
+ [
+ "ansible-test",
+ "network-integration",
+ "--allow-unsupported",
+ module_name,
+ ],
+ ) as process:
+ process.communicate()
+
+
+def main():
+ if len(sys.argv) == 1:
+ sys.exit("File path must be passed as an argument.")
+ if is_path_module(sys.argv[1]) is True:
+ module_name = get_module_name_from_module(sys.argv[1])
+ if is_path_integration_test(sys.argv[1]) is True:
+ module_name = get_module_name_from_test(sys.argv[1])
+ if len(sys.argv) == 3: # Specify ansible-test path
+ execute_tests(module_name, sys.argv[2])
+ else:
+ execute_tests(module_name)
+
+
+if __name__ == "__main__":
+ main()
diff --git a/ansible_collections/cisco/meraki/scripts/sublime-build/requirements.txt b/ansible_collections/cisco/meraki/scripts/sublime-build/requirements.txt
new file mode 100644
index 000000000..dca9a9096
--- /dev/null
+++ b/ansible_collections/cisco/meraki/scripts/sublime-build/requirements.txt
@@ -0,0 +1 @@
+click