Skip to content

Commit af2472f

Browse files
authored
use GitHub Actions instead of Travis CI
... as Travis no longer supports open source.
1 parent 3354b88 commit af2472f

File tree

13 files changed

+177
-111
lines changed

13 files changed

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

.travis.yml

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

README.rst

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

morepath_sqlalchemy/app.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010

1111

1212
class DBSessionRequest(Request):
13-
1413
@reify
1514
def db_session(self):
1615
return Session()

morepath_sqlalchemy/collection.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,14 @@
33
MAX_LIMIT = 20
44

55

6-
class DocumentCollection(object):
6+
class DocumentCollection:
77
def __init__(self, db_session, offset, limit):
88
self.db_session = db_session
99
self.offset = offset
1010
self.limit = min(limit, MAX_LIMIT)
1111

1212
def query(self):
13-
return self.db_session.query(Document).offset(self.offset) \
14-
.limit(self.limit)
13+
return self.db_session.query(Document).offset(self.offset).limit(self.limit)
1514

1615
def add(self, title, content):
1716
session = self.db_session

morepath_sqlalchemy/model.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@
44
Base = declarative_base()
55

66

7-
class Root(object):
7+
class Root:
88
pass
99

1010

1111
class Document(Base):
12-
__tablename__ = 'document'
12+
__tablename__ = "document"
1313

1414
id = Column(Integer, primary_key=True)
1515
title = Column(Text)

morepath_sqlalchemy/path.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,16 @@
33
from .model import Document, Root
44

55

6-
@App.path(model=Root, path='/')
6+
@App.path(model=Root, path="/")
77
def get_root():
88
return Root()
99

1010

11-
@App.path(model=Document, path='documents/{id}',
12-
converters={'id': int})
11+
@App.path(model=Document, path="documents/{id}", converters={"id": int})
1312
def get_document(request, id):
1413
return request.db_session.query(Document).filter(Document.id == id).first()
1514

1615

17-
@App.path(model=DocumentCollection, path='documents')
16+
@App.path(model=DocumentCollection, path="documents")
1817
def get_document_collection(request, offset=0, limit=10):
1918
return DocumentCollection(request.db_session, offset, limit)

morepath_sqlalchemy/run.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
from .model import Base
77

88

9-
def run(): # pragma: no cover
10-
engine = sqlalchemy.create_engine('sqlite:///morepath_sqlalchemy.db')
9+
def run(): # pragma: no cover
10+
engine = sqlalchemy.create_engine("sqlite:///morepath_sqlalchemy.db")
1111
Session.configure(bind=engine)
1212
Base.metadata.create_all(engine)
1313

morepath_sqlalchemy/tests/test_sqlalchemy.py

Lines changed: 29 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111

1212
def setup_module(module):
13-
engine = sqlalchemy.create_engine('sqlite:///:memory:')
13+
engine = sqlalchemy.create_engine("sqlite:///:memory:")
1414
Session.configure(bind=engine)
1515
Base.metadata.create_all(engine)
1616

@@ -21,7 +21,7 @@ def setup_module(module):
2121
def test_documents():
2222
c = Client(App())
2323

24-
collection_response = c.get('/documents')
24+
collection_response = c.get("/documents")
2525

2626
assert collection_response.json["documents"] == []
2727
assert "http://localhost/documents/add" in collection_response.json["add"]
@@ -33,22 +33,21 @@ def test_add_submit():
3333
c = Client(App())
3434

3535
response = c.post(
36-
'/documents/add_submit',
37-
{'title': 'My Title', 'content': 'My Content'}
36+
"/documents/add_submit", {"title": "My Title", "content": "My Content"}
3837
)
3938

40-
assert response.body == b'<p>Awesome 1</p>'
39+
assert response.body == b"<p>Awesome 1</p>"
4140

4241

4342
def test_document():
4443
c = Client(App())
4544

46-
response = c.get('/documents/1')
45+
response = c.get("/documents/1")
4746
new_document_response = {
4847
"id": 1,
4948
"title": "My Title",
5049
"content": "My Content",
51-
"link": "http://localhost/documents/1"
50+
"link": "http://localhost/documents/1",
5251
}
5352

5453
assert response.json == new_document_response
@@ -57,15 +56,17 @@ def test_document():
5756
def test_previous_next():
5857
c = Client(App())
5958

60-
c.post('/documents/add_submit', {'title': 'Two', 'content': 'Secundus'})
59+
c.post("/documents/add_submit", {"title": "Two", "content": "Secundus"})
6160

62-
response = c.get('/documents/?limit=1&offset=0')
63-
expected_documents = [{
64-
"id": 1,
65-
"title": "My Title",
66-
"content": "My Content",
67-
"link": "http://localhost/documents/1"
68-
}]
61+
response = c.get("/documents/?limit=1&offset=0")
62+
expected_documents = [
63+
{
64+
"id": 1,
65+
"title": "My Title",
66+
"content": "My Content",
67+
"link": "http://localhost/documents/1",
68+
}
69+
]
6970

7071
assert response.json["documents"] == expected_documents
7172
assert "http://localhost/documents/add" in response.json["add"]
@@ -74,13 +75,15 @@ def test_previous_next():
7475
assert "limit=1" in response.json["next"]
7576
assert "offset=1" in response.json["next"]
7677

77-
response = c.get('/documents/?limit=1&offset=1')
78-
expected_documents = [{
79-
"id": 2,
80-
"title": "Two",
81-
"content": "Secundus",
82-
"link": "http://localhost/documents/2"
83-
}]
78+
response = c.get("/documents/?limit=1&offset=1")
79+
expected_documents = [
80+
{
81+
"id": 2,
82+
"title": "Two",
83+
"content": "Secundus",
84+
"link": "http://localhost/documents/2",
85+
}
86+
]
8487

8588
assert response.json["documents"] == expected_documents
8689
assert "http://localhost/documents/add" in response.json["add"]
@@ -93,9 +96,9 @@ def test_previous_next():
9396
def test_add():
9497
c = Client(App())
9598

96-
response = c.get('/documents/add')
99+
response = c.get("/documents/add")
97100

98-
expected_response = b'''\
101+
expected_response = b"""\
99102
<html>
100103
<body>
101104
<form action="/documents/add_submit" method="POST">
@@ -105,12 +108,12 @@ def test_add():
105108
</form>
106109
</body>
107110
</html>
108-
'''
111+
"""
109112

110113
assert response.body == expected_response
111114

112115

113116
def test_root():
114117
c = Client(App())
115118

116-
c.get('/', status=302)
119+
c.get("/", status=302)

0 commit comments

Comments
 (0)