From a6cb202624e29ec4ee4cb989ed10e8c92be85574 Mon Sep 17 00:00:00 2001 From: Hugo van Kemenade Date: Sun, 5 Nov 2023 22:54:09 +0200 Subject: [PATCH] Test via tox --- .coveragerc | 7 +++++++ .github/workflows/tests.yml | 32 +++++++++++++++++++++----------- .gitignore | 2 ++ pyproject.toml | 5 +++++ tox.ini | 19 +++++++++++++++++++ 5 files changed, 54 insertions(+), 11 deletions(-) create mode 100644 .coveragerc create mode 100644 tox.ini 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 84a157e3b..37ed84a5b 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -15,10 +15,12 @@ jobs: matrix: # when adding new versions, update the one used to test # friend projects below to the latest one - python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"] - os: [ubuntu-latest, macos-latest, windows-latest] + python-version: ["pypy3.10", "3.8", "3.9", "3.10", "3.11", "3.12"] + os: [windows-latest, macos-latest, ubuntu-latest] + steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 + - name: Set up Python ${{ matrix.python-version }} uses: actions/setup-python@v4 with: @@ -26,14 +28,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.12' && 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 5f4d12743..912145cca 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}