Compare commits

..

5 Commits

Author SHA1 Message Date
26853a9dfe Skip phone deploy when the app is unchanged
Some checks are pending
md-naming / markdown naming convention (push) Waiting to run
pre-commit / pre-commit (${{ matrix.group }}) (flutter, flutter-analyze, ) (push) Waiting to run
pre-commit / pre-commit (${{ matrix.group }}) (mypy, mypy, ) (push) Waiting to run
pre-commit / pre-commit (${{ matrix.group }}) (pylint, pylint, ) (push) Waiting to run
pre-commit / pre-commit (${{ matrix.group }}) (rest, , mypy,pylint,flutter-analyze,dependency-freshness) (push) Waiting to run
Tests / test (push) Waiting to run
Tests / lock-popup-safety (push) Waiting to run
Tests / flutter test (shard ${{ matrix.shard }}) (0) (push) Waiting to run
Tests / flutter test (shard ${{ matrix.shard }}) (1) (push) Waiting to run
Tests / flutter test (shard ${{ matrix.shard }}) (2) (push) Waiting to run
Tests / flutter test (shard ${{ matrix.shard }}) (3) (push) Waiting to run
Tests / flutter test (shard ${{ matrix.shard }}) (4) (push) Waiting to run
Tests / flutter test (shard ${{ matrix.shard }}) (5) (push) Waiting to run
Tests / flutter test (shard ${{ matrix.shard }}) (6) (push) Waiting to run
Tests / flutter test (shard ${{ matrix.shard }}) (7) (push) Waiting to run
Tests / flutter test (shard ${{ matrix.shard }}) (8) (push) Waiting to run
Tests / flutter test (shard ${{ matrix.shard }}) (9) (push) Waiting to run
Tests / flutter-coverage (push) Blocked by required conditions
Tests / web-coverage (push) Waiting to run
repo-contract / repo contract (push) Waiting to run
deploy.sh records the workout app's git tree after each phone install
and skips the phone when the tree is the same, so a PC-only change
deploys with the phone unplugged. No record means the phone is needed.

Todo: 2556952d
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-19 21:25:51 +01:00
84e8f7fff5 Drop freshness-only deps from CI pre-commit
pyyaml and packaging were installed only for dependency-freshness,
which CI no longer runs.

Todo: 2556952d
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-19 21:10:46 +01:00
9c4f8e32cf Bump sickdays to 0.5.6
Todo: 2556952d
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-19 21:05:11 +01:00
edde541f91 Cap CI mirror pytest at 4 xdist workers
-n auto (16 workers) peaked at 3.2 GiB and the kernel OOM-killed the
ci-pytest gate step in capped.sh's 4 GiB slice. 4 workers fit in 2 GiB
and finish in 19 s instead of 58 s under the CPU cap.

Todo: 2556952d
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-19 21:05:02 +01:00
62fa631b6b get rid of github ci/cd version check of package…
Todo: 2556952d
2026-11-19 20:46:45 +01:00
11 changed files with 162 additions and 85 deletions

View File

