From 6249018c0cfe9e9442d82123ee0d87c2c0556e0b Mon Sep 17 00:00:00 2001 From: Gil Forcada Codinachs Date: Sun, 4 Jun 2023 09:41:53 +0200 Subject: [PATCH 1/4] Configuring with plone/meta --- .editorconfig | 14 +++++++ .flake8 | 14 +++++++ .github/workflows/meta.yml | 28 ++++++++++++++ .gitignore | 52 ++++++++++++++++++++++++- .meta.toml | 8 +++- .pre-commit-config.yaml | 34 +++++++++++++++++ news/047ec50d.internal | 2 + pyproject.toml | 51 ++++++++++++++++++++++++- tox.ini | 78 ++++++++++++++++++++++++++++++++++++-- 9 files changed, 273 insertions(+), 8 deletions(-) create mode 100644 .flake8 create mode 100644 .github/workflows/meta.yml create mode 100644 news/047ec50d.internal diff --git a/.editorconfig b/.editorconfig index b4158b8..919b411 100644 --- a/.editorconfig +++ b/.editorconfig @@ -1,5 +1,6 @@ # Generated from: # https://github.com/plone/meta/tree/master/config/default +# See the inline comments on how to expand/tweak this configuration file # # EditorConfig Configuration file, for more details see: # http://EditorConfig.org @@ -32,8 +33,21 @@ indent_size = 4 # 2 space indentation indent_size = 2 +[*.{json,jsonl,js,jsx,ts,tsx,css,less,scss,html}] # Frontend development +# 2 space indentation +indent_size = 2 + [{Makefile,.gitmodules}] # Tab indentation (no size specified, but view as 4 spaces) indent_style = tab indent_size = unset tab_width = unset + + +## +# Add extra configuration options in .meta.toml: +# [editorconfig] +# extra_lines = """ +# _your own configuration lines_ +# """ +## diff --git a/.flake8 b/.flake8 new file mode 100644 index 0000000..c156803 --- /dev/null +++ b/.flake8 @@ -0,0 +1,14 @@ +# Generated from: +# https://github.com/plone/meta/tree/master/config/default +# See the inline comments on how to expand/tweak this configuration file +[flake8] +doctests = 1 +ignore = + # black takes care of line length + E501, + # black takes care of where to break lines + W503, + # black takes care of spaces within slicing (list[:]) + E203, + # black takes care of spaces after commas + E231, diff --git a/.github/workflows/meta.yml b/.github/workflows/meta.yml new file mode 100644 index 0000000..4748f0f --- /dev/null +++ b/.github/workflows/meta.yml @@ -0,0 +1,28 @@ +# Generated from: +# https://github.com/plone/meta/tree/master/config/default +# See the inline comments on how to expand/tweak this configuration file +name: Meta +on: + push: + branches: + - master + - main + pull_request: + branches: + - master + - main + workflow_dispatch: + +jobs: + qa: + uses: plone/meta/.github/workflows/qa.yml@master + test: + uses: plone/meta/.github/workflows/test.yml@master + coverage: + uses: plone/meta/.github/workflows/coverage.yml@master + dependencies: + uses: plone/meta/.github/workflows/dependencies.yml@master + release-ready: + uses: plone/meta/.github/workflows/release_ready.yml@master + circular: + uses: plone/meta/.github/workflows/circular.yml@master diff --git a/.gitignore b/.gitignore index a12c186..0690a90 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,50 @@ -*.py? -plone.resource.egg-info/ +# Generated from: +# https://github.com/plone/meta/tree/master/config/default +# See the inline comments on how to expand/tweak this configuration file +# python related +*.egg-info +*.pyc +*.pyo + +# tools related +build/ +.coverage +coverage.xml +dist/ +docs/_build +__pycache__/ +.tox +.vscode/ +node_modules/ + +# venv / buildout related +bin/ +develop-eggs/ +eggs/ +.eggs/ +etc/ +.installed.cfg +lib/ +lib64 +.mr.developer.cfg +parts/ +pyvenv.cfg +var/ + +# mxdev +/instance/ +/.make-sentinels/ +/*-mxdev.txt +/reports/ +/sources/ +/venv/ +.installed.txt + + +## +# Add extra configuration options in .meta.toml: +# [gitignore] +# extra_lines = """ +# _your own configuration lines_ +# """ +## diff --git a/.meta.toml b/.meta.toml index 99342b2..7831d0a 100644 --- a/.meta.toml +++ b/.meta.toml @@ -1,5 +1,11 @@ # Generated from: # https://github.com/plone/meta/tree/master/config/default +# See the inline comments on how to expand/tweak this configuration file [meta] template = "default" -commit-id = "2a4ba395" +commit-id = "c73a9bf7" + +[pre_commit] +zpretty_extra_lines = """ + exclude: test.html +""" diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 5d50720..3b3fb3e 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,5 +1,6 @@ # Generated from: # https://github.com/plone/meta/tree/master/config/default +# See the inline comments on how to expand/tweak this configuration file ci: autofix_prs: false autoupdate_schedule: monthly @@ -23,6 +24,14 @@ repos: hooks: - id: zpretty exclude: test.html + +## +# Add extra configuration options in .meta.toml: +# [pre_commit] +# zpretty_extra_lines = """ +# _your own configuration lines_ +# """ +## - repo: https://github.com/PyCQA/flake8 rev: 6.0.0 hooks: @@ -33,6 +42,14 @@ repos: - id: codespell additional_dependencies: - tomli + +## +# Add extra configuration options in .meta.toml: +# [pre_commit] +# codespell_extra_lines = """ +# _your own configuration lines_ +# """ +## - repo: https://github.com/mgedmin/check-manifest rev: "0.49" hooks: @@ -41,3 +58,20 @@ repos: rev: "4.2" hooks: - id: pyroma +- repo: https://github.com/mgedmin/check-python-versions + rev: "0.21.2" + hooks: + - id: check-python-versions + args: ['--only', 'setup.py,pyproject.toml'] +- repo: https://github.com/collective/i18ndude + rev: "6.0.0" + hooks: + - id: i18ndude + +## +# Add extra configuration options in .meta.toml: +# [pre_commit] +# extra_lines = """ +# _your own configuration lines_ +# """ +## diff --git a/news/047ec50d.internal b/news/047ec50d.internal new file mode 100644 index 0000000..c08f539 --- /dev/null +++ b/news/047ec50d.internal @@ -0,0 +1,2 @@ +Update configuration files. +[plone devs] diff --git a/pyproject.toml b/pyproject.toml index 639f77a..46d3d7a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,8 +1,9 @@ # Generated from: # https://github.com/plone/meta/tree/master/config/default +# See the inline comments on how to expand/tweak this configuration file [tool.towncrier] -filename = "CHANGES.rst" directory = "news/" +filename = "CHANGES.rst" title_format = "{version} ({project_date})" underlines = ["-", ""] @@ -42,6 +43,15 @@ profile = "plone" [tool.black] target-version = ["py38"] +[tool.codespell] +ignore-words-list = "discreet," +skip = "*.po," +## +# Add extra configuration options in .meta.toml: +# [pyproject] +# codespell_ignores = "foo,bar" +# codespell_skip = "*.po,*.map,package-lock.json" +## [tool.dependencychecker] Zope = [ @@ -82,3 +92,42 @@ Zope = [ 'Products.CMFCore', 'Products.CMFDynamicViewFTI', ] python-dateutil = ['dateutil'] + +## +# Add extra configuration options in .meta.toml: +# [pyproject] +# dependencies_ignores = "['zestreleaser.towncrier']" +# dependencies_mappings = [ +# "gitpython = ['git']", +# "pygithub = ['github']", +# ] +# """ +## + +[tool.check-manifest] +ignore = [ + ".editorconfig", + ".meta.toml", + ".pre-commit-config.yaml", + "tox.ini", + ".flake8", + "mx.ini", + +] +## +# Add extra configuration options in .meta.toml: +# [pyproject] +# check_manifest_ignores = """ +# "*.map.js", +# "*.pyc", +# """ +## + + +## +# Add extra configuration options in .meta.toml: +# [pyproject] +# extra_lines = """ +# _your own configuration lines_ +# """ +## diff --git a/tox.ini b/tox.ini index 0c73f0c..a782724 100644 --- a/tox.ini +++ b/tox.ini @@ -1,16 +1,36 @@ # Generated from: # https://github.com/plone/meta/tree/master/config/default +# See the inline comments on how to expand/tweak this configuration file [tox] # We need 4.4.0 for constrain_package_deps. min_version = 4.4.0 envlist = - format lint test + dependencies + + +## +# Add extra configuration options in .meta.toml: +# [tox] +# envlist_lines = """ +# my_other_environment +# """ +# config_lines = """ +# my_extra_top_level_tox_configuration_lines +# """ +## [testenv] +skip_install = true allowlist_externals = - sh + echo + false +# Make sure typos like `tox -e formaat` are caught instead of silently doing nothing. +# See https://github.com/tox-dev/tox/issues/2858. +commands = + echo "Unrecognized environment name {envname}" + false [testenv:format] description = automatically reformat code @@ -42,7 +62,10 @@ commands = dependencychecker [testenv:dependencies-graph] -description = generate a graph out of the package's dependencies +description = generate a graph out of the dependencies of the package +skip_install = false +allowlist_externals = + sh deps = pipdeptree==2.5.1 graphviz # optional dependency of pipdeptree @@ -50,7 +73,9 @@ commands = sh -c 'pipdeptree --exclude setuptools,wheel,pipdeptree,zope.interface,zope.component --graph-output svg > dependencies.svg' [testenv:test] +description = run the distribution tests use_develop = true +skip_install = false constrain_package_deps = true set_env = ROBOT_BROWSER=headlesschrome deps = @@ -62,7 +87,9 @@ extras = test [testenv:coverage] +description = get a test coverage report use_develop = true +skip_install = false constrain_package_deps = true set_env = ROBOT_BROWSER=headlesschrome deps = @@ -70,7 +97,50 @@ deps = zope.testrunner -c https://dist.plone.org/release/6.0-dev/constraints.txt commands = - coverage run {envbindir}/zope-testrunner --all --test-path={toxinidir} -s plone.resource {posargs} + coverage run --source plone.resource {envbindir}/zope-testrunner --quiet --all --test-path={toxinidir} -s plone.resource {posargs} coverage report -m --format markdown extras = test + +[testenv:release-check] +description = ensure that the distribution is ready to release +skip_install = true +deps = + twine + build + towncrier + -c https://dist.plone.org/release/6.0-dev/constraints.txt +commands = + # fake version to not have to install the package + # we build the change log as news entries might break + # the README that is displayed on PyPI + towncrier build --version=100.0.0 --yes + python -m build --sdist --no-isolation + twine check dist/* + +[testenv:circular] +description = ensure there are no cyclic dependencies +use_develop = true +skip_install = false +allowlist_externals = + sh +deps = + pipdeptree + pipforester + -c https://dist.plone.org/release/6.0-dev/constraints.txt +commands = + # Generate the full dependency tree + sh -c 'pipdeptree -j > forest.json' + # Generate a DOT graph with the circular dependencies, if any + pipforester -i forest.json -o forest.dot --cycles + # Report if there are any circular dependencies, i.e. error if there are any + pipforester -i forest.json --check-cycles + + +## +# Add extra configuration options in .meta.toml: +# [tox] +# extra_lines = """ +# my_other_environment +# """ +## From 35be913e56e92ad1ac5f55babad18190c3e1a517 Mon Sep 17 00:00:00 2001 From: Gil Forcada Codinachs Date: Sun, 4 Jun 2023 09:42:28 +0200 Subject: [PATCH 2/4] cleanup: remove unused file --- setup.cfg | 23 ----------------------- 1 file changed, 23 deletions(-) delete mode 100644 setup.cfg diff --git a/setup.cfg b/setup.cfg deleted file mode 100644 index 0da8f8f..0000000 --- a/setup.cfg +++ /dev/null @@ -1,23 +0,0 @@ -# Generated from: -# https://github.com/plone/meta/tree/master/config/default -[bdist_wheel] -universal = 0 - -[flake8] -doctests = 1 -ignore = - # black takes care of line length - E501, - # black takes care of where to break lines - W503, - # black takes care of spaces within slicing (list[:]) - E203, - # black takes care of spaces after commas - E231, - -[check-manifest] -ignore = - .editorconfig - .meta.toml - .pre-commit-config.yaml - tox.ini From f68a05525fb645978ec5ba8da5712b7438e3bda9 Mon Sep 17 00:00:00 2001 From: Gil Forcada Codinachs Date: Sun, 4 Jun 2023 09:55:56 +0200 Subject: [PATCH 3/4] chore: specify long description mime type --- setup.py | 1 + 1 file changed, 1 insertion(+) diff --git a/setup.py b/setup.py index 46155ac..f8ad7bb 100644 --- a/setup.py +++ b/setup.py @@ -14,6 +14,7 @@ version=version, description="Static files for Plone", long_description=(open("README.rst").read() + "\n" + open("CHANGES.rst").read()), + long_description_content_type="text/x-rst", classifiers=[ "Development Status :: 5 - Production/Stable", "Framework :: Plone", From 21148daa54629674cad3c18c356fd0fc4f5a03a7 Mon Sep 17 00:00:00 2001 From: Gil Forcada Codinachs Date: Sun, 4 Jun 2023 10:00:06 +0200 Subject: [PATCH 4/4] chore: use pathlib.read_text This avoids having a resource warning when installing. --- setup.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/setup.py b/setup.py index f8ad7bb..fdf1252 100644 --- a/setup.py +++ b/setup.py @@ -1,3 +1,4 @@ +from pathlib import Path from setuptools import find_packages from setuptools import setup @@ -9,11 +10,15 @@ "plone.testing", ] +long_description = ( + f"{Path('README.rst').read_text()}\n{Path('CHANGES.rst').read_text()}" +) + setup( name="plone.resource", version=version, description="Static files for Plone", - long_description=(open("README.rst").read() + "\n" + open("CHANGES.rst").read()), + long_description=long_description, long_description_content_type="text/x-rst", classifiers=[ "Development Status :: 5 - Production/Stable",