Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add gh actions #3

Merged
merged 7 commits into from
Sep 12, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[flake8]
# Recommend matching the black line length (default 88),
# rather than using the flake8 default of 79:
max-line-length = 100000
extend-ignore =
# See https://github.com/PyCQA/pycodestyle/issues/373
E203,
35 changes: 35 additions & 0 deletions .github/workflows/black.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: Black
on: [push]
jobs:
build:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: [3.8]

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-

# install black
- name: install black
run: pip install black

# run black
- name: run black
run: black src/ --check --diff
35 changes: 35 additions & 0 deletions .github/workflows/flake8.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: Flake8
on: [push]
jobs:
build:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: [3.8]

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-

# install flake8
- name: install flake8
run: pip install flake8

# run black
- name: run flake8
run: flake8 src/ setup.py
35 changes: 35 additions & 0 deletions .github/workflows/pyroma.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: Pyroma
on: [push]
jobs:
build:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: [3.8]

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-

# install pyroma
- name: install pyroma
run: pip install pyroma

# run pyroma
- name: run pyroma
run: pyroma -n 10 -d .
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Basic tests
name: Tests
'on':
push:
branches:
Expand Down
40 changes: 40 additions & 0 deletions .github/workflows/zpretty.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: zpretty
on: [push]
jobs:
build:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: [3.8]

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-

# install zpretty
- name: install zpretty
run: pip install zpretty

# run zpretty
- name: run zpretty
run: find src/ -name *.zcml | xargs zpretty -i

# XXX: this doesn't work on gh actions (https://github.com/plone/plone.restapi/pull/1119/checks?check_run_id=2686474411)
# # run git diff
# - name: run git diff
# run: git diff --exit-code
2 changes: 1 addition & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ Compatibility
Volto requires specific versions of plone.volto and plone.restapi:

+---------+------------------------+-----------------------+
| | plone.volto | plone.restapi |
| | plone.volto | plone.restapi |
+---------+------------------------+-----------------------+
| | 1.x | 6.0.0 and below |
+---------+------------------------+-----------------------+
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Keep this file in sync with: https://github.com/kitconcept/buildout/edit/master/requirements.txt
setuptools==42.0.2
zc.buildout==2.13.3
black==19.3b0
black==21.8b0
4 changes: 1 addition & 3 deletions src/plone/volto/behaviors/preview.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,5 @@ class IPreview(model.Schema):
)

preview_caption = TextLine(
title=_(u"Preview image caption"),
description=u"",
required=False,
title=_(u"Preview image caption"), description=u"", required=False
)
2 changes: 1 addition & 1 deletion src/plone/volto/blocksuuidfixer.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@


class DuplicatedBlocksUUIDFixer(BrowserView):
""" This script refreshes all UUIDs found in blocks with a new UUID to ensure all UUIDs are unique"""
"""This script refreshes all UUIDs found in blocks with a new UUID to ensure all UUIDs are unique"""

def __call__(self):
alsoProvides(self.request, IDisableCSRFProtection)
Expand Down
4 changes: 2 additions & 2 deletions src/plone/volto/setuphandlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def enable_pam(portal):


def ensure_pam_consistency(portal):
""" Makes sure that all the content in a language branch has language """
"""Makes sure that all the content in a language branch has language"""

# Ensure that all the objects below an LFR is of the intended language
pc = getToolByName(portal, "portal_catalog")
Expand Down Expand Up @@ -220,7 +220,7 @@ def setupPortletAt(portal, portlet_type, manager, path, name="", **kw):


def create_default_homepage(context, default_home=default_lrf_home):
""" This method allows to pass a dict with the homepage blocks and blocks_layout keys"""
"""This method allows to pass a dict with the homepage blocks and blocks_layout keys"""
portal = api.portal.get()
# Test for PAM installed
try:
Expand Down
9 changes: 2 additions & 7 deletions src/plone/volto/testing.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,7 @@ def setUpPloneSite(self, portal):


PLONE_VOLTO_CORE_INTEGRATION_TESTING = IntegrationTesting(
bases=(PLONE_VOLTO_CORE_FIXTURE,),
name="PloneVoltoCoreLayer:IntegrationTesting",
bases=(PLONE_VOLTO_CORE_FIXTURE,), name="PloneVoltoCoreLayer:IntegrationTesting"
)


Expand All @@ -52,10 +51,6 @@ def setUpPloneSite(self, portal):


PLONE_VOLTO_CORE_ACCEPTANCE_TESTING = FunctionalTesting(
bases=(
PLONE_VOLTO_CORE_FIXTURE,
REMOTE_LIBRARY_BUNDLE_FIXTURE,
z2.ZSERVER_FIXTURE,
),
bases=(PLONE_VOLTO_CORE_FIXTURE, REMOTE_LIBRARY_BUNDLE_FIXTURE, z2.ZSERVER_FIXTURE),
name="PloneVoltoCoreLayer:AcceptanceTesting",
)
18 changes: 5 additions & 13 deletions src/plone/volto/tests/test_scripts.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@
from plone.volto.scripts.blocksremoveserver import array_href_replace_server
from plone.volto.scripts.blocksremoveserver import string_url_replace_server
from plone.volto.scripts.blocksremoveserver import array_url_replace_server
from plone.volto.scripts.blocksremoveserver import (
array_preview_image_replace_server,
)
from plone.volto.scripts.blocksremoveserver import array_preview_image_replace_server
from plone.volto.scripts.listingaddsummary import migrate_listing_block_to_summary
from plone.volto.scripts.searchscalesinimageblocks import remove_image_scales

