Skip to content

v0.7.0: Mobile UI refactor, improved project tools, bug fixes #22

v0.7.0: Mobile UI refactor, improved project tools, bug fixes

v0.7.0: Mobile UI refactor, improved project tools, bug fixes #22

Workflow file for this run

# ═══════════════════════════════════════════════════════════════
# Tofu (豆腐) — Continuous Integration
# ═══════════════════════════════════════════════════════════════
#
# Runs on every push to main and on all pull requests.
# Jobs: lint → test-unit → test-api → healthcheck
# Visual E2E tests run separately (optional, non-blocking).
#
# ═══════════════════════════════════════════════════════════════
name: CI
on:
push:
branches: [main]
pull_request:
branches: [main]
concurrency:
group: ci-${{ github.ref }}
cancel-in-progress: true
env:
TRADING_ENABLED: "0"
PYTHONDONTWRITEBYTECODE: "1"
jobs:
# ── Lint ─────────────────────────────────────────────────────
lint:
name: Lint (ruff)
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.12"
cache: pip
- name: Install ruff
run: pip install ruff
- name: Ruff check
run: ruff check lib/ routes/ tests/
# ── Unit Tests ───────────────────────────────────────────────
test-unit:
name: Unit Tests (Python ${{ matrix.python-version }})
runs-on: ubuntu-latest
needs: lint
timeout-minutes: 10
strategy:
matrix:
python-version: ["3.10", "3.12"]
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
cache: pip
- name: Install dependencies
run: |
pip install -r requirements.txt
pip install pytest pytest-cov
- name: Run unit tests with coverage
run: >
python -m pytest -m unit
--cov=lib --cov=routes
--cov-report=term-missing
--cov-report=xml:coverage.xml
--tb=short -q
- name: Upload coverage artifact
if: matrix.python-version == '3.12'
uses: actions/upload-artifact@v4
with:
name: coverage-report
path: coverage.xml
retention-days: 14
if-no-files-found: ignore
# ── API Integration Tests ───────────────────────────────────
test-api:
name: API Integration Tests
runs-on: ubuntu-latest
needs: lint
timeout-minutes: 15
services:
postgres:
image: postgres:17
env:
POSTGRES_USER: chatui
POSTGRES_PASSWORD: chatui
POSTGRES_DB: chatui
ports:
- 5432:5432
options: >-
--health-cmd "pg_isready -U chatui"
--health-interval 10s
--health-timeout 5s
--health-retries 5
env:
CHATUI_PG_HOST: localhost
CHATUI_PG_PORT: "5432"
CHATUI_PG_USER: chatui
CHATUI_PG_PASSWORD: chatui
CHATUI_PG_DBNAME: chatui
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.12"
cache: pip
- name: Install dependencies
run: |
pip install -r requirements.txt
pip install pytest pytest-cov
- name: Run API tests
run: >
python -m pytest -m api
--cov=lib --cov=routes
--cov-report=term-missing
--tb=short -q
# ── Healthcheck ─────────────────────────────────────────────
healthcheck:
name: Healthcheck
runs-on: ubuntu-latest
needs: lint
timeout-minutes: 10
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.12"
cache: pip
- name: Install dependencies
run: pip install -r requirements.txt
- name: Run healthcheck
run: python healthcheck.py
# ── Visual E2E Tests (optional, non-blocking) ───────────────
test-visual:
name: Visual E2E Tests
runs-on: ubuntu-latest
needs: [test-unit, test-api]
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
continue-on-error: true
timeout-minutes: 20
services:
postgres:
image: postgres:17
env:
POSTGRES_USER: chatui
POSTGRES_PASSWORD: chatui
POSTGRES_DB: chatui
ports:
- 5432:5432
options: >-
--health-cmd "pg_isready -U chatui"
--health-interval 10s
--health-timeout 5s
--health-retries 5
env:
CHATUI_PG_HOST: localhost
CHATUI_PG_PORT: "5432"
CHATUI_PG_USER: chatui
CHATUI_PG_PASSWORD: chatui
CHATUI_PG_DBNAME: chatui
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.12"
cache: pip
- name: Install dependencies
run: |
pip install -r requirements.txt
pip install pytest
playwright install --with-deps chromium
- name: Run visual tests
run: python -m pytest -m visual --tb=short -q
- name: Upload screenshots
if: always()
uses: actions/upload-artifact@v4
with:
name: screenshots
path: tests/screenshots/
retention-days: 7
if-no-files-found: ignore