From a31b4bb198deaeddad050d452b261f67cda77ac1 Mon Sep 17 00:00:00 2001 From: Tim Vink Date: Sun, 8 Sep 2024 11:30:28 +0000 Subject: [PATCH] Use pyproject.toml, update gh actions --- .github/workflows/pythonpublish.yml | 6 +- .github/workflows/scheduled_unittests.yml | 4 +- .github/workflows/unittests.yml | 7 +- .github/workflows/unittests_codecov.yml | 14 +-- CONTRIBUTING.md | 9 +- .../__init__.py | 0 pyproject.toml | 116 ++++++++++++++++++ ...t_requirements.txt => requirements_dev.txt | 3 +- setup.py | 42 ------- .../__init__.py | 1 + .../ci.py | 0 .../css/timeago.css | 0 .../dates.py | 0 .../exclude.py | 0 .../js/timeago.min.js | 0 .../js/timeago_mkdocs_material.js | 0 .../plugin.py | 0 .../util.py | 0 18 files changed, 130 insertions(+), 72 deletions(-) delete mode 100644 mkdocs_git_revision_date_localized_plugin/__init__.py create mode 100644 pyproject.toml rename tests/test_requirements.txt => requirements_dev.txt (61%) delete mode 100644 setup.py create mode 100644 src/mkdocs_git_revision_date_localized_plugin/__init__.py rename {mkdocs_git_revision_date_localized_plugin => src/mkdocs_git_revision_date_localized_plugin}/ci.py (100%) rename {mkdocs_git_revision_date_localized_plugin => src/mkdocs_git_revision_date_localized_plugin}/css/timeago.css (100%) rename {mkdocs_git_revision_date_localized_plugin => src/mkdocs_git_revision_date_localized_plugin}/dates.py (100%) rename {mkdocs_git_revision_date_localized_plugin => src/mkdocs_git_revision_date_localized_plugin}/exclude.py (100%) rename {mkdocs_git_revision_date_localized_plugin => src/mkdocs_git_revision_date_localized_plugin}/js/timeago.min.js (100%) rename {mkdocs_git_revision_date_localized_plugin => src/mkdocs_git_revision_date_localized_plugin}/js/timeago_mkdocs_material.js (100%) rename {mkdocs_git_revision_date_localized_plugin => src/mkdocs_git_revision_date_localized_plugin}/plugin.py (100%) rename {mkdocs_git_revision_date_localized_plugin => src/mkdocs_git_revision_date_localized_plugin}/util.py (100%) diff --git a/.github/workflows/pythonpublish.yml b/.github/workflows/pythonpublish.yml index a0391c9..63c5921 100644 --- a/.github/workflows/pythonpublish.yml +++ b/.github/workflows/pythonpublish.yml @@ -30,12 +30,10 @@ jobs: run: | git config --global user.name "Github Action" git config --global user.email "githubaction@gmail.com" - pip install -r tests/test_requirements.txt - pip install mkdocs-material + pip install -r requirements_dev.txt pip install . pytest - - name: Build run: | python setup.py sdist bdist_wheel @@ -46,5 +44,5 @@ jobs: - name: Deploy mkdocs site run: | - pip install mkdocs-git-authors-plugin + pip install -r requirements_dev.txt mkdocs gh-deploy --force diff --git a/.github/workflows/scheduled_unittests.yml b/.github/workflows/scheduled_unittests.yml index 5679dec..58dd70c 100644 --- a/.github/workflows/scheduled_unittests.yml +++ b/.github/workflows/scheduled_unittests.yml @@ -20,14 +20,14 @@ jobs: - name: Setup Python uses: actions/setup-python@master with: - python-version: "3.11" + python-version: "3.12" - name: Install dependencies run: | pip3 install --upgrade pip pip3 install --upgrade setuptools pip3 install --upgrade wheel - pip3 install -r tests/test_requirements.txt + pip3 install -r requirements_dev.txt pip3 install . - name: Run unit tests diff --git a/.github/workflows/unittests.yml b/.github/workflows/unittests.yml index 2ec52b1..6d0d68c 100644 --- a/.github/workflows/unittests.yml +++ b/.github/workflows/unittests.yml @@ -23,14 +23,9 @@ jobs: pip3 install --upgrade pip pip3 install --upgrade setuptools pip3 install --upgrade wheel - pip3 install pyflakes - pip3 install -r tests/test_requirements.txt + pip3 install -r requirements_dev.txt pip3 install . - - name: Static code checking with pyflakes - run: | - pyflakes mkdocs_git_revision_date_localized_plugin - - name: Run unit tests run: | git config --global user.name "Github Action" diff --git a/.github/workflows/unittests_codecov.yml b/.github/workflows/unittests_codecov.yml index 1e07c34..d271b96 100644 --- a/.github/workflows/unittests_codecov.yml +++ b/.github/workflows/unittests_codecov.yml @@ -31,14 +31,9 @@ jobs: pip3 install --upgrade pip pip3 install --upgrade setuptools pip3 install --upgrade wheel - pip3 install pyflakes - pip3 install -r tests/test_requirements.txt + pip install -r requirements_dev.txt pip3 install . - - name: Static code checking with pyflakes - run: | - pyflakes mkdocs_git_revision_date_localized_plugin - - name: Generate coverage report run: | git config --global user.name "Github Action" @@ -47,9 +42,10 @@ jobs: - name: Upload coverage to Codecov if: "contains(env.USING_COVERAGE, matrix.python-version)" - uses: codecov/codecov-action@v1 + uses: codecov/codecov-action@v4 with: - token: ${{ secrets.CODECOV_TOKEN }} - file: ./coverage.xml + files: ./coverage.xml flags: unittests fail_ci_if_error: false + env: + CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} \ No newline at end of file diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 3a924dd..f10cde8 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -12,20 +12,13 @@ Thanks for considering to contribute to this project! Some guidelines: Make sure to install an editable version before running the tests: ```python -pip install -r tests/test_requirements.txt +pip install -r requirement_dev.txt pip install -e . pytest --cov=mkdocs_git_revision_date_localized_plugin --cov-report term-missing tests/ ``` If it makes sense, writing tests for your PRs is always appreciated and will help get them merged. -In addition, this project uses [flake8](https://github.com/PyCQA/flake8) for static code checking: - -```python -pip install pyflakes -pyflakes tests/ mkdocs_git_revision_date_localized_plugin/ -``` - ## Manual testing To quickly serve a test website with your latest changes to the plugin use the sites in our tests suite. diff --git a/mkdocs_git_revision_date_localized_plugin/__init__.py b/mkdocs_git_revision_date_localized_plugin/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..4b85733 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,116 @@ +[build-system] +requires = ["setuptools>=70.0", "setuptools-scm>=8.0"] +build-backend = "setuptools.build_meta" + +[project.entry-points."mkdocs.plugins"] +"git-revision-date-localized" = "mkdocs_git_revision_date_localized_plugin.plugin:GitRevisionDateLocalizedPlugin" + +[project] +name="mkdocs-git-revision-date-localized-plugin" +keywords = ["mkdocs", "plugin"] +authors = [ + { name = "Tim Vink", email = "vinktim@gmail.com" } +] +license = { text = "MIT" } + +description="Mkdocs plugin that enables displaying the localized date of the last git modification of a markdown file." +readme = { file = "README.md", content-type = "text/markdown" } + +requires-python=">=3.8" + +classifiers=[ + "Operating System :: OS Independent", + "Programming Language :: Python", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.8", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "License :: OSI Approved :: MIT License", +] + +dynamic = ["version","dependencies","optional-dependencies"] + +[project.urls] +"Homepage" = "https://github.com/timvink/mkdocs-git-revision-date-localized-plugin" + +[tool.setuptools.dynamic] +version = {attr = "mkdocs_git_revision_date_localized_plugin.__version__"} + +dependencies={file = ["requirements.txt"]} + +optional-dependencies.dev={file = ["requirements_dev.txt"]} +optional-dependencies.base={file = ["requirements.txt"]} +optional-dependencies.all={file = ["requirements.txt", "requirements_dev.txt"]} + +[tool.pytest.ini_options] +markers = [ + "serial", + "no_temp_caching", +] + +# https://github.com/charliermarsh/ruff +[tool.ruff] + +# Rules to apply +lint.select= ["E", "F", "I", "UP"] + +# Exclude rules +lint.ignore = ['D104' + ,'D212' + ,'D200' + ,'D412' + ,'E731' + ,'E501' + ,'E722' + ,'D104' + ,'E402' + ,"UP038" # UP038 Use `X | Y` in `isinstance` call instead of `(X, Y)` +] + +# Exclude files in tests dir +lint.exclude = [ + ".bzr", + ".direnv", + ".eggs", + ".git", + ".hg", + ".mypy_cache", + ".nox", + ".pants.d", + ".pytype", + ".ruff_cache", + ".svn", + ".tox", + ".venv", + "__pypackages__", + "_build", + "buck-out", + "build", + "dist", + "node_modules", + "venv", +] + +# Set line length, keep same as black +line-length = 120 + +extend-exclude = [ + "*.yml", + "*.toml", + "*.md", + ".json", + "Makefile", + "*.txt", +] + + #supported for python 3.10 +target-version = "py310" + +# Always autofix +fix = true + +[tool.uv] +dev-dependencies = [ + "ruff", +] \ No newline at end of file diff --git a/tests/test_requirements.txt b/requirements_dev.txt similarity index 61% rename from tests/test_requirements.txt rename to requirements_dev.txt index d931df0..66f09e3 100644 --- a/tests/test_requirements.txt +++ b/requirements_dev.txt @@ -4,4 +4,5 @@ codecov click mkdocs-material mkdocs-static-i18n -mkdocs-gen-files \ No newline at end of file +mkdocs-gen-files +mkdocs-git-authors-plugin \ No newline at end of file diff --git a/setup.py b/setup.py deleted file mode 100644 index 8f16a95..0000000 --- a/setup.py +++ /dev/null @@ -1,42 +0,0 @@ -from setuptools import find_packages, setup - -file = open("README.md", "r") -LONG_DESCRIPTION = file.read() -file.close() - -file = open("requirements.txt", "r") -DEPENDENCIES = file.readlines() -file.close() - -del file - -setup( - name="mkdocs-git-revision-date-localized-plugin", - version="1.2.7", - description="Mkdocs plugin that enables displaying the localized date of the last git modification of a markdown file.", - long_description=LONG_DESCRIPTION, - long_description_content_type="text/markdown", - keywords="mkdocs git date timeago babel plugin", - url="https://github.com/timvink/mkdocs-git-revision-date-localized-plugin", - author="Tim Vink", - author_email="vinktim@gmail.com", - include_package_data=True, - license="MIT", - python_requires=">=3.8", - classifiers=[ - "Programming Language :: Python :: 3", - "Programming Language :: Python :: 3.8", - "Programming Language :: Python :: 3.9", - "Programming Language :: Python :: 3.10", - "Programming Language :: Python :: 3.11", - "License :: OSI Approved :: MIT License", - "Operating System :: OS Independent", - ], - install_requires=DEPENDENCIES, - packages=find_packages(), - entry_points={ - "mkdocs.plugins": [ - "git-revision-date-localized = mkdocs_git_revision_date_localized_plugin.plugin:GitRevisionDateLocalizedPlugin" - ] - }, -) diff --git a/src/mkdocs_git_revision_date_localized_plugin/__init__.py b/src/mkdocs_git_revision_date_localized_plugin/__init__.py new file mode 100644 index 0000000..7fac44f --- /dev/null +++ b/src/mkdocs_git_revision_date_localized_plugin/__init__.py @@ -0,0 +1 @@ +__version__ = "1.2.8" \ No newline at end of file diff --git a/mkdocs_git_revision_date_localized_plugin/ci.py b/src/mkdocs_git_revision_date_localized_plugin/ci.py similarity index 100% rename from mkdocs_git_revision_date_localized_plugin/ci.py rename to src/mkdocs_git_revision_date_localized_plugin/ci.py diff --git a/mkdocs_git_revision_date_localized_plugin/css/timeago.css b/src/mkdocs_git_revision_date_localized_plugin/css/timeago.css similarity index 100% rename from mkdocs_git_revision_date_localized_plugin/css/timeago.css rename to src/mkdocs_git_revision_date_localized_plugin/css/timeago.css diff --git a/mkdocs_git_revision_date_localized_plugin/dates.py b/src/mkdocs_git_revision_date_localized_plugin/dates.py similarity index 100% rename from mkdocs_git_revision_date_localized_plugin/dates.py rename to src/mkdocs_git_revision_date_localized_plugin/dates.py diff --git a/mkdocs_git_revision_date_localized_plugin/exclude.py b/src/mkdocs_git_revision_date_localized_plugin/exclude.py similarity index 100% rename from mkdocs_git_revision_date_localized_plugin/exclude.py rename to src/mkdocs_git_revision_date_localized_plugin/exclude.py diff --git a/mkdocs_git_revision_date_localized_plugin/js/timeago.min.js b/src/mkdocs_git_revision_date_localized_plugin/js/timeago.min.js similarity index 100% rename from mkdocs_git_revision_date_localized_plugin/js/timeago.min.js rename to src/mkdocs_git_revision_date_localized_plugin/js/timeago.min.js diff --git a/mkdocs_git_revision_date_localized_plugin/js/timeago_mkdocs_material.js b/src/mkdocs_git_revision_date_localized_plugin/js/timeago_mkdocs_material.js similarity index 100% rename from mkdocs_git_revision_date_localized_plugin/js/timeago_mkdocs_material.js rename to src/mkdocs_git_revision_date_localized_plugin/js/timeago_mkdocs_material.js diff --git a/mkdocs_git_revision_date_localized_plugin/plugin.py b/src/mkdocs_git_revision_date_localized_plugin/plugin.py similarity index 100% rename from mkdocs_git_revision_date_localized_plugin/plugin.py rename to src/mkdocs_git_revision_date_localized_plugin/plugin.py diff --git a/mkdocs_git_revision_date_localized_plugin/util.py b/src/mkdocs_git_revision_date_localized_plugin/util.py similarity index 100% rename from mkdocs_git_revision_date_localized_plugin/util.py rename to src/mkdocs_git_revision_date_localized_plugin/util.py