Expand All @@ -31,10 +29,7 @@ def setUp(self):
behavior_list.append("volto.blocks")
fti.behaviors = tuple(behavior_list)

self.portal.invokeFactory(
"Document",
id=u"doc1",
)
self.portal.invokeFactory("Document", id=u"doc1")
self.doc1 = self.portal["doc1"]
self.image = self.portal[
self.portal.invokeFactory("Image", id="image1", title="Target image")
Expand Down Expand Up @@ -244,14 +239,13 @@ def test_string_url_replace_server(self):
"alt": "Bild 3",
"size": "l",
"url": "{}".format(self.image.absolute_url()),
},
}
}

result = string_url_replace_server(blocks, self.portal.absolute_url(), "")

self.assertEqual(
result["7bad5afd-ea6a-472a-a521-452810e1d286"]["url"],
"/image1",
result["7bad5afd-ea6a-472a-a521-452810e1d286"]["url"], "/image1"
)

blocks = {
Expand Down Expand Up @@ -395,9 +389,7 @@ def test_array_url_replace_server(self):
)

def test_migrate_listing_block_to_summary(self):
blocks = {
"@type": "listing",
}
blocks = {"@type": "listing"}

result = migrate_listing_block_to_summary(blocks)

Expand Down
10 changes: 2 additions & 8 deletions src/plone/volto/tests/test_transforms.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,7 @@ def setUp(self):
behavior_list.append("volto.blocks")
fti.behaviors = tuple(behavior_list)

self.portal.invokeFactory(
"Document",
id="doc1",
)
self.portal.invokeFactory("Document", id="doc1")
self.image = self.portal[
self.portal.invokeFactory("Image", id="image-1", title="Target image")
]
Expand Down Expand Up @@ -260,10 +257,7 @@ def test_serialize_slate(self):
"6b2be2e6-9857-4bcc-a21a-29c0449e1c68": {"@type": "title"},
}

res = self.serialize(
context=self.portal["doc1"],
blocks=blocks,
)
res = self.serialize(context=self.portal["doc1"], blocks=blocks)

value = res["e248ecb5-b787-4e04-b1b3-98febf4539d1"]["columns"][0]["value"]
link = value[0]["children"][1]["children"][1]
Expand Down
5 changes: 1 addition & 4 deletions src/plone/volto/tests/test_upgrades.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,7 @@ def setUp(self):
behavior_list.append("volto.blocks")
fti.behaviors = tuple(behavior_list)

self.portal.invokeFactory(
"Document",
id=u"doc1",
)
self.portal.invokeFactory("Document", id=u"doc1")
self.image = self.portal[
self.portal.invokeFactory("Image", id="image-1", title="Target image")
]
Expand Down
12 changes: 6 additions & 6 deletions src/plone/volto/transforms.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def __init__(self, context, request):
self.request = request

def _transform(self, block):
""" this mutates the object directly """
"""this mutates the object directly"""

block_type = block.get("@type", "")
handlers = []
Expand Down Expand Up @@ -86,13 +86,13 @@ def __call__(self, block):
@adapter(IBlocks, IBrowserRequest)
@implementer(IBlockFieldDeserializationTransformer)
class NestedResolveUIDDeserializer(NestedResolveUIDDeserializerBase):
""" Deserializer for content-types that implements IBlocks behavior """
"""Deserializer for content-types that implements IBlocks behavior"""


@adapter(IPloneSiteRoot, IBrowserRequest)
@implementer(IBlockFieldDeserializationTransformer)
class NestedResolveUIDDeserializerRoot(NestedResolveUIDDeserializerBase):
""" Deserializer for site root """
"""Deserializer for site root"""


class NestedResolveUIDSerializerBase(object):
Expand All @@ -104,7 +104,7 @@ def __init__(self, context, request):
self.request = request

def _transform(self, block):
""" this mutates the object directly """
"""this mutates the object directly"""

block_type = block.get("@type", "")
handlers = []
Expand Down Expand Up @@ -160,10 +160,10 @@ def __call__(self, value):
@adapter(IBlocks, IBrowserRequest)
@implementer(IBlockFieldDeserializationTransformer)
class NestedResolveUIDSerializer(NestedResolveUIDSerializerBase):
""" Deserializer for content-types that implements IBlocks behavior """
"""Deserializer for content-types that implements IBlocks behavior"""


@adapter(IPloneSiteRoot, IBrowserRequest)
@implementer(IBlockFieldDeserializationTransformer)
class NestedResolveUIDSerializerRoot(NestedResolveUIDSerializerBase):
""" Deserializer for site root """
"""Deserializer for site root"""