Skip to content

Commit

Permalink
ci: add tox.ini file
Browse files Browse the repository at this point in the history
  • Loading branch information
jorgepiloto committed Dec 2, 2024
1 parent 7fc9b54 commit 0d3b3c7
Show file tree
Hide file tree
Showing 2 changed files with 90 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -192,3 +192,6 @@ src/ansys/grpc/

# C extensions
*.so

# Ignore auto-generated API reference
doc/source/api
87 changes: 87 additions & 0 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
[tox]
description = Default tox environments list
envlist =
code-style
doc-style-{linux,windows}
doc-{links,html,pdf}
dist
skip_missing_interpreters = true
isolated_build = true
isolated_build_env = build

[testenv]
description = Checks for project testing with desired extras
basepython =
test39: python3.9
test310: python3.10
test311: python3.11
test312: python3.12
{style,doc,dist}: python3
passenv =
setenv =
PYTHONUNBUFFERED = yes
deps =
-r{toxinidir}/requirements/requirements_test.txt
commands =
pytest {toxinidir}/tests

[testenv:code-style]
description = Checks project code style
skip_install = true
deps =
pre-commit
commands =
pre-commit install
pre-commit run --all-files --show-diff-on-failure

[testenv:doc-style-{linux,windows}]
description = Checks project documentation style
skip_install = true
allowlist_externals =
find
vale
bash
cmd
platform =
linux: linux
windows: win32
commands =
linux: bash -c 'rst_files=$(find {toxinidir}/doc/source -type f -name "*.rst" ! -path "doc/source/api/*") && py_files=$(find {toxinidir}/examples -type f -name "*.py" ! -name "*_*") && vale_files="$rst_files $py_files" && vale sync --config="{toxinidir}/doc/.vale.ini" && vale --config="{toxinidir}/doc/.vale.ini" $rst_files'
windows: cmd /c "for /r {toxinidir}\doc\source %i in (*.rst) do @echo %i | findstr /v /i \doc\source\api\ > tmp_rst_files.txt"
windows: cmd /c "for /r {toxinidir}\examples %i in (*.py) do @echo %i | findstr /v /i *_* >> tmp_py_files.txt"
windows: cmd /c "setlocal enabledelayedexpansion && for /f %i in (tmp_rst_files.txt) do @set vale_files=!vale_files! %i && for /f %i in (tmp_py_files.txt) do @set vale_files=!vale_files! %i && vale sync --config="{toxinidir}\doc\.vale.ini" && vale --config="{toxinidir}\doc\.vale.ini" !rst_files! && endlocal"

[testenv:doc-{clean,links,html,pdf}]
description = Check if documentation generates properly
allowlist_externals =
pdflatex
setenv =
SOURCE_DIR = doc/source
BUILD_DIR = doc/_build
STATIC_DIR = doc/source/_static
SPHINX_APIDOC_OPTIONS=inherited-members
links: BUILDER = linkcheck
html: BUILDER = html
pdf: BUILDER = latex
links,html,pdf: BUILDER_OPTS = --color -v -j auto -W --keep-going
deps =
-r{toxinidir}/requirements/requirements_docs.txt
commands =
# Remove rendered documentation and additional static files
clean: python -c "import shutil, sys; shutil.rmtree(sys.argv[1], ignore_errors=True)" "{toxinidir}/{env:BUILD_DIR}"
clean: python -c "import shutil, sys; shutil.rmtree(sys.argv[1], ignore_errors=True)" "{toxinidir}/{env:STATIC_DIR}/artifacts"

# Render documentation with desired builder
links,html,pdf: sphinx-apidoc -o {toxinidir}/doc/source/api {toxinidir}/src/ansys {toxinidir}/src/ansys/dpf/core/log.py \
{toxinidir}/src/ansys/dpf/core/help.py {toxinidir}/src/ansys/dpf/core/mapping_types.py {toxinidir}/src/ansys/dpf/core/ipconfig.py \
{toxinidir}/src/ansys/dpf/core/field_base.py {toxinidir}/src/ansys/dpf/core/cache.py {toxinidir}/src/ansys/dpf/core/misc.py \
{toxinidir}/src/ansys/dpf/core/check_version.py {toxinidir}/src/ansys/dpf/core/operators/build.py {toxinidir}/src/ansys/dpf/core/operators/specification.py \
{toxinidir}/src/ansys/dpf/core/vtk_helper.py {toxinidir}/src/ansys/dpf/core/label_space.py {toxinidir}/src/ansys/dpf/core/examples/python_plugins/* \
{toxinidir}/src/ansys/dpf/core/examples/examples.py {toxinidir}/src/ansys/dpf/gate/* {toxinidir}/src/ansys/dpf/gatebin/* {toxinidir}/src/ansys/grpc/dpf/* \
{toxinidir}/src/ansys/dpf/core/property_fields_container.py \
-f --implicit-namespaces --separate --no-headings
links,html,pdf: sphinx-build -d "{toxworkdir}/doc_doctree" {env:SOURCE_DIR} "{toxinidir}/{env:BUILD_DIR}/{env:BUILDER}" {env:BUILDER_OPTS} -b {env:BUILDER}

# PDF documentation
pdf: pdflatex -interaction=nonstopmode -output-directory="{toxinidir}/{env:BUILD_DIR}/{env:BUILDER}" {toxinidir}/{env:BUILD_DIR}/{env:BUILDER}/ansys-dpf-core.tex

0 comments on commit 0d3b3c7

Please sign in to comment.