Fix issues found by CI on Gitea runner
- cli.py: remove redundant cast to str (mypy strict, click 8.5+ types prompt); annotate prompt result explicitly - test_storage.py: use now-relative timestamps instead of hardcoded 2026-08 dates so history-filter tests do not rot over time - add Gitea Actions CI workflow (.gitea/workflows/ci.yml)
This commit is contained in:
@@ -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
|
||||||
@@ -3,7 +3,6 @@
|
|||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from typing import cast
|
|
||||||
|
|
||||||
import click
|
import click
|
||||||
|
|
||||||
@@ -49,10 +48,12 @@ def _prompt_str(
|
|||||||
default_note: str = "(Enter — оставить)",
|
default_note: str = "(Enter — оставить)",
|
||||||
) -> str:
|
) -> str:
|
||||||
prompt = f"{label} [{current or 'пусто'}] {default_note}: "
|
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 == "":
|
if value == "":
|
||||||
return current
|
return current
|
||||||
return cast(str, value)
|
return value
|
||||||
|
|
||||||
|
|
||||||
@click.group()
|
@click.group()
|
||||||
|
|||||||
@@ -108,14 +108,15 @@ def test_save_and_get_latest_model_metrics(tmp_path) -> None:
|
|||||||
|
|
||||||
def test_history_upsert_same_day(tmp_path) -> None:
|
def test_history_upsert_same_day(tmp_path) -> None:
|
||||||
storage = Storage(tmp_path / "cache.db")
|
storage = Storage(tmp_path / "cache.db")
|
||||||
|
timestamp = dt.datetime.now(dt.timezone.utc) - dt.timedelta(days=1)
|
||||||
point = HistoryPoint(
|
point = HistoryPoint(
|
||||||
timestamp=dt.datetime(2026, 8, 1, 12, 0),
|
timestamp=timestamp,
|
||||||
amount_rub=Decimal("10.00"),
|
amount_rub=Decimal("10.00"),
|
||||||
tokens=TokenUsage(input_tokens=5),
|
tokens=TokenUsage(input_tokens=5),
|
||||||
)
|
)
|
||||||
storage.save_history(point)
|
storage.save_history(point)
|
||||||
point2 = HistoryPoint(
|
point2 = HistoryPoint(
|
||||||
timestamp=dt.datetime(2026, 8, 1, 12, 0),
|
timestamp=timestamp,
|
||||||
amount_rub=Decimal("15.00"),
|
amount_rub=Decimal("15.00"),
|
||||||
tokens=TokenUsage(input_tokens=8),
|
tokens=TokenUsage(input_tokens=8),
|
||||||
)
|
)
|
||||||
@@ -151,7 +152,7 @@ def test_save_snapshot_combined(tmp_path) -> None:
|
|||||||
metrics=_metrics(),
|
metrics=_metrics(),
|
||||||
models=_models(),
|
models=_models(),
|
||||||
history_point=HistoryPoint(
|
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"),
|
amount_rub=Decimal("854.83"),
|
||||||
tokens=TokenUsage(input_tokens=100),
|
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 = Storage(tmp_path / "cache.db")
|
||||||
storage.save_history(
|
storage.save_history(
|
||||||
HistoryPoint(
|
HistoryPoint(
|
||||||
timestamp=dt.datetime(2026, 8, 18),
|
timestamp=dt.datetime.now(dt.timezone.utc) - dt.timedelta(days=1),
|
||||||
amount_rub=Decimal("1"),
|
amount_rub=Decimal("1"),
|
||||||
tokens=TokenUsage(input_tokens=1),
|
tokens=TokenUsage(input_tokens=1),
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user