diff --git a/.gitea/workflows/ci.yml b/.gitea/workflows/ci.yml index c470ee1..5df5f7f 100644 --- a/.gitea/workflows/ci.yml +++ b/.gitea/workflows/ci.yml @@ -23,7 +23,8 @@ jobs: - run: python -m pip install -r requirements.txt - run: python -m pytest -q - run: node --check app/static/admin.js - - run: sh -n infra/postgres-backup.sh infra/install-postgres-backup-cron.sh + - run: sh -n infra/postgres-backup.sh + - run: sh -n infra/install-postgres-backup-cron.sh deploy: if: (github.event_name == 'push' && github.ref == 'refs/heads/main') || github.event_name == 'workflow_dispatch' diff --git a/CHANGELOG.md b/CHANGELOG.md index 7a3d138..7e5c2e2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,9 +1,10 @@ # Changelog -## 0.8.13 +## 0.8.14 - Production CD больше не создаёт backup при каждом deploy; еженедельная задача - сохраняет один полный PostgreSQL backup с атомарной заменой. + сохраняет один полный PostgreSQL backup с атомарной заменой; ошибки и + пропущенные из-за lock запуски пишутся в system log. ## 0.8.12 diff --git a/README.md b/README.md index 86007a8..297b5ef 100644 --- a/README.md +++ b/README.md @@ -135,4 +135,4 @@ node --check app/static/admin.js Тесты с данными используют временную SQLite; отдельные API smoke-тесты запускают приложение с его текущей конфигурацией. Браузерная проверка: `pip install playwright`, `python -m playwright install chromium`, затем `python tests/browser_admin.py`. Она проверяет реальный рендеринг страниц, клавиатуру, диалог, фильтры и восстановление прогресса после ошибки. Скриншоты сохраняются во временную папку; путь выводится в конце. -Версия сервиса: `0.8.13`. Админка всегда показывает версии backend и frontend в footer. +Версия сервиса: `0.8.14`. Админка всегда показывает версии backend и frontend в footer. diff --git a/app/version.py b/app/version.py index 7a95865..4eff412 100644 --- a/app/version.py +++ b/app/version.py @@ -1,3 +1,3 @@ -APP_VERSION = "0.8.13" -FRONTEND_VERSION = "0.8.13" -BACKEND_VERSION = "0.8.13" +APP_VERSION = "0.8.14" +FRONTEND_VERSION = "0.8.14" +BACKEND_VERSION = "0.8.14" diff --git a/infra/install-postgres-backup-cron.sh b/infra/install-postgres-backup-cron.sh index 38d032e..6b2c003 100644 --- a/infra/install-postgres-backup-cron.sh +++ b/infra/install-postgres-backup-cron.sh @@ -6,5 +6,5 @@ app_dir=$(CDPATH= cd -- "$(dirname "$0")/.." && pwd) trap 'rm -f -- "$temporary"' EXIT HUP INT TERM crontab -l 2>/dev/null | grep -v 'postgres-backup.sh' > "$temporary" || true -printf '%s\n' "30 3 * * 0 flock -n /tmp/miem-postgres-backup.lock $app_dir/infra/postgres-backup.sh >/dev/null 2>&1" >> "$temporary" +printf '%s\n' "30 3 * * 0 flock -w 3600 /tmp/miem-postgres-backup.lock $app_dir/infra/postgres-backup.sh || logger -t miem-postgres-backup -- 'backup skipped or failed'" >> "$temporary" crontab "$temporary" diff --git a/infra/postgres-backup.sh b/infra/postgres-backup.sh index 7779aea..6ca034d 100644 --- a/infra/postgres-backup.sh +++ b/infra/postgres-backup.sh @@ -7,12 +7,14 @@ backup_dir="$HOME/backups/postgres" backup="$backup_dir/postgres-latest.sql" temporary="$backup.tmp.$$" +log() { logger -t miem-postgres-backup -- "$*" 2>/dev/null || true; } + mkdir -p "$backup_dir" -trap 'rm -f -- "$temporary"' EXIT HUP INT TERM +trap 'status=$?; rm -f -- "$temporary"; [ "$status" -eq 0 ] || log "backup failed"; exit "$status"' EXIT HUP INT TERM cd "$app_dir" docker compose exec -T postgres sh -c 'pg_dumpall -U "$POSTGRES_USER"' > "$temporary" test -s "$temporary" mv "$temporary" "$backup" find "$HOME/backups/miem_workers" -maxdepth 1 -type f -name 'miem_workers-*.sql' -delete 2>/dev/null || true -printf '%s\n' "Created $backup" +log "created $backup" diff --git a/pyproject.toml b/pyproject.toml index 5098e39..c6dbdbc 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "miem-workers" -version = "0.8.13" +version = "0.8.14" description = "MIEM employees parser, admin API, and web admin" requires-python = ">=3.11" dependencies = [ diff --git a/tests/test_api.py b/tests/test_api.py index 3579175..5ed3888 100644 --- a/tests/test_api.py +++ b/tests/test_api.py @@ -18,7 +18,7 @@ def test_health_returns_versions(): response = TestClient(app).get("/api/health") assert response.status_code == 200 - assert response.json()["backend_version"] == "0.8.13" + assert response.json()["backend_version"] == "0.8.14" def test_api_employees_and_stats_require_admin_session():