From 2e8d852a93e39ef615884dc55c43038680f5a7f5 Mon Sep 17 00:00:00 2001 From: Waozi Date: Thu, 22 Oct 2026 22:18:11 -0300 Subject: [PATCH] Release tested commits without blocking ongoing development --- .github/workflows/fdroid.yml | 20 ++++ .github/workflows/release.yml | 37 +++++++- AGENTS.md | 14 +-- docs/cells.md | 49 +++++----- droid/build.gradle | 2 +- .../gradle/wrapper/gradle-wrapper.properties | 3 +- mk/release.mk | 2 +- scripts/phone-check.py | 44 +++++++-- scripts/release-ready.sh | 11 ++- scripts/release.py | 91 ++++++++++++++++++- tests/entity_profile_ui_test.py | 55 +++++++---- tests/phone_check_gate_test.py | 39 ++++++++ tests/release_test.py | 37 +++++++- 13 files changed, 341 insertions(+), 63 deletions(-) diff --git a/.github/workflows/fdroid.yml b/.github/workflows/fdroid.yml index 1d2d7005b..5b1589a41 100644 --- a/.github/workflows/fdroid.yml +++ b/.github/workflows/fdroid.yml @@ -8,7 +8,16 @@ on: schedule: - cron: '23 7 * * *' workflow_dispatch: + inputs: + revision: + description: Exact committed candidate (defaults to the triggering commit) + required: false + type: string workflow_call: + inputs: + revision: + required: false + type: string permissions: contents: read @@ -22,6 +31,16 @@ jobs: # Official F-Droid buildserver, pinned for repeatable verification. image: registry.gitlab.com/fdroid/fdroidserver@sha256:1ea8bef1820bff06c2974e31b4fc4c79c364cd24231b86e71fa4b926797e0dac steps: + - name: Require an immutable candidate + env: + CANDIDATE: ${{ inputs.revision || github.sha }} + shell: bash + run: | + if ! [[ "$CANDIDATE" =~ ^[0-9a-f]{40}$ ]]; then + echo "::error::revision must be a full commit ID, never a branch or tag" + exit 1 + fi + # Checkout's LFS support requires git-lfs inside the job container. - name: Install recipe dependencies run: | @@ -33,6 +52,7 @@ jobs: - name: Checkout candidate uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 # v4.3.0 with: + ref: ${{ inputs.revision || github.sha }} path: build/xyz.waozi.inbe lfs: true persist-credentials: false diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 0ef37510b..25bbab8e7 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -25,22 +25,37 @@ on: - 'packaging/**' - '.github/workflows/release.yml' workflow_dispatch: + inputs: + revision: + description: Exact committed release candidate (defaults to the triggering commit) + required: false + type: string permissions: contents: write concurrency: - group: ${{ github.workflow }}-${{ github.ref }} - cancel-in-progress: true + group: ${{ github.workflow }}-${{ inputs.revision || github.sha }} + cancel-in-progress: false jobs: secret-scan: name: Secret Scan runs-on: ubuntu-latest steps: + - name: Require an immutable candidate + env: + CANDIDATE: ${{ inputs.revision || github.sha }} + run: | + if ! [[ "$CANDIDATE" =~ ^[0-9a-f]{40}$ ]]; then + echo "::error::revision must be a full commit ID, never a branch or tag" + exit 1 + fi + - name: Checkout Repository uses: actions/checkout@v4 with: + ref: ${{ inputs.revision || github.sha }} fetch-depth: 0 - name: Fetch Ziran packages @@ -79,6 +94,7 @@ jobs: - name: Checkout Repository uses: actions/checkout@v4 with: + ref: ${{ inputs.revision || github.sha }} fetch-depth: 1 lfs: true @@ -154,6 +170,8 @@ jobs: name: F-Droid needs: secret-scan uses: ./.github/workflows/fdroid.yml + with: + revision: ${{ inputs.revision || github.sha }} verify-fdroid: name: Verify F-Droid reproducibility @@ -198,6 +216,7 @@ jobs: - name: Checkout Repository uses: actions/checkout@v4 with: + ref: ${{ inputs.revision || github.sha }} fetch-depth: 1 lfs: true @@ -253,6 +272,7 @@ jobs: - name: Checkout Repository uses: actions/checkout@v4 with: + ref: ${{ inputs.revision || github.sha }} fetch-depth: 1 lfs: true @@ -308,6 +328,7 @@ jobs: - name: Checkout Repository uses: actions/checkout@v4 with: + ref: ${{ inputs.revision || github.sha }} fetch-depth: 1 lfs: true @@ -374,6 +395,7 @@ jobs: - name: Checkout Repository uses: actions/checkout@v4 with: + ref: ${{ inputs.revision || github.sha }} fetch-depth: 1 - name: Fetch Ziran packages @@ -489,6 +511,7 @@ jobs: - name: Checkout Repository uses: actions/checkout@v4 with: + ref: ${{ inputs.revision || github.sha }} fetch-depth: 1 - name: Fetch Ziran packages @@ -549,6 +572,7 @@ jobs: - name: Checkout Repository uses: actions/checkout@v4 with: + ref: ${{ inputs.revision || github.sha }} fetch-depth: 1 - name: Fetch Ziran packages @@ -609,6 +633,7 @@ jobs: - name: Checkout Repository uses: actions/checkout@v4 with: + ref: ${{ inputs.revision || github.sha }} fetch-depth: 1 - name: Fetch Ziran packages @@ -666,6 +691,7 @@ jobs: - name: Checkout Repository uses: actions/checkout@v4 with: + ref: ${{ inputs.revision || github.sha }} fetch-depth: 1 - name: Fetch Ziran packages @@ -715,6 +741,7 @@ jobs: - name: Checkout Repository uses: actions/checkout@v4 with: + ref: ${{ inputs.revision || github.sha }} fetch-depth: 1 - name: Fetch Ziran packages @@ -777,6 +804,7 @@ jobs: - name: Checkout Repository uses: actions/checkout@v4 with: + ref: ${{ inputs.revision || github.sha }} fetch-depth: 1 - name: Fetch Ziran packages @@ -938,6 +966,7 @@ jobs: - name: Checkout Repository uses: actions/checkout@v4 with: + ref: ${{ inputs.revision || github.sha }} fetch-depth: 0 - name: Download Release Artifacts @@ -1129,6 +1158,8 @@ jobs: - name: Checkout Repository uses: actions/checkout@v4 + with: + ref: ${{ inputs.revision || github.sha }} - name: Download Release Artifacts uses: actions/download-artifact@v4 @@ -1256,6 +1287,8 @@ jobs: steps: - name: Checkout uses: actions/checkout@v4 + with: + ref: ${{ inputs.revision || github.sha }} - name: Check Amazon Appstore Secrets id: amazon_secrets diff --git a/AGENTS.md b/AGENTS.md index 59cc422db..5b52b666f 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -15,12 +15,14 @@ Only the GitHub Actions release workflow creates or pushes release tags. - A new version publishes only with a passing phone check of its exact app content (`app_tree` over `APP_PATHS` in `scripts/phone-check.py`). Release - with `make release-ready` (CI's checks in its Ubuntu container), then - `make release` with the development Moto connected: it checks the APK and - makes the one "Release Inner Breeze X.Y.Z" commit. After a late fix, run - both again; the unpushed release commit moves above the fix, so there are - no "Record" commits. Tests, docs and tooling may change after the check, - app paths may not. See [docs/cells.md](docs/cells.md#verification). + with `RELEASE_READY_REVISION=COMMIT make release-ready`, then + `make release REVISION=COMMIT APK=PATH BUILD_RECEIPT=PATH` with the development + Moto connected. The APK and its provenance come from the same fixed-source + overlay. Master, locks and peer edits keep changing freely. The release + commit retains the tested source; if master advanced, a merge preserves + all newer source and history. The workflow can release that exact commit + through its `revision` input. Never freeze the checkout for testing. + See [docs/cells.md](docs/cells.md#verification). - Packages declare the oldest host interface they run on (`host_api` per app in `apps/versions.json`); the host runs `oldest_host_api` to `host_api`. Raise `host_api` when the host interface changes and `oldest_host_api` only diff --git a/docs/cells.md b/docs/cells.md index 9e8ed3f5d..f87ee0870 100644 --- a/docs/cells.md +++ b/docs/cells.md @@ -807,29 +807,34 @@ the `TOOLING` that only checks or publishes). The Release workflow refuses a new tag without it or when the pushed app content differs. Tests, docs and tooling may change after the check; any app change needs a new one. -A release is one commit, made last: +A release names one fixed commit while peers keep working on master: -1. Add the numeric `CHANGELOG.md` entry and run `./update_version.sh` while - the release takes shape, as before. -2. `make release-ready` runs CI's checks on HEAD in the Test job's Ubuntu - 24.04 container with the locked packages: Secret Scan, package URLs, the - large-file guard, `make test`, `make visual-test` and - `make package-compat-test`. It does not run the browser add-on smoke - tests, shard 0's Daochi sync test or the platform builds. A run takes - about 90 minutes; outputs stay in `build/release-ready/`. The container - reads unchanged files from this checkout, so when another session edits - files during the run, it reports them and records no pass. -3. With the development Moto connected (here or through the ThinkPad), - `make release` builds the debug APK for its ABI (or takes `APK=...`), - checks it and commits the receipt and any version files as - "Release Inner Breeze X.Y.Z". It refuses uncommitted app files, package - overrides that are not clean on their `ziran.lock` commit, and content - that `make release-ready` did not pass. -4. A late fix is an ordinary commit followed by steps 2 and 3 again; the - unpushed release commit moves above the fix and takes the new receipt. - Pushed history is never rewritten. -5. Push master only with the owner's say-so; the workflow tags and - publishes. +1. Add the numeric `CHANGELOG.md` entry, run `./update_version.sh`, and commit + the intended source. Do not freeze the repository, dependency lock or + another session's work. +2. `RELEASE_READY_REVISION=COMMIT make release-ready` runs the local CI suites + in the Ubuntu 24.04 container with the candidate's locked packages: + Secret Scan, package URLs, file sizes, all tests, visual tests, package + compatibility, Chrome and muted Firefox smoke tests, and the pinned real + Daochi sync server. Platform release builds remain separate. The existing + repository overlay materializes every candidate file and recreates source + directories, so later edits, new files and commits cannot enter the run. + Outputs stay in `build/release-ready/`. +3. Build the Moto APK in the same fixed-source overlay and save its content + identity and SHA-256 build receipt. With the development app closed by + the owner, run `make release REVISION=COMMIT APK=PATH BUILD_RECEIPT=PATH`. + The exact APK must pass the minute-long practice and resume check; + physical-phone images use Harmony's owner-only review. The command checks + both the local gate stamp and APK provenance against the fixed candidate. +4. The command creates "Release Inner Breeze X.Y.Z" from the tested source + plus its receipt. If master advanced, a merge keeps the release in its + history while preserving every newer committed source file, staged edit + and unfinished file. No existing history is rewritten. +5. Push the approved history and run Release for its exact release commit + using the workflow's `revision` input when master has moved on. Every + platform and reusable F-Droid build checks out that same candidate. + Subsequent master commits cannot cancel its release. Only the workflow + creates the release tag after all required gates pass. Harmony Projects shows this wrapper release, every cell version and its Moto screenshots. Harmony's `make inbe-release-verify` checks the latest published diff --git a/droid/build.gradle b/droid/build.gradle index c0dae7274..09e238ee8 100644 --- a/droid/build.gradle +++ b/droid/build.gradle @@ -1,5 +1,5 @@ plugins { - id 'com.android.application' version '8.9.1' apply false + id 'com.android.application' version '8.13.2' apply false id 'org.jetbrains.kotlin.android' version '2.3.0' apply false id 'com.google.gms.google-services' version '4.5.0' apply false } diff --git a/droid/gradle/wrapper/gradle-wrapper.properties b/droid/gradle/wrapper/gradle-wrapper.properties index e2847c820..c99f97449 100644 --- a/droid/gradle/wrapper/gradle-wrapper.properties +++ b/droid/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,7 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.11.1-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.13-bin.zip +distributionSha256Sum=20f1b1176237254a6fc204d8434196fa11a4cfb387567519c61556e8710aed78 networkTimeout=10000 validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME diff --git a/mk/release.mk b/mk/release.mk index 18b65f510..9473f3635 100644 --- a/mk/release.mk +++ b/mk/release.mk @@ -39,4 +39,4 @@ release-ready: sh scripts/release-ready.sh release: - python3 scripts/release.py $(if $(APK),--apk "$(APK)",) + python3 scripts/release.py $(if $(REVISION),--revision "$(REVISION)",) $(if $(APK),--apk "$(APK)",) $(if $(BUILD_RECEIPT),--build-receipt "$(BUILD_RECEIPT)",) diff --git a/scripts/phone-check.py b/scripts/phone-check.py index 574c2e736..d57cfde9f 100644 --- a/scripts/phone-check.py +++ b/scripts/phone-check.py @@ -121,7 +121,12 @@ class Phone: raise ValueError("Inner Breeze did not start: " + output.strip()) def pid(self, package): - return self.shell("pidof", package).strip() + try: + return self.shell("pidof", package).strip() + except subprocess.CalledProcessError as error: + if error.returncode == 1 and not error.stdout: + return "" + raise def apk_identity(apk): @@ -205,13 +210,31 @@ def changed_app_files(root): return changed, untracked -def source_state(): - commit = git(ROOT, "rev-parse", "HEAD").strip() +def source_state(revision=None): + commit = git(ROOT, "rev-parse", (revision or "HEAD") + "^{commit}").strip() + if revision: + text = git(ROOT, "show", commit + ":src/core/version.zi") + versions = re.findall(r'^VersionString :: "([0-9]+\.[0-9]+\.[0-9]+)"$', text, re.M) + if len(versions) != 1: + raise ValueError("the fixed candidate has no valid application version") + return commit, [], [], versions[0] changed, untracked = changed_app_files(ROOT) version = run([sys.executable, ROOT / "scripts/check-version.py", "--print-version"]).decode().strip() return commit, changed, untracked, version +def require_build_receipt(apk, path, revision): + """Bind a fixed-source phone run to the APK exported by its isolated build.""" + if path is None: + raise ValueError("a fixed candidate requires its isolated APK build receipt") + receipt = json.loads(path.read_text()) + digest = receipt.get("apk", {}).get("sha256") + if (receipt.get("status") != "passed" or + receipt.get("app_tree") != app_tree(ROOT, revision) or + digest != hashlib.sha256(apk.read_bytes()).hexdigest()): + raise ValueError("the APK build receipt does not match this fixed app content and APK") + + def layout_shift(before, after): """Mean pixel difference of the practice header, which does not animate.""" from PIL import Image, ImageChops, ImageStat @@ -281,6 +304,8 @@ def check(phone, apk, seconds, evidence): package = identity["package"] if phone.adb("get-state").decode().strip() != "device": raise ValueError("the phone is not connected and authorized") + if phone.pid(package): + raise ValueError("the development app is already running; leave it open until the owner closes it") transfer = "" try: if phone.host != "local": @@ -343,14 +368,21 @@ def main(): parser.add_argument("--seconds", type=int, default=60) parser.add_argument("--record", action="store_true", help="write a passing result to releases/phone-checks/VERSION.json for the release gate") + parser.add_argument("--revision", help="check the APK of this fixed committed candidate while master changes") + parser.add_argument("--build-receipt", type=Path, + help="isolated APK build provenance, required with --revision") args = parser.parse_args() for name in ("DISPLAY", "WAYLAND_DISPLAY", "XAUTHORITY", "DBUS_SESSION_BUS_ADDRESS"): os.environ.pop(name, None) apk = args.apk.resolve(strict=True) - commit, changed, untracked, version = source_state() + commit, changed, untracked, version = source_state(args.revision) + if args.revision: + require_build_receipt(apk, args.build_receipt, commit) if args.record and (untracked or args.seconds < 60): parser.error("a recorded check needs a full minute and no untracked app files:\n" + "\n".join(untracked)) - checked_app = app_tree(ROOT) + checked_app = app_tree(ROOT, commit if args.revision else None) + if apk_identity(apk)["version_name"] != version: + raise ValueError("the APK version differs from the candidate; no installation attempted") stamp = datetime.now(timezone.utc).strftime("%Y%m%dT%H%M%SZ") evidence = ROOT / "backup/phone-checks" / f"{version}-{stamp}" evidence.mkdir(parents=True, exist_ok=True) @@ -370,7 +402,7 @@ def main(): "background and resume"], passed=passed, checked_at=datetime.now(timezone.utc).isoformat(timespec="seconds")) (evidence / "receipt.json").write_text(json.dumps(receipt, indent=2) + "\n") - if args.record and app_tree(ROOT) != checked_app: + if args.record and not args.revision and app_tree(ROOT) != checked_app: raise SystemExit("app files changed during the check; nothing was recorded") if args.record and passed: target = ROOT / RECEIPTS / f"{version}.json" diff --git a/scripts/release-ready.sh b/scripts/release-ready.sh index 5bfca5ec0..bf7c2db46 100755 --- a/scripts/release-ready.sh +++ b/scripts/release-ready.sh @@ -27,9 +27,14 @@ root=$(CDPATH= cd -- "$(dirname -- "$0")/.." && pwd) cd "$root" output=build/release-ready -image_tag=$(cat .github/local-ci/Containerfile .github/apt/test-packages.txt .github/apt/web-packages.txt .github/emscripten-version | sha256sum | cut -c1-12) -image=localhost/inbe-ci:$image_tag commit=$(git rev-parse "${RELEASE_READY_REVISION:-HEAD}^{commit}") +image_tag=$({ + git show "$commit:.github/local-ci/Containerfile" + git show "$commit:.github/apt/test-packages.txt" + git show "$commit:.github/apt/web-packages.txt" + git show "$commit:.github/emscripten-version" +} | sha256sum | cut -c1-12) +image=localhost/inbe-ci:$image_tag # Read the candidate from Git objects, never the changing files on disk. content=$(python3 - "$commit" <<'PY_CONTENT' @@ -106,7 +111,7 @@ fi if ! podman image exists "$image"; then echo "release-ready: building $image" - podman build -t "$image" -f .github/local-ci/Containerfile .github + git archive "$commit:.github" | podman build -t "$image" -f local-ci/Containerfile - # Replace the images of older package lists; one still in use stays. podman images --format '{{.Repository}}:{{.Tag}}' localhost/inbe-ci \ | grep -v ":$image_tag\$" | xargs -r podman rmi >/dev/null 2>&1 || true diff --git a/scripts/release.py b/scripts/release.py index af957c644..63229b34d 100755 --- a/scripts/release.py +++ b/scripts/release.py @@ -231,15 +231,96 @@ def release_at_head(version): return subject == SUBJECT.format(version=version) and unpushed_release(version) != "" -def require_release_ready(): +def require_release_ready(revision="HEAD"): try: stamp = json.loads(READY_STAMP.read_text()) except (OSError, ValueError): raise Refused("make release-ready has not passed here; run it first") from None - content = phone_check.release_content(ROOT, "HEAD") + content = phone_check.release_content(ROOT, revision) if stamp.get("passed") is not True or stamp.get("content") != content: raise Refused("make release-ready passed for other content " - f"({stamp.get('commit', '?')[:10]}); run it again for HEAD") + f"({stamp.get('commit', '?')[:10]}); run it again for the candidate") + + +def fixed_release_commit(base, version, details): + """Keep the tested source immutable and preserve later master work verbatim.""" + path = f"{phone_check.RECEIPTS}/{version}.json" + blob = subprocess.run(["git", "-C", ROOT, "hash-object", "-w", "--stdin"], + input=(ROOT / path).read_bytes(), capture_output=True, check=True).stdout.decode().strip() + author = dict(os.environ, GIT_AUTHOR_NAME="Waozi", GIT_AUTHOR_EMAIL="waozi@proton.me", + GIT_COMMITTER_NAME="Waozi", GIT_COMMITTER_EMAIL="waozi@proton.me") + + def record(parent, message, other_parent=None): + with tempfile.TemporaryDirectory(prefix="inbe-release-index-") as temporary: + environment = dict(author, GIT_INDEX_FILE=str(Path(temporary) / "index")) + git("read-tree", parent, env=environment) + git("update-index", "--add", "--cacheinfo", "100644", blob, path, env=environment) + tree = git("write-tree", env=environment).strip() + command = ["git", "-C", ROOT, "commit-tree", tree, "-p", parent] + if other_parent: + command += ["-p", other_parent] + return subprocess.run(command, input=message + "\n", env=author, text=True, + check=True, capture_output=True).stdout.strip() + + release = record(base, SUBJECT.format(version=version) + "\n\n" + details) + for _ in range(10): + head = git("rev-parse", "refs/heads/master").strip() + if subprocess.run(["git", "-C", ROOT, "merge-base", "--is-ancestor", base, head], + capture_output=True).returncode: + raise Refused("the candidate is outside master's history; no branch was changed") + target = release if head == base else record( + head, f"Merge tested Inner Breeze {version} release history", release) + result = subprocess.run(["git", "-C", ROOT, "update-ref", "refs/heads/master", target, head], + capture_output=True) + if result.returncode == 0: + # Only this receipt enters the real index. Peer edits and staged + # files are untouched; the merge tree retains their committed source. + git("update-index", "--add", "--cacheinfo", "100644", blob, path) + output = ROOT / "build/release-candidate.json" + output.parent.mkdir(parents=True, exist_ok=True) + output.write_text(json.dumps(dict(version=version, source_commit=base, + release_commit=release, master_commit=target), indent=2) + "\n") + return release + raise Refused("master advanced repeatedly; the immutable release object is saved and no peer work was changed") + + +def release_fixed(args): + revision = git("rev-parse", args.revision + "^{commit}").strip() + headings = re.findall(r"^## \[(\d+\.\d+\.\d+)\]", git("show", revision + ":CHANGELOG.md"), re.M) + if not headings: + raise Refused("the candidate has no numeric release entry") + version = headings[0] + step(f"Inner Breeze {version}: fixed committed candidate") + require_new_version(version) + require_release_ready(revision) + checked_app = phone_check.app_tree(ROOT, revision) + if args.phone_check_waiver: + receipt = dict(schema=3, status="waived", version=version, app_tree=checked_app, + source_commit=revision, reason=args.phone_check_waiver.strip(), + authorized_at=datetime.now(timezone.utc).isoformat(timespec="seconds")) + target = ROOT / phone_check.RECEIPTS / f"{version}.json" + target.parent.mkdir(parents=True, exist_ok=True) + target.write_text(json.dumps(receipt, indent=2) + "\n") + else: + if args.apk is None: + raise Refused("a fixed candidate needs its isolated APK and --build-receipt") + apk = args.apk.resolve(strict=True) + phone_check.require_build_receipt(apk, args.build_receipt, revision) + subprocess.run([sys.executable, ROOT / "scripts/phone-check.py", apk, "--record", + "--host", args.host, "--serial", args.serial, "--revision", revision, + "--build-receipt", args.build_receipt], check=True) + receipt = gate.validate(ROOT, version, revision) + if receipt["app_tree"] != checked_app: + raise Refused("the recorded check is for other app content") + if receipt.get("status") == "waived": + details = "Moto check waived by owner: " + receipt["reason"] + else: + timing = receipt["practice"] + details = f"Phone check: {timing['fps']} fps, {timing['late_percent']}% late frames." + release = fixed_release_commit(revision, version, details) + gate.validate(ROOT, version, release) + print("Fixed release commit prepared; master and peer working files are preserved. Nothing was pushed.") + return 0 def build_apk(phone): @@ -262,6 +343,8 @@ def main(): parser.add_argument("--apk", type=Path, help="an APK built from the current sources") parser.add_argument("--host", default=os.environ.get("INBE_PHONE_HOST", "auto")) parser.add_argument("--serial", default=os.environ.get("INBE_PHONE_SERIAL", "ZE2223BQZT")) + parser.add_argument("--revision", help="release this tested fixed commit while peers keep working on master") + parser.add_argument("--build-receipt", type=Path, help="provenance for the isolated candidate APK") parser.add_argument("--phone-check-waiver", metavar="OWNER_AUTHORIZATION", help="skip the Moto only when explicitly authorized by the owner for this release") args = parser.parse_args() @@ -270,6 +353,8 @@ def main(): try: if git("symbolic-ref", "--short", "HEAD").strip() != "master": raise Refused("releases are made on master") + if args.revision: + return release_fixed(args) version = changelog_version() step(f"Inner Breeze {version}") require_new_version(version) diff --git a/tests/entity_profile_ui_test.py b/tests/entity_profile_ui_test.py index 4c0e673e7..ea08c5fad 100644 --- a/tests/entity_profile_ui_test.py +++ b/tests/entity_profile_ui_test.py @@ -1,4 +1,4 @@ -"""Entity edits reuse Inbe's account and survive restart on a private display.""" +"""Entity Profile preserves the host account, picture and inline Dew on a private display.""" import contextlib import json import os @@ -85,38 +85,59 @@ with contextlib.ExitStack() as stack: settings = driver.wait(label="Settings", role="button") assert account["x"] + account["width"] <= settings["x"], "Profile is not left of Settings" driver.press(focus_id=6792, role="button") - driver.wait(label="Name", role="text_field") + driver.wait(label="Change picture", role="button") + driver.wait(label="Dew balance", role="text") + assert not driver.find(label="Dew balance", role="button"), "Dew is still a separate shortcut" + assert not driver.find(label="Name", role="text_field"), "Removed Name field is visible" + assert not driver.find(label="Intention", role="text_field"), "Removed Intention field is visible" assert len(driver.find(role="title_bar", visible=True)) == 1 - with application("edit", seed=True) as process: + with application("seed", seed=True): before = credentials() identities = {value for _, key, value in before if key == "sync_public_id" and value} assert len(identities) == 1 and len(next(iter(identities))) == 64, "Fixture account missing" owner = next(iter(identities)) + with sqlite3.connect(profile / "inbe.db") as database: + user = database.execute("SELECT user_id FROM settings WHERE key='sync_public_id' " + "AND value=? LIMIT 1", (owner,)).fetchone()[0] + for key, value in (("profile_display_name", "Existing desktop name"), + ("profile_intention", "Existing private intention")): + database.execute("INSERT INTO settings(user_id,key,value,updated_at) VALUES(?,?,?,2) " + "ON CONFLICT(user_id,key) DO UPDATE SET value=excluded.value," + "updated_at=excluded.updated_at", (user, key, value)) + shared = Path(environment["ENTITY_DATA"]) / "profiles" / owner / "profile.json" + if shared.exists(): + saved = json.loads(shared.read_text()) + saved.update(name="Existing desktop name", intention="Existing private intention") + shared.write_text(json.dumps(saved) + "\n") + with application("edit"): open_profile() - driver.press(label="Dew balance", role="button") - driver.wait(label="Dew balance", role="title_bar") - driver.press(label="Back", role="button") - driver.wait(label="Name", role="text_field") - driver.press(label="Name", role="text_field") - driver.key("a", control=True) - driver.type("Entity desktop fixture") - driver.key("enter") - shared = Path(environment["ENTITY_DATA"]) / "profiles" / owner / "profile.json" + driver.wait(label="Manage data", role="button") + for label in ("Today", "Active days", "Sessions"): + driver.wait(label=label, role="text", visible=False) + assert not driver.find(label="Progress", role="button"), "Activity still uses a separate row" + driver.press(label="Change picture", role="button") + driver.wait(label="Profile picture", role="button") + driver.press(label="Profile picture", role="button", index=1) deadline = time.monotonic() + 15 while time.monotonic() < deadline: - if shared.exists() and json.loads(shared.read_text()).get("name") == "Entity desktop fixture": + if shared.exists() and json.loads(shared.read_text()).get("picture") == 1: break time.sleep(.05) document = json.loads(shared.read_text()) - assert document["name"] == "Entity desktop fixture", "Profile edit was not saved" + assert document["picture"] == 1, "Picture edit was not saved" + assert document["name"] == "Existing desktop name", "Hidden name was changed" + assert document["intention"] == "Existing private intention", "Hidden intention was changed" assert document["owner_id"] == owner, "Entity used a different account" assert credentials() == before, "Editing Entity changed Inbe account keys" assert not (Path(environment["ENTITY_DATA"]) / "account.key").exists(), "Entity made another account" + driver.press(label="Done", role="button") + driver.wait(label="Dew balance", role="text") with application("restart"): open_profile() - field = driver.wait(label="Name", role="text_field") - assert field.get("value") == "Entity desktop fixture", "Profile edit was lost after restart" + driver.press(label="Change picture", role="button") + pictures = driver.find(label="Profile picture", role="button", visible=True) + assert len(pictures) > 1 and pictures[1].get("selected"), "Picture edit was lost after restart" assert credentials() == before, "Restart changed Inbe account keys" assert json.loads(shared.read_text())["owner_id"] == owner @@ -145,4 +166,4 @@ with contextlib.ExitStack() as stack: for label in versions), versions assert "Show beta apps" not in labels, "Removed beta setting is still visible" -print("Entity desktop: profile editing, existing host account, saved name, restart and installed-only About passed") +print("Entity desktop: inline Dew/Activity, preserved hidden fields, host account, saved picture, restart and installed-only About passed") diff --git a/tests/phone_check_gate_test.py b/tests/phone_check_gate_test.py index d390204e0..88e263f0f 100644 --- a/tests/phone_check_gate_test.py +++ b/tests/phone_check_gate_test.py @@ -1,11 +1,13 @@ """The release gate accepts only a passing phone check of the released app content.""" import copy +import hashlib import importlib.util import json from pathlib import Path import subprocess import tempfile import unittest +from unittest import mock ROOT = Path(__file__).resolve().parents[1] spec = importlib.util.spec_from_file_location("check_phone_check", ROOT / "scripts/check-phone-check.py") @@ -68,6 +70,43 @@ class PhoneCheckGateTest(unittest.TestCase): self.record() self.assertEqual(gate.validate(self.root, "3.0.0")["version"], "3.0.0") + def test_fixed_apk_provenance_is_independent_of_peer_source_edits(self): + apk = self.root / "candidate.apk" + apk.write_bytes(b"synthetic isolated APK") + path = self.root / "build.json" + path.write_text(json.dumps(dict(status="passed", app_tree=self.checked_app, + apk=dict(sha256=hashlib.sha256(apk.read_bytes()).hexdigest())))) + self.commit({"src/main.zi": "peer committed work\n"}) + (self.root / "src/core/version.zi").write_text('VersionString :: "4.0.0"\n') + with mock.patch.object(phone_check, "ROOT", self.root): + phone_check.require_build_receipt(apk, path, self.checked) + self.assertEqual(phone_check.source_state(self.checked), (self.checked, [], [], "2.9.9")) + with self.assertRaisesRegex(ValueError, "does not match"): + phone_check.require_build_receipt(apk, path, "HEAD") + apk.write_bytes(b"different APK") + with self.assertRaisesRegex(ValueError, "does not match"): + phone_check.require_build_receipt(apk, path, self.checked) + + def test_running_owner_app_rejects_before_install_or_input(self): + phone = mock.Mock() + phone.adb.return_value = b"device\n" + phone.pid.return_value = "1234" + with mock.patch.object(phone_check, "apk_identity", return_value={"package": "fixture.debug"}): + with self.assertRaisesRegex(ValueError, "already running"): + phone_check.check(phone, self.root / "candidate.apk", 60, self.root) + self.assertEqual(phone.adb.call_args_list, [mock.call("get-state")]) + phone.shell.assert_not_called() + + def test_missing_process_is_empty_but_adb_failure_is_not_ignored(self): + phone = phone_check.Phone("local", "Fixture") + with mock.patch.object(phone, "shell", side_effect=subprocess.CalledProcessError( + 1, ["pidof"], output=b"")): + self.assertEqual(phone.pid("fixture.debug"), "") + with mock.patch.object(phone, "shell", side_effect=subprocess.CalledProcessError( + 1, ["adb"], output=b"device offline")): + with self.assertRaises(subprocess.CalledProcessError): + phone.pid("fixture.debug") + def test_docs_tests_and_tooling_may_change_after_the_check(self): self.record() later = {"docs/notes.md": "later documentation\n", "tests/extra.py": "\n", diff --git a/tests/release_test.py b/tests/release_test.py index e2be35802..eadf14823 100644 --- a/tests/release_test.py +++ b/tests/release_test.py @@ -33,7 +33,7 @@ class ReleaseTest(unittest.TestCase): for key, value in (("user.email", "test@example.invalid"), ("user.name", "Test")): git(self.root, "config", key, value) git(self.root, "remote", "add", "origin", str(self.origin)) - self.commit({"src/main.zi": "one\n", "src/core/version.zi": "2.9.9\n", "docs/notes.md": "notes\n"}, + self.commit({".gitignore": "/build/\n", "src/main.zi": "one\n", "src/core/version.zi": "2.9.9\n", "docs/notes.md": "notes\n"}, "Start") git(self.root, "push", "-q", "origin", "master") git(self.root, "fetch", "-q", "origin") @@ -167,6 +167,41 @@ class ReleaseTest(unittest.TestCase): with self.assertRaisesRegex(release.Refused, "the lock pins"): release.require_locked_overrides() + def test_fixed_release_preserves_later_commits_and_staged_source(self): + base = git(self.root, "rev-parse", "HEAD").strip() + peer = self.commit({"src/main.zi": "peer committed\n"}, "Peer feature") + (self.root / "src/main.zi").write_text("peer staged\n") + git(self.root, "add", "src/main.zi") + (self.root / "docs/notes.md").write_text("peer unfinished\n") + receipt = self.root / "releases/phone-checks/3.0.0.json" + receipt.parent.mkdir(parents=True) + receipt.write_text('{"passed":true}\n') + + candidate = release.fixed_release_commit(base, "3.0.0", "Verified fixture") + + self.assertEqual(git(self.root, "show", candidate + ":src/main.zi"), "one\n") + self.assertEqual(git(self.root, "show", "HEAD:src/main.zi"), "peer committed\n") + self.assertEqual(git(self.root, "show", ":src/main.zi"), "peer staged\n") + self.assertEqual((self.root / "src/main.zi").read_text(), "peer staged\n") + self.assertEqual((self.root / "docs/notes.md").read_text(), "peer unfinished\n") + self.assertEqual(git(self.root, "show", candidate + ":releases/phone-checks/3.0.0.json"), + receipt.read_text()) + self.assertEqual(git(self.root, "log", "-1", "--format=%P").split(), [peer, candidate]) + self.assertEqual(git(self.root, "log", "-1", "--format=%an <%ae>", candidate).strip(), + "Waozi ") + self.assertEqual(git(self.root, "status", "--porcelain"), + " M docs/notes.md\nM src/main.zi\n") + + def test_fixed_release_appends_without_rewriting_history(self): + base = git(self.root, "rev-parse", "HEAD").strip() + receipt = self.root / "releases/phone-checks/3.0.0.json" + receipt.parent.mkdir(parents=True) + receipt.write_text('{"passed":true}\n') + candidate = release.fixed_release_commit(base, "3.0.0", "Verified fixture") + self.assertEqual(git(self.root, "rev-parse", "HEAD").strip(), candidate) + self.assertEqual(git(self.root, "log", "-1", "--format=%P").strip(), base) + self.assertEqual(git(self.root, "status", "--porcelain"), "") + class MotoWorkflowGateTest(unittest.TestCase): def check_run(self, jobs, *, head=None, path=".github/workflows/release.yml"):