Kansho/.gitea/workflows/test.yml
Lars 9d79e3e92f
Some checks failed
Deploy Development / deploy (push) Successful in 51s
Test Suite / pytest-backend (push) Failing after 2m32s
Test Suite / smoke-dev (push) Successful in 0s
Test Suite / frontend-build (push) Successful in 15s
Run backend tests with pytest after Dev deploy.
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-09-07 14:47:04 +02:00

87 lines
3.4 KiB
YAML

name: Test Suite
on:
push:
branches: [develop]
workflow_run:
workflows: ["Deploy Development"]
types: [completed]
workflow_dispatch:
jobs:
pytest-backend:
if: ${{ github.event_name != 'workflow_run' || github.event.workflow_run.conclusion == 'success' }}
runs-on: ubuntu-latest
steps:
- name: pytest against Dev Postgres (kansho_test)
run: |
set -e
APP_DIR="/home/lars/docker/kansho-dev"
COMPOSE_FILE="docker-compose.dev-env.yml"
echo "pytest uses Dev Postgres (${APP_DIR}); event=${{ github.event_name }}"
cd "$APP_DIR"
for i in $(seq 1 60); do
if [ -f "$APP_DIR/backend/pytest.ini" ] && docker compose -f "$COMPOSE_FILE" exec -T backend true 2>/dev/null; then
echo "backend and pytest.ini ready (attempt $i)"
break
fi
if [ "$i" -eq 60 ]; then
echo "timeout waiting for Dev checkout/backend"
docker compose -f "$COMPOSE_FILE" ps || true
ls -la "$APP_DIR/backend" || true
exit 1
fi
sleep 5
done
PGUSER="$(docker compose -f "$COMPOSE_FILE" exec -T postgres printenv POSTGRES_USER | tr -d '\r')"
echo "test database kansho_test on the existing Dev Postgres (owner ${PGUSER})"
docker compose -f "$COMPOSE_FILE" exec -T postgres \
psql -U "$PGUSER" -d postgres -v ON_ERROR_STOP=1 \
-c "SELECT pg_terminate_backend(pid) FROM pg_stat_activity WHERE datname = 'kansho_test' AND pid <> pg_backend_pid();"
docker compose -f "$COMPOSE_FILE" exec -T postgres \
psql -U "$PGUSER" -d postgres -v ON_ERROR_STOP=1 \
-c "DROP DATABASE IF EXISTS kansho_test;"
docker compose -f "$COMPOSE_FILE" exec -T postgres \
psql -U "$PGUSER" -d postgres -v ON_ERROR_STOP=1 \
-c "CREATE DATABASE kansho_test OWNER ${PGUSER};"
docker compose -f "$COMPOSE_FILE" run --rm --no-deps \
-v "${APP_DIR}:/src:ro" \
-w /src/backend \
-e KANSHO_DB_BACKEND=postgres \
-e DB_NAME=kansho_test \
-e KANSHO_PROVIDER_KEY= \
-e KANSHO_DETECT_PROVIDER_KEY= \
-e PYTHONUTF8=1 \
backend sh -lc '
set -e
unset KANSHO_DB_PATH
pip install -q -r requirements-dev.txt
python -m pytest tests -m "not slow" -ra -vv --tb=short
'
smoke-dev:
if: ${{ github.event_name != 'workflow_run' || github.event.workflow_run.conclusion == 'success' }}
runs-on: ubuntu-latest
steps:
- name: Non-destructive smoke against the running Dev app
run: |
set -e
echo "live Dev API (kansho_dev), read-only health"
curl -sf http://localhost:8096/api/health
echo
curl -sf http://localhost:3096/api/health
echo
echo "LAN smoke OK. Public URL after TLS: https://dev.kansho.jinkendo.de"
frontend-build:
if: ${{ github.event_name != 'workflow_run' || github.event.workflow_run.conclusion == 'success' }}
runs-on: ubuntu-latest
steps:
- name: Frontend production build on Dev checkout
run: |
set -e
APP_DIR="/home/lars/docker/kansho-dev"
cd "$APP_DIR/frontend"
npm ci
npm run build