Add github actions to run linting and tests (#1349)

This commit is contained in:
Jonathan Kim 2021-07-16 16:56:15 +01:00 committed by GitHub
parent afa44e8a5f
commit 46bb1202e4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 107 additions and 21 deletions

26
.github/workflows/deploy.yml vendored Normal file
View File

@ -0,0 +1,26 @@
name: 🚀 Deploy to PyPI
on:
push:
tags:
- 'v*'
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up Python 3.9
uses: actions/setup-python@v2
with:
python-version: 3.9
- name: Build wheel and source tarball
run: |
pip install wheel
python setup.py sdist bdist_wheel
- name: Publish a Python distribution to PyPI
uses: pypa/gh-action-pypi-publish@v1.1.0
with:
user: __token__
password: ${{ secrets.pypi_password }}

26
.github/workflows/lint.yml vendored Normal file
View File

@ -0,0 +1,26 @@
name: Lint
on: [push, pull_request]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up Python 3.9
uses: actions/setup-python@v2
with:
python-version: 3.9
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install tox
- name: Run lint 💅
run: tox
env:
TOXENV: pre-commit
- name: Run mypy
run: tox
env:
TOXENV: mypy

26
.github/workflows/tests.yml vendored Normal file
View File

@ -0,0 +1,26 @@
name: Tests
on: [push, pull_request]
jobs:
build:
runs-on: ubuntu-latest
strategy:
max-parallel: 4
matrix:
python-version: ["2.7", "3.6", "3.7", "3.8", "3.9"]
steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install tox tox-gh-actions
- name: Test with tox
run: tox
env:
TOXENV: ${{ matrix.toxenv }}

View File

@ -18,11 +18,11 @@ repos:
hooks: hooks:
- id: pyupgrade - id: pyupgrade
- repo: https://github.com/ambv/black - repo: https://github.com/ambv/black
rev: 18.9b0 rev: 21.6b0
hooks: hooks:
- id: black - id: black
language_version: python3 language_version: python3
- repo: https://github.com/PyCQA/flake8 - repo: https://github.com/PyCQA/flake8
rev: 3.7.7 rev: 3.9.2
hooks: hooks:
- id: flake8 - id: flake8

View File

@ -54,10 +54,10 @@ for i, letter in enumerate(letter_chars):
def edges(selected_letters): def edges(selected_letters):
return [ return [
{ {
"node": {"id": base64("Letter:%s" % l.id), "letter": l.letter}, "node": {"id": base64("Letter:%s" % letter.id), "letter": letter.letter},
"cursor": base64("arrayconnection:%s" % l.id), "cursor": base64("arrayconnection:%s" % letter.id),
} }
for l in [letters[i] for i in selected_letters] for letter in [letters[i] for i in selected_letters]
] ]

View File

@ -135,7 +135,7 @@ class Mutation(ObjectType):
def Field( def Field(
cls, name=None, description=None, deprecation_reason=None, required=False cls, name=None, description=None, deprecation_reason=None, required=False
): ):
""" Mount instance of mutation Field. """ """Mount instance of mutation Field."""
return Field( return Field(
cls._meta.output, cls._meta.output,
args=cls._meta.arguments, args=cls._meta.arguments,

View File

@ -399,7 +399,7 @@ def test_big_list_of_containers_multiple_fields_query_benchmark(benchmark):
def test_big_list_of_containers_multiple_fields_custom_resolvers_query_benchmark( def test_big_list_of_containers_multiple_fields_custom_resolvers_query_benchmark(
benchmark benchmark,
): ):
class Container(ObjectType): class Container(ObjectType):
x = Int() x = Int()

View File

@ -49,6 +49,9 @@ tests_require = [
"pytest-benchmark", "pytest-benchmark",
"pytest-cov", "pytest-cov",
"pytest-mock", "pytest-mock",
# pinning fastdiff dep (required by snapshottest) because later versions
# require wasmer 1.0.0 which is not compatible with Python 2.7
"fastdiff==0.2.0",
"snapshottest", "snapshottest",
"coveralls", "coveralls",
"promise", "promise",

View File

@ -56,10 +56,10 @@ for i, letter in enumerate(letter_chars):
def edges(selected_letters): def edges(selected_letters):
return [ return [
{ {
"node": {"id": base64("Letter:%s" % l.id), "letter": l.letter}, "node": {"id": base64("Letter:%s" % letter.id), "letter": letter.letter},
"cursor": base64("arrayconnection:%s" % l.id), "cursor": base64("arrayconnection:%s" % letter.id),
} }
for l in [letters[i] for i in selected_letters] for letter in [letters[i] for i in selected_letters]
] ]

27
tox.ini
View File

@ -1,20 +1,27 @@
[tox] [tox]
envlist = flake8,py27,py34,py35,py36,py37,pre-commit,pypy,mypy envlist = py{27,36,37,38,39},flake8,pre-commit,mypy
skipsdist = true
[gh-actions]
python =
2.7: py27
3.6: py36
3.7: py37
3.8: py38
3.9: py39
[testenv] [testenv]
passenv = *
usedevelop = True
deps = deps =
.[test] -e.[test]
py{35,36,37}: pytest-asyncio py{36,37,38,39}: pytest-asyncio
setenv = setenv =
PYTHONPATH = .:{envdir} PYTHONPATH = .:{envdir}
commands = commands =
py{27,py}: py.test --cov=graphene graphene examples {posargs} py{27}: py.test --cov=graphene graphene examples {posargs}
py{35}: py.test --cov=graphene graphene examples tests_asyncio {posargs} py{36,37,38,39}: py.test --cov=graphene graphene examples tests_asyncio tests_py36 {posargs}
py{36,37}: py.test --cov=graphene graphene examples tests_asyncio tests_py36 {posargs}
[testenv:pre-commit] [testenv:pre-commit]
basepython=python3.7
deps = deps =
pre-commit>0.12.0 pre-commit>0.12.0
setenv = setenv =
@ -23,9 +30,9 @@ commands =
pre-commit {posargs:run --all-files} pre-commit {posargs:run --all-files}
[testenv:mypy] [testenv:mypy]
basepython=python3.7
deps = deps =
mypy mypy
types-six
commands = commands =
mypy graphene mypy graphene
@ -34,5 +41,3 @@ deps = flake8
commands = commands =
pip install -e . pip install -e .
flake8 graphene flake8 graphene
[pytest]