Reuse fixed release-ready outputs and one shared build cache

Custom RELEASE_READY_OUTPUT names now map to build/release-ready, and
only build/release-ready-phone keeps a separate purpose, so task and
version names no longer leave a new folder per run. Both share
build/release-ready/home under an exclusive cache lease held through
container exit. The release command uses the same mapping. Phone
installs take a lock, select only an APK this run built and reuse the
default signed path. Nothing prunes existing output.
This commit is contained in:
waozi committed 2026-11-01 18:41:58 -03:00
1 parent 8408d63f84
commit b8bfb7ff1c
9 files changed
+416 -32

No files matched your search

+19
View File
@@ -0,0 +1,19 @@
#!/usr/bin/env python3
"""Validate and map bounded outputs for release-ready and the release gate."""
import re
import sys
def release_ready_output(requested="build/release-ready"):
if not re.fullmatch(r"build/release-ready(?:-[a-z0-9][a-z0-9-]*)?", requested):
raise ValueError("RELEASE_READY_OUTPUT must be build/release-ready or build/release-ready-NAME")
if requested == "build/release-ready-phone":
return requested
return "build/release-ready"
if __name__ == "__main__":
try:
print(release_ready_output(sys.argv[1]))
except ValueError as error:
sys.exit(str(error))
+19 -4
View File
@@ -27,6 +27,15 @@ keystore=${ANDROID_DEBUG_KEYSTORE:-$HOME/.config/.android/debug.keystore}
android_sdk=${ANDROID_SDK_ROOT:-${ANDROID_HOME:-$HOME/Android/Sdk}}
output=build/release-ready-phone
# Serialize the complete build/sign/install operation, including --apk calls.
# This lock lives outside reusable output, so no run can replace its inode.
mkdir -p .cache/release-ready
exec 7>.cache/release-ready/phone-install.lock
if ! flock -n 7; then
echo "phone-install: another phone install is running" >&2
exit 1
fi
device=pixel
revision=HEAD
apk=""
@@ -62,6 +71,10 @@ phone() {
}
abi=$(phone shell getprop ro.product.cpu.abi | tr -d '\r')
[ -n "$abi" ] || fail "could not read the phone's ABI"
case "$abi" in
arm64-v8a|armeabi-v7a|x86|x86_64) ;;
*) fail "unsupported Android ABI: $abi" ;;
esac
echo "phone-install: $(phone shell getprop ro.product.model | tr -d '\r') ($serial, $abi)"
if [ "$device" = moto ]; then
@@ -75,11 +88,13 @@ fi
if [ -z "$apk" ]; then
commit=$(git rev-parse "$revision^{commit}")
echo "phone-install: building $(git log -1 --format='%h %s' "$commit")"
# A failed build must not leave an earlier APK to install.
find "$output/build/android" -name "app*-$abi-debug.apk" -delete 2>/dev/null || true
# set -e stops a failed build before any earlier APK can be installed.
# Select only APKs copied by this run; do not delete another build's files.
started=.cache/release-ready/phone-build-start
touch "$started"
RELEASE_READY_REVISION=$commit RELEASE_READY_OUTPUT=$output RELEASE_READY_INCREMENTAL=1 \
sh scripts/release-ready.sh ANDROID_ABI="$abi" android-debug
apk=$(find "$output/build/android" -name "app*-$abi-debug.apk" | head -n 1)
apk=$(find "$output/build/android" -name "app*-$abi-debug.apk" -newer "$started" | head -n 1)
[ -f "$apk" ] || fail "the build left no app-$abi-debug.apk in $output/build/android"
fi
[ -f "$apk" ] || fail "no APK at $apk"
@@ -88,7 +103,7 @@ fi
# with this machine's.
[ -f "$keystore" ] || fail "no debug keystore at $keystore"
build_tools=$(ls -d "$android_sdk"/build-tools/* | sort -V | tail -n 1)
signed=build/phone-install/$(basename "$apk" .apk)-signed.apk
signed=build/phone-install/app-$abi-debug-signed.apk
mkdir -p build/phone-install
"$build_tools/zipalign" -f -p 4 "$apk" "$signed.aligned"
"$build_tools/apksigner" sign --ks "$keystore" --ks-pass pass:android \
+45 -21
View File
@@ -10,7 +10,7 @@
# edits and new files in the canonical checkout cannot enter the tests. Peers
# keep working on master; nothing this container writes reaches their checkout.
# Packages use the fixed lock without local overrides or untracked secrets.
# Build outputs stay in build/release-ready/ (or RELEASE_READY_OUTPUT); a run
# Build outputs reuse build/release-ready/ or build/release-ready-phone/; a run
# takes about 90 minutes.
#
# Covered: ci.yml Secret Scan, Package URLs, large-file guard, all three test
@@ -30,16 +30,46 @@ set -eu
root=$(CDPATH= cd -- "$(dirname -- "$0")/.." && pwd)
cd "$root"
# RELEASE_READY_OUTPUT gives a second run its own build/release-ready-NAME
# outputs, so a fixed-commit build can run beside an active check.
output=${RELEASE_READY_OUTPUT:-build/release-ready}
case "$output" in
build/release-ready|build/release-ready-[a-z0-9]*) ;;
*) echo "release-ready: RELEASE_READY_OUTPUT must be build/release-ready-NAME" >&2; exit 2 ;;
esac
case "$output" in
*[!a-z0-9/-]*) echo "release-ready: RELEASE_READY_OUTPUT must be build/release-ready-NAME" >&2; exit 2 ;;
esac
# Legacy task/version names are aliases, never additional permanent outputs.
requested_output=${RELEASE_READY_OUTPUT:-build/release-ready}
output=$(python3 scripts/check-build-layout.py "$requested_output") || exit 2
if [ "$output" != "$requested_output" ]; then
echo "release-ready: $requested_output reuses $output"
fi
# Lock before writing any output. Never follow an output symlink into another
# purpose's files. There is deliberately no scan or cleanup of old folders.
for directory in build "$output" "$output/build" build/release-ready build/release-ready/home; do
if [ -L "$directory" ]; then
echo "release-ready: refusing symlink $directory" >&2
exit 2
fi
done
mkdir -p "$output"
if [ -L "$output/lock" ]; then
echo "release-ready: refusing symlink $output/lock" >&2
exit 2
fi
exec 9>"$output/lock"
if ! flock -n 9; then
echo "release-ready: another run is using $output" >&2
exit 1
fi
# Every fixed-commit run uses the same home, including Ziran's URL+commit
# source cache and Gradle's downloads. Hold this lease until Podman exits:
# package tools may repair sources and build inside their cached checkouts.
# Different output purposes can queue, but cannot mutate this cache together.
cache="$root/build/release-ready"
mkdir -p "$cache"
if [ -L "$cache/cache.lock" ]; then
echo "release-ready: refusing symlink $cache/cache.lock" >&2
exit 2
fi
exec 8>"$cache/cache.lock"
echo "release-ready: waiting for the shared build cache"
flock 8
mkdir -p "$cache/home" "$output/build"
commit=$(git rev-parse "${RELEASE_READY_REVISION:-HEAD}^{commit}")
image_tag=$({
git show "$commit:.github/local-ci/Containerfile"
@@ -126,7 +156,6 @@ else
printf "\nrelease-ready: every covered local CI job passed\n"
fi'
mkdir -p "$output/build" "$output/home"
sync_server=""
sync_mount_source="$root/$output/sync-unused"
mkdir -p "$sync_mount_source"
@@ -137,13 +166,6 @@ if [ "$#" -eq 0 ]; then
git -C "$sync_server" cat-file -e "$sync_commit^{commit}"
sync_mount_source=$sync_server
fi
# One run at a time: runs share build/release-ready/.
exec 9>"$output/lock"
if ! flock -n 9; then
echo "release-ready: another run is using $output" >&2
exit 1
fi
# Containers here need no session keyring. Creating one counts against the
# account's kernel key quota (200 keys), which long-lived sessions fill, and
# a full quota stops every container from starting.
@@ -183,10 +205,12 @@ podman run --rm --pull=never --userns=keep-id \
$dns_option \
-v "$root:/src:O" \
-v "$root/$output/build:/src/build" \
-v "$root/$output/home:/home/ubuntu" \
-v "$cache/home:/home/ubuntu" \
-v "$sync_mount_source:/sync-server:O" \
$android_mount \
-e HOME=/home/ubuntu -e CI=true -e RELEASE_READY_COMMIT="$commit" \
-e HOME=/home/ubuntu -e XDG_CACHE_HOME=/home/ubuntu/.cache \
-e GRADLE_USER_HOME=/home/ubuntu/.gradle \
-e CI=true -e RELEASE_READY_COMMIT="$commit" \
-e RELEASE_READY_INCREMENTAL="$incremental" \
-e RELEASE_READY_SNAPSHOT="$snapshot" \
-w /src "$image" sh -c "$inside" release-ready "$@" || status=$?
+7 -6
View File
@@ -35,12 +35,6 @@ import tempfile
import time
ROOT = Path(__file__).resolve().parents[1]
# RELEASE_READY_OUTPUT names a separate release-ready run's outputs, as in
# scripts/release-ready.sh.
READY_OUTPUT = os.environ.get("RELEASE_READY_OUTPUT", "build/release-ready")
if not re.fullmatch(r"build/release-ready(-[a-z0-9][a-z0-9-]*)?", READY_OUTPUT):
raise SystemExit("RELEASE_READY_OUTPUT must be build/release-ready-NAME")
READY_STAMP = ROOT / READY_OUTPUT / "stamp.json"
SUBJECT = "Release Inner Breeze {version}"
# What ./update_version.sh writes; only these may join the release commit.
VERSION_FILES = ("droid/app/build.gradle", "src/core/version.h", "src/core/version.zi", "windows/inbe.rc",
@@ -57,6 +51,13 @@ def load(name, path):
phone_check = load("phone_check", "scripts/phone-check.py")
gate = load("check_phone_check", "scripts/check-phone-check.py")
build_layout = load("build_layout", "scripts/check-build-layout.py")
try:
READY_OUTPUT = build_layout.release_ready_output(
os.environ.get("RELEASE_READY_OUTPUT", "build/release-ready"))
except ValueError as error:
raise SystemExit(str(error)) from error
READY_STAMP = ROOT / READY_OUTPUT / "stamp.json"
class Refused(Exception):