Files
mtusi2026lab2/student-tests/lab2/ci.application.example.yml
T
OlegRood 834876c938 ЛР 2: закрыть уровень 4
Завершить PostgreSQL, Redis-сессии, миграции, таймауты и диагностику. Зафиксировать собственные тесты и доказательства финального прогона: 43 PASS, 0 FAIL, 0 SKIP; 768 HTTP-запросов без ошибок. Добавить официальный отчёт с запуском, архитектурой, SQL-планами и ограничениями. PR отложен до завершения уровня 5.
2026-10-28 13:30:26 +03:00

63 lines
2.6 KiB
YAML

# Example only. This is NOT installed into .github/workflows by the test task.
# PostgreSQL acceptance job; add the chosen cache service/adapters for grade 4/5.
name: Lab2 application example
on: [push, pull_request]
permissions:
contents: read
jobs:
postgres-acceptance:
runs-on: ubuntu-latest
services:
postgres:
image: postgres:18
env:
POSTGRES_USER: lab2_ci
POSTGRES_DB: lab2_ci
# Public synthetic fixture credential for this disposable CI service.
POSTGRES_PASSWORD: ci-fixture-only
ports: ["5432:5432"]
options: >-
--health-cmd="pg_isready -U lab2_ci -d lab2_ci"
--health-interval=5s --health-timeout=3s --health-retries=10
env:
AUTH_TEST_DATABASE_URL: postgres://lab2_ci:ci-fixture-only@127.0.0.1:5432/lab2_ci?sslmode=disable
MIGRATE_TEST_DATABASE_URL: postgres://lab2_ci:ci-fixture-only@127.0.0.1:5432/lab2_ci?sslmode=disable
LAB2_TEST_DATABASE_URL: postgres://lab2_ci:ci-fixture-only@127.0.0.1:5432/lab2_ci?sslmode=disable
LAB2_BASE_URL: http://127.0.0.1:8080
APP_HOST: 0.0.0.0
APP_PORT: "8080"
SESSION_TTL_SECONDS: "3600"
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: "1.27.1"
- uses: actions/setup-python@v5
with:
python-version: "3.12"
- run: python -m pip install -r requirements-dev.txt
- run: make check validate PYTHON=python
- run: python -m unittest discover -s student-tests/lab2 -p test_harness.py -v
- run: go test -race ./... -count=1
- name: Build, migrate, run actual HTTP checks
shell: bash
run: |
set -euo pipefail
go build -o "$RUNNER_TEMP/lab2-api" ./cmd/api
go build -o "$RUNNER_TEMP/lab2-migrate" ./cmd/migrate
export DATABASE_URL_FILE="$RUNNER_TEMP/lab2-database-url"
umask 077
printf '%s' "$LAB2_TEST_DATABASE_URL" > "$DATABASE_URL_FILE"
"$RUNNER_TEMP/lab2-migrate"
"$RUNNER_TEMP/lab2-api" > "$RUNNER_TEMP/lab2-api.log" 2>&1 &
api_pid=$!
trap 'kill "$api_pid" 2>/dev/null || true' EXIT
ready=0
for attempt in {1..60}; do
if curl -fsS "$LAB2_BASE_URL/health/ready" >/dev/null; then ready=1; break; fi
sleep 0.5
done
test "$ready" -eq 1
make test BASE_URL="$LAB2_BASE_URL"
python student-tests/lab2/run.py --suite auth --suite business-boundaries --suite business-cursors --suite read-after-write --suite sql-plan --output student-tests/lab2/output/ci.json