Skip to content

Commit

Permalink
Merge pull request #55 from kindermax/use-gh-actions
Browse files Browse the repository at this point in the history
use gh actions
  • Loading branch information
kindermax committed Jul 23, 2021
2 parents fb8e313 + 7b14c56 commit 13e9eb5
Show file tree
Hide file tree
Showing 8 changed files with 49 additions and 63 deletions.
25 changes: 25 additions & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: Test
on:
- push
- pull_request
jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [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 tox tox-gh-actions codecov
python -m pip install -r requirements-tox.txt
- name: Run flake8
if: startsWith(matrix.python-version, '3.9')
run: tox -e flake8
- name: Run unit tests
run: tox -- --cov
14 changes: 0 additions & 14 deletions .travis.yml

This file was deleted.

25 changes: 5 additions & 20 deletions examples/graphql_federation.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
import logging

from typing import (
TypedDict,
)

from flask import Flask, request, jsonify

from hiku.federation.directive import (
Expand Down Expand Up @@ -33,17 +29,6 @@
log = logging.getLogger(__name__)


class Cart(TypedDict):
id: int
status: str


class CartItem(TypedDict):
id: int
cart_id: int
name: str


def get_by_id(id_, collection):
for item in collection:
if item['id'] == id_:
Expand All @@ -58,13 +43,13 @@ def find_all_by_id(id_, collection, key='id'):

data = {
'carts': [
Cart(id=1, status='NEW'),
Cart(id=2, status='ORDERED'),
dict(id=1, status='NEW'),
dict(id=2, status='ORDERED'),
],
'cart_items': [
CartItem(id=10, cart_id=1, name='Ipad'),
CartItem(id=20, cart_id=2, name='Book'),
CartItem(id=21, cart_id=2, name='Pen'),
dict(id=10, cart_id=1, name='Ipad'),
dict(id=20, cart_id=2, name='Book'),
dict(id=21, cart_id=2, name='Pen'),
]
}

Expand Down
3 changes: 2 additions & 1 deletion hiku/graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,8 @@ def func(fields, ids) -> List[List[T]]
- ``ids`` - list node identifiers
"""
def __init__(self, name, type_, func, *, options=None, description=None, directives=None):
def __init__(self, name, type_, func, *, options=None, description=None,
directives=None):
"""
:param str name: name of the field
:param type_: type of the field or ``None``
Expand Down
7 changes: 2 additions & 5 deletions hiku/introspection/graphql.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import re
import json
import typing as t
from dataclasses import dataclass

from functools import partial
from collections import OrderedDict
Expand Down Expand Up @@ -35,10 +34,8 @@
)


@dataclass
class Directive:
@dataclass
class Argument:
class Directive(t.NamedTuple):
class Argument(t.NamedTuple):
name: str
type_ident: t.Any
description: str
Expand Down
1 change: 1 addition & 0 deletions tests/test_federation/test_introspection_graphql.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ def _union(name, possible_types=None):
'possibleTypes': possible_types
}


def _seq_of(_type):
return {'kind': 'NON_NULL', 'name': None,
'ofType': {'kind': 'LIST', 'name': None,
Expand Down
23 changes: 5 additions & 18 deletions tests/test_federation/utils.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from typing import TypedDict

from hiku.federation.directive import (
External,
Key,
Expand All @@ -23,17 +21,6 @@
)


class Cart(TypedDict):
id: int
status: str


class CartItem(TypedDict):
id: int
cart_id: int
name: str


def get_by_id(id_, collection):
for item in collection:
if item['id'] == id_:
Expand All @@ -48,13 +35,13 @@ def find_all_by_id(id_, collection, key='id'):

data = {
'carts': [
Cart(id=1, status='NEW'),
Cart(id=2, status='ORDERED'),
dict(id=1, status='NEW'),
dict(id=2, status='ORDERED'),
],
'cart_items': [
CartItem(id=10, cart_id=1, name='Ipad'),
CartItem(id=20, cart_id=2, name='Book'),
CartItem(id=21, cart_id=2, name='Pen'),
dict(id=10, cart_id=1, name='Ipad'),
dict(id=20, cart_id=2, name='Book'),
dict(id=21, cart_id=2, name='Pen'),
]
}

Expand Down
14 changes: 9 additions & 5 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
[tox]
envlist = py35,py36,py37,pypy3,py37-flake8,py38
envlist = py35,py36,py37,pypy3,py38,py39

[testenv]
commands = py.test tests {posargs}
deps = -r requirements-tox.txt

[testenv:py37-flake8]
[testenv:flake8]
commands = flake8
deps = flake8

[flake8]
max-line-length = 80
exclude = *_pb2.py,.tox,.git,env,docs
exclude = *_pb2.py,.tox,.git,env,docs,.venv

[pytest]
addopts = -q --tb=native
Expand All @@ -24,9 +24,13 @@ filterwarnings =
ignore::DeprecationWarning:google.*
ignore::DeprecationWarning:sqlalchemy.*

[travis]
[gh-actions]
python =
3.7: py37,py37-flake8
3.5: py35
3.6: py36
3.7: py37
3.8: py38
3.9: py39

[coverage:run]
branch = True
Expand Down

0 comments on commit 13e9eb5

Please sign in to comment.