diff --git a/.coveragerc b/.coveragerc new file mode 100644 index 000000000..0f1270750 --- /dev/null +++ b/.coveragerc @@ -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__.: diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 12f4139c1..ff94f3e2b 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -20,8 +20,10 @@ 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: @@ -29,14 +31,22 @@ jobs: 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 }} diff --git a/.gitignore b/.gitignore index b57921aa4..c92356674 100644 --- a/.gitignore +++ b/.gitignore @@ -2,7 +2,9 @@ build/ dist/ __pycache__/ *.egg-info/ +.coverage .envrc .tox/ .venv/ tests/fixtures/friends/ +coverage.xml diff --git a/pyproject.toml b/pyproject.toml index 138ea92e3..298c32435 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -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" diff --git a/tox.ini b/tox.ini new file mode 100644 index 000000000..fe5261b02 --- /dev/null +++ b/tox.ini @@ -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}