@ -1,62 +0,0 @@
name: dependency freshness
# Every dependency on its ecosystem's newest STABLE release, enforced on push
# as well as at commit time. The local pre-commit hook only sees the manifests
# in a commit and can be skipped entirely by a fresh clone that never ran
# `pre-commit install`; this runs `--all` over the whole repo.
#
# `--strict` is CI-only. Offline the gate degrades to its cached answer and
# passes, because `--no-verify` is banned locally and a hook that hard-failed
# on a flaky connection would leave no way to commit. A runner is always
# online, so here an undeterminable answer is a real failure.
#
# Expect this to go red for reasons this repo's commit did not cause: an
# upstream release overnight is enough. That is the chosen behaviour -- the
# alternative is a gate that only notices staleness when someone remembers to
# look.
on:
push:
branches: [main]
pull_request:
workflow_dispatch:
jobs:
dependency-freshness:
name: dependencies on newest stable
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
# The gate lives in the shared utils repo so every repo resolves the
# same "latest stable" the same way. Checking it out beats vendoring a
# copy, which is exactly how a gate and its survey start disagreeing.
- name: Check out the shared gate
uses: actions/checkout@v4
with:
repository: kuhyx/utils
path: .utils
# "3.x", never a pinned minor: the Python target IS the interpreter the
# gate runs under (registries/toolchain.python_installed), so a runner
# held a release behind this machine reports a repo's `requires-python`
# as excluding "latest" while the same check passes locally. flax-docs-mcp
# hit exactly that -- `>=3.14` green here, red on a 3.13 runner.
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.x"
- name: Install the gate's two runtime dependencies
run: python -m pip install --upgrade pyyaml packaging
- name: Cache registry lookups
uses: actions/cache@v4
with:
path: ~/.cache/dep-freshness
key: dep-freshness-${{ hashFiles('**/pubspec.yaml', '**/pyproject.toml',
'**/requirements*.txt', '**/package.json', '**/Cargo.toml', '**/go.mod') }}
restore-keys: dep-freshness-
- name: Every dependency is on newest stable
run: bash .utils/scripts/check_dependency_freshness.sh --all --strict

View File

@ -28,9 +28,10 @@ jobs:
- group: flutter
hooks: flutter-analyze
skip: ""
# dependency-freshness is local only (pre-commit hook), never in CI.
- group: rest
hooks: ""
skip: mypy,pylint,flutter-analyze
skip: mypy,pylint,flutter-analyze,dependency-freshness
name: pre-commit (${{ matrix.group }})
steps:
- uses: actions/checkout@v4
@ -93,12 +94,11 @@ jobs:
# Every hook brings its own environment except the language: system
# ones, and those all run in `rest`: screens-fit imports screen_locker
# (and so its runtime deps) and dependency-freshness needs pyyaml and
# packaging. The other groups need pre-commit alone. uv with a cached
# (and so its runtime deps). The other groups need pre-commit alone. uv with a cached
# wheel store replaces a ~27 s pip install.
- name: Install requirements for the system hooks
if: matrix.group == 'rest'
run: uv pip install --system -r requirements.txt pyyaml packaging
run: uv pip install --system -r requirements.txt
- name: Install pre-commit
if: matrix.group != 'rest'
run: uv pip install --system pre-commit

View File

@ -9,7 +9,7 @@ on:
env:
# Bucket count for the Flutter suite; the matrix below lists 0..N-1.
# 10, not more: the account runs at most 20 jobs at once, and a push also
# starts ~10 others (pre-commit, freshness, the rest of this file). At 12
# starts ~10 others (pre-commit, the rest of this file). At 12
# three shards queued for up to 34 s and the workflow took 91 s.
FLUTTER_SHARDS: 10

View File

