Skip to content

Commit

Permalink
Add tox for easy testing of multiple Python versions (#100)
Browse files Browse the repository at this point in the history
  • Loading branch information
hugovk authored Nov 24, 2023
1 parent ac9d13a commit f5ee878
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 9 deletions.
7 changes: 7 additions & 0 deletions .coveragerc
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# .coveragerc to control coverage.py

[report]
# Regexes for lines to exclude from consideration
exclude_also =
# Don't complain if non-runnable code isn't run:
if __name__ == .__main__.:
28 changes: 19 additions & 9 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,23 +20,33 @@ jobs:
exclude:
# TODO Add Windows when regex wheel available for 3.13
- {os: windows-latest, python-version: "3.13"}

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
allow-prereleases: true
cache: pip
cache-dependency-path: .github/workflows/tests.yml
- name: Upgrade pip
run: python -m pip install --upgrade pip
- name: Install pytest
run: python -m pip install --upgrade pytest
- name: Install sphinx-lint to pull dependencies
run: python -m pip install -v .

- name: Install dependencies
run: |
python -m pip install -U pip
python -m pip install -U wheel
python -m pip install -U tox
- name: Download more tests from friend projects
if: matrix.python-version == '3.13' && matrix.os == 'ubuntu-latest'
run: sh download-more-tests.sh
- name: run tests
run: python -m pytest
- name: Tox tests
run: |
tox -e py
- name: Upload coverage
uses: codecov/codecov-action@v3
with:
flags: ${{ matrix.os }}
name: ${{ matrix.os }} Python ${{ matrix.python-version }}
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ build/
dist/
__pycache__/
*.egg-info/
.coverage
.envrc
.tox/
.venv/
tests/fixtures/friends/
coverage.xml
5 changes: 5 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@ dependencies = [
dynamic = ["version"]


[project.optional-dependencies]
tests = [
"pytest",
"pytest-cov",
]
[project.urls]
Repository = "https://github.com/sphinx-contrib/sphinx-lint"
Changelog = "https://github.com/sphinx-contrib/sphinx-lint/releases"
Expand Down
19 changes: 19 additions & 0 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
[tox]
requires =
tox>=4.2
env_list =
py{py3, 313, 312, 311, 310, 39, 38}

[testenv]
extras =
tests
pass_env =
FORCE_COLOR
commands =
{envpython} -m pytest \
--cov sphinxlint \
--cov tests \
--cov-report html \
--cov-report term \
--cov-report xml \
{posargs}

0 comments on commit f5ee878

Please sign in to comment.