Simplified workflows.
Signed-off-by: Pavel Kirilin <s3riussan@gmail.com>
This commit is contained in:
@@ -25,6 +25,7 @@ jobs:
|
|||||||
push: true
|
push: true
|
||||||
file: ./Dockerfile
|
file: ./Dockerfile
|
||||||
platforms: linux/amd64
|
platforms: linux/amd64
|
||||||
|
target: prod
|
||||||
tags: |
|
tags: |
|
||||||
gitea.le-memese.com/s3rius/zangramru:latest
|
gitea.le-memese.com/s3rius/zangramru:latest
|
||||||
gitea.le-memese.com/s3rius/zangramru:${{ gitea.ref_name }}
|
gitea.le-memese.com/s3rius/zangramru:${{ gitea.ref_name }}
|
||||||
|
|||||||
@@ -4,12 +4,6 @@ on: push
|
|||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
lint:
|
lint:
|
||||||
strategy:
|
|
||||||
matrix:
|
|
||||||
cmd:
|
|
||||||
- ruff-format
|
|
||||||
- ruff
|
|
||||||
- mypy
|
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
@@ -22,13 +16,11 @@ jobs:
|
|||||||
- name: Install deps
|
- name: Install deps
|
||||||
run: uv sync
|
run: uv sync
|
||||||
- name: Run lint check
|
- name: Run lint check
|
||||||
run: uv run pre-commit run -a ${{ matrix.cmd }}
|
run: uv run pre-commit run -a
|
||||||
pytest:
|
pytest:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
- name: Create .env
|
|
||||||
run: touch .env
|
|
||||||
- name: Set up Python
|
- name: Set up Python
|
||||||
uses: actions/setup-python@v6
|
uses: actions/setup-python@v6
|
||||||
with:
|
with:
|
||||||
|
|||||||
@@ -31,3 +31,11 @@ RUN --mount=from=uv,source=/usr/local/bin/uv,target=/bin/uv \
|
|||||||
uv sync --locked --no-dev
|
uv sync --locked --no-dev
|
||||||
|
|
||||||
CMD ["/usr/local/bin/python", "-m", "zangramru"]
|
CMD ["/usr/local/bin/python", "-m", "zangramru"]
|
||||||
|
|
||||||
|
FROM prod AS dev
|
||||||
|
|
||||||
|
RUN --mount=from=uv,source=/usr/local/bin/uv,target=/bin/uv \
|
||||||
|
--mount=type=cache,target=/root/.cache/uv \
|
||||||
|
uv sync --locked --all-groups
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+4
-2
@@ -10,6 +10,7 @@ from piccolo.table import create_tables, drop_tables
|
|||||||
|
|
||||||
from zangramru.settings import settings
|
from zangramru.settings import settings
|
||||||
from zangramru.web.application import get_app
|
from zangramru.web.application import get_app
|
||||||
|
from zangramru.web.lifespan import lifespan_setup
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture(scope="session")
|
@pytest.fixture(scope="session")
|
||||||
@@ -73,14 +74,15 @@ async def setup_db() -> AsyncGenerator[None, None]:
|
|||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def fastapi_app() -> FastAPI:
|
async def fastapi_app() -> AsyncGenerator[FastAPI, None]:
|
||||||
"""
|
"""
|
||||||
Fixture for creating FastAPI app.
|
Fixture for creating FastAPI app.
|
||||||
|
|
||||||
:return: fastapi app with mocked dependencies.
|
:return: fastapi app with mocked dependencies.
|
||||||
"""
|
"""
|
||||||
application = get_app()
|
application = get_app()
|
||||||
return application # noqa: RET504
|
async with lifespan_setup(application):
|
||||||
|
yield application
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
|
|||||||
@@ -1,19 +0,0 @@
|
|||||||
import uuid
|
|
||||||
|
|
||||||
from fastapi import FastAPI
|
|
||||||
from httpx import AsyncClient
|
|
||||||
from starlette import status
|
|
||||||
|
|
||||||
|
|
||||||
async def test_echo(fastapi_app: FastAPI, client: AsyncClient) -> None:
|
|
||||||
"""
|
|
||||||
Tests that echo route works.
|
|
||||||
|
|
||||||
:param fastapi_app: current application.
|
|
||||||
:param client: client for the app.
|
|
||||||
"""
|
|
||||||
url = fastapi_app.url_path_for("send_echo_message")
|
|
||||||
message = uuid.uuid4().hex
|
|
||||||
response = await client.post(url, json={"message": message})
|
|
||||||
assert response.status_code == status.HTTP_200_OK
|
|
||||||
assert response.json()["message"] == message
|
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
from fastapi import FastAPI
|
||||||
|
from httpx import AsyncClient
|
||||||
|
from starlette import status
|
||||||
|
|
||||||
|
from zangramru.web.api.puzzles.schema import PuzzleOutputDTO
|
||||||
|
|
||||||
|
|
||||||
|
async def test_get_random_puzzle(fastapi_app: FastAPI, client: AsyncClient) -> None:
|
||||||
|
"""
|
||||||
|
Tests that echo route works.
|
||||||
|
|
||||||
|
:param fastapi_app: current application.
|
||||||
|
:param client: client for the app.
|
||||||
|
"""
|
||||||
|
url = fastapi_app.url_path_for("random_puzzle")
|
||||||
|
response = await client.get(url)
|
||||||
|
assert response.status_code == status.HTTP_200_OK
|
||||||
|
dto = PuzzleOutputDTO.model_validate(response.json())
|
||||||
|
assert sum(len(row) for row in dto.board) == 16
|
||||||
|
assert len(dto.solutions) >= 10
|
||||||
Reference in New Issue
Block a user