From 14637bb8cedf28ccdb833c61877ae2338c7ff57a Mon Sep 17 00:00:00 2001 From: Timo Stollenwerk Date: Sun, 20 Dec 2020 13:28:01 +0100 Subject: [PATCH] Gh actions (#114) * make update * Pin httpie to last py2 compatible version * Fix Plone 5.2 buildout with version pins. * Fix p 5.2 buildout * Properly pin httpie * make update * make update * Remove httpie * Add gh actions * black * pin check-manifest * pin check-manifest * pin urllib3 * Exclude 3.7 with plone 5.1 * Pin idna * Remove Travis --- .github/workflows/ci.yml | 60 +++++++++++++++++++++++++++++++++++ .travis.yml | 32 ------------------- Makefile | 10 ++++-- README.rst | 3 -- base.cfg | 1 - ci.cfg | 7 ++++ plone-4.3.x.cfg | 38 +++++++++------------- plone-5.1.x.cfg | 23 ++++++++++---- plone-5.2.x.cfg | 19 ++++++++--- requirements.txt | 2 +- src/plone/rest/cors.py | 8 ++--- src/plone/rest/errors.py | 3 +- src/plone/rest/events.py | 2 +- src/plone/rest/interfaces.py | 8 ++--- src/plone/rest/negotiation.py | 8 ++--- src/plone/rest/patches.py | 2 +- src/plone/rest/traverse.py | 3 +- src/plone/rest/zcml.py | 3 +- versions.cfg | 44 +++++++++++++++++++++++++ 19 files changed, 183 insertions(+), 93 deletions(-) create mode 100644 .github/workflows/ci.yml delete mode 100644 .travis.yml create mode 100644 ci.cfg diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..7388994 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,60 @@ +name: plone.rest CI +on: [push] +jobs: + build: + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + python-version: [3.7, 2.7] + plone-version: [5.2, 5.1, 4.3] + exclude: + - python-version: 3.7 + plone-version: 4.3 + - python-version: 3.7 + plone-version: 5.1 + + steps: + + # git checkout + - uses: actions/checkout@v2 + + # python setup + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v1 + with: + python-version: ${{ matrix.python-version }} + + # python cache + - uses: actions/cache@v1 + with: + path: ~/.cache/pip + key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }} + restore-keys: | + ${{ runner.os }}-pip- + + # python install + - run: pip install virtualenv + - run: pip install wheel + - name: pip install + run: pip install -r requirements.txt + - name: choose Plone version + run: sed -ie "s#plone-x.x.x.cfg#plone-${{ matrix.plone-version }}.x.cfg#" ci.cfg + + # buildout + - name: buildout + run: buildout -t 10 -c ci.cfg + env: + CI: true + + # black + - name: black + run: if [ "${{ matrix.plone-version }}" == "5.2" ] && [ ${{ matrix.python-version }} == '3.7' ]; then pip install black && black src/ --check; fi + + # code analysis + - name: black + run: bin/code-analysis + + # test + - name: test + run: bin/test diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 38ef75b..0000000 --- a/.travis.yml +++ /dev/null @@ -1,32 +0,0 @@ -language: python -python: - - 2.7.15 - - 3.7 -cache: - pip: true - directories: - - $HOME/buildout-cache -env: - - PLONE_VERSION=4.3.x - - PLONE_VERSION=5.1.x - - PLONE_VERSION=5.2.x -jobs: - exclude: - - python: 3.7 - env: PLONE_VERSION=4.3.x - - python: 3.7 - env: PLONE_VERSION=5.1.x -before_install: - - mkdir -p $HOME/buildout-cache/{eggs,downloads} - - pip install -r requirements.txt -install: - - sed -ie "s#plone-x.x.x.cfg#plone-$PLONE_VERSION.cfg#" travis.cfg - - buildout -N -t 3 -c travis.cfg -script: - - if [ -f "bin/black" ]; then bin/black src/ --check ; fi - - bin/code-analysis - - bin/test - - bin/test-coverage -after_success: - - pip install -q coveralls - - coveralls diff --git a/Makefile b/Makefile index 1058c76..871a3cd 100644 --- a/Makefile +++ b/Makefile @@ -3,7 +3,7 @@ SHELL := /bin/bash CURRENT_DIR:=$(shell dirname $(realpath $(lastword $(MAKEFILE_LIST)))) -version = 3.7 +version = 3 # We like colors # From: https://coderwall.com/p/izxssa/colored-makefile-for-golang-projects @@ -27,7 +27,7 @@ update: ## Update Make and Buildout wget -O plone-4.3.x.cfg https://raw.githubusercontent.com/kitconcept/buildout/master/plone-4.3.x.cfg wget -O plone-5.1.x.cfg https://raw.githubusercontent.com/kitconcept/buildout/master/plone-5.1.x.cfg wget -O plone-5.2.x.cfg https://raw.githubusercontent.com/kitconcept/buildout/master/plone-5.2.x.cfg - wget -O travis.cfg https://raw.githubusercontent.com/kitconcept/buildout/master/travis.cfg + wget -O ci.cfg https://raw.githubusercontent.com/kitconcept/buildout/master/ci.cfg wget -O versions.cfg https://raw.githubusercontent.com/kitconcept/buildout/master/versions.cfg .installed.cfg: bin/buildout *.cfg @@ -71,6 +71,12 @@ build-plone-5.2: .installed.cfg ## Build Plone 5.2 bin/pip install -r requirements.txt bin/buildout -c plone-5.2.x.cfg +.PHONY: Build Plone 5.2 Performance +build-plone-5.2-performance: .installed.cfg ## Build Plone 5.2 + bin/pip install --upgrade pip + bin/pip install -r requirements.txt + bin/buildout -c plone-5.2.x-performance.cfg + .PHONY: Test test: ## Test bin/test diff --git a/README.rst b/README.rst index 31a79a6..2e3c096 100644 --- a/README.rst +++ b/README.rst @@ -1,6 +1,3 @@ -.. image:: https://secure.travis-ci.org/plone/plone.rest.png?branch=master - :target: http://travis-ci.org/plone/plone.rest - .. image:: https://img.shields.io/coveralls/github/plone/plone.rest.svg :alt: Coveralls github :target: https://coveralls.io/github/plone/plone.restapi diff --git a/base.cfg b/base.cfg index 59ebfd7..10182f5 100644 --- a/base.cfg +++ b/base.cfg @@ -58,7 +58,6 @@ eggs = towncrier readme docutils - httpie [sources] plone.dexterity = git git://github.com/plone/plone.dexterity.git pushurl=git@github.com:plone/plone.dexterity.git branch=plip-680 diff --git a/ci.cfg b/ci.cfg new file mode 100644 index 0000000..af1a4f2 --- /dev/null +++ b/ci.cfg @@ -0,0 +1,7 @@ +[buildout] +extends = plone-x.x.x.cfg + +[code-analysis] +recipe = plone.recipe.codeanalysis +pre-commit-hook = False +return-status-codes = True diff --git a/plone-4.3.x.cfg b/plone-4.3.x.cfg index 3a0c6cb..488b7fd 100644 --- a/plone-4.3.x.cfg +++ b/plone-4.3.x.cfg @@ -1,38 +1,30 @@ [buildout] extends = base.cfg - http://dist.plone.org/release/4.3.19/versions.cfg + https://dist.plone.org/release/4.3.20/versions.cfg + versions.cfg [versions] +plone.testing = 5.0.0 pytz = 2017.3 zope.interface = 4.1.0 + # fixes zlib failure: https://stackoverflow.com/questions/34631806/fail-during-installation-of-pillow-python-module-in-linux # Pillow = 5.4.1 future = 0.17.1 six = 1.11.0 -# Required for Python 2.7 compatibility -more-itertools = <6.0.0 -zipp = >=0.5, <2a - -# plone.restapi specific -plone.schema = 1.2.0 +# fixes: SyntaxError: invalid syntax (more.py, line 340) +zipp = 0.5.2 -# zest.releaser -zest.releaser = 6.20.1 -twine = 1.11.0 -requests = 2.22.0 -towncrier = 19.2.0 -zestreleaser.towncrier = 1.1.0 -# docutils = 0.13.1 +# more-itertools >= 6.0.0 dropped python2.7 support +more-itertools = 5.0.0 -# Sphinx -Sphinx = 1.6.5 -docutils = 0.14 +# Error: The requirement ('Pygments>=2.5.1') is not allowed by your [versions] constraint (2.2.0) Pygments = 2.5.2 -sphinxcontrib-httpexample = 0.7.0 -sphinxcontrib-httpdomain = 1.5.0 -sphinx-rtd-theme = 0.2.4 -Jinja2 = 2.10 -Babel = 2.5.1 -astunparse = 1.6.2 \ No newline at end of file + +# Last pyrsistent version that is python 2 compatible: +pyrsistent = 0.15.7 + +# Error: The requirement ('distlib<1,>=0.3.1') is not allowed by your [versions] constraint (0.3.0) +distlib = 0.3.1 diff --git a/plone-5.1.x.cfg b/plone-5.1.x.cfg index b3d7a7e..ab72b98 100644 --- a/plone-5.1.x.cfg +++ b/plone-5.1.x.cfg @@ -1,19 +1,30 @@ [buildout] extends = base.cfg - http://dist.plone.org/release/5.1.6/versions.cfg + https://dist.plone.org/release/5.1.7/versions.cfg + versions.cfg [versions] +plone.testing = 5.0.0 + +# Error: The requirement ('virtualenv>=20.0.35') is not allowed by your [versions] constraint (20.0.26) +virtualenv = 20.0.35 + +# Error: The requirement ('distlib<1,>=0.3.1') is not allowed by your [versions] constraint (0.3.0) +distlib = 0.3.1 + # fixes: SyntaxError: invalid syntax (more.py, line 340) zipp = 0.5.2 -# plone.restapi specific -plone.schema = 1.2.0 +# Error: The requirement ('urllib3<1.23,>=1.21.1') is not allowed by your [versions] constraint (1.25.10) +urllib3 = 1.21.1 + +# Error: The requirement ('idna<2.7,>=2.5') is not allowed by your [versions] constraint (2.10) +idna = 2.5 # zest.releaser zest.releaser = 6.20.1 twine = 1.11.0 -requests = 2.22.0 towncrier = 19.2.0 zestreleaser.towncrier = 1.1.0 # docutils = 0.13.1 @@ -21,10 +32,10 @@ zestreleaser.towncrier = 1.1.0 # Sphinx Sphinx = 1.6.5 docutils = 0.14 -Pygments = 2.5.2 +Pygments = 2.5.1 sphinxcontrib-httpexample = 0.7.0 sphinxcontrib-httpdomain = 1.5.0 sphinx-rtd-theme = 0.2.4 Jinja2 = 2.10 Babel = 2.5.1 -astunparse = 1.6.2 \ No newline at end of file +astunparse = 1.6.2 diff --git a/plone-5.2.x.cfg b/plone-5.2.x.cfg index dbb9600..d65b44e 100644 --- a/plone-5.2.x.cfg +++ b/plone-5.2.x.cfg @@ -1,10 +1,21 @@ [buildout] extends = base.cfg - http://dist.plone.org/release/5.2.1/versions.cfg -find-links += http://dist.plone.org/thirdparty/ + https://dist.plone.org/release/5.2.3/versions.cfg +find-links += https://dist.plone.org/thirdparty/ versions=versions [versions] -# httpie depdendency, Pygments conflicts with -Pygments = 2.5.2 +black = 20.8b1 + +# Error: The requirement ('virtualenv>=20.0.35') is not allowed by your [versions] constraint (20.0.26) +virtualenv = 20.0.35 + +# Error: The requirement ('pep517>=0.9') is not allowed by your [versions] constraint (0.8.2) +pep517 = 0.9.1 + +# Error: The requirement ('importlib-metadata>=1') is not allowed by your [versions] constraint (0.23) +importlib-metadata = 2.0.0 + +# last py2 compatible version +check-manifest = 0.41 \ No newline at end of file diff --git a/requirements.txt b/requirements.txt index f6ac0d7..69d3090 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,3 +1,3 @@ # Keep this file in sync with: https://github.com/kitconcept/buildout/edit/master/requirements.txt setuptools==42.0.2 -zc.buildout==2.13.2 +zc.buildout==2.13.3 diff --git a/src/plone/rest/cors.py b/src/plone/rest/cors.py index 7fd230c..dbc2035 100644 --- a/src/plone/rest/cors.py +++ b/src/plone/rest/cors.py @@ -26,8 +26,8 @@ def __init__(self, context, request): def process_simple_request(self): """Process the current request as a simple CORS request by setting the - appropriate access control headers. Returns True if access control - headers were set. + appropriate access control headers. Returns True if access control + headers were set. """ origin = self._allowed_origin() if not origin: @@ -43,8 +43,8 @@ def process_simple_request(self): def process_preflight_request(self): """Process the current request as a CORS preflight request by setting - the appropriate access control headers. Returns True if access - control headers were set. + the appropriate access control headers. Returns True if access + control headers were set. """ origin = self._allowed_origin() if not origin: diff --git a/src/plone/rest/errors.py b/src/plone/rest/errors.py index 1eed12b..8227ff4 100644 --- a/src/plone/rest/errors.py +++ b/src/plone/rest/errors.py @@ -231,8 +231,7 @@ def attempt_redirect(self): @memoize def _url(self): - """Get the current, canonical URL - """ + """Get the current, canonical URL""" return self.request.get( "ACTUAL_URL", self.request.get( diff --git a/src/plone/rest/events.py b/src/plone/rest/events.py index f22f543..e2c65ce 100644 --- a/src/plone/rest/events.py +++ b/src/plone/rest/events.py @@ -7,7 +7,7 @@ def mark_as_api_request(event): """Mark a request as IAPIRequest if there's a service registered for the - actual request method and Accept header. + actual request method and Accept header. """ request = event.request method = request.get("REQUEST_METHOD", "GET") diff --git a/src/plone/rest/interfaces.py b/src/plone/rest/interfaces.py index 963969b..ac18224 100644 --- a/src/plone/rest/interfaces.py +++ b/src/plone/rest/interfaces.py @@ -3,18 +3,16 @@ class IAPIRequest(Interface): - """Marker for API requests. - """ + """Marker for API requests.""" class IService(Interface): - """Marker for REST services. - """ + """Marker for REST services.""" class ICORSPolicy(Interface): """Provides methods for processing simple and preflight CORS requests by - adding access control headers. + adding access control headers. """ def process_simple_request(): diff --git a/src/plone/rest/negotiation.py b/src/plone/rest/negotiation.py index 15423b4..7a47d5a 100644 --- a/src/plone/rest/negotiation.py +++ b/src/plone/rest/negotiation.py @@ -7,7 +7,7 @@ def parse_accept_header(accept): """Parse the given Accept header ignoring any parameters and return a list - of media type tuples. + of media type tuples. """ media_types = [] for media_range in accept.split(","): @@ -20,8 +20,8 @@ def parse_accept_header(accept): def lookup_service_id(method, accept): """Lookup the service id for the given request method and Accept header. - Only Accept headers containing exactly one media type are considered for - negotiation. + Only Accept headers containing exactly one media type are considered for + negotiation. """ media_types = parse_accept_header(accept) if len(media_types) != 1: @@ -40,7 +40,7 @@ def lookup_service_id(method, accept): def register_service(method, media_type): """Register a service for the given request method and media type and - return it's service id. + return it's service id. """ service_id = u"{}_{}_{}_".format(method, media_type[0], media_type[1]) types = _services.setdefault(method, {}) diff --git a/src/plone/rest/patches.py b/src/plone/rest/patches.py index c28dfac..97b618f 100644 --- a/src/plone/rest/patches.py +++ b/src/plone/rest/patches.py @@ -4,7 +4,7 @@ def __before_publishing_traverse__(self, arg1, arg2=None): """Pre-traversal hook that stops traversal to prevent the default view - to be appended. Appending the default view would break REST calls. + to be appended. Appending the default view would break REST calls. """ # XXX hack around a bug(?) in BeforeTraverse.MultiHook REQUEST = arg2 or arg1 diff --git a/src/plone/rest/traverse.py b/src/plone/rest/traverse.py index 259d83a..1cacba9 100644 --- a/src/plone/rest/traverse.py +++ b/src/plone/rest/traverse.py @@ -52,8 +52,7 @@ def browserDefault(self, request): @implementer(IBrowserPublisher) class RESTWrapper(object): - """A wrapper for objects traversed during a REST request. - """ + """A wrapper for objects traversed during a REST request.""" def __init__(self, context, request): self.context = context diff --git a/src/plone/rest/zcml.py b/src/plone/rest/zcml.py index 287398a..b41521b 100644 --- a/src/plone/rest/zcml.py +++ b/src/plone/rest/zcml.py @@ -20,8 +20,7 @@ class IService(Interface): - """ - """ + """""" method = TextLine( title=u"The name of the view that should be the default. " diff --git a/versions.cfg b/versions.cfg index 4087d74..de6710f 100644 --- a/versions.cfg +++ b/versions.cfg @@ -2,3 +2,47 @@ # Buildout setuptools = zc.buildout = +zc.recipe.egg = 2.0.3 + +# fixes Getting distribution for 'configparser'. assert newdist is not None # newloc above is missing our dist?! +configparser = 3.5.3 + +# fixes Error: The requirement ('Pygments>=2.5.1') is not allowed by your [versions] constraint (2.2.0) +Pygments = 2.5.1 + +# plone.recipe.varnish +plone.recipe.varnish = 1.3 + +# Code-analysis +plone.recipe.codeanalysis = 3.0.1 +coverage = 3.7.1 +pep8 = 1.7.1 +flake8 = 3.5.0 +flake8-coding = 1.3.2 +pycodestyle = 2.3.1 + +# Release +zest.releaser = 6.17.0 +twine = 1.11.0 +requests = 2.18.4 +towncrier = 19.2.0 +zestreleaser.towncrier = 1.1.0 +docutils = 0.13.1 + +# Sphinx +Sphinx = 1.6.5 +docutils = 0.14 +Pygments = 2.2.0 +sphinxcontrib-httpexample = 0.7.0 +sphinxcontrib-httpdomain = 1.5.0 +sphinx-rtd-theme = 0.2.4 +Jinja2 = 2.10 +Babel = 2.5.1 + +# plone.rest(api) specific pins + +# last py2 compatible version +httpie = 1.0.3 + +# last py2 compatible version +check-manifest = 0.41 \ No newline at end of file