20 AI testers on 20 different phones, in parallel, on GitHub's free runners: Claude Code agents on iOS Simulators and Android emulators that find broken flows, translation, layout and accessibility bugs
Python accessibility-testingai-agentsai-testingandroidandroid-emulatorclaudeclaude-codee2e-testingexploratory-testingexpofluttergithub-actionsiosios-simulatorllmmobile-testingqareact-nativetest-automationui-testing
build_args input: extra arguments for the automatic build, like --dart-define for Flutter; keys in a BUILD_ARGS secret
Pierre RAFFALLI08fa4eaf4e88
diff --git a/.github/workflows/agent-testers.yml b/.github/workflows/agent-testers.ymlindex 53e4ef2..f111b55 100644--- a/.github/workflows/agent-testers.yml+++ b/.github/workflows/agent-testers.yml@@ -35,6 +35,9 @@ on:ios_app_path:description: Path of the Simulator .app produced by ios_builddefault: ""+ build_args:+ description: "Extra arguments for the automatic build, both platforms: --dart-define=API_URL=https://... for Flutter, Gradle and xcodebuild arguments for the others. Public on a public repo: put keys in the BUILD_ARGS secret"+ default: ""source_repo:description: owner/name of the app repo (empty = this repo)default: ""@@ -115,6 +118,8 @@ jobs:env:APP_DIR: ${{ inputs.source_repo != '' && format('src/{0}', inputs.app_dir) || inputs.app_dir }}BUILD_COMMAND: ${{ inputs.android_build }}+ BUILD_ARGS: ${{ inputs.build_args }}+ BUILD_ARGS_SECRET: ${{ secrets.BUILD_ARGS }}ARTIFACT: ${{ inputs.apk_path }}run: bash scripts/build/android.sh "$APP_DIR" "${{ inputs.framework }}"- name: Encrypt APK@@ -161,6 +166,8 @@ jobs:env:APP_DIR: ${{ inputs.source_repo != '' && format('src/{0}', inputs.app_dir) || inputs.app_dir }}BUILD_COMMAND: ${{ inputs.ios_build }}+ BUILD_ARGS: ${{ inputs.build_args }}+ BUILD_ARGS_SECRET: ${{ secrets.BUILD_ARGS }}ARTIFACT: ${{ inputs.ios_app_path }}IOS_SCHEME: ${{ vars.IOS_SCHEME }} # optional repo variable, for projects with several schemesrun: bash scripts/build/ios.sh "$APP_DIR" "${{ inputs.framework }}"diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 2e52aae..912a25d 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -2,6 +2,7 @@## Unreleased+- **Build arguments**: the `build_args` input adds arguments to the automatic build of both platforms, like `--dart-define=API_URL=https://staging.example.com` for a Flutter app that needs its backend address (Gradle and xcodebuild arguments for the other frameworks). Keys go in a `BUILD_ARGS` secret, never printed ([scripts/build/args.sh](scripts/build/args.sh)).- **How each agent ended, on the run page**: finished, out of turns, usage limit, refused token or key, no API credit, rate limit or overloaded API, as an annotation with what to do next, plus turns and cost in the job summary. Nothing the agent wrote is printed, since public logs are public. `collect.sh` prints the same line for each agent ([scripts/agent_status.py](scripts/agent_status.py)).- **setup.sh**: asks again after an empty paste or a wrong choice, checks an API key with Anthropic before saving it (a free call, the key never on the command line), warns when a token does not look like one and when the repo is private, where macOS minutes count ten times. `setup.ps1` does the same, except the online check.- **Feedback**: issue forms to share how a run went on your app, and three questions about a hosted version for teams.diff --git a/README.es.md b/README.es.mdindex 0dcbac4..487f090 100644--- a/README.es.md+++ b/README.es.md@@ -102,6 +102,7 @@ gh workflow run agent-testers.yml -f source_repo=you/app -f app_id=com.you.app \| `model`, `llm_base_url` | `sonnet` por defecto, `haiku` para gastar menos, o cualquier API compatible con Anthropic con su clave en un secret `LLM_API_KEY` ([docs/cheaper-models.md](docs/cheaper-models.md)) || `framework` | `auto` (por defecto) o fuerza uno de los frameworks de abajo || `android_build` + `apk_path`, `ios_build` + `ios_app_path` | Tu propio comando de compilación, o la descarga de una app ya compilada (rutas relativas a `app_dir`) |+| `build_args` | Argumentos extra para la compilación automática de las dos plataformas, como `--dart-define=API_URL=https://staging.example.com` en Flutter (argumentos de Gradle y xcodebuild en los demás). Las claves van en un secreto `BUILD_ARGS`: en un repo público, las entradas de cada ejecución son públicas || `block_hosts` | Hosts de analítica bloqueados durante las pruebas || `record_video` | Grabación de pantalla de cada teléfono, cifrada con los informes |diff --git a/README.ja.md b/README.ja.mdindex 4c0cbdd..ccf282f 100644--- a/README.ja.md+++ b/README.ja.md@@ -102,6 +102,7 @@ gh workflow run agent-testers.yml -f source_repo=you/app -f app_id=com.you.app \| `model`、`llm_base_url` | デフォルトは `sonnet`。費用を抑えるなら `haiku`、または Anthropic 互換の任意の API(キーは `LLM_API_KEY` シークレットに設定)([docs/cheaper-models.md](docs/cheaper-models.md)) || `framework` | `auto`(デフォルト)、または下のフレームワークのいずれかを指定 || `android_build` + `apk_path`, `ios_build` + `ios_app_path` | 独自のビルドコマンド、またはビルド済みアプリのダウンロード(パスは `app_dir` からの相対パス) |+| `build_args` | 自動ビルドに追加する引数(両プラットフォーム共通)。Flutter なら `--dart-define=API_URL=https://staging.example.com`、それ以外は Gradle と xcodebuild の引数。公開リポジトリでは実行時の入力も公開されるので、キーは `BUILD_ARGS` シークレットに入れてください || `block_hosts` | テスト中にブロックする分析系のホスト || `record_video` | 各端末の画面録画(レポートと一緒に暗号化) |diff --git a/README.md b/README.mdindex e92b206..788543b 100644--- a/README.md+++ b/README.md@@ -101,6 +101,7 @@ gh workflow run agent-testers.yml -f source_repo=you/app -f app_id=com.you.app \| `model`, `llm_base_url` | `sonnet` by default, `haiku` to spend less, or any Anthropic-compatible API with its key in an `LLM_API_KEY` secret ([docs/cheaper-models.md](docs/cheaper-models.md)) || `framework` | `auto` (default) or force one of the frameworks below || `android_build` + `apk_path`, `ios_build` + `ios_app_path` | Your own build command, or a download of a prebuilt app (paths relative to `app_dir`) |+| `build_args` | Extra arguments for the automatic build of both platforms, like `--dart-define=API_URL=https://staging.example.com` for Flutter (Gradle and xcodebuild arguments for the others). Keys go in a `BUILD_ARGS` secret: run inputs are public on a public repo || `block_hosts` | Analytics hosts blocked during tests || `record_video` | Screen recording of each phone, encrypted with the reports |diff --git a/README.pt-BR.md b/README.pt-BR.mdindex 99941fd..cabaec7 100644--- a/README.pt-BR.md+++ b/README.pt-BR.md@@ -102,6 +102,7 @@ gh workflow run agent-testers.yml -f source_repo=you/app -f app_id=com.you.app \| `model`, `llm_base_url` | `sonnet` por padrão, `haiku` para gastar menos, ou qualquer API compatível com a Anthropic com a chave em um secret `LLM_API_KEY` ([docs/cheaper-models.md](docs/cheaper-models.md)) || `framework` | `auto` (padrão) ou force um dos frameworks abaixo || `android_build` + `apk_path`, `ios_build` + `ios_app_path` | Seu próprio comando de build, ou o download de um app já compilado (caminhos relativos a `app_dir`) |+| `build_args` | Argumentos extras para a compilação automática das duas plataformas, como `--dart-define=API_URL=https://staging.example.com` no Flutter (argumentos de Gradle e xcodebuild nos outros). Chaves vão num secret `BUILD_ARGS`: num repositório público, as entradas de cada execução são públicas || `block_hosts` | Hosts de analytics bloqueados durante os testes || `record_video` | Gravação de tela de cada celular, criptografada com os relatórios |diff --git a/README.zh-CN.md b/README.zh-CN.mdindex 8a66867..e34bdf7 100644--- a/README.zh-CN.md+++ b/README.zh-CN.md@@ -101,6 +101,7 @@ gh workflow run agent-testers.yml -f source_repo=you/app -f app_id=com.you.app \| `model`、`llm_base_url` | 默认 `sonnet`,想省钱用 `haiku`,也可以用任何兼容 Anthropic 接口的 API,密钥放在 `LLM_API_KEY` secret 里([docs/cheaper-models.md](docs/cheaper-models.md)) || `framework` | `auto`(默认),或强制使用下表中的某个框架 || `android_build` + `apk_path`, `ios_build` + `ios_app_path` | 你自己的构建命令,或下载一个预构建的应用(路径相对于 `app_dir`) |+| `build_args` | 自动构建时追加的参数,两个平台都生效:Flutter 用 `--dart-define=API_URL=https://staging.example.com`,其他框架是 Gradle 和 xcodebuild 的参数。公开仓库里每次运行的输入都是公开的,密钥请放进 `BUILD_ARGS` secret || `block_hosts` | 测试期间屏蔽的统计分析域名 || `record_video` | 每台手机的录屏,与报告一起加密 |diff --git a/plugins/mobile-agent-testers/skills/setup/SKILL.md b/plugins/mobile-agent-testers/skills/setup/SKILL.mdindex 49483dd..1c8d77d 100644--- a/plugins/mobile-agent-testers/skills/setup/SKILL.md+++ b/plugins/mobile-agent-testers/skills/setup/SKILL.md@@ -69,7 +69,9 @@ React Native, Capacitor/Ionic, Kotlin Multiplatform, native Kotlin/Java andSwift/Objective-C, .NET MAUI (beta). Force it with `-f framework=<name>` ifdetection is wrong. For anything else, or to test an app that is alreadybuilt, set `android_build` + `apk_path` and `ios_build` + `ios_app_path`-(a build command or a download; paths relative to `app_dir`). For a native+(a build command or a download; paths relative to `app_dir`). If the automatic+build only needs extra arguments, like Flutter's `--dart-define=API_URL=...`, put them+in `-f build_args=...`, and keys in a `BUILD_ARGS` secret (run inputs are public). For a nativeiOS project with several schemes, set the repo variable: `gh variable set IOS_SCHEME --body <scheme>`.## 4. Personas and briefdiff --git a/scripts/build/android.sh b/scripts/build/android.shindex 380034c..465eca9 100755--- a/scripts/build/android.sh+++ b/scripts/build/android.sh@@ -1,7 +1,8 @@#!/usr/bin/env bash# Builds an APK that installs on an emulator, for any supported framework.# Usage: bash scripts/build/android.sh <app dir> <framework|auto>-# Env (optional): BUILD_COMMAND + ARTIFACT (custom build or prebuilt app)+# Env (optional): BUILD_COMMAND + ARTIFACT (custom build or prebuilt app),+# BUILD_ARGS / BUILD_ARGS_SECRET (extra arguments for the automatic build: scripts/build/args.sh)# Output: $GITHUB_WORKSPACE/app.apk. All tool output goes to results/build-android.logset -uo pipefailROOT=${GITHUB_WORKSPACE:-$PWD}; mkdir -p "$ROOT/results"; LOG="$ROOT/results/build-android.log"@@ -13,32 +14,34 @@ fail() { echo "::error::Android build failed ($FW): see the encrypted build log"npm_install() { [ -f package.json ] && { q npm ci || q npm install; }; return 0; }apk() { find "${1:-.}" -path "*build/outputs/apk/*$2*/*.apk" -not -name '*androidTest*' -not -name '*unaligned*' | head -1; }+. "$ROOT/scripts/build/args.sh"; BUILD_ARGV=()if [ -n "${BUILD_COMMAND:-}" ]; then+ [ -n "${BUILD_ARGS:-}${BUILD_ARGS_SECRET:-}" ] && echo "::warning::build_args is ignored with a custom android_build command"FW=custom; q bash -c "$BUILD_COMMAND" || fail; OUT=${ARTIFACT:?ARTIFACT (path of the .apk) is required with BUILD_COMMAND}-else case "$FW" in+else build_args || exit 1; case "$FW" influtter). "$ROOT/scripts/build/flutter_sdk.sh"; flutter_sdk || failq flutter pub get || fail# Debug, like the iOS Simulator build: no signing key needed, a faster build,# and Flutter draws its overflow warnings on screen, where the agents see them- q flutter build apk --debug --target-platform android-x64 || fail+ q flutter build apk --debug --target-platform android-x64 ${BUILD_ARGV[@]+"${BUILD_ARGV[@]}"} || failOUT=$(ls build/app/outputs/flutter-apk/*debug*.apk 2>/dev/null | head -1) ;;expo)npm_install; q env CI=1 npx expo prebuild --platform android --no-install || fail- (cd android && q ./gradlew assembleRelease -PreactNativeArchitectures=x86_64 --build-cache) || fail; OUT=$(apk android release) ;;+ (cd android && q ./gradlew assembleRelease -PreactNativeArchitectures=x86_64 --build-cache ${BUILD_ARGV[@]+"${BUILD_ARGV[@]}"}) || fail; OUT=$(apk android release) ;;react-native)- npm_install; (cd android && q ./gradlew assembleRelease -PreactNativeArchitectures=x86_64 --build-cache) || fail; OUT=$(apk android release) ;;+ npm_install; (cd android && q ./gradlew assembleRelease -PreactNativeArchitectures=x86_64 --build-cache ${BUILD_ARGV[@]+"${BUILD_ARGV[@]}"}) || fail; OUT=$(apk android release) ;;capacitor)# Release APKs are unsigned in a fresh Capacitor project: the debug APK is self-containednpm_install; q npm run build --if-present; q npx cap sync android || fail- (cd android && q ./gradlew assembleDebug --build-cache) || fail; OUT=$(apk android debug) ;;+ (cd android && q ./gradlew assembleDebug --build-cache ${BUILD_ARGV[@]+"${BUILD_ARGV[@]}"}) || fail; OUT=$(apk android debug) ;;maui)TF=$(grep -ohE 'net[0-9.]+-android' ./*.csproj | head -1)- q dotnet workload install maui-android && q dotnet publish -f "$TF" -c Release -p:AndroidPackageFormat=apk -o "$RUNNER_TEMP/maui" || fail+ q dotnet workload install maui-android && q dotnet publish -f "$TF" -c Release -p:AndroidPackageFormat=apk -o "$RUNNER_TEMP/maui" ${BUILD_ARGV[@]+"${BUILD_ARGV[@]}"} || failOUT=$(find "$RUNNER_TEMP/maui" -name '*-Signed.apk' | head -1) ;;kmp|native)D=.; [ -x ./gradlew ] || D=android- (cd "$D" && chmod +x gradlew && q ./gradlew assembleDebug --build-cache) || fail; OUT=$(apk "$D" debug) ;;+ (cd "$D" && chmod +x gradlew && q ./gradlew assembleDebug --build-cache ${BUILD_ARGV[@]+"${BUILD_ARGV[@]}"}) || fail; OUT=$(apk "$D" debug) ;;*) echo "::error::Unknown framework $FW"; exit 1 ;;esac; fi[ -n "${OUT:-}" ] && [ -f "$OUT" ] || { echo "::error::No APK found after the $FW build"; exit 1; }diff --git a/scripts/build/args.sh b/scripts/build/args.shnew file mode 100644index 0000000..6278fa6--- /dev/null+++ b/scripts/build/args.sh@@ -0,0 +1,22 @@+# shellcheck shell=bash+# Sourced by the build scripts. Extra arguments for the automatic build, from the+# build_args input and the BUILD_ARGS secret (inputs of a public repo's runs are+# public: keys go in the secret). They are added to the build command of both+# platforms: `flutter build` for Flutter (--dart-define=API_URL=..., or+# --dart-define-from-file=config.json), Gradle and xcodebuild for the others, and+# dotnet for .NET MAUI. Quotes work like in a shell: --dart-define="NAME=two words".+# Sets BUILD_ARGV. Expand it as ${BUILD_ARGV[@]+"${BUILD_ARGV[@]}"}: an empty array+# with set -u breaks the bash 3.2 of macOS otherwise.+build_args() {+ local all="${BUILD_ARGS:-} ${BUILD_ARGS_SECRET:-}" out a+ BUILD_ARGV=()+ case "$all" in *[![:space:]]*) ;; *) return 0 ;; esac+ # never print the values: the secret part must stay out of the public log+ out=$(python3 -c 'import shlex, sys+for a in shlex.split(sys.argv[1]):+ print(a)' "$all" 2>/dev/null) || { echo "::error::build_args or the BUILD_ARGS secret has unbalanced quotes"; return 1; }+ while IFS= read -r a; do [ -n "$a" ] && BUILD_ARGV+=("$a"); done <<EOF+$out+EOF+ echo "Extra build arguments: ${#BUILD_ARGV[@]}"+}diff --git a/scripts/build/ios.sh b/scripts/build/ios.shindex bc86ce9..ba64925 100755--- a/scripts/build/ios.sh+++ b/scripts/build/ios.sh@@ -1,7 +1,8 @@#!/usr/bin/env bash# Builds an iOS Simulator .app (arm64, unsigned) for any supported framework.# Usage: bash scripts/build/ios.sh <app dir> <framework|auto>-# Env (optional): BUILD_COMMAND + ARTIFACT (custom build or prebuilt .app), IOS_SCHEME+# Env (optional): BUILD_COMMAND + ARTIFACT (custom build or prebuilt .app), IOS_SCHEME,+# BUILD_ARGS / BUILD_ARGS_SECRET (extra arguments for the automatic build: scripts/build/args.sh)# Output: $GITHUB_WORKSPACE/app-ios.tgz. All tool output goes to results/build-ios.logset -uo pipefailROOT=${GITHUB_WORKSPACE:-$PWD}; mkdir -p "$ROOT/results"; LOG="$ROOT/results/build-ios.log"@@ -26,17 +27,19 @@ print(base if base in sc else sc[0])" "$c")}echo "Scheme: $s"q xcodebuild "$@" -scheme "$s" -configuration "${IOS_CONFIGURATION:-Release}" -sdk iphonesimulator \-destination 'generic/platform=iOS Simulator' -derivedDataPath "$RUNNER_TEMP/dd" \- EXCLUDED_ARCHS=x86_64 ONLY_ACTIVE_ARCH=YES CODE_SIGNING_ALLOWED=NO build || fail+ EXCLUDED_ARCHS=x86_64 ONLY_ACTIVE_ARCH=YES CODE_SIGNING_ALLOWED=NO ${BUILD_ARGV[@]+"${BUILD_ARGV[@]}"} build || failOUT=$(find "$RUNNER_TEMP/dd/Build/Products" -maxdepth 2 -path '*iphonesimulator/*.app' -not -name '*Tests*' | head -1)}+. "$ROOT/scripts/build/args.sh"; BUILD_ARGV=()if [ -n "${BUILD_COMMAND:-}" ]; then+ [ -n "${BUILD_ARGS:-}${BUILD_ARGS_SECRET:-}" ] && echo "::warning::build_args is ignored with a custom ios_build command"FW=custom; q bash -c "$BUILD_COMMAND" || fail; OUT=${ARTIFACT:?ARTIFACT (path of the .app) is required with BUILD_COMMAND}-else case "$FW" in+else build_args || exit 1; case "$FW" influtter). "$ROOT/scripts/build/flutter_sdk.sh"; flutter_sdk || fail# Flutter only builds debug for the Simulator; it runs standalone there- q flutter pub get && q flutter build ios --simulator --debug || fail+ q flutter pub get && q flutter build ios --simulator --debug ${BUILD_ARGV[@]+"${BUILD_ARGV[@]}"} || failOUT=$(find build/ios/iphonesimulator -maxdepth 1 -name '*.app' | head -1) ;;expo)npm_install; q env CI=1 npx expo prebuild --platform ios --no-install || fail@@ -48,7 +51,7 @@ else case "$FW" in[ -f ios/App/Podfile ] && (cd ios/App && q pod install); xcbuild ios/App ;;maui)TF=$(grep -ohE 'net[0-9.]+-ios' ./*.csproj | head -1)- q dotnet workload install maui-ios && q dotnet build -f "$TF" -c Debug -p:RuntimeIdentifier=iossimulator-arm64 || fail+ q dotnet workload install maui-ios && q dotnet build -f "$TF" -c Debug -p:RuntimeIdentifier=iossimulator-arm64 ${BUILD_ARGV[@]+"${BUILD_ARGV[@]}"} || failOUT=$(find bin -path '*iossimulator-arm64*' -name '*.app' -maxdepth 6 | head -1) ;;kmp)xcbuild "$(dirname "$(find . -maxdepth 3 -name '*.xcodeproj' -not -path '*/Pods/*' | head -1)")" ;;diff --git a/skills/mobile-agent-testers/SKILL.md b/skills/mobile-agent-testers/SKILL.mdindex 1cc6065..4b59fb3 100644--- a/skills/mobile-agent-testers/SKILL.md+++ b/skills/mobile-agent-testers/SKILL.md@@ -69,7 +69,9 @@ React Native, Capacitor/Ionic, Kotlin Multiplatform, native Kotlin/Java andSwift/Objective-C, .NET MAUI (beta). Force it with `-f framework=<name>` ifdetection is wrong. For anything else, or to test an app that is alreadybuilt, set `android_build` + `apk_path` and `ios_build` + `ios_app_path`-(a build command or a download; paths relative to `app_dir`). For a native+(a build command or a download; paths relative to `app_dir`). If the automatic+build only needs extra arguments, like Flutter's `--dart-define=API_URL=...`, put them+in `-f build_args=...`, and keys in a `BUILD_ARGS` secret (run inputs are public). For a nativeiOS project with several schemes, set the repo variable: `gh variable set IOS_SCHEME --body <scheme>`.## 4. Personas and briefdiff --git a/tests/test_build_args.py b/tests/test_build_args.pynew file mode 100644index 0000000..3444354--- /dev/null+++ b/tests/test_build_args.py@@ -0,0 +1,104 @@+"""build_args input and BUILD_ARGS secret, offline: scripts/build/args.sh, then the+automatic Flutter builds of both platforms with a stand-in for flutter."""+import os+import shutil+import subprocess+import tempfile+import unittest+from pathlib import Path++ROOT = Path(__file__).resolve().parent.parent+FAKE_FLUTTER = """#!/usr/bin/env bash+printf '%s\\n' "$@" > "$FAKE_LOG.$1.$2"+case "$1 $2" in+ "build apk") mkdir -p build/app/outputs/flutter-apk && echo apk > build/app/outputs/flutter-apk/app-debug.apk ;;+ "build ios") mkdir -p build/ios/iphonesimulator/Runner.app ;;+esac+"""+++def parse(build_args="", secret=""):+ script = ('set -u; . scripts/build/args.sh; build_args; code=$?; '+ 'echo "code=$code"; for a in ${BUILD_ARGV[@]+"${BUILD_ARGV[@]}"}; do echo "arg=$a"; done')+ env = dict(os.environ, BUILD_ARGS=build_args, BUILD_ARGS_SECRET=secret)+ out = subprocess.run(["bash", "-c", script], cwd=ROOT, env=env, capture_output=True, text=True).stdout+ args = [l[4:] for l in out.splitlines() if l.startswith("arg=")]+ shown = "\n".join(l for l in out.splitlines() if not l.startswith("arg="))+ return args, shown+++class Parse(unittest.TestCase):+ def test_input_then_secret_with_shell_quotes(self):+ args, shown = parse('--dart-define=API_URL=https://staging.example.com --dart-define="TITLE=two words"',+ "--dart-define=KEY=s3cret")+ self.assertEqual(args, ["--dart-define=API_URL=https://staging.example.com",+ "--dart-define=TITLE=two words", "--dart-define=KEY=s3cret"])+ self.assertIn("Extra build arguments: 3", shown)+ self.assertIn("code=0", shown)+ self.assertNotIn("s3cret", shown)++ def test_nothing_set_is_fine_under_set_u(self):+ args, shown = parse("", " ")+ self.assertEqual(args, [])+ self.assertIn("code=0", shown)+ self.assertNotIn("Extra build arguments", shown)++ def test_unbalanced_quotes_fail_without_showing_values(self):+ args, shown = parse("", '--dart-define="KEY=s3cret')+ self.assertIn("code=1", shown)+ self.assertIn("unbalanced quotes", shown)+ self.assertNotIn("s3cret", shown)+++class FlutterBuilds(unittest.TestCase):+ def setUp(self):+ self.root = Path(tempfile.mkdtemp())+ shutil.copytree(ROOT / "scripts" / "build", self.root / "scripts" / "build")+ (self.root / "app").mkdir()+ (self.root / "app" / "pubspec.yaml").write_text("name: app\n")+ bin_dir = self.root / "bin"+ bin_dir.mkdir()+ (bin_dir / "flutter").write_text(FAKE_FLUTTER)+ (bin_dir / "flutter").chmod(0o755)+ self.log = self.root / "flutter-args"+ self.env = dict(os.environ, PATH=f"{bin_dir}:{os.environ['PATH']}", GITHUB_WORKSPACE=str(self.root),+ RUNNER_TEMP=str(self.root / "tmp"), FAKE_LOG=str(self.log),+ BUILD_ARGS="--dart-define=API_URL=https://staging.example.com",+ BUILD_ARGS_SECRET="--dart-define=KEY=s3cret")++ def build(self, platform, **env):+ return subprocess.run(["bash", f"scripts/build/{platform}.sh", "app", "auto"], cwd=self.root,+ env=dict(self.env, **env), capture_output=True, text=True)++ def test_android(self):+ proc = self.build("android")+ self.assertEqual(proc.returncode, 0, proc.stdout + proc.stderr)+ args = Path(f"{self.log}.build.apk").read_text().split("\n")+ self.assertIn("--dart-define=API_URL=https://staging.example.com", args)+ self.assertIn("--dart-define=KEY=s3cret", args)+ self.assertTrue((self.root / "app.apk").exists())+ self.assertNotIn("s3cret", proc.stdout + proc.stderr)++ def test_ios(self):+ proc = self.build("ios")+ self.assertEqual(proc.returncode, 0, proc.stdout + proc.stderr)+ args = Path(f"{self.log}.build.ios").read_text().split("\n")+ self.assertEqual(args[:3], ["build", "ios", "--simulator"])+ self.assertIn("--dart-define=KEY=s3cret", args)+ self.assertTrue((self.root / "app-ios.tgz").exists())++ def test_no_extra_arguments(self):+ proc = self.build("android", BUILD_ARGS="", BUILD_ARGS_SECRET="")+ self.assertEqual(proc.returncode, 0, proc.stdout + proc.stderr)+ args = [a for a in Path(f"{self.log}.build.apk").read_text().split("\n") if a]+ self.assertEqual(args, ["build", "apk", "--debug", "--target-platform", "android-x64"])++ def test_ignored_with_a_custom_build_command(self):+ (self.root / "app" / "prebuilt.apk").write_text("apk")+ proc = self.build("android", BUILD_COMMAND="true", ARTIFACT="prebuilt.apk")+ self.assertEqual(proc.returncode, 0, proc.stdout + proc.stderr)+ self.assertIn("::warning::build_args is ignored with a custom android_build command", proc.stdout)+++if __name__ == "__main__":+ unittest.main()