mirror of
https://github.com/kuhyx/screen-locker.git
synced 2026-11-29 18:53:20 +01:00
Compare commits
No commits in common. "50c32c4f4005e6210d8c088288d42f7d2bb278d2" and "ccc0e0993834b6acbfad1947c0afe583af5f4bf4" have entirely different histories.
50c32c4f40
...
ccc0e09938
@ -122,4 +122,3 @@ wait, and tests pin the retry to 0.
|
|||||||
- lint: `pre-commit run ruff --all-files`
|
- lint: `pre-commit run ruff --all-files`
|
||||||
- coverage: `python -m pytest -n auto -p no:sugar -q`
|
- coverage: `python -m pytest -n auto -p no:sugar -q`
|
||||||
- coverage-gaps: `coverage-gaps coverage.lcov`
|
- coverage-gaps: `coverage-gaps coverage.lcov`
|
||||||
- deploy: `git -C ~/src/screen-locker pull --ff-only && bash ~/src/screen-locker/scripts/deploy.sh` (reinstalls, restarts web/poke/runnerup units, health-checks them, then release-deploys the workout app; exit 46 from the phone guard means kuhy reruns it with `PHONE_PROTECT_ALLOW=com.kuhy.workout_app`)
|
|
||||||
|
|||||||
@ -12,7 +12,7 @@ dependencies = [
|
|||||||
"freedays @ git+https://github.com/kuhyx/utils@freedays-v0.4.0#subdirectory=freedays",
|
"freedays @ git+https://github.com/kuhyx/utils@freedays-v0.4.0#subdirectory=freedays",
|
||||||
"earned-time @ git+https://github.com/kuhyx/utils@earned-time-v0.21.0#subdirectory=earned_time",
|
"earned-time @ git+https://github.com/kuhyx/utils@earned-time-v0.21.0#subdirectory=earned_time",
|
||||||
"holds @ git+https://github.com/kuhyx/utils@holds-v0.1.0#subdirectory=holds",
|
"holds @ git+https://github.com/kuhyx/utils@holds-v0.1.0#subdirectory=holds",
|
||||||
"sickdays @ git+https://github.com/kuhyx/utils@sickdays-v0.5.0#subdirectory=sickdays",
|
"sickdays @ git+https://github.com/kuhyx/utils@sickdays-v0.4.0#subdirectory=sickdays",
|
||||||
]
|
]
|
||||||
|
|
||||||
[project.scripts]
|
[project.scripts]
|
||||||
|
|||||||
@ -22,7 +22,7 @@ pytest-xdist==3.8.0
|
|||||||
# module imports it itself, so it is declared rather than assumed.
|
# module imports it itself, so it is declared rather than assumed.
|
||||||
requests==2.34.2
|
requests==2.34.2
|
||||||
ruff==0.17.4
|
ruff==0.17.4
|
||||||
sickdays @ git+https://github.com/kuhyx/utils@sickdays-v0.5.0#subdirectory=sickdays
|
sickdays @ git+https://github.com/kuhyx/utils@sickdays-v0.4.0#subdirectory=sickdays
|
||||||
types-requests==2.33.0.20261030
|
types-requests==2.33.0.20261030
|
||||||
# Direct dependency since the Firebase session stream (_session_stream) catches
|
# Direct dependency since the Firebase session stream (_session_stream) catches
|
||||||
# urllib3's own errors on the long-lived SSE read; requests pulls it in, but
|
# urllib3's own errors on the long-lived SSE read; requests pulls it in, but
|
||||||
|
|||||||
@ -1,115 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
# Deploy screen-locker for real: update the live clone, reinstall, restart the
|
|
||||||
# long-running user units, prove they are healthy, then ship the workout app.
|
|
||||||
#
|
|
||||||
# Usage: bash scripts/deploy.sh [--health-only]
|
|
||||||
#
|
|
||||||
# Every path is anchored on the LIVE clone (~/src/screen-locker), never on this
|
|
||||||
# script's own directory: install.sh installs editable from wherever it sits,
|
|
||||||
# so running a worktree copy of it would point the services at scratch code.
|
|
||||||
#
|
|
||||||
# workout-locker.service is deliberately NOT restarted: it is the login-time
|
|
||||||
# gate and starting it can lock the display. Its timer is only re-enabled.
|
|
||||||
#
|
|
||||||
# Phone: phone_deploy.sh refuses com.kuhy.workout_app (exit 46) unless kuhy
|
|
||||||
# runs this himself with PHONE_PROTECT_ALLOW=com.kuhy.workout_app and the app
|
|
||||||
# closed. This script never sets that variable; it passes the caller's
|
|
||||||
# environment through and fails loudly when the guard refuses.
|
|
||||||
#
|
|
||||||
# Seams: SCREEN_LOCKER_LIVE (live clone), DEPLOY_WEB_PORT (health port).
|
|
||||||
# Exit: 0 healthy and installed everywhere | 1 any step or check failed.
|
|
||||||
|
|
||||||
set -euo pipefail
|
|
||||||
|
|
||||||
readonly LIVE="${SCREEN_LOCKER_LIVE:-$HOME/src/screen-locker}"
|
|
||||||
readonly PY="/usr/bin/python3"
|
|
||||||
readonly APP_DIR="stronglift_replacement/workout_app"
|
|
||||||
readonly PHONE_DEPLOY="$HOME/.claude/scripts/phone_deploy.sh"
|
|
||||||
readonly UNITS=(screen-locker-web.service workout-poke.service runnerup-watch.service)
|
|
||||||
|
|
||||||
die() { echo "deploy: FAIL: $*" >&2; exit 1; }
|
|
||||||
ok() { echo "deploy: ok: $*"; }
|
|
||||||
|
|
||||||
main_pid() { systemctl --user show -p MainPID --value "$1"; }
|
|
||||||
|
|
||||||
web_port() {
|
|
||||||
if [[ -n "${DEPLOY_WEB_PORT:-}" ]]; then
|
|
||||||
echo "$DEPLOY_WEB_PORT"
|
|
||||||
else
|
|
||||||
(cd /tmp && "$PY" -c 'from screen_locker._web_server import DEFAULT_PORT; print(DEFAULT_PORT)')
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
# /api/health answers and reports enforcement armed; retried while the
|
|
||||||
# freshly restarted server binds its port.
|
|
||||||
check_web() {
|
|
||||||
local port body i
|
|
||||||
port="$(web_port)"
|
|
||||||
for i in $(seq 1 15); do
|
|
||||||
if body="$(curl -fsS --max-time 2 "http://127.0.0.1:$port/api/health" 2>/dev/null)"; then
|
|
||||||
jq -e '.armed == true' >/dev/null <<<"$body" \
|
|
||||||
|| die "web health on :$port says enforcement is NOT armed"
|
|
||||||
ok "web /api/health on :$port armed (try $i)"
|
|
||||||
return 0
|
|
||||||
fi
|
|
||||||
sleep 1
|
|
||||||
done
|
|
||||||
die "web /api/health on :$port did not answer within 15 s"
|
|
||||||
}
|
|
||||||
|
|
||||||
health() {
|
|
||||||
local unit
|
|
||||||
for unit in "${UNITS[@]}"; do
|
|
||||||
systemctl --user is-active --quiet "$unit" || die "$unit is not active"
|
|
||||||
ok "$unit active"
|
|
||||||
done
|
|
||||||
check_web
|
|
||||||
"$PY" "$LIVE/scripts/check_enforcement_armed.py" --quiet \
|
|
||||||
|| die "check_enforcement_armed.py: enforcement is not armed"
|
|
||||||
ok "enforcement armed"
|
|
||||||
"$PY" "$LIVE/scripts/poke_selftest.py" sandbox >/dev/null \
|
|
||||||
|| die "workout-poke sandbox self-test failed"
|
|
||||||
ok "workout-poke signed sandbox round trip"
|
|
||||||
local mod
|
|
||||||
mod="$(cd /tmp && "$PY" -c 'import screen_locker; print(screen_locker.__file__)')"
|
|
||||||
[[ "$mod" == "$LIVE"/* ]] || die "screen_locker imports from $mod, not $LIVE"
|
|
||||||
ok "screen_locker imports from the live clone"
|
|
||||||
}
|
|
||||||
|
|
||||||
desktop() {
|
|
||||||
local unit
|
|
||||||
declare -A before=()
|
|
||||||
git -C "$LIVE" pull --ff-only || die "git pull --ff-only in $LIVE (dirty or diverged?)"
|
|
||||||
[[ "$(git -C "$LIVE" rev-parse HEAD)" == "$(git -C "$LIVE" rev-parse '@{u}')" ]] \
|
|
||||||
|| die "$LIVE HEAD is not its upstream after the pull"
|
|
||||||
ok "live clone at $(git -C "$LIVE" rev-parse --short HEAD)"
|
|
||||||
bash "$LIVE/install.sh" || die "install.sh failed"
|
|
||||||
for unit in "${UNITS[@]}"; do before[$unit]="$(main_pid "$unit")"; done
|
|
||||||
systemctl --user restart "${UNITS[@]}" || die "restart of ${UNITS[*]} failed"
|
|
||||||
for unit in "${UNITS[@]}"; do
|
|
||||||
[[ "$(main_pid "$unit")" != "${before[$unit]}" ]] \
|
|
||||||
|| die "$unit kept PID ${before[$unit]}: restart did not take"
|
|
||||||
done
|
|
||||||
ok "restarted ${UNITS[*]}"
|
|
||||||
}
|
|
||||||
|
|
||||||
phone() {
|
|
||||||
local rc=0
|
|
||||||
bash "$PHONE_DEPLOY" "$LIVE/$APP_DIR" --release || rc=$?
|
|
||||||
case "$rc" in
|
|
||||||
0) ok "workout app release build installed on the phone" ;;
|
|
||||||
46) die "phone_deploy protect guard (exit 46) refused com.kuhy.workout_app;" \
|
|
||||||
"kuhy runs: PHONE_PROTECT_ALLOW=com.kuhy.workout_app bash $LIVE/scripts/deploy.sh" \
|
|
||||||
"with the workout app closed" ;;
|
|
||||||
*) die "phone_deploy.sh exited $rc (see its exit-code table)" ;;
|
|
||||||
esac
|
|
||||||
}
|
|
||||||
|
|
||||||
if [[ "${1:-}" == "--health-only" ]]; then
|
|
||||||
health
|
|
||||||
exit 0
|
|
||||||
fi
|
|
||||||
desktop
|
|
||||||
health
|
|
||||||
phone
|
|
||||||
ok "deployed"
|
|
||||||
@ -1172,11 +1172,11 @@ packages:
|
|||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
path: sync_settings_ui
|
path: sync_settings_ui
|
||||||
ref: "sync_settings_ui-v0.7.0"
|
ref: "sync_settings_ui-v0.6.3"
|
||||||
resolved-ref: "3084080d744c348a217727e26a6be838e7d5a4ff"
|
resolved-ref: eef7af4c86837ee82891493587ff3456297e5dea
|
||||||
url: "https://github.com/kuhyx/utils"
|
url: "https://github.com/kuhyx/utils"
|
||||||
source: git
|
source: git
|
||||||
version: "0.7.0"
|
version: "0.6.3"
|
||||||
synchronized:
|
synchronized:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
|
|||||||
@ -63,7 +63,7 @@ dependencies:
|
|||||||
sync_settings_ui:
|
sync_settings_ui:
|
||||||
git:
|
git:
|
||||||
url: https://github.com/kuhyx/utils
|
url: https://github.com/kuhyx/utils
|
||||||
ref: sync_settings_ui-v0.7.0
|
ref: sync_settings_ui-v0.6.3
|
||||||
path: sync_settings_ui
|
path: sync_settings_ui
|
||||||
url_launcher: 6.3.3
|
url_launcher: 6.3.3
|
||||||
uuid: 4.6.0
|
uuid: 4.6.0
|
||||||
|
|||||||
@ -3,7 +3,6 @@ import 'package:flutter/material.dart';
|
|||||||
import 'package:flutter_test/flutter_test.dart';
|
import 'package:flutter_test/flutter_test.dart';
|
||||||
import 'package:http/http.dart' as http;
|
import 'package:http/http.dart' as http;
|
||||||
import 'package:sqflite_common_ffi/sqflite_ffi.dart';
|
import 'package:sqflite_common_ffi/sqflite_ffi.dart';
|
||||||
import 'package:sync_settings_ui/sync_settings_ui.dart';
|
|
||||||
import 'package:workout_app/models/exercise.dart';
|
import 'package:workout_app/models/exercise.dart';
|
||||||
import 'package:workout_app/models/workout_plan.dart';
|
import 'package:workout_app/models/workout_plan.dart';
|
||||||
import 'package:workout_app/screens/settings_screen.dart';
|
import 'package:workout_app/screens/settings_screen.dart';
|
||||||
@ -106,9 +105,9 @@ void main() {
|
|||||||
await tester.tap(iconLabeled('Sync settings'));
|
await tester.tap(iconLabeled('Sync settings'));
|
||||||
await tester.pumpAndSettle();
|
await tester.pumpAndSettle();
|
||||||
|
|
||||||
// The shared package's own screen (text-free since sync_settings_ui 0.7.0,
|
// The shared package's own screen -- its AppBar title, not this app's.
|
||||||
// so it is found by type, not by its old AppBar title).
|
expect(find.text('Sync settings'), findsOneWidget);
|
||||||
expect(find.byType(SyncSettingsScreen), findsOneWidget);
|
expect(find.text('Firebase sync'), findsWidgets);
|
||||||
});
|
});
|
||||||
|
|
||||||
testWidgets('opening Advanced sync (GitHub) pushes the app-local screen', (
|
testWidgets('opening Advanced sync (GitHub) pushes the app-local screen', (
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user