@ -145,7 +145,7 @@ repos:
- crdt-sync @ git+https://github.com/kuhyx/utils@crdt-sync-v0.11.1#subdirectory=crdt-sync
- earned-time @ git+https://github.com/kuhyx/utils@earned-time-v0.22.0#subdirectory=earned_time
- freedays @ git+https://github.com/kuhyx/utils@freedays-v0.4.3#subdirectory=freedays
- sickdays @ git+https://github.com/kuhyx/utils@sickdays-v0.5.5#subdirectory=sickdays
- sickdays @ git+https://github.com/kuhyx/utils@sickdays-v0.5.6#subdirectory=sickdays
# Same pin as workout_app/tools/render_finish_chime.sh installs.
- music_theory @ git+https://github.com/kuhyx/utils@music-theory-v0.1.0#subdirectory=music_theory
- mcp>=2,<3
@ -168,7 +168,7 @@ repos:
- crdt-sync @ git+https://github.com/kuhyx/utils@crdt-sync-v0.11.1#subdirectory=crdt-sync
- earned-time @ git+https://github.com/kuhyx/utils@earned-time-v0.22.0#subdirectory=earned_time
- freedays @ git+https://github.com/kuhyx/utils@freedays-v0.4.3#subdirectory=freedays
- sickdays @ git+https://github.com/kuhyx/utils@sickdays-v0.5.5#subdirectory=sickdays
- sickdays @ git+https://github.com/kuhyx/utils@sickdays-v0.5.6#subdirectory=sickdays
- mcp>=2,<3
- pydantic
@ -459,7 +459,8 @@ repos:
# Runs WITHOUT --strict on purpose. Offline it degrades to the cached
# answer and passes with a loud banner; `--no-verify` is banned here, so
# a hook that hard-failed on a flaky connection would leave no way to
# commit at all. CI, always online, is the strict authority.
# commit at all. The strict run is local only (CI does not check
# freshness): scripts/check_dependency_freshness.sh --all --strict
- id: dependency-freshness
name: dependencies on newest stable
entry: scripts/check_dependency_freshness.sh

View File

