diff --git a/.gitea/workflows/ci.yml b/.gitea/workflows/ci.yml new file mode 100644 index 0000000..b4020a4 --- /dev/null +++ b/.gitea/workflows/ci.yml @@ -0,0 +1,40 @@ +name: CI + +on: + push: + branches: [main] + pull_request: + workflow_dispatch: + +jobs: + checks: + runs-on: docker + steps: + - name: Install Python and tools + run: | + apk add --no-cache python3 py3-pip git + python3 -m venv /opt/venv + echo "/opt/venv/bin" >> "$GITHUB_PATH" + + - name: Checkout + run: | + git init -q + git remote add origin "${GITHUB_SERVER_URL:-http://10.8.0.52:8080}/$GITHUB_REPOSITORY.git" + git fetch -q --depth 1 origin "$GITHUB_SHA" + git checkout -q FETCH_HEAD + + - name: Install dependencies + run: | + python -m pip install --upgrade pip + python -m pip install -e ".[dev]" + + - name: Lint (ruff) + run: | + ruff check --fix src tests + ruff check src tests + + - name: Typecheck (mypy) + run: mypy src + + - name: Tests (pytest + coverage) + run: python -m pytest -v --cov=selectel_ml_tui --cov-report=term-missing \ No newline at end of file diff --git a/src/selectel_ml_tui/cli.py b/src/selectel_ml_tui/cli.py index 186ea90..114faea 100644 --- a/src/selectel_ml_tui/cli.py +++ b/src/selectel_ml_tui/cli.py @@ -3,7 +3,6 @@ from __future__ import annotations from pathlib import Path -from typing import cast import click @@ -49,10 +48,12 @@ def _prompt_str( default_note: str = "(Enter — оставить)", ) -> str: prompt = f"{label} [{current or 'пусто'}] {default_note}: " - value = click.prompt(prompt, default="", hide_input=hide_input, show_default=False) + value: str = click.prompt( + prompt, default="", hide_input=hide_input, show_default=False + ) if value == "": return current - return cast(str, value) + return value @click.group() diff --git a/tests/test_storage.py b/tests/test_storage.py index 1b7ad21..0384f43 100644 --- a/tests/test_storage.py +++ b/tests/test_storage.py @@ -108,14 +108,15 @@ def test_save_and_get_latest_model_metrics(tmp_path) -> None: def test_history_upsert_same_day(tmp_path) -> None: storage = Storage(tmp_path / "cache.db") + timestamp = dt.datetime.now(dt.timezone.utc) - dt.timedelta(days=1) point = HistoryPoint( - timestamp=dt.datetime(2026, 8, 1, 12, 0), + timestamp=timestamp, amount_rub=Decimal("10.00"), tokens=TokenUsage(input_tokens=5), ) storage.save_history(point) point2 = HistoryPoint( - timestamp=dt.datetime(2026, 8, 1, 12, 0), + timestamp=timestamp, amount_rub=Decimal("15.00"), tokens=TokenUsage(input_tokens=8), ) @@ -151,7 +152,7 @@ def test_save_snapshot_combined(tmp_path) -> None: metrics=_metrics(), models=_models(), history_point=HistoryPoint( - timestamp=dt.datetime(2026, 8, 1, 12, 0), + timestamp=dt.datetime.now(dt.timezone.utc) - dt.timedelta(days=1), amount_rub=Decimal("854.83"), tokens=TokenUsage(input_tokens=100), ), @@ -225,7 +226,7 @@ def test_clear_removes_all_rows(tmp_path) -> None: storage = Storage(tmp_path / "cache.db") storage.save_history( HistoryPoint( - timestamp=dt.datetime(2026, 8, 18), + timestamp=dt.datetime.now(dt.timezone.utc) - dt.timedelta(days=1), amount_rub=Decimal("1"), tokens=TokenUsage(input_tokens=1), )