From 9c74dec866c95f412c0680780925793ac7bf0e7c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20G=C3=BCttler?= Date: Mon, 27 Apr 2026 07:13:13 +0200 Subject: [PATCH] perf: speed up deploy-android via MobSF pre-warm and parallel integration tests Start MobSF as a dep of build-android (_mobsf-start) so it warms up during the APK build instead of blocking afterwards (saves up to 90 s). Add _integrations task to run integration and integration-ui in parallel since they use random Stalwart ports and different Flutter build targets. Also add `docker rm ... || true` before `docker run` in both _mobsf-start and mobsf_scan.sh to handle stopped-but-not-removed containers gracefully. Co-Authored-By: Claude Sonnet 4.6 --- Taskfile.yml | 25 ++++++++++++++++++++++--- done.md | 12 ++++++++++++ next.md | 4 ---- scripts/mobsf_scan.sh | 1 + 4 files changed, 35 insertions(+), 7 deletions(-) diff --git a/Taskfile.yml b/Taskfile.yml index fe70527..e140867 100644 --- a/Taskfile.yml +++ b/Taskfile.yml @@ -133,9 +133,24 @@ tasks: Android platform 34 or higher not found. Install it with: ${ANDROID_HOME:-$HOME/Android/Sdk}/cmdline-tools/latest/bin/sdkmanager "build-tools;34.0.0" "platforms;android-34" + _mobsf-start: + internal: true + run: once + cmds: + - cmd: | + if ! docker ps -q --filter name=mobsf-sharedinbox | grep -q .; then + docker rm mobsf-sharedinbox 2>/dev/null || true + docker pull -q opensecurity/mobile-security-framework-mobsf:latest >/dev/null 2>&1 || true + docker run -d --rm \ + --name mobsf-sharedinbox \ + -p 8000:8000 \ + -e MOBSF_API_KEY=sharedinbox-dev \ + opensecurity/mobile-security-framework-mobsf:latest >/dev/null + fi + build-android: desc: Build a release APK and run a MobSF security scan - deps: [_preflight, _android-sdk-check, _pub-get] + deps: [_preflight, _android-sdk-check, _pub-get, _mobsf-start] cmds: - ANDROID_HOME=${ANDROID_HOME:-$HOME/Android/Sdk} fvm flutter build apk --release --no-pub | grep -Ev "was tree-shaken|Tree-shaking can be disabled" - scripts/mobsf_scan.sh @@ -177,10 +192,14 @@ tasks: desc: Pre-commit checks — analyze + unit tests + widget tests (no build, no integration) deps: [analyze, test, test-widget] + _integrations: + internal: true + run: once + deps: [integration, integration-ui] + check: desc: Full check suite — unit tests first, then integration (merges coverage), then gate deps: [analyze, test-widget, build-linux, test] cmds: - - task: integration - - task: integration-ui + - task: _integrations - task: coverage diff --git a/done.md b/done.md index 5f57573..8b9e727 100644 --- a/done.md +++ b/done.md @@ -6,6 +6,18 @@ Tasks get moved from next.md to done.md ## Tasks +## Speed up `task deploy-android` + +Two parallelism improvements: + +- `_integrations` internal task: runs `integration` and `integration-ui` in parallel (they use + random Stalwart ports and different Flutter build targets so there is no conflict). +- `_mobsf-start` internal task: starts the MobSF Docker container as a dep of `build-android`, + so it warms up concurrently with the APK build instead of blocking for up to 90 s afterwards. +- `scripts/mobsf_scan.sh`: added `docker rm $CONTAINER_NAME 2>/dev/null || true` before + `docker run` to handle stopped-but-not-yet-removed containers (same fix applied to the new + `_mobsf-start` task). + ## Android E2E test verifies APK before deploy `task deploy-android` now runs `integration-android` (the full Android E2E test) before diff --git a/next.md b/next.md index 1ce6351..4246423 100644 --- a/next.md +++ b/next.md @@ -18,10 +18,6 @@ Then commit. ## Tasks -make `task deploy-android` faster. More concurrent tasks? Caching? - ---- - I opened an account. How to get back to the list of accounts? I saw no way to do that. diff --git a/scripts/mobsf_scan.sh b/scripts/mobsf_scan.sh index a0073ef..2c595b6 100755 --- a/scripts/mobsf_scan.sh +++ b/scripts/mobsf_scan.sh @@ -24,6 +24,7 @@ command -v docker >/dev/null 2>&1 || { echo "docker not found — install Docker # Start MobSF if not already running. if ! docker ps --format '{{.Names}}' 2>/dev/null | grep -q "^${CONTAINER_NAME}$"; then echo "Starting MobSF Docker container (this may take a moment on first run)..." + docker rm "$CONTAINER_NAME" 2>/dev/null || true # Pull quietly first so progress-bar noise doesn't overwrite other output. docker pull -q opensecurity/mobile-security-framework-mobsf:latest >/dev/null 2>&1 docker run -d --rm \