Skip to content

Commit fa66994

Browse files
authored
use gh actions (#8)
* use gh actions * use github actions for ci
1 parent a13fe6a commit fa66994

File tree

11 files changed

+170
-139
lines changed

11 files changed

+170
-139
lines changed

.github/workflows/main.yml

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
name: CI
2+
3+
# Controls when the action will run.
4+
on:
5+
# Triggers the workflow on push or pull request events
6+
push:
7+
pull_request:
8+
schedule:
9+
- cron: '0 12 * * 0' # run once a week on Sunday
10+
11+
# Allows you to run this workflow manually from the Actions tab
12+
workflow_dispatch:
13+
14+
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
15+
jobs:
16+
tests:
17+
name: "Python ${{ matrix.python-version }}"
18+
runs-on: "ubuntu-latest"
19+
20+
strategy:
21+
matrix:
22+
python-version: ["3.6", "3.7", "3.8", "3.9", "pypy3"]
23+
24+
# Steps represent a sequence of tasks that will be executed as part of the job
25+
steps:
26+
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
27+
- uses: "actions/checkout@v2"
28+
- uses: "actions/setup-python@v2"
29+
with:
30+
python-version: "${{ matrix.python-version }}"
31+
- name: "Install dependencies"
32+
run: |
33+
set -xe
34+
python -VV
35+
python -m site
36+
python -m pip install --upgrade pip setuptools wheel
37+
python -m pip install --upgrade virtualenv tox tox-gh-actions
38+
- name: "Run tox targets for ${{ matrix.python-version }}"
39+
run: "python -m tox"
40+
41+
- name: "Report to coveralls"
42+
# coverage is only created in the py39 environment
43+
# --service=github is a workaround for bug
44+
# https://github.com/coveralls-clients/coveralls-python/issues/251
45+
if: "matrix.python-version == '3.9'"
46+
run: |
47+
pip install coveralls
48+
coveralls --service=github
49+
env:
50+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.pre-commit-config.yaml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
repos:
2+
- repo: https://github.com/psf/black
3+
rev: 20.8b1
4+
hooks:
5+
- id: black
6+
args: [--line-length=80]
7+
- repo: https://gitlab.com/pycqa/flake8
8+
rev: "3.8.4"
9+
hooks:
10+
- id: flake8
11+
- repo: https://github.com/asottile/pyupgrade
12+
rev: v2.7.4
13+
hooks:
14+
- id: pyupgrade
15+
args: [--py36-plus]

.travis.yml

Lines changed: 0 additions & 31 deletions
This file was deleted.

HISTORY.rst

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,15 @@ Changelog
44
0.0.3 (unreleased)
55
~~~~~~~~~~~~~~~~~~
66

7-
- Add support for Python 3.6 - 3.8.
7+
- Add support for Python 3.6 - 3.9.
88

99
- Remove support for Python versions < 3.6.
1010

11-
- Add Python 3.5 and make it the default test environment.
11+
- Add Python 3.5 and make it the default test environment. (superseded)
1212
[henri-hulski]
1313

14+
- Use GitHub Actions for CI.
15+
1416
0.0.2 (2016-04-18)
1517
~~~~~~~~~~~~~~~~~~~
1618

README.rst

Lines changed: 15 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,17 @@
1+
.. image:: https://github.com/morepath/more.itsdangerous/workflows/CI/badge.svg?branch=master
2+
:target: https://github.com/morepath/more.itsdangerous/actions?workflow=CI
3+
:alt: CI Status
4+
5+
.. image:: https://coveralls.io/repos/github/morepath/more.itsdangerous/badge.svg?branch=master
6+
:target: https://coveralls.io/github/morepath/morepath_sqlamore.itsdangerouslchemy?branch=master
7+
8+
.. image:: https://img.shields.io/pypi/v/more.itsdangerous.svg
9+
:target: https://pypi.org/project/more.itsdangerous/
10+
11+
.. image:: https://img.shields.io/pypi/pyversions/more.itsdangerous.svg
12+
:target: https://pypi.org/project/more.itsdangerous/
13+
14+
115
More Itsdangerous
216
=================
317

@@ -65,7 +79,7 @@ Install tox and run it::
6579

6680
Limit the tests to a specific python version::
6781

68-
tox -e py38
82+
tox -e py39
6983

7084
Conventions
7185
-----------
@@ -76,26 +90,6 @@ More Itsdangerous follows PEP8 as close as possible. To test for it run::
7690

7791
More Itsdangerous uses `Semantic Versioning <http://semver.org/>`_
7892

79-
Build Status
80-
------------
81-
82-
.. image:: https://travis-ci.com/morepath/more.itsdangerous.png
83-
:target: https://travis-ci.com/morepath/more.itsdangerous
84-
:alt: Build Status
85-
86-
Coverage
87-
--------
88-
89-
.. image:: https://coveralls.io/repos/morepath/more.itsdangerous/badge.png?branch=master
90-
:target: https://coveralls.io/r/morepath/more.itsdangerous?branch=master
91-
:alt: Project Coverage
92-
93-
Latests PyPI Release
94-
--------------------
95-
.. image:: https://img.shields.io/pypi/v/more.itsdangerous.svg
96-
:target: https://crate.io/packages/more.itsdangerous
97-
:alt: Latest PyPI Release
98-
9993
License
10094
-------
10195
more.itsdangerous is released under the revised BSD license

more/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__import__('pkg_resources').declare_namespace(__name__)
1+
__import__("pkg_resources").declare_namespace(__name__)

more/itsdangerous/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
from more.itsdangerous.identity_policy import IdentityPolicy
22

3-
__all__ = ['IdentityPolicy']
3+
__all__ = ["IdentityPolicy"]

more/itsdangerous/identity_policy.py

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66

77
class IdentityPolicy:
8-
""" A Morepath IdentityPolicy that stores attributes of the identity
8+
"""A Morepath IdentityPolicy that stores attributes of the identity
99
as cookies with a signature.
1010
1111
You probably want to override this class in your application, to fit it
@@ -16,7 +16,7 @@ class IdentityPolicy:
1616
"""
1717

1818
def __init__(self, max_age=3600, secure=True, httponly=True):
19-
""" Configures the identity policy with the following values:
19+
"""Configures the identity policy with the following values:
2020
2121
:max_age:
2222
The max age of both the signature and the cookie in seconds.
@@ -37,7 +37,7 @@ def __init__(self, max_age=3600, secure=True, httponly=True):
3737

3838
@morepath.reify
3939
def secret(self):
40-
""" The secret used to for the signatures.
40+
"""The secret used to for the signatures.
4141
4242
As long as the secret is not stored anywhere, the signed values all
4343
become invalid every time the secret is changed. Currently, that
@@ -54,7 +54,7 @@ def identity_class(self):
5454

5555
@property
5656
def required_keys(self):
57-
""" The attributes of the identity which are signed and stored as
57+
"""The attributes of the identity which are signed and stored as
5858
cookies.
5959
6060
This is useful to add additional values that are present on your
@@ -68,11 +68,11 @@ def required_keys(self):
6868
6969
"""
7070

71-
return ('userid', )
71+
return ("userid",)
7272

7373
@property
7474
def cookie_settings(self):
75-
""" Returns the default cookie settings.
75+
"""Returns the default cookie settings.
7676
7777
See also:
7878
@@ -81,13 +81,13 @@ def cookie_settings(self):
8181
8282
"""
8383
return {
84-
'max_age': self.max_age,
85-
'secure': self.secure,
86-
'httponly': self.httponly
84+
"max_age": self.max_age,
85+
"secure": self.secure,
86+
"httponly": self.httponly,
8787
}
8888

8989
def identify(self, request):
90-
""" Returns the identity of the given request, if *all* cookies
90+
"""Returns the identity of the given request, if *all* cookies
9191
match, or None.
9292
9393
"""
@@ -115,7 +115,7 @@ def forget(self, response, request):
115115
response.delete_cookie(key)
116116

117117
def sign(self, unsigned_value, salt):
118-
""" Signs a value with a salt using itsdangerous.TimestampSigner and
118+
"""Signs a value with a salt using itsdangerous.TimestampSigner and
119119
returns the resulting signed value.
120120
121121
The salt might not be what you think it is:
@@ -124,7 +124,7 @@ def sign(self, unsigned_value, salt):
124124
return TimestampSigner(self.secret, salt=salt).sign(unsigned_value)
125125

126126
def unsign(self, signed_value, salt):
127-
""" Takes the signed value and returns it unsigned, if possible.
127+
"""Takes the signed value and returns it unsigned, if possible.
128128
129129
If the signature is bad or if it expired, None is returned.
130130
"""
@@ -138,7 +138,7 @@ def unsign(self, signed_value, salt):
138138
unsigned = signer.unsign(signed_value, max_age=self.max_age)
139139

140140
# see http://pythonhosted.org/itsdangerous/#python-3-notes
141-
return unsigned.decode('utf-8')
141+
return unsigned.decode("utf-8")
142142

143143
except (SignatureExpired, BadSignature):
144144
return None

more/itsdangerous/tests/test_identity_policy.py

Lines changed: 27 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -24,59 +24,58 @@ def delete_cookie(self, key):
2424
def test_signatures():
2525
ip = IdentityPolicy()
2626

27-
assert ip.unsign(ip.sign('admin', 'username'), 'username') == 'admin'
28-
assert ip.unsign(ip.sign('admin ', 'username'), 'username') == 'admin '
29-
assert ip.unsign(ip.sign('admin', 'username'), 'role') is None
27+
assert ip.unsign(ip.sign("admin", "username"), "username") == "admin"
28+
assert ip.unsign(ip.sign("admin ", "username"), "username") == "admin "
29+
assert ip.unsign(ip.sign("admin", "username"), "role") is None
3030

3131

3232
def test_expired_signature():
3333

3434
ip = IdentityPolicy(max_age=0.1)
35-
signed = ip.sign('admin', 'username')
35+
signed = ip.sign("admin", "username")
3636

37-
assert ip.unsign(signed, 'username') == 'admin'
37+
assert ip.unsign(signed, "username") == "admin"
3838
time.sleep(1.0)
39-
assert ip.unsign(signed, 'username') is None
39+
assert ip.unsign(signed, "username") is None
4040

4141

4242
def test_policy():
4343
ip = IdentityPolicy()
44-
identity = morepath.Identity(userid='aaron', role='admin')
44+
identity = morepath.Identity(userid="aaron", role="admin")
4545
request = TestRequest()
4646
response = TestResponse()
4747

4848
ip.remember(response, request, identity)
4949

50-
assert 'userid' in response.cookies
51-
assert 'role' not in response.cookies
50+
assert "userid" in response.cookies
51+
assert "role" not in response.cookies
5252

5353

5454
def test_custom_policy():
55-
5655
class CustomIdentityPolicy(IdentityPolicy):
57-
required_keys = ('userid', 'role')
56+
required_keys = ("userid", "role")
5857

5958
ip = CustomIdentityPolicy()
60-
identity = morepath.Identity(userid='aaron', role='admin')
59+
identity = morepath.Identity(userid="aaron", role="admin")
6160
request = TestRequest()
6261
response = TestResponse()
6362

6463
ip.remember(response, request, identity)
6564

66-
assert response.cookies['userid'].startswith(b'aaron.')
67-
assert response.cookies['role'].startswith(b'admin.')
68-
assert response.cookie_args['userid'] == response.cookie_args['role'] == {
69-
'max_age': 3600,
70-
'secure': True,
71-
'httponly': True
72-
}
65+
assert response.cookies["userid"].startswith(b"aaron.")
66+
assert response.cookies["role"].startswith(b"admin.")
67+
assert (
68+
response.cookie_args["userid"]
69+
== response.cookie_args["role"]
70+
== {"max_age": 3600, "secure": True, "httponly": True}
71+
)
7372

7473
request.cookies = response.cookies
7574

76-
assert ip.identify(request).userid == 'aaron'
77-
assert ip.identify(request).role == 'admin'
75+
assert ip.identify(request).userid == "aaron"
76+
assert ip.identify(request).role == "admin"
7877

79-
del request.cookies['role']
78+
del request.cookies["role"]
8079

8180
assert ip.identify(request) is None
8281

@@ -87,11 +86,11 @@ class CustomIdentityPolicy(IdentityPolicy):
8786

8887
def test_cookie_settings():
8988
ip = IdentityPolicy()
90-
assert ip.cookie_settings['max_age'] == 3600
91-
assert ip.cookie_settings['secure']
92-
assert ip.cookie_settings['httponly']
89+
assert ip.cookie_settings["max_age"] == 3600
90+
assert ip.cookie_settings["secure"]
91+
assert ip.cookie_settings["httponly"]
9392

9493
ip = IdentityPolicy(max_age=1, secure=False, httponly=False)
95-
assert ip.cookie_settings['max_age'] == 1
96-
assert not ip.cookie_settings['secure']
97-
assert not ip.cookie_settings['httponly']
94+
assert ip.cookie_settings["max_age"] == 1
95+
assert not ip.cookie_settings["secure"]
96+
assert not ip.cookie_settings["httponly"]

0 commit comments

Comments
 (0)