Skip to content

Commit

Permalink
chore: Fix issues on CI
Browse files Browse the repository at this point in the history
Signed-off-by: André Carvalho <[email protected]>
  • Loading branch information
RedRoserade committed Jul 17, 2022
1 parent 9b2768c commit 3fa5c9b
Show file tree
Hide file tree
Showing 6 changed files with 54 additions and 29 deletions.
23 changes: 13 additions & 10 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,15 @@ jobs:
python-version: ["3.8", "3.9", "3.10"]
steps:
- uses: actions/checkout@v3

- name: Install poetry
run: pip install poetry

- uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
cache: "pip"
cache-dependency-path: "poetry.lock"

- name: Install poetry
run: pip install poetry

- name: Install dependencies
run: poetry install

Expand All @@ -39,19 +38,23 @@ jobs:
run: make docker-up

- name: Test
run: make test
# Wait for RabbitMQ to start.
run: sleep 10 && make test

test-build-docs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Install poetry
run: pip install poetry
- uses: actions/setup-python@v3
- uses: actions/setup-python@v4
with:
python-version: 3.x
python-version: "3.10"
cache: "pip"
cache-dependency-path: "poetry.lock"

- name: Install poetry
run: pip install poetry

- name: Install dependencies
run: poetry install
- run: mkdocs build --verbose --clean --strict

- run: poetry run mkdocs build --verbose --clean --strict
16 changes: 9 additions & 7 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,24 @@ on:
env:
POETRY_VIRTUALENVS_CREATE: false


jobs:
deploy:
permissions:
contents: write
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Install poetry
run: pip install poetry
- uses: actions/setup-python@v3
with:
python-version: 3.x
cache: 'pip'
cache-dependency-path: 'poetry.lock'
python-version: "3.10"
cache: "pip"
cache-dependency-path: "poetry.lock"

- name: Install poetry
run: pip install poetry

- name: Install dependencies
run: poetry install

- name: Build and push docs
run: mkdocs gh-deploy --force
run: poetry run mkdocs gh-deploy --force
11 changes: 7 additions & 4 deletions mognet/backend/redis_result_backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import gzip
import json
import logging
import sys
from asyncio import shield
from datetime import timedelta
from typing import (
Expand All @@ -30,7 +31,6 @@
from pydantic.tools import parse_raw_as
from redis.asyncio import from_url
from redis.exceptions import ConnectionError, TimeoutError
from typing_extensions import TypeAlias

from mognet.backend.backend_config import Encoding, ResultBackendConfig
from mognet.backend.base_result_backend import AppParameters, BaseResultBackend
Expand All @@ -40,15 +40,18 @@
from mognet.model.result_state import READY_STATES, ResultState
from mognet.tools.urls import censor_credentials

if sys.version_info < (3, 10):
from typing_extensions import TypeAlias
else:
from typing import TypeAlias

if TYPE_CHECKING:
from redis.asyncio import Redis # noqa: F401

_log = logging.getLogger(__name__)


_EncodedHSetPayload: TypeAlias = Mapping[
Union[str, bytes], Union[bytes, float, int, str]
]
_EncodedHSetPayload = Mapping[Union[str, bytes], Union[bytes, float, int, str]]

_F = TypeVar("_F", bound=Callable[..., Awaitable[Any]])
_Redis: TypeAlias = "Redis[Any]"
Expand Down
18 changes: 15 additions & 3 deletions mognet/primitives/request.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,26 @@
from datetime import datetime, timedelta
from typing import Any, Dict, Generic, List, Optional, Tuple, TypeVar, Union
from typing import (
TYPE_CHECKING,
Any,
Dict,
Generic,
List,
Optional,
Tuple,
TypeVar,
Union,
)
from uuid import UUID, uuid4

from pydantic import BaseModel, conint
from pydantic.fields import Field
from typing_extensions import TypeAlias

TReturn = TypeVar("TReturn")

Priority: TypeAlias = conint(ge=0, le=10) # type: ignore
if TYPE_CHECKING:
Priority = int
else:
Priority = conint(ge=0, le=10)


class Request(BaseModel, Generic[TReturn]):
Expand Down
8 changes: 7 additions & 1 deletion mognet/state/redis_state_backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,23 @@

import json
import logging
import sys
from typing import TYPE_CHECKING, Any, Optional, TypeVar, cast
from uuid import UUID

from redis.asyncio import from_url
from typing_extensions import TypeAlias

from mognet.exceptions.base_exceptions import NotConnected
from mognet.state.base_state_backend import BaseStateBackend
from mognet.state.state_backend_config import StateBackendConfig
from mognet.tools.urls import censor_credentials

if sys.version_info < (3, 10):
from typing_extensions import TypeAlias
else:
from typing import TypeAlias


if TYPE_CHECKING:
from redis.asyncio import Redis # noqa: F401

Expand Down
7 changes: 3 additions & 4 deletions mognet/testing/pytest_integration.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
import asyncio
from typing import AsyncIterable, Callable
from typing import Any, AsyncIterable

import pytest_asyncio

from mognet import App


def create_app_fixture(app: App) -> Callable[[], App]:
def create_app_fixture(app: App) -> Any:
"""Create a Pytest fixture for a Mognet application."""

@pytest_asyncio.fixture # type: ignore
async def app_fixture() -> AsyncIterable[App]:
async with app:
start_task = asyncio.create_task(app.start())
Expand All @@ -22,4 +21,4 @@ async def app_fixture() -> AsyncIterable[App]:
except BaseException: # pylint: disable=broad-except
pass

return app_fixture # type: ignore
return pytest_asyncio.fixture(app_fixture)

0 comments on commit 3fa5c9b

Please sign in to comment.