Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
16 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
193 changes: 193 additions & 0 deletions .github/workflows/play-validation.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,193 @@
name: Experimental Play validation

# This verifies the experimental variant; passing does not imply Play policy approval.
on:
pull_request:
workflow_dispatch:

permissions:
contents: read

jobs:
private-report-receiver:
runs-on: ubuntu-latest
defaults:
run:
working-directory: services/play-report-worker
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '22'
- run: npm ci --no-audit --no-fund
- run: npm test
- run: npm run check:deploy
- run: npm run test:integration

validate:
runs-on: ubuntu-latest
timeout-minutes: 90
steps:
- uses: actions/checkout@v4
- uses: actions/setup-java@v4
with:
distribution: temurin
java-version: '17'
- uses: gradle/actions/setup-gradle@v4
- name: Test bundled runtime asset verification
run: |
python3 -m unittest discover -s scripts/tests -p 'test_prepare_play_runtime_assets.py'
python3 -m unittest discover -s scripts/tests -p 'test_prepare_play_apk_cache.py'
python3 -m unittest discover -s scripts/tests -p 'test_prepare_play_alpine_sources.py'
python3 -m unittest discover -s scripts/tests -p 'test_prepare_play_qemu_experiment.py'
python3 -m unittest discover -s scripts/tests -p 'test_check_play_guest_elf_alignment.py'
python3 -m unittest discover -s scripts/tests -p 'test_run_play_offline_device_tests.py'
python3 -m unittest discover -s scripts/tests -p 'test_generate_play_apk_inventory.py'
python3 scripts/generate_play_apk_inventory.py --check
- name: Static analysis, tests, lint, APK and AAB
env:
GITHUB_CLIENT_ID: ${{ vars.AND_CODE_GITHUB_CLIENT_ID }}
run: |
if [ -z "$GITHUB_CLIENT_ID" ]; then
echo '::warning::AND_CODE_GITHUB_CLIENT_ID is not set; GitHub sign-in and AI reports are unavailable in these artifacts.'
fi
# Concurrent Kotlin compilation of several flavors exhausted the hosted runner's heap.
./gradlew --max-workers=1 --no-parallel detektPlaySources spotlessCheck \
:app:assemblePlayDebug :app:assemblePlayRelease :app:bundlePlayRelease \
:app:testPlayDebugUnitTest :app:lintPlayDebug \
:app:testGithubDebugUnitTest :app:testFdroidDebugUnitTest \
:app:assemblePlayDebugAndroidTest :app:assembleGithubDebugAndroidTest :app:assembleFdroidDebugAndroidTest
- name: Verify Play-only instrumented test isolation
run: |
python3 - <<'PY'
from pathlib import Path
from zipfile import ZipFile
for flavor in ('play', 'github', 'fdroid'):
apk = Path(f'app/build/outputs/apk/androidTest/{flavor}/debug/app-{flavor}-debug-androidTest.apk')
with ZipFile(apk) as archive:
dex_files = [archive.read(name) for name in archive.namelist() if name.endswith('.dex')]
for test in (b'PlayBundledAssetsInstrumentedTest', b'PlayOfflineInstallInstrumentedTest'):
found = any(test in dex for dex in dex_files)
assert found == (flavor == 'play'), (flavor, test, found)
PY
- name: Inspect merged Play manifest
run: |
python3 - <<'PY'
import xml.etree.ElementTree as ET
path = 'app/build/intermediates/merged_manifests/playDebug/processPlayDebugManifest/AndroidManifest.xml'
root = ET.parse(path).getroot()
android = '{http://schemas.android.com/apk/res/android}'
assert root.attrib['package'] == 'com.yugahashimoto.andcode.play'
assert int(root.find('uses-sdk').attrib[android + 'targetSdkVersion']) >= 36
PY
unzip -p app/build/outputs/apk/play/debug/app-play-debug.apk assets/local-runtime-manifest.json | python3 -c 'import json, sys; assert json.load(sys.stdin)["port"] == 4107'
unzip -Z1 app/build/outputs/apk/play/debug/app-play-debug.apk > "$RUNNER_TEMP/play-apk-files.txt"
grep -Fx 'assets/play-runtime/arm64-v8a/alpine.tgz' "$RUNNER_TEMP/play-apk-files.txt"
grep -Fx 'assets/play-runtime/x86_64/alpine.tgz' "$RUNNER_TEMP/play-apk-files.txt"
grep -Fx 'assets/play-runtime/arm64-v8a/opencode.tgz' "$RUNNER_TEMP/play-apk-files.txt"
grep -Fx 'assets/play-runtime/x86_64/opencode.tgz' "$RUNNER_TEMP/play-apk-files.txt"
grep -Fx 'assets/play-runtime/arm64-v8a/apk-cache.tgz' "$RUNNER_TEMP/play-apk-files.txt"
grep -Fx 'assets/play-runtime/x86_64/apk-cache.tgz' "$RUNNER_TEMP/play-apk-files.txt"
python3 - <<'PY'
import hashlib, json, zipfile
manifest = json.load(open('app/src/play/assets/local-runtime-manifest.json'))
with zipfile.ZipFile('app/build/outputs/apk/play/debug/app-play-debug.apk') as apk:
apk_cache_hashes = json.loads(apk.read('assets/play-runtime/apk-cache-hashes.json'))
for abi in ('arm64-v8a', 'x86_64'):
for name, expected in (('alpine', manifest['architectures'][abi]['alpineSha256']),
('opencode', manifest['architectures'][abi]['openCodeSha256']),
('apk-cache', apk_cache_hashes[abi])):
path = f'assets/play-runtime/{abi}/{name}.tgz'
assert apk.getinfo(path).compress_type == zipfile.ZIP_STORED
data = apk.read(path)
assert hashlib.sha256(data).hexdigest() == expected
PY
- name: Verify release signing isolation
run: python3 -m unittest discover -s scripts/tests -p 'test_play_signing_isolation.py'
- name: Validate bundle with pinned bundletool
run: |
curl -fsSL --retry 3 -o "$RUNNER_TEMP/bundletool.jar" https://github.com/google/bundletool/releases/download/1.18.2/bundletool-all-1.18.2.jar
echo '378b5434cd1378bef6b2bc527b8c7f0ff2584b273830335bce54d6d0813c8584 '"$RUNNER_TEMP/bundletool.jar" | sha256sum -c -
java -jar "$RUNNER_TEMP/bundletool.jar" validate --bundle=app/build/outputs/bundle/playRelease/app-play-release.aab
- name: Check APK ZIP alignment
run: |
build_tools="$(find "$ANDROID_HOME/build-tools" -mindepth 1 -maxdepth 1 -type d | sort -V | tail -1)"
"$build_tools/zipalign" -c -P 16 -v 4 app/build/outputs/apk/play/debug/app-play-debug.apk
- name: Check ELF LOAD alignment
run: |
python3 -m unittest discover -s scripts/tests -p 'test_check_android_elf_alignment.py'
for artifact in app/build/outputs/apk/play/debug/app-play-debug.apk app/build/outputs/bundle/playRelease/app-play-release.aab; do
status=0
python3 scripts/check_android_elf_alignment.py --warn-elf32 "$artifact" > "$RUNNER_TEMP/$(basename "$artifact").elf.txt" || status=$?
cat "$RUNNER_TEMP/$(basename "$artifact").elf.txt"
if grep -q '^WARN ' "$RUNNER_TEMP/$(basename "$artifact").elf.txt"; then
echo "::warning::$artifact has 32-bit ELF segments below 16 KB; investigate 32-bit execution before release"
fi
if [ "$status" -ne 0 ]; then exit "$status"; fi
done
- name: Audit bundled Linux guest ELF alignment
run: |
python3 scripts/check_play_guest_elf_alignment.py \
--runtime build/generated/play-runtime-assets \
--cache build/generated/play-apk-cache-assets \
--output "$RUNNER_TEMP/play-guest-elf-alignment.json"
- name: Save experimental artifacts and reports
if: always()
uses: actions/upload-artifact@v4
with:
name: experimental-play-validation
path: |
app/build/outputs/apk/play/
app/build/outputs/bundle/playRelease/
app/build/reports/
app/build/intermediates/merged_manifests/playDebug/
${{ runner.temp }}/*.elf.txt
${{ runner.temp }}/play-guest-elf-alignment.json
if-no-files-found: warn

offline-runtime-x86-16k:
runs-on: ubuntu-latest
timeout-minutes: 90
steps:
- uses: actions/checkout@v4
- uses: actions/setup-java@v4
with:
distribution: temurin
java-version: '17'
- uses: gradle/actions/setup-gradle@v4
- name: Build Play APKs before disabling device networking
run: ./gradlew --max-workers=1 --no-parallel :app:assemblePlayDebug :app:assemblePlayDebugAndroidTest
- name: Prepare optional QEMU diagnostic, not shipped in the app
continue-on-error: true
run: python3 scripts/prepare_play_qemu_experiment.py --output build/play-qemu-experiment-x86
- name: Enable KVM access
run: |
echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules
sudo udevadm control --reload-rules
sudo udevadm trigger --name-match=kvm
- name: Check offline test runner syntax
run: bash -n scripts/run_play_offline_device_tests.sh
- name: Run offline setup on 16 KB x86_64 Android
uses: ReactiveCircus/android-emulator-runner@a421e43855164a8197daf9d8d40fe71c6996bb0d # v2
with:
api-level: 35
target: google_apis_ps16k
arch: x86_64
profile: pixel_2
disable-animations: true
emulator-options: -no-window -gpu swiftshader_indirect -no-audio -no-boot-anim
script: bash scripts/run_play_offline_device_tests.sh || { if [ -f build/play-qemu-experiment-x86/qemu-x86_64 ]; then bash scripts/run_play_qemu_experiment.sh || true; fi; exit 1; }
- name: Save offline test diagnostics
if: failure()
uses: actions/upload-artifact@v4
with:
name: play-x86-offline-failure
path: |
${{ runner.temp }}/play-offline-logcat.txt
${{ runner.temp }}/play-offline-instrumentation.txt
${{ runner.temp }}/qemu-experiment-version.txt
${{ runner.temp }}/qemu-experiment-install.txt
${{ runner.temp }}/qemu-experiment-native-probe.txt
${{ runner.temp }}/qemu-experiment-server.txt
${{ runner.temp }}/qemu-experiment-health.txt
if-no-files-found: ignore
11 changes: 11 additions & 0 deletions PRIVACY.md
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,17 @@ service's terms.

## 12. Contact

The experimental Play flavor offers an optional in-app report for an AI response. When an operator
configures the private report endpoint, the selected reason and the excerpt you explicitly enter are
sent to the operator through Cloudflare Workers and D1. The operator's report database deletes entries
approximately 90 days after receipt; Cloudflare may process the IP address and retain service or backup
records under its own terms. Reports are reviewed by the operator to improve safety. No account is
required. If the endpoint is not configured, the app instead offers a clearly labeled public GitHub
issue using your connected account; your GitHub username, reason and entered excerpt are public.
No conversation text, source files, attachments, or credentials are automatically included in either
mode. The app blocks some common credential patterns, but detection is incomplete: review the excerpt
and do not include personal information or secrets.

This project is maintained on GitHub at
[yuga-hashimoto/and-code](https://github.com/yuga-hashimoto/and-code). Open an issue there with
privacy questions or data-deletion requests related to this repository's code.
Loading
Loading