diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 6dbc0a0..e685ccd 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -16,18 +16,11 @@ jobs: with: python-version: "3.x" - uses: actions/checkout@v4 - - name: Lint with black through tox + - name: Lint through tox run: | pip install tox - tox -e black - - name: Lint with isort through tox - run: | - pip install tox - tox -e isort - - name: Lint with pylint through tox - run: | - pip install tox - tox -e pylint + tox -e format-and-lint + tests: runs-on: ${{ matrix.os }} @@ -42,14 +35,11 @@ jobs: with: python-version: "3.x" - uses: actions/checkout@v4 - - name: Run tests with pytest - run: | - pip install tox - tox -e py3 - - name: Run doctests for python snippets in markdown files + - name: Run tests through tox run: | pip install tox - tox -e doctest + tox -e test + docs: runs-on: ubuntu-latest steps: diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 61fd8d9..6b11445 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -12,7 +12,7 @@ default_language_version: python: python3 repos: - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.5.0 + rev: v4.6.0 hooks: - id: check-added-large-files args: ['--maxkb=1000'] @@ -30,16 +30,16 @@ repos: # exclude autogenerated files exclude: /README\.rst$|\.pot?$ - repo: https://github.com/psf/black - rev: 24.1.0 # Make sure to use the same tag/version as specified in tox.ini. + rev: 24.4.0 hooks: - id: black language_version: python3 - repo: https://github.com/pre-commit/mirrors-isort - rev: v5.10.1 # Make sure to use the same tag/version as specified in tox.ini. + rev: v5.10.1 hooks: - id: isort - repo: https://github.com/nbQA-dev/nbQA - rev: 1.7.1 + rev: 1.8.5 hooks: - id: nbqa-black additional_dependencies: [black==22.8.0] diff --git a/docs/source/docs_dev/continuous_integration.md b/docs/source/docs_dev/continuous_integration.md index 46443dd..0011a2b 100644 --- a/docs/source/docs_dev/continuous_integration.md +++ b/docs/source/docs_dev/continuous_integration.md @@ -5,18 +5,23 @@ Install `tueplots` with all ci-related dependencies via ``` pip install .[ci] ``` + + +## Tox Run all checks via ``` tox ``` or only run the tests via ``` -tox -e pytest +tox -e test ``` -or use tox (which also runs the linter, and the python-code-snippets in this readme). +or only run the linter via ``` -tox +tox -e format-and-lint ``` + +## Pre-commit hook The CI checks for compliance of the code with black and isort, and runs the tests and the notebooks. To automatically satisfy the former, there is a pre-commit that can be used (do this once): ``` @@ -24,3 +29,8 @@ pip install pre-commit pre-commit install ``` From then on, your code will be checked for isort and black compatibility automatically. + + +Both the pre-commit hook and tox point to isort, black, and so on. +We do our best to match their versions. If you run into version conflicts +between those two tools, please let us know! diff --git a/tox.ini b/tox.ini index 3af5e1b..b1f40eb 100644 --- a/tox.ini +++ b/tox.ini @@ -1,56 +1,44 @@ [tox] -envlist = pytest, doctest, black, isort, pylint, docs +envlist = test, format-and-lint, docs isolated_build = True -[testenv:pytest] -description = Executing tests with pytest +[testenv:test] +description = Execute all sorts of tests deps = pytest pytest-cases -commands = - pytest {posargs} - -[testenv:doctest] -description = Executing code snippets in readme with doctest -deps = matplotlib commands = + pytest {posargs} python -m doctest docs/source/getting_started/application_icml2022.md python -m doctest docs/source/getting_started/usage_example.md -[testenv:black] -description = Code linting with Black +[testenv:format-and-lint] +description = Lint the code with black, isort, and pylint deps = black - nbqa -commands = - black --check --diff . - nbqa black --check --diff . - -[testenv:isort] -description = Sorting imports with isort -deps = isort nbqa -commands = - isort --check --diff . - nbqa isort --check --diff . - -[testenv:pylint] -description = Linting (pylint) -deps = pylint -ignore_errors = true commands = - pylint tueplots --jobs=0 - pylint tests --jobs=0 --disable="missing-function-docstring" + black --check --diff . --quiet + isort --check --diff . --quiet + nbqa black --check --diff . --quiet + nbqa isort --check --diff . --quiet + pylint tueplots --jobs=0 --score no + pylint tests --jobs=0 --disable="missing-function-docstring" --score no + + [testenv:docs] description = Build the HTML docs passenv = HOME deps = + # The doc-dependencies are separate because + # we need to be able to tell readthedocs where + # to find them (there is no access to tox). -r {toxinidir}/docs/requirements-sphinx-build.txt changedir = docs allowlist_externals = make