diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..615323a --- /dev/null +++ b/.editorconfig @@ -0,0 +1,39 @@ +# Generated from: +# https://github.com/zopefoundation/meta/tree/master/config/zope-product +# +# EditorConfig Configuration file, for more details see: +# http://EditorConfig.org +# EditorConfig is a convention description, that could be interpreted +# by multiple editors to enforce common coding conventions for specific +# file types + +# top-most EditorConfig file: +# Will ignore other EditorConfig files in Home directory or upper tree level. +root = true + + +[*] # For All Files +# Unix-style newlines with a newline ending every file +end_of_line = lf +insert_final_newline = true +trim_trailing_whitespace = true +# Set default charset +charset = utf-8 +# Indent style default +indent_style = space +# Max Line Length - a hard line wrap, should be disabled +max_line_length = off + +[*.{py,cfg,ini}] +# 4 space indentation +indent_size = 4 + +[*.{yml,zpt,pt,dtml}] +# 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 diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml new file mode 100644 index 0000000..b6cde7f --- /dev/null +++ b/.github/workflows/tests.yml @@ -0,0 +1,54 @@ +# Generated from: +# https://github.com/zopefoundation/meta/tree/master/config/zope-product +name: tests + +on: + push: + pull_request: + schedule: + - cron: '0 12 * * 0' # run once a week on Sunday + +jobs: + build: + strategy: + matrix: + config: + # [Python version, tox env] + - ["3.8", "lint"] + - ["2.7", "py27"] + - ["3.5", "py35"] + - ["3.6", "py36"] + - ["3.7", "py37"] + - ["3.8", "py38"] + - ["3.9", "py39"] + - ["3.8", "coverage"] + + runs-on: ubuntu-latest + name: ${{ matrix.config[1] }} + steps: + - uses: actions/checkout@v2 + - name: Set up Python + uses: actions/setup-python@v2 + with: + python-version: ${{ matrix.config[0] }} + - name: Pip cache + uses: actions/cache@v2 + with: + path: ~/.cache/pip + key: ${{ runner.os }}-pip-${{ matrix.config[0] }}-${{ hashFiles('setup.*', 'tox.ini') }} + restore-keys: | + ${{ runner.os }}-pip-${{ matrix.config[0] }}- + ${{ runner.os }}-pip- + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install tox + - name: Test + run: tox -e ${{ matrix.config[1] }} + - name: Coverage + if: matrix.config[1] == 'coverage' + run: | + pip install coveralls coverage-python-version + coveralls --service=github + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.gitignore b/.gitignore index f388004..f8055eb 100644 --- a/.gitignore +++ b/.gitignore @@ -1,52 +1,29 @@ -# mac cruft -.DS_Store - -#emacs cruft -*~ -*#* -*flymake.py -.ropeproject - -# vim cruft -*.swp - -# wing cruft -*.wpr - -#buildout/virtualenv cruft -bin -lib -src -include -parts -develop-eggs -.installed.cfg -.mr.developer.cfg - -#python cruft -*.egg -*.egg-info -.noseids -*prof* -pip-log.txt +# Generated from: +# https://github.com/zopefoundation/meta/tree/master/config/zope-product +*.egg-info/ +*.profraw *.pyc -dist -pyvenv.cfg - -# test cruft -*_test +*.pyo .coverage +.coverage.* +.eggs/ +.installed.cfg +.mr.developer.cfg +.tox/ +.vscode/ +__pycache__/ +bin/ +build/ coverage.xml -# SQLite test db -testdb - -# Sphinx cruft -_build - -# backup cruft -*.old -*.orig - -# Misc cruft -*.log -*.pid +develop-eggs/ +develop/ +dist/ +docs/_build +eggs/ +etc/ +lib/ +lib64 +log/ +parts/ +pyvenv.cfg +var/ diff --git a/.meta.toml b/.meta.toml new file mode 100644 index 0000000..72aab24 --- /dev/null +++ b/.meta.toml @@ -0,0 +1,29 @@ +# Generated from: +# https://github.com/zopefoundation/meta/tree/master/config/zope-product +[meta] +template = "zope-product" +commit-id = "1e429ac2cee8215eabfd77a45e1def750ebaa4a2" + +[python] +with-appveyor = false +with-pypy = false +with-legacy-python = true +with-docs = false +with-sphinx-doctests = false + +[tox] +use-flake8 = true + +[coverage] +fail-under = 75 + +[isort] +known_zope = "transaction" +known_first_party = "z3c.sqlalchemy, zope.sqlalchemy" +known_third_party = "mock, six, sqlalchemy, testfixtures" + +[manifest] +additional-rules = [ + "include buildout4.cfg", + "recursive-include src *.zpt", + ] diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 8e2ce73..0000000 --- a/.travis.yml +++ /dev/null @@ -1,27 +0,0 @@ -dist: focal -language: python -python: - - 2.7 - - 3.5 - - 3.6 - - 3.7 - - 3.8 - - 3.9 - -install: - - pip install -U pip tox-travis - -script: - - tox - -after_success: - - coverage combine - - coveralls - -notifications: - email: false - -cache: - pip: true - directories: - - eggs/ diff --git a/MANIFEST.in b/MANIFEST.in index 1c44c8d..d0bee46 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1,9 +1,14 @@ +# Generated from: +# https://github.com/zopefoundation/meta/tree/master/config/zope-product include *.rst -include *.py include *.txt include buildout.cfg -include zope4.cfg include tox.ini +recursive-include src *.pt recursive-include src *.py +recursive-include src *.rst +recursive-include src *.txt +recursive-include src *.zcml +include buildout4.cfg recursive-include src *.zpt diff --git a/README.rst b/README.rst index 8b6255a..c91f749 100644 --- a/README.rst +++ b/README.rst @@ -1,3 +1,18 @@ +.. image:: https://github.com/zopefoundation/Products.SQLAlchemyDA/actions/workflows/tests.yml/badge.svg + :target: https://github.com/zopefoundation/Products.SQLAlchemyDA/actions/workflows/tests.yml + +.. image:: https://coveralls.io/repos/github/zopefoundation/Products.SQLAlchemyDA/badge.svg + :target: https://coveralls.io/github/zopefoundation/Products.SQLAlchemyDA + +.. image:: https://img.shields.io/pypi/v/Products.SQLAlchemyDA.svg + :target: https://pypi.org/project/Products.SQLAlchemyDA/ + :alt: Current version on PyPI + +.. image:: https://img.shields.io/pypi/pyversions/Products.SQLAlchemyDA.svg + :target: https://pypi.org/project/Products.SQLAlchemyDA/ + :alt: Supported Python versions + + Zope ZSQL-SQLAlchemy Integration Wrapper ======================================== diff --git a/buildout4.cfg b/buildout4.cfg new file mode 100644 index 0000000..b4bc622 --- /dev/null +++ b/buildout4.cfg @@ -0,0 +1,5 @@ +[buildout] +extends = + buildout.cfg + http://zopefoundation.github.io/Zope/releases/4.x/versions.cfg + diff --git a/setup.cfg b/setup.cfg index c20e6c1..ea8ee4c 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,31 +1,25 @@ +# Generated from: +# https://github.com/zopefoundation/meta/tree/master/config/zope-product [bdist_wheel] -universal = 0 +universal = 1 +[flake8] +doctests = 1 +no-accept-encodings = True +htmldir = parts/flake8 + +[check-manifest] +ignore = + .editorconfig + .meta.toml [isort] force_single_line = True combine_as_imports = True sections = FUTURE,STDLIB,THIRDPARTY,ZOPE,FIRSTPARTY,LOCALFOLDER -known_first_party = z3c.sqlalchemy known_third_party = mock, six, sqlalchemy, testfixtures known_zope = transaction +known_first_party = z3c.sqlalchemy, zope.sqlalchemy default_section = ZOPE line_length = 79 lines_after_imports = 2 - -[flake8] -no-accept-encodings = True - - -[coverage:run] -branch = True -source = Products.SQLAlchemyDA -omit = - -[coverage:report] -precision = 2 -show_missing = False -sort = Name - -[coverage:html] -directory = parts/coverage diff --git a/src/Products/SQLAlchemyDA/da.py b/src/Products/SQLAlchemyDA/da.py index 3fca47e..4ee7e2e 100644 --- a/src/Products/SQLAlchemyDA/da.py +++ b/src/Products/SQLAlchemyDA/da.py @@ -19,11 +19,11 @@ from OFS.PropertyManager import PropertyManager from OFS.SimpleItem import SimpleItem from Products.PageTemplates.PageTemplateFile import PageTemplateFile -from zope.sqlalchemy import mark_changed from z3c.sqlalchemy import createSAWrapper from z3c.sqlalchemy import getSAWrapper from z3c.sqlalchemy.interfaces import ISQLAlchemyWrapper +from zope.sqlalchemy import mark_changed logger = logging.getLogger('SQLAlchemyDA') diff --git a/tox.ini b/tox.ini index 2093d66..f5adbcc 100644 --- a/tox.ini +++ b/tox.ini @@ -1,75 +1,91 @@ +# Generated from: +# https://github.com/zopefoundation/meta/tree/master/config/zope-product [tox] +minversion = 3.18 envlist = + lint py27 py35 py36 py37 py38 py39 - lint coverage [testenv] -commands_pre = - py27,py35: {envbindir}/buildout -nc {toxinidir}/zope4.cfg buildout:directory={envdir} buildout:develop={toxinidir} install test - !py27-!py35: {envbindir}/buildout -nc {toxinidir}/buildout.cfg buildout:directory={envdir} buildout:develop={toxinidir} install test -commands = - coverage run {envbindir}/test skip_install = true +# We need to pin setuptools until we have zc.buildout 3.0. deps = + setuptools < 52 zc.buildout - coverage -setenv = - COVERAGE_FILE=.coverage.{envname} - -[testenv:coverage] -basepython = python3 commands_pre = + py27,py35: {envbindir}/buildout -nc {toxinidir}/buildout4.cfg buildout:directory={envdir} buildout:develop={toxinidir} install test + !py27-!py35: {envbindir}/buildout -nc {toxinidir}/buildout.cfg buildout:directory={envdir} buildout:develop={toxinidir} install test commands = - coverage erase - coverage combine - coverage html -i - coverage xml -i - coverage report -i --fail-under=75 -deps = - {[testenv]deps} -depends = - py27 - py35 - py36 - py37 - py38 - py39 -setenv = - COVERAGE_FILE=.coverage + {envbindir}/test {posargs:-cv} [testenv:lint] basepython = python3 commands_pre = -skip_install = true - + mkdir -p {toxinidir}/parts/flake8 +allowlist_externals = + mkdir +commands = + isort --check-only --diff {toxinidir}/src {toxinidir}/setup.py + - flake8 --format=html {toxinidir}/src {toxinidir}/setup.py + flake8 {toxinidir}/src {toxinidir}/setup.py + check-manifest + check-python-versions deps = - isort + check-manifest + check-python-versions flake8 + isort # helper to generate HTML reports: flake8-html # Useful flake8 plugins that are Python and Plone specific: flake8-coding flake8-debugger - flake8-deprecated - flake8-todo mccabe - # Potential flake8 plugins that should be used: # TBD - #flake8-blind-except - #flake8-commas - #flake8-docstrings - #flake8-mypy - #flake8-pep3101 - #flake8-plone-hasattr - #flake8-string-format - #flake8_strict - #flake8-quotes +[testenv:isort-apply] +basepython = python3 +commands_pre = +deps = + isort +commands = + isort {toxinidir}/src {toxinidir}/setup.py [] + +[testenv:coverage] +basepython = python3 +skip_install = true +allowlist_externals = + mkdir +deps = + {[testenv]deps} + coverage + coverage-python-version commands = - isort --check-only --diff {toxinidir}/src setup.py - flake8 src setup.py + mkdir -p {toxinidir}/parts/htmlcov + coverage run {envbindir}/test {posargs:-cv} + coverage html + coverage report -m --fail-under=75 + +[coverage:run] +branch = True +plugins = coverage_python_version +source = src + +[coverage:report] +precision = 2 +exclude_lines = + pragma: no cover + pragma: nocover + except ImportError: + raise NotImplementedError + if __name__ == '__main__': + self.fail + raise AssertionError + +[coverage:html] +directory = parts/htmlcov diff --git a/zope4.cfg b/zope4.cfg deleted file mode 100644 index 4fac8a7..0000000 --- a/zope4.cfg +++ /dev/null @@ -1,4 +0,0 @@ -[buildout] -extends = - buildout.cfg - https://zopefoundation.github.io/Zope/releases/4.x/versions.cfg