From c3d518fc1e3a1dae1316c2a375a7fe40ebf90175 Mon Sep 17 00:00:00 2001 From: Tobias Raabe Date: Tue, 12 Mar 2024 23:03:43 +0100 Subject: [PATCH 1/4] Update infra. --- .../.pre-commit-config.yaml | 4 -- .../.readthedocs.yaml | 17 ++++-- {{cookiecutter.project_slug}}/README.md | 4 +- .../docs/docs_environment.yml | 22 ------- {{cookiecutter.project_slug}}/environment.yml | 4 +- {{cookiecutter.project_slug}}/pyproject.toml | 60 +++++++++++++++++++ {{cookiecutter.project_slug}}/setup.cfg | 41 ------------- {{cookiecutter.project_slug}}/tox.ini | 16 +++-- 8 files changed, 86 insertions(+), 82 deletions(-) delete mode 100644 {{cookiecutter.project_slug}}/docs/docs_environment.yml delete mode 100644 {{cookiecutter.project_slug}}/setup.cfg diff --git a/{{cookiecutter.project_slug}}/.pre-commit-config.yaml b/{{cookiecutter.project_slug}}/.pre-commit-config.yaml index 4d2146e..6560564 100644 --- a/{{cookiecutter.project_slug}}/.pre-commit-config.yaml +++ b/{{cookiecutter.project_slug}}/.pre-commit-config.yaml @@ -24,10 +24,6 @@ repos: - id: python-no-log-warn - id: python-use-type-annotations - id: text-unicode-replacement-char -- repo: https://github.com/asottile/setup-cfg-fmt - rev: v2.2.0 - hooks: - - id: setup-cfg-fmt - repo: https://github.com/aio-libs/sort-all rev: v1.2.0 hooks: diff --git a/{{cookiecutter.project_slug}}/.readthedocs.yaml b/{{cookiecutter.project_slug}}/.readthedocs.yaml index b508b44..1478786 100644 --- a/{{cookiecutter.project_slug}}/.readthedocs.yaml +++ b/{{cookiecutter.project_slug}}/.readthedocs.yaml @@ -1,10 +1,17 @@ version: 2 build: - image: latest + os: ubuntu-22.04 + tools: + python: "3.10" -python: - version: 3.10 +sphinx: + configuration: docs/source/conf.py + fail_on_warning: true -conda: - environment: docs/docs_environment.yml +python: + install: + - method: pip + path: . + extra_requirements: + - docs diff --git a/{{cookiecutter.project_slug}}/README.md b/{{cookiecutter.project_slug}}/README.md index 9bcbae0..bf38756 100644 --- a/{{cookiecutter.project_slug}}/README.md +++ b/{{cookiecutter.project_slug}}/README.md @@ -15,14 +15,14 @@ cookiecutter.github_username }}/{{ cookiecutter.project_slug }}) {% endif %} cookiecutter.github_username }}/{{ cookiecutter.project_slug }}/main.svg)](https://results.pre-commit.ci/latest/github/{{ cookiecutter.github_username }}/{{ cookiecutter.project_slug }}/main) -[![image](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black) +[![Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff) ## Usage To get started, create the environment with ```console -$ conda/mamba env create +$ mamba env create ``` To build the project, type diff --git a/{{cookiecutter.project_slug}}/docs/docs_environment.yml b/{{cookiecutter.project_slug}}/docs/docs_environment.yml deleted file mode 100644 index 690a754..0000000 --- a/{{cookiecutter.project_slug}}/docs/docs_environment.yml +++ /dev/null @@ -1,22 +0,0 @@ -channels: - - conda-forge - - nodefaults - -dependencies: - - python >= 3.10 - - pip - - setuptools_scm - - toml - - # Documentation - - furo - - ipython - - nbsphinx - - myst-parser - - sphinx - - sphinx-design - - sphinx-copybutton - - - pip: - - ../ - - sphinxext-opengraph diff --git a/{{cookiecutter.project_slug}}/environment.yml b/{{cookiecutter.project_slug}}/environment.yml index ff1f71c..e135210 100644 --- a/{{cookiecutter.project_slug}}/environment.yml +++ b/{{cookiecutter.project_slug}}/environment.yml @@ -14,7 +14,7 @@ dependencies: - conda-lock # Package dependencies - - pytask >=0.2 + - pytask >=0.4 # Misc - black @@ -34,5 +34,5 @@ dependencies: - sphinx-panels - pip: - - -e . - sphinxext-opengraph + - -e . diff --git a/{{cookiecutter.project_slug}}/pyproject.toml b/{{cookiecutter.project_slug}}/pyproject.toml index 83670b4..c6c349f 100644 --- a/{{cookiecutter.project_slug}}/pyproject.toml +++ b/{{cookiecutter.project_slug}}/pyproject.toml @@ -4,6 +4,66 @@ requires = ["setuptools>=45", "wheel", "setuptools_scm[toml]>=6.0"] [tool.setuptools_scm] write_to = "src/{{ cookiecutter.project_slug }}/_version.py" +[project] +name = "{{ cookiecutter.project_slug }}" +description = "{{ cookiecutter.project_description }}" +requires-python = ">=3.8" +classifiers = [ + "Intended Audience :: Science/Research", + "License :: OSI Approved :: {{ cookiecutter.open_source_license }} License", + "Operating System :: MacOS :: MacOS X", + "Operating System :: Microsoft :: Windows", + "Operating System :: POSIX", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3 :: Only", +] +dynamic = ["version"] +dependencies = ["pytask"] + +[project.readme] +file = "README.md" +content-type = "text/markdown" + +[project.license] +text = "{{ cookiecutter.open_source_license }}" + +[[project.authors]] +name = "{{ cookiecutter.author }}" +email = "{{ cookiecutter.email }}" + +[project.optional-dependencies] +docs = [ + "furo", + "ipython", + "myst-parser", + "nbsphinx", + "sphinx", + "sphinx-copybutton", + "sphinx-design>=0.3", + "sphinx-toolbox", + "sphinxext-opengraph", +] +test = [] + +[project.urls] +Changelog = "https://github.com/{{ cookiecutter.github_username }}/{{ cookiecutter.project_slug }}" +Documentation = "https://github.com/{{ cookiecutter.github_username }}/{{ cookiecutter.project_slug }}" +Github = "https://github.com/{{ cookiecutter.github_username }}/{{ cookiecutter.project_slug }}" +Tracker = "https://github.com/{{ cookiecutter.github_username }}/{{ cookiecutter.project_slug }}/issues" + +[tool.setuptools] +include-package-data = true +zip-safe = false +platforms = ["unix", "linux", "osx", "win32"] +license-files = ["LICENSE"] + +[tool.setuptools.package-dir] +"" = "src" + +[tool.setuptools.packages.find] +where = ["src"] +namespaces = false + {% if cookiecutter.add_mypy == "yes" %}[tool.mypy] files = ["src", "tests"] check_untyped_defs = true diff --git a/{{cookiecutter.project_slug}}/setup.cfg b/{{cookiecutter.project_slug}}/setup.cfg deleted file mode 100644 index 39f8479..0000000 --- a/{{cookiecutter.project_slug}}/setup.cfg +++ /dev/null @@ -1,41 +0,0 @@ -[metadata] -name = {{ cookiecutter.project_slug }} -description = {{ cookiecutter.project_description }} -long_description = file: README.md -long_description_content_type = text/markdown -url = https://github.com/{{ cookiecutter.github_username }}/{{ cookiecutter.project_slug }} -author = {{ cookiecutter.author }} -author_email = {{ cookiecutter.email }} -license = {{ cookiecutter.open_source_license }} -{% if cookiecutter.open_source_license != 'Not open source' %}license_file = LICENSE -{% endif %}platforms = unix, linux, osx, cygwin, win32 -classifiers = - Intended Audience :: Science/Research - License :: OSI Approved :: {{ cookiecutter.open_source_license }} License - Operating System :: MacOS :: MacOS X - Operating System :: Microsoft :: Windows - Operating System :: POSIX - Programming Language :: Python :: 3 - Programming Language :: Python :: 3 :: Only -project_urls = - Changelog = https://github.com/{{ cookiecutter.github_username }}/{{ cookiecutter.project_slug }} - Documentation = https://github.com/{{ cookiecutter.github_username }}/{{ cookiecutter.project_slug }} - Github = https://github.com/{{ cookiecutter.github_username }}/{{ cookiecutter.project_slug }} - Tracker = https://github.com/{{ cookiecutter.github_username }}/{{ cookiecutter.project_slug }}/issues - -[options] -packages = find: -install_requires = - pytask -python_requires = >=3.8 -include_package_data = True -package_dir = - =src -zip_safe = False - -[options.packages.find] -where = src - -[check-manifest] -ignore = - src/{{ cookiecutter.project_slug }}/_version.py diff --git a/{{cookiecutter.project_slug}}/tox.ini b/{{cookiecutter.project_slug}}/tox.ini index 1f2169e..76e568a 100644 --- a/{{cookiecutter.project_slug}}/tox.ini +++ b/{{cookiecutter.project_slug}}/tox.ini @@ -1,10 +1,11 @@ [tox] -envlist = pytest, sphinx +requires = tox>=4 +envlist = docs, test [testenv] -usedevelop = true +package = editable -[testenv:pytest] +[testenv:test] conda_channels = conda-forge nodefaults @@ -14,8 +15,11 @@ conda_deps = pytest-cov pytest-xdist - # Package dependencies - pytask - commands = pytest {posargs} + +[testenv:docs] +extras = docs, test +commands = + - sphinx-build -n -T -b html -d {envtmpdir}/doctrees docs/source docs/build/html + - sphinx-build -n -T -b doctest -d {envtmpdir}/doctrees docs/source docs/build/html From 1ca0e1709fa3e0ecb5752991fb21e8977422a4cc Mon Sep 17 00:00:00 2001 From: Tobias Raabe Date: Tue, 12 Mar 2024 23:08:40 +0100 Subject: [PATCH 2/4] Update. --- .github/workflows/main.yml | 7 +--- codecov.yml | 1 - .../.github/dependabot.yml | 5 +++ .../.github/workflows/main.yml | 32 +++---------------- {{cookiecutter.project_slug}}/codecov.yml | 26 +++++++++++++++ {{cookiecutter.project_slug}}/dependabot.yml | 12 +++++++ {{cookiecutter.project_slug}}/pyproject.toml | 13 +------- 7 files changed, 50 insertions(+), 46 deletions(-) create mode 100644 {{cookiecutter.project_slug}}/codecov.yml create mode 100644 {{cookiecutter.project_slug}}/dependabot.yml diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index f9fb346..4eaae9f 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -5,9 +5,6 @@ concurrency: group: ${{ github.head_ref || github.run_id }} cancel-in-progress: true -env: - CONDA_EXE: mamba - on: push: branches: @@ -43,6 +40,4 @@ jobs: run: tox -e test -- --cov=./ --cov-report=xml - name: Upload coverage reports of tests. - if: runner.os == 'Linux' && matrix.python-version == '3.10' - shell: bash -l {0} - run: bash <(curl -s https://codecov.io/bash) + uses: codecov/codecov-action@v4 diff --git a/codecov.yml b/codecov.yml index 4892c14..7fc9643 100644 --- a/codecov.yml +++ b/codecov.yml @@ -24,4 +24,3 @@ coverage: ignore: - ".tox/**/*" - - "setup.py" diff --git a/{{cookiecutter.project_slug}}/.github/dependabot.yml b/{{cookiecutter.project_slug}}/.github/dependabot.yml index 718572b..fbb58d4 100644 --- a/{{cookiecutter.project_slug}}/.github/dependabot.yml +++ b/{{cookiecutter.project_slug}}/.github/dependabot.yml @@ -5,3 +5,8 @@ updates: directory: "/" schedule: interval: "weekly" + + groups: + github-actions: + patterns: + - "*" diff --git a/{{cookiecutter.project_slug}}/.github/workflows/main.yml b/{{cookiecutter.project_slug}}/.github/workflows/main.yml index 45adfcc..f61c9b2 100644 --- a/{{cookiecutter.project_slug}}/.github/workflows/main.yml +++ b/{{cookiecutter.project_slug}}/.github/workflows/main.yml @@ -30,7 +30,7 @@ jobs: python-version: ['3.8', '3.9', '3.10', '3.11', '3.12'] steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - uses: mamba-org/provision-with-micromamba@main with: environment-file: false @@ -42,31 +42,9 @@ jobs: tox-conda cache-downloads: true - # Unit, integration, and end-to-end tests. - - - name: Run unit tests and doctests. - shell: bash -l {0} - run: tox -e pytest -- src tests -m "unit or (not integration and not end_to_end)" --cov=./ --cov-report=xml -n auto - - - name: Upload coverage report for unit tests and doctests. - if: runner.os == 'Linux' && matrix.python-version == '3.10' - shell: bash -l {0} - run: bash <(curl -s https://codecov.io/bash) -F unit -c - - - name: Run integration tests. + - name: Run tests and doctests. shell: bash -l {0} - run: tox -e pytest -- src tests -m integration --cov=./ --cov-report=xml -n auto + run: tox -e pytest - - name: Upload coverage reports of integration tests. - if: runner.os == 'Linux' && matrix.python-version == '3.10' - shell: bash -l {0} - run: bash <(curl -s https://codecov.io/bash) -F integration -c - - - name: Run end-to-end tests. - shell: bash -l {0} - run: tox -e pytest -- src tests -m end_to_end --cov=./ --cov-report=xml -n auto - - - name: Upload coverage reports of end-to-end tests. - if: runner.os == 'Linux' && matrix.python-version == '3.10' - shell: bash -l {0} - run: bash <(curl -s https://codecov.io/bash) -F end_to_end -c + - name: Upload coverage report + uses: codecov/codecov-action@v4 diff --git a/{{cookiecutter.project_slug}}/codecov.yml b/{{cookiecutter.project_slug}}/codecov.yml new file mode 100644 index 0000000..7fc9643 --- /dev/null +++ b/{{cookiecutter.project_slug}}/codecov.yml @@ -0,0 +1,26 @@ +codecov: + branch: main + +coverage: + precision: 2 + round: down + range: 80...100 + status: + project: + default: + threshold: 1% + unit: + threshold: 1% + flags: + - unit + integration: + threshold: 1% + flags: + - integration + end_to_end: + threshold: 1% + flags: + - end_to_end + +ignore: + - ".tox/**/*" diff --git a/{{cookiecutter.project_slug}}/dependabot.yml b/{{cookiecutter.project_slug}}/dependabot.yml new file mode 100644 index 0000000..fbb58d4 --- /dev/null +++ b/{{cookiecutter.project_slug}}/dependabot.yml @@ -0,0 +1,12 @@ +version: 2 + +updates: + - package-ecosystem: "github-actions" + directory: "/" + schedule: + interval: "weekly" + + groups: + github-actions: + patterns: + - "*" diff --git a/{{cookiecutter.project_slug}}/pyproject.toml b/{{cookiecutter.project_slug}}/pyproject.toml index c6c349f..f06690c 100644 --- a/{{cookiecutter.project_slug}}/pyproject.toml +++ b/{{cookiecutter.project_slug}}/pyproject.toml @@ -106,16 +106,5 @@ convention = "numpy" [tool.pytest.ini_options] addopts = ["--doctest-modules"] -testpaths = ["tests"] -filterwarnings = [ - "ignore: the imp module is deprecated in favour of importlib", - "ignore: Using or importing the ABCs from 'collections' instead of from", - "ignore: The (parser|symbol) module is deprecated and will be removed in future", -] -markers = [ - "wip: Tests that are work-in-progress.", - "unit: Flag for unit tests which target mainly a single function.", - "integration: Flag for integration tests which may comprise of multiple unit tests.", - "end_to_end: Flag for tests that cover the whole program.", -] +testpaths = ["src", "tests"] norecursedirs = [".idea", ".tox"] From b1e25c223438993b7065b4906857be76480328c9 Mon Sep 17 00:00:00 2001 From: Tobias Raabe Date: Tue, 12 Mar 2024 23:09:28 +0100 Subject: [PATCH 3/4] Fix. --- docs/source/changes.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/source/changes.md b/docs/source/changes.md index e6ec852..7cf458d 100644 --- a/docs/source/changes.md +++ b/docs/source/changes.md @@ -6,6 +6,7 @@ them in reverse chronological order. ## 1.7.0 - 2024-xx-xx - {pull}`39` updates the pre-commit hooks. +- {pull}`41` updates the infrastructure. ## 1.6.0 - 2023-11-23 From cac138a714efe4247155137121abf90146d4a997 Mon Sep 17 00:00:00 2001 From: Tobias Raabe Date: Tue, 12 Mar 2024 23:23:44 +0100 Subject: [PATCH 4/4] update hooks. --- {{cookiecutter.project_slug}}/.pre-commit-config.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/{{cookiecutter.project_slug}}/.pre-commit-config.yaml b/{{cookiecutter.project_slug}}/.pre-commit-config.yaml index 6560564..a8ba69d 100644 --- a/{{cookiecutter.project_slug}}/.pre-commit-config.yaml +++ b/{{cookiecutter.project_slug}}/.pre-commit-config.yaml @@ -29,12 +29,12 @@ repos: hooks: - id: sort-all - repo: https://github.com/charliermarsh/ruff-pre-commit - rev: v0.1.6 + rev: v0.3.2 hooks: - id: ruff - id: ruff-format {% if cookiecutter.python_version in ["3.10", "3.11", "3.12"] %}- repo: https://github.com/dosisod/refurb - rev: v1.24.0 + rev: v2.0.0 hooks: - id: refurb {% endif %} @@ -59,7 +59,7 @@ repos: args: [--wrap, "88"] files: (docs/.) {% if cookiecutter.add_mypy == "yes" %}- repo: https://github.com/pre-commit/mirrors-mypy - rev: 'v1.7.0' + rev: 'v1.9.0' hooks: - id: mypy args: [