11# This is work in progress, testing workflow in local/CI is gradually being transferred to tox
22
33# Usage instructions:
4+
45# `tox` will run all tests sequentially, `tox --parallel` will run all tests in parallel (much faster).
56# Run specific selection of tests with `tox -e pretest,<list-of-tests>,posttest` e.g., `tox -e pretest,test-api,test-launcher,posttest`
67# `--parallel` flag can be passed when running specific selections.
78
9+ # For packaging, build wheels for specific platform with `tox -e build-wheel -- <platform_name>`.
10+ # If `tox -e build-wheel` is run without passing a platform, tox will automatically build the ffl wheels based on the operating system
11+ # on which it is executing: windows -> "win_amd64", linux -> "manylinux_2_17_x86_64", mac -> "any"
12+
813[tox]
914description = Default tox environment list and core configurations
1015
11- # List all tests to run in parallel or sequential mode here
12- # So invocation can be specified as `tox`/`tox --parallel` to run all tests in sequential/parallel mode
1316envlist = pretest,test-{api,launcher,server,local_server,multi_server,remote_workflow,remote_operator,workflow,service,operators},posttest
1417
1518isolated_build_env = build
@@ -24,17 +27,6 @@ pass_env =
2427 ANSYSLMD_LICENSE_FILE
2528 AWP_ROOT242
2629
27- package = external # To allow custom wheel builds
28-
29- [testenv:build_external]
30- description = Environment for custom build of package wheels, solves PyDPF custom wheel building requirement
31-
32- package_glob = {toxinidir}{/}dist{/}ansys_dpf_core*
33-
34- # {on_platform} substitution to automatically detect os type.
35- commands =
36- python .ci/build_wheel.py -p {on_platform} -w
37-
3830[testenv:pretest]
3931description = Environment to kill servers and organize test files prior to testing
4032
@@ -115,4 +107,71 @@ deps =
115107 -r requirements/requirements_test.txt
116108
117109commands =
118- pytest {env:PYTEST_PYTHON_FILES} {env:DEBUG} {env:COVERAGE} {env:RERUNS} {env:JUNITXML}
110+ pytest {env:PYTEST_PYTHON_FILES} {env:DEBUG} {env:COVERAGE} {env:RERUNS} {env:JUNITXML}
111+
112+ [testenv:doc-{clean,links,html}]
113+ description = Environment for documentation generation
114+
115+ setenv =
116+ SOURCE_DIR = doc/source
117+ BUILD_DIR = doc/build
118+ BUILDER_OPTS = --color -j auto
119+ links: BUILDER = linkcheck
120+ html: BUILDER = html
121+
122+ skip_install =
123+ clean: True
124+
125+ deps =
126+ links,html: -r requirements/requirements_docs.txt
127+
128+ commands_pre =
129+ # Clear any running servers that may be locking resources
130+ html,links: python -c " import psutil; proc_name = 'Ans.Dpf.Grpc'; nb_procs = len([proc.kill() for proc in psutil.process_iter() if proc_name in proc.name()]); \
131+ html,links: print(f'Killed \{nb_procs} \{proc_name} processes.')"
132+
133+ commands =
134+ # Remove previously rendered documentation
135+ clean: python -c " import shutil, sys; shutil.rmtree(sys.argv[1], ignore_errors=True)" " {toxinidir}/{env:BUILD_DIR}"
136+
137+ # Ensure vtk compatibility
138+ html: python -m pip uninstall --yes vtk
139+ html: python -m pip install --extra-index-url https://wheels.vtk.org vtk-osmesa ==9.2.20230527.dev0
140+
141+ # Clean files from previous build
142+ html: python -c " \
143+ html: from os.path import exists; import shutil; \
144+ html: [(shutil.rmtree(p) if exists(p) else None) for p in ['{env:SOURCE_DIR}/images/auto-generated']]; \
145+ html: [(shutil.move(src, dst) if exists(src) else None) for src, dst in \
146+ html: [('{env:SOURCE_DIR}/examples/07-python-operators/plugins', '{env:SOURCE_DIR}/_temp/plugins'), \
147+ html: ('{env:SOURCE_DIR}/examples/04-advanced/02-volume_averaged_stress', '{env:SOURCE_DIR}/_temp/04_advanced'), \
148+ html: ('{env:SOURCE_DIR}/examples/12-fluids/02-fluids_results', '{env:SOURCE_DIR}/_temp/12_fluids')]]; \
149+ html: [shutil.rmtree(p) for p in ['{env:SOURCE_DIR}/examples'] if exists(p)]; \
150+ html: [(shutil.move(src, dst) if exists(src) else None) for src, dst in \
151+ html: [('{env:SOURCE_DIR}/_temp/plugins', '{env:SOURCE_DIR}/examples/07-python-operators/plugins'), \
152+ html: ('{env:SOURCE_DIR}/_temp/04_advanced', '{env:SOURCE_DIR}/examples/04-advanced/02-volume_averaged_stress'), \
153+ html: ('{env:SOURCE_DIR}/_temp/12_fluids', '{env:SOURCE_DIR}/examples/12-fluids/02-fluids_results')]]; \
154+ html: [shutil.rmtree(p) for p in ['{env:SOURCE_DIR}/_temp'] if exists(p)]"
155+
156+ # Build documentation
157+ html,links: sphinx-build -b {env:BUILDER} {env:SOURCE_DIR} {env:BUILD_DIR}/{env:BUILDER} {env:BUILDER_OPTS}
158+
159+ # Patch pyVista issue with elemental plots by copying necessary images
160+ html: python -c " \
161+ html: import os, shutil, glob; os.makedirs('build/html/_images', exist_ok=True); \
162+ html: [(shutil.copy(src, 'build/html/_images') if os.path.exists(src) else print(f'Source not found: {src}')) for src in \
163+ html: glob.glob('{env:SOURCE_DIR}/examples/04-advanced/02-volume_averaged_stress/*') + glob.glob('{env:SOURCE_DIR}/examples/12-fluids/02-fluids_results/*')]"
164+
165+
166+ commands_post =
167+ # Clear any running servers that may be locking resources
168+ html,links: python -c " import psutil; proc_name = 'Ans.Dpf.Grpc'; nb_procs = len([proc.kill() for proc in psutil.process_iter() if proc_name in proc.name()]); \
169+ html,links: print(f'Killed \{nb_procs} \{proc_name} processes.')"
170+
171+ [testenv:build-wheel]
172+ description = Environment for custom build of package wheels
173+
174+ skip_install = True
175+
176+ commands =
177+ python .ci/build_wheel.py -p {posargs:{on_platform}} -w
0 commit comments