Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make a tox.ini which is more sunpy like - Mk II #26

Merged
merged 7 commits into from
Feb 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion {{ cookiecutter.package_name }}/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,10 @@ open_astronomy_package_template_example = "{{ cookiecutter.module_name }}.exampl

{% endif -%}
[project.optional-dependencies]
test = [
tests = [
"pytest",
"pytest-doctestplus",
"pytest-cov",
]
docs = [
"sphinx",
Expand Down
70 changes: 38 additions & 32 deletions {{ cookiecutter.package_name }}/tox.ini
Original file line number Diff line number Diff line change
@@ -1,57 +1,63 @@
[tox]
min_version = 4.0
requires =
tox-pypi-filter>=0.14
envlist =
py{38,39,310,311}-test
py38-test-oldestdeps
py{39,310,311,312}
py312-devdeps
py39-oldestdeps
build_docs
isolated_build = true

[testenv]
# tox environments are constructed with so-called 'factors' (or terms)
# separated by hyphens, e.g. test-devdeps-cov. Lines below starting with factor:
# will only take effect if that factor is included in the environment name. To
# see a list of example environments that can be run, along with a description,
# run:
#
# tox -l -v
#
pypi_filter = https://raw.githubusercontent.com/sunpy/sunpy/main/.test_package_pins.txt
# Run the tests in a temporary directory to make sure that we don't import
# the package from the source tree
change_dir = .tmp/{envname}
description =
run tests
oldestdeps: with the oldest supported version of key dependencies
devdeps: with the latest developer version of key dependencies

# Pass through the following environment variables which may be needed for the CI
pass_env =
HOME
WINDIR
LC_ALL
LC_CTYPE
CC
CI
TRAVIS

# Suppress display of matplotlib plots generated during docs build
set_env =
set_env =
MPLBACKEND=agg

# Run the tests in a temporary directory to make sure that we don't import
# the package from the source tree
change_dir = .tmp/{envname}
devdeps: PIP_EXTRA_INDEX_URL = https://pypi.anaconda.org/astropy/simple https://pypi.anaconda.org/scientific-python-nightly-wheels/simple
# Define the base test command here to allow us to add more flags for each tox factor
PYTEST_COMMAND = pytest -vvv -r fEs --pyargs {{ cookiecutter.module_name }} --cov-report=xml --cov={{ cookiecutter.module_name }} --cov-config={toxinidir}/pyproject.toml {toxinidir}/docs

deps =
# For packages which publish nightly wheels this will pull the latest nightly
devdeps: numpy>=0.0.dev0
# Packages without nightly wheels will be built from source like this
# devdeps: git+https://github.com/ndcube/ndcube
oldestdeps: minimum_dependencies
pytest-cov

# The following indicates which extras_require from setup.cfg will be installed
# The following indicates which extras_require will be installed
extras =
test
tests

commands_pre =
oldestdeps: minimum_dependencies packagename --filename requirements-min.txt
oldestdeps: pip install -r requirements-min.txt
pip freeze
pip freeze --all --no-input

commands =
pytest --pyargs packagename --cov {{ cookiecutter.module_name }} --cov-report xml:coverage.xml --cov-report term-missing {posargs}
# To run different commands for different factors exclude the factor from the default command like this
# !online: {env:PYTEST_COMMAND} {posargs}
# Then specify a specific one like this
# online: {env:PYTEST_COMMAND} --remote-data=any {posargs}
# If you have no factors which require different commands this is all you need:
{env:PYTEST_COMMAND} {posargs}

# Uncomment this once we add pre-commit
#[testenv:codestyle]
#pypi_filter =
#skip_install = true
#description = Run all style and file checks with pre-commit
#deps =
# pre-commit
#commands =
# pre-commit install-hooks
# pre-commit run --color always --all-files --show-diff-on-failure

[testenv:build_docs]
description = invoke sphinx-build to build the HTML docs
Expand Down