Skip to content

Commit 46bb120

Browse files
authored
Add github actions to run linting and tests (#1349)
1 parent afa44e8 commit 46bb120

File tree

10 files changed

+107
-21
lines changed

10 files changed

+107
-21
lines changed

.github/workflows/deploy.yml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
name: 🚀 Deploy to PyPI
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*'
7+
8+
jobs:
9+
build:
10+
runs-on: ubuntu-latest
11+
12+
steps:
13+
- uses: actions/checkout@v2
14+
- name: Set up Python 3.9
15+
uses: actions/setup-python@v2
16+
with:
17+
python-version: 3.9
18+
- name: Build wheel and source tarball
19+
run: |
20+
pip install wheel
21+
python setup.py sdist bdist_wheel
22+
- name: Publish a Python distribution to PyPI
23+
uses: pypa/[email protected]
24+
with:
25+
user: __token__
26+
password: ${{ secrets.pypi_password }}

.github/workflows/lint.yml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
name: Lint
2+
3+
on: [push, pull_request]
4+
5+
jobs:
6+
build:
7+
runs-on: ubuntu-latest
8+
9+
steps:
10+
- uses: actions/checkout@v2
11+
- name: Set up Python 3.9
12+
uses: actions/setup-python@v2
13+
with:
14+
python-version: 3.9
15+
- name: Install dependencies
16+
run: |
17+
python -m pip install --upgrade pip
18+
pip install tox
19+
- name: Run lint 💅
20+
run: tox
21+
env:
22+
TOXENV: pre-commit
23+
- name: Run mypy
24+
run: tox
25+
env:
26+
TOXENV: mypy

.github/workflows/tests.yml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
name: Tests
2+
3+
on: [push, pull_request]
4+
5+
jobs:
6+
build:
7+
runs-on: ubuntu-latest
8+
strategy:
9+
max-parallel: 4
10+
matrix:
11+
python-version: ["2.7", "3.6", "3.7", "3.8", "3.9"]
12+
13+
steps:
14+
- uses: actions/checkout@v2
15+
- name: Set up Python ${{ matrix.python-version }}
16+
uses: actions/setup-python@v2
17+
with:
18+
python-version: ${{ matrix.python-version }}
19+
- name: Install dependencies
20+
run: |
21+
python -m pip install --upgrade pip
22+
pip install tox tox-gh-actions
23+
- name: Test with tox
24+
run: tox
25+
env:
26+
TOXENV: ${{ matrix.toxenv }}

.pre-commit-config.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,11 @@ repos:
1818
hooks:
1919
- id: pyupgrade
2020
- repo: https://github.com/ambv/black
21-
rev: 18.9b0
21+
rev: 21.6b0
2222
hooks:
2323
- id: black
2424
language_version: python3
2525
- repo: https://github.com/PyCQA/flake8
26-
rev: 3.7.7
26+
rev: 3.9.2
2727
hooks:
2828
- id: flake8

graphene/relay/tests/test_connection_query.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,10 @@ def resolve_connection_letters(self, info, **args):
5454
def edges(selected_letters):
5555
return [
5656
{
57-
"node": {"id": base64("Letter:%s" % l.id), "letter": l.letter},
58-
"cursor": base64("arrayconnection:%s" % l.id),
57+
"node": {"id": base64("Letter:%s" % letter.id), "letter": letter.letter},
58+
"cursor": base64("arrayconnection:%s" % letter.id),
5959
}
60-
for l in [letters[i] for i in selected_letters]
60+
for letter in [letters[i] for i in selected_letters]
6161
]
6262

6363

graphene/types/mutation.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ def __init_subclass_with_meta__(
135135
def Field(
136136
cls, name=None, description=None, deprecation_reason=None, required=False
137137
):
138-
""" Mount instance of mutation Field. """
138+
"""Mount instance of mutation Field."""
139139
return Field(
140140
cls._meta.output,
141141
args=cls._meta.arguments,

graphene/types/tests/test_query.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -399,7 +399,7 @@ def resolve_all_containers(self, info):
399399

400400

401401
def test_big_list_of_containers_multiple_fields_custom_resolvers_query_benchmark(
402-
benchmark
402+
benchmark,
403403
):
404404
class Container(ObjectType):
405405
x = Int()

setup.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,9 @@ def run_tests(self):
4949
"pytest-benchmark",
5050
"pytest-cov",
5151
"pytest-mock",
52+
# pinning fastdiff dep (required by snapshottest) because later versions
53+
# require wasmer 1.0.0 which is not compatible with Python 2.7
54+
"fastdiff==0.2.0",
5255
"snapshottest",
5356
"coveralls",
5457
"promise",

tests_asyncio/test_relay_connection.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,10 @@ def resolve_connection_letters(self, info, **args):
5656
def edges(selected_letters):
5757
return [
5858
{
59-
"node": {"id": base64("Letter:%s" % l.id), "letter": l.letter},
60-
"cursor": base64("arrayconnection:%s" % l.id),
59+
"node": {"id": base64("Letter:%s" % letter.id), "letter": letter.letter},
60+
"cursor": base64("arrayconnection:%s" % letter.id),
6161
}
62-
for l in [letters[i] for i in selected_letters]
62+
for letter in [letters[i] for i in selected_letters]
6363
]
6464

6565

tox.ini

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,27 @@
11
[tox]
2-
envlist = flake8,py27,py34,py35,py36,py37,pre-commit,pypy,mypy
3-
skipsdist = true
2+
envlist = py{27,36,37,38,39},flake8,pre-commit,mypy
3+
4+
[gh-actions]
5+
python =
6+
2.7: py27
7+
3.6: py36
8+
3.7: py37
9+
3.8: py38
10+
3.9: py39
411

512
[testenv]
13+
passenv = *
14+
usedevelop = True
615
deps =
7-
.[test]
8-
py{35,36,37}: pytest-asyncio
16+
-e.[test]
17+
py{36,37,38,39}: pytest-asyncio
918
setenv =
1019
PYTHONPATH = .:{envdir}
1120
commands =
12-
py{27,py}: py.test --cov=graphene graphene examples {posargs}
13-
py{35}: py.test --cov=graphene graphene examples tests_asyncio {posargs}
14-
py{36,37}: py.test --cov=graphene graphene examples tests_asyncio tests_py36 {posargs}
21+
py{27}: py.test --cov=graphene graphene examples {posargs}
22+
py{36,37,38,39}: py.test --cov=graphene graphene examples tests_asyncio tests_py36 {posargs}
1523

1624
[testenv:pre-commit]
17-
basepython=python3.7
1825
deps =
1926
pre-commit>0.12.0
2027
setenv =
@@ -23,9 +30,9 @@ commands =
2330
pre-commit {posargs:run --all-files}
2431

2532
[testenv:mypy]
26-
basepython=python3.7
2733
deps =
2834
mypy
35+
types-six
2936
commands =
3037
mypy graphene
3138

@@ -34,5 +41,3 @@ deps = flake8
3441
commands =
3542
pip install -e .
3643
flake8 graphene
37-
38-
[pytest]

0 commit comments

Comments
 (0)