@ -124,7 +124,7 @@ wait, and tests pin the retry to 0.
- lint: `pre-commit run ruff --all-files`
- coverage: `python -m pytest -n auto -p no:sugar -q`
- 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`)
- 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 (skipped when its source tree matches the last phone install, `~/.local/state/screen-locker/phone_app_tree`); exit 46 from the phone guard means kuhy reruns it with `PHONE_PROTECT_ALLOW=com.kuhy.workout_app`)
## Pre-push gate (<=60 s)

View File

@ -12,7 +12,7 @@ dependencies = [
"freedays @ git+https://github.com/kuhyx/utils@freedays-v0.4.3#subdirectory=freedays",
"earned-time @ git+https://github.com/kuhyx/utils@earned-time-v0.22.0#subdirectory=earned_time",
"holds @ git+https://github.com/kuhyx/utils@holds-v0.1.0#subdirectory=holds",
"sickdays @ git+https://github.com/kuhyx/utils@sickdays-v0.5.5#subdirectory=sickdays",
"sickdays @ git+https://github.com/kuhyx/utils@sickdays-v0.5.6#subdirectory=sickdays",
]
[project.scripts]

View File

@ -21,8 +21,8 @@ pytest-xdist==3.8.0
# token over the REST endpoint; crdt-sync already pulls requests in, but this
# module imports it itself, so it is declared rather than assumed.
requests==2.34.2
ruff==0.17.5
sickdays @ git+https://github.com/kuhyx/utils@sickdays-v0.5.5#subdirectory=sickdays
ruff==0.17.6
sickdays @ git+https://github.com/kuhyx/utils@sickdays-v0.5.6#subdirectory=sickdays
types-requests==2.33.0.20261030
# 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

View File

@ -0,0 +1,114 @@
"""scripts/deploy.sh --phone-only: skip the phone when its app is unchanged.
A PC-only change (CI config, a Python pin) must deploy with the phone
unplugged: the workout app installed last time is byte-for-byte the same
source. The skip keys on the git tree of the app directory recorded after the
last successful phone install, so an app change is never skipped.
"""
from __future__ import annotations
import os
from pathlib import Path
import subprocess
import pytest
ROOT = Path(__file__).resolve().parents[2]
DEPLOY = ROOT / "scripts" / "deploy.sh"
APP_DIR = "stronglift_replacement/workout_app"
# conftest replaces subprocess.run process-wide for every test; this module
# needs the real one, captured at import time before any fixture runs.
_real_run = subprocess.run
def _git(repo: Path, *args: str) -> str:
"""Run git in ``repo`` and return its stripped stdout."""
env = {**os.environ, "GIT_CONFIG_GLOBAL": os.devnull}
env.pop("GIT_DIR", None)
out = _real_run(
["git", "-C", str(repo), *args],
check=True,
capture_output=True,
text=True,
env=env,
)
return out.stdout.strip()
@pytest.fixture(name="live")
def _live_repo(tmp_path: Path) -> Path:
"""A throwaway 'live clone' with one committed app file."""
repo = tmp_path / "live"
(repo / APP_DIR).mkdir(parents=True)
(repo / APP_DIR / "pubspec.yaml").write_text("name: workout_app\n")
_git(repo, "init", "-q")
_git(repo, "-c", "user.email=t@t", "-c", "user.name=t", "add", ".")
_git(repo, "-c", "user.email=t@t", "-c", "user.name=t", "commit", "-qm", "c")
return repo
def _fake_phone(tmp_path: Path, rc: int) -> tuple[Path, Path]:
"""A stand-in phone_deploy.sh exiting ``rc``; returns (script, call log)."""
calls = tmp_path / "phone_calls"
script = tmp_path / "phone_deploy.sh"
script.write_text(f'#!/bin/bash\necho "$@" >> "{calls}"\nexit {rc}\n')
return script, calls
def _run(live: Path, phone: Path, marker: Path) -> subprocess.CompletedProcess[str]:
env = {
**os.environ,
"SCREEN_LOCKER_LIVE": str(live),
"PHONE_DEPLOY": str(phone),
"PHONE_APP_MARKER": str(marker),
}
env.pop("GIT_DIR", None)
return _real_run(
["bash", str(DEPLOY), "--phone-only"],
check=False,
capture_output=True,
text=True,
env=env,
)
def test_unchanged_app_skips_unreachable_phone(live: Path, tmp_path: Path) -> None:
"""Recorded tree == current tree: exit 0 without touching the phone."""
phone, calls = _fake_phone(tmp_path, 30)
marker = tmp_path / "state" / "phone_app_tree"
marker.parent.mkdir()
marker.write_text(_git(live, "rev-parse", f"HEAD:{APP_DIR}") + "\n")
result = _run(live, phone, marker)
assert not result.returncode, result.stderr
assert "unchanged" in result.stdout
assert not calls.exists()
def test_changed_app_still_needs_the_phone(live: Path, tmp_path: Path) -> None:
"""A different recorded tree: phone_deploy runs and its exit 30 fails."""
phone, calls = _fake_phone(tmp_path, 30)
marker = tmp_path / "phone_app_tree"
marker.write_text("0" * 40 + "\n")
result = _run(live, phone, marker)
assert result.returncode == 1
assert calls.exists()
assert "exited 30" in result.stderr
def test_no_marker_fails_closed(live: Path, tmp_path: Path) -> None:
"""No record of an install: the phone is required, not skipped."""
phone, calls = _fake_phone(tmp_path, 30)
result = _run(live, phone, tmp_path / "missing" / "phone_app_tree")
assert result.returncode == 1
assert calls.exists()
def test_install_records_the_tree(live: Path, tmp_path: Path) -> None:
"""A successful install writes the app tree, so the next deploy can skip."""
phone, calls = _fake_phone(tmp_path, 0)
marker = tmp_path / "state" / "phone_app_tree"
result = _run(live, phone, marker)
assert not result.returncode, result.stderr
assert calls.exists()
assert marker.read_text().strip() == _git(live, "rev-parse", f"HEAD:{APP_DIR}")

View File

@ -11,7 +11,7 @@
#
# Usage:
# scripts/check_dependency_freshness.sh <file> [<file> ...] # pre-commit
# scripts/check_dependency_freshness.sh --all --strict # CI
# scripts/check_dependency_freshness.sh --all --strict # full local run
#
# Exit: 0 current | 1 behind | 2 allowlist wrong | 3 undeterminable (offline)
# ============================================================================

View File

@ -22,7 +22,7 @@
# Usage: ci_mirror.sh [venv|precommit|pytest|all] [pytest args...]
# Each step is its own manual hook (ci-venv, ci-precommit-*, ci-pytest) so no
# single call outlives the 60 s action cap; `all` (the default) is the old
# one-shot behaviour. pytest runs under xdist (-n auto --dist worksteal):
# one-shot behaviour. pytest runs under xdist (-n 4 --dist worksteal):
# serial it was ~85 s, and pytest-cov merges the workers' coverage.
# ============================================================================
@ -105,9 +105,12 @@ run_precommit_group() {
run_pytest_clean_venv() {
log "pytest in the clean venv (mirrors the Tests workflow)"
# CI_MIRROR_WORKERS: xdist worker count (default auto = one per core; on a
# busy 24-core box that is ~3 GiB and trips the capped.sh memory ceiling).
"$VENV_DIR/bin/python" -m pytest -n "${CI_MIRROR_WORKERS:-auto}" --dist worksteal "$@" \
# CI_MIRROR_WORKERS: xdist worker count. Default 4, not auto: one worker
# per core (16 here) peaked at 3.2 GiB and the kernel OOM-killed the step
# inside capped.sh's 4 GiB session slice (2026-11-19). capped.sh gives the
# job 10-20 % of the cores (1.6-3.2 here), so more than 4 workers buys no
# speed, only memory.
"$VENV_DIR/bin/python" -m pytest -n "${CI_MIRROR_WORKERS:-4}" --dist worksteal "$@" \
|| fail "pytest (clean requirements.txt venv)"
}

View File

@ -2,8 +2,6 @@
# 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.
@ -16,7 +14,16 @@
# 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).
# The phone step is skipped when the workout app's source is unchanged since
# the last successful phone install: a PC-only change (CI config, a Python pin)
# then deploys with the phone unplugged. The key is the git tree of APP_DIR,
# written to PHONE_APP_MARKER after each install; no marker means the phone is
# required (fail closed). Any app change gives a new tree, so it is never skipped.
#
# Usage: bash scripts/deploy.sh [--health-only | --phone-only]
#
# Seams: SCREEN_LOCKER_LIVE (live clone), DEPLOY_WEB_PORT (health port),
# PHONE_DEPLOY (installer), PHONE_APP_MARKER (last installed app tree).
# Exit: 0 healthy and installed everywhere | 1 any step or check failed.
set -euo pipefail
@ -24,7 +31,8 @@ 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 PHONE_DEPLOY="${PHONE_DEPLOY:-$HOME/.claude/scripts/phone_deploy.sh}"
readonly PHONE_APP_MARKER="${PHONE_APP_MARKER:-$HOME/.local/state/screen-locker/phone_app_tree}"
readonly UNITS=(screen-locker-web.service workout-poke.service runnerup-watch.service)
die() { echo "deploy: FAIL: $*" >&2; exit 1; }
@ -94,10 +102,19 @@ desktop() {
}
phone() {
local rc=0
local rc=0 tree
tree="$(git -C "$LIVE" rev-parse "HEAD:$APP_DIR")" || die "no $APP_DIR tree at $LIVE HEAD"
if [[ "$(cat "$PHONE_APP_MARKER" 2>/dev/null || true)" == "$tree" ]]; then
ok "workout app unchanged since the last phone install (tree ${tree:0:10}); phone step skipped"
return 0
fi
bash "$PHONE_DEPLOY" "$LIVE/$APP_DIR" --release || rc=$?
case "$rc" in
0) ok "workout app release build installed on the phone" ;;
0)
mkdir -p "$(dirname "$PHONE_APP_MARKER")"
printf '%s\n' "$tree" > "$PHONE_APP_MARKER"
ok "workout app release build installed on the phone (tree ${tree:0:10})"
;;
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" ;;
@ -105,6 +122,10 @@ phone() {
esac
}
if [[ "${1:-}" == "--phone-only" ]]; then
phone
exit 0
fi
if [[ "${1:-}" == "--health-only" ]]; then
health
exit 0