<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Jawad Mashhadiea on Medium]]></title>
        <description><![CDATA[Stories by Jawad Mashhadiea on Medium]]></description>
        <link>https://medium.com/@YuseiAtlas?source=rss-c5ed3134b266------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*MNr4qbwQ_Zvf3illAAHd2Q.jpeg</url>
            <title>Stories by Jawad Mashhadiea on Medium</title>
            <link>https://medium.com/@YuseiAtlas?source=rss-c5ed3134b266------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 23 Nov 2026 05:21:18 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@YuseiAtlas/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[How We Reduced Our Maestro Test Time by 80% (And Saved Money)]]></title>
            <link>https://tech-blog.goflink.com/how-we-reduced-our-maestro-test-time-by-80-and-saved-money-ef0e073fc009?source=rss-c5ed3134b266------2</link>
            <guid isPermaLink="false">https://medium.com/p/ef0e073fc009</guid>
            <category><![CDATA[android]]></category>
            <category><![CDATA[maestros]]></category>
            <category><![CDATA[software-testing]]></category>
            <category><![CDATA[mobile]]></category>
            <category><![CDATA[ios]]></category>
            <dc:creator><![CDATA[Jawad Mashhadiea]]></dc:creator>
            <pubDate>Mon, 05 Jan 2026 09:15:06 GMT</pubDate>
            <atom:updated>2026-01-05T15:15:32.764Z</atom:updated>
            <content:encoded><![CDATA[<p>At Flink, we take testing seriously. Our mobile apps handle grocery deliveries for millions of customers, and a broken checkout flow means someone’s weekly grocery shopping just went sideways. So we invested heavily in end-to-end testing using Maestro and WireMock. What we didn’t anticipate was that our test suite would eventually become the bottleneck that made us question our life choices.</p><h3>The Pain</h3><p>Back in the day, when we were young and naive, our CI workflow looked as follows:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*h7j-N2Pqwhkl6Wxo9wA59Q.png" /></figure><p>With 36 tests averaging 2.8 minutes each, the test execution alone took around 105 minutes on Android and 75 minutes on iOS. Add build time, emulator startup, and reporting overhead, and we were looking at 120+ minute pipelines.</p><p>The real problem wasn’t just the time. It was the feedback loop. Push a fix, wait two hours. Discover the fix didn’t work. Push another fix. Wait another two hours. Repeat until you’ve lost the will to live or the sun has set, whichever comes first.</p><p>We couldn’t add this pipeline to PR checks because nobody wants to wait two hours for every commit. So we ran it post-merge, which meant we’d discover broken tests after the code was already in develop. Not ideal.</p><p>And here’s the kicker: every new test added 2.8 minutes to the pipeline. The test suite was growing, but so was our frustration.</p><h3>The Expensive Solution</h3><p>The obvious answer was parallelization. Early on, we realized that we could shard our tests and run them on multiple machines, so we came up with this workflow:</p><ol><li>Build the app once</li><li>Split tests into 7 shards</li><li>Ran each shard on a separate CI machine in parallel</li><li>Aggregate the results</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4IerYgO0X-DMkd6Iv8BhHA.png" /><figcaption>Parallel Maestro Pipeline Using 8 Bitrise Builds</figcaption></figure><p>It worked beautifully. The pipeline dropped to around 30 minutes. We were heroes.</p><p><strong>For about a week.</strong></p><p>Then we did the math. Each pipeline run consumed 8 CI builds (7 shards + 1 build job). We run this pipeline multiple times a day, across 4 apps (iOS and Android for both Consumer and Rider). At that rate, we’d burn through our CI budget in a couple of months. Getting enough credits to sustain this meant spending tens of thousands of extra euros per year.</p><p>So we shelved the parallel pipeline for “debugging purposes” and went back to the slow sequential runs. The dream of fast feedback remained just that: a dream.</p><h3>The Problem with Parallelization</h3><p>Why couldn’t we just run multiple emulators on a single machine? Two reasons, both related to WireMock.</p><p><strong>Problem 1: Port Collision</strong></p><p>All our tests pointed to localhost:4000 where WireMock was running. If we spun up 4 emulators and used Maestro&#39;s--shard-split=4, all 4 emulators would hit the same WireMock instance. Some tests modify WireMock&#39;s state to simulate different scenarios (e.g., Netherlands checkout vs. Germany checkout). With parallel execution, one test might set up a Netherlands scenario while another test might expect Germany. Chaos ensues. Tests fail randomly. Engineers cry.</p><p><strong>Problem 2: Fresh State</strong></p><p>We reset WireMock’s state at the start of each test to ensure a clean state. This worked fine sequentially, but with parallel execution, one test’s reset would wipe out another test’s carefully configured scenario mid-execution.</p><p>The solution was obvious: run multiple WireMock servers, one per shard, each on a different port. The problem was telling each emulator which port to use.</p><p>Maestro’s --shard-split flag distributes tests across devices, but it doesn&#39;t expose which shard a test is running on. There&#39;s no $SHARD_INDEX variable you can pass to your app. We couldn&#39;t dynamically tell the login test, &quot;hey, you&#39;re on shard 2, use port 4001.&quot;</p><p>We were stuck.</p><h3>The Eureka Moment</h3><p>One day, it hit us: what if we didn’t wait for Maestro to solve this? What if we figured out how Maestro shards tests and did the port injection ourselves?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/480/0*1_fHolfLR78cPs-G.gif" /><figcaption>Finding out that OSS repos can be used for more than copying the import command</figcaption></figure><p>The idea was simple but required some reverse engineering:</p><ol><li>Clone the Maestro repo and understand how it distributes tests across shards</li><li>Write a script that replicates this sharding logic</li><li>Before running tests, inject the correct WireMock port into each test file based on which shard it will run on</li><li>Let Maestro do its thing, oblivious to our manipulation</li></ol><p>Turns out Maestro’s sharding is straightforward: it sorts test files alphabetically and assigns them round-robin style (index % num_shards). If you have tests A, B, C, D and 2 shards, shard 1 gets A and C, shard 2 gets B and D.</p><p>We took this knowledge and did some magic, injecting the port as an environment variable directly in the test files themselves.</p><p>The test files go from this:</p><pre>appId: com.example.app<br>---<br>- launchApp<br>- tapOn: &quot;Login&quot;</pre><p>To this:</p><pre>appId: com.example.app<br>env:<br>  WIREMOCK_PORT: 4001<br>---<br>- launchApp<br>- tapOn: &quot;Login&quot;</pre><p>On the app side, we added a Retrofit interceptor (Android) that reads this port from the launch arguments and overrides the base URL. iOS required similar but slightly easier changes due to how networking is configured there.</p><h3>The Implementation (aka The Magic)</h3><p>We wrote <a href="https://gist.github.com/yuseiatlas/a957fbfe83e3aa3eb6f22b3b1f50c45b#file-shard_and_update_ports-py">shard_and_update_ports.py</a>, which handles tag filtering (we exclude staging, disabled, production, and tracking tests), replicates Maestro&#39;s sharding algorithm, and updates each YAML file with the appropriate port.</p><p>For starting multiple emulators, we also wrote a small bash script <a href="https://gist.github.com/yuseiatlas/5aa8bdfc894a38882aca6763cc2cfaed#file-start-multiple-emulators-sh">start-multiple-emulators.sh</a>.</p><p>And here’s how we start multiple WireMock servers, one per emulator:</p><pre>_start-wiremock-servers:<br>  steps:<br>    - script:<br>        title: Start Multiple WireMock Servers<br>        inputs:<br>          - content: |-<br>              #!/usr/bin/env bash<br>              set -euo pipefail<br><br>              echo &quot;Starting multiple WireMock servers...&quot;<br>              cd wiremock<br><br>              # Get list of active emulator devices<br>              devices=($(adb devices | grep emulator | awk &#39;{print $1}&#39;))<br>              num_devices=${#devices[@]}<br><br>              echo &quot;Found $num_devices active emulator devices&quot;<br><br>              # Start WireMock servers for each device, starting from port 4000<br>              for ((i=1; i&lt;=num_devices; i++)); do<br>                  port=$((4000 + i - 1))<br>                  device=${devices[$((i - 1))]}<br><br>                  echo &quot;Starting WireMock server on port $port for device $device (shard $i)&quot;<br>                  java -jar MockServer.jar --port $port --verbose &gt; $BITRISE_DEPLOY_DIR/wiremock-shard-$i.log 2&gt;&amp;1 &amp;<br><br>                  # Wait a moment for the server to start<br>                  sleep 2<br>              done<br><br>              echo &quot;All WireMock servers started&quot;</pre><p>The main workflow ties it all together:</p><pre>run-maestro-ui-tests:<br>  meta:<br>    bitrise.io:<br>      machine_type_id: g2.linux.5x-large<br>  before_run:<br>    - _setup<br>    - _build-wiremock<br>    - _start-emulators<br>    - _install-apk-on-emulators<br>    - _configure-emulators<br>    - _start-wiremock-servers<br>    - _install-maestro<br>    - _start-screen-recording<br>  after_run:<br>    - _stop-screen-recording<br>    - _clean-up-maestro-artifacts<br>    - _report-maestro-ui-test-results<br>  steps:<br>    - script:<br>        title: Run Maestro Parallel Tests<br>        inputs:<br>          - content: |-<br>              #!/usr/bin/env bash<br>              set -euxo pipefail<br><br>              python3 scripts/maestro/shard_and_update_ports.py --shards $EMULATORS_COUNT --port 4000 --dir .maestro/flows --exclude-tags staging,disabled,production,tracking<br><br>              # run the Maestro tests in parallel on multiple emulators<br>              maestro test --env APP_ID=FLINK_APP_ID --exclude-tags=staging,disabled,production,tracking --shard-split=$EMULATORS_COUNT --format junit --output $BITRISE_DEPLOY_DIR/test_run.xml --flatten-debug-output --debug-output $BITRISE_DEPLOY_DIR .maestro/</pre><blockquote><em>While we’re using Bitrise, nothing here is Bitrise-specific. It’s just shell scripts, Python, and standard CI concepts. You can port this to GitHub Actions, CircleCI, Jenkins, or whatever CI system you’re using. The core idea — manipulate test files before Maestro sees them, run multiple mock servers on different ports — works anywhere.</em></blockquote><blockquote><em>Also, we’ve simplified some of the scripts in this article for clarity. The iOS and Android implementations have slight differences (different ways to list devices, different recording tools, etc.). You’ll need to adapt these to your own stack and test setup.</em></blockquote><h3>Finding the Right Balance</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/498/0*NVB239rFvMyYD4uF.gif" /><figcaption>The Balance</figcaption></figure><p>With the technical issue resolved, we began experimenting with the number of parallel devices.</p><p>We began with 2 emulators and gradually increased. More emulators meant faster execution, but also more resource consumption. At some point, the CI machine started struggling.</p><p>On Android, we found that 14 emulators on a machine with 32 CPU cores and 128GB RAM was the sweet spot. Beyond that, the emulator startup time exceeded the time saved from parallelization. We tried launching emulators in parallel and other optimizations, but the gains were marginal.</p><p>iOS was trickier. We’re running virtualized simulators on a virtualized CI environment (it’s turtles all the way down), and this caused stability issues. More than 4 simulators led to frequent freezing and crashes. Locally, on native Mac hardware, we could run 7 simulators without issues. But CI is a different beast.</p><p>We settled on:</p><ul><li><strong>Android</strong>: 14 emulators on Bitrise’s g2.linux.5x-large (32 cores, 128GB RAM)</li><li><strong>iOS</strong>: 4 simulators on Bitrise’s M4 Pro X Large (14 cores, 54GB RAM)</li></ul><h3>iOS: Clone, Don’t Create</h3><p>On iOS, we discovered a trick that significantly improved stability and startup time: instead of launching multiple simulators from scratch, we launch one simulator, install the app on it, configure everything, and then clone it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/220/0*LcLWXIZI0kspdWv6.gif" /><figcaption>iOS Style: Shadow Clone Script</figcaption></figure><p>The xcrun simctl clone command creates an exact copy of a running simulator, including the installed app, settings, and state. This is faster than creating fresh simulators and installing the app on each one. More importantly, it&#39;s more stable — the cloned simulators behave identically since they start from the same base state.</p><p>Here’s the workflow:</p><ol><li>Start a single simulator.</li><li>Install the app and configure settings (locale, language, disable autofill, etc.)</li><li>Shut down the simulator (you can’t clone a running simulator)</li><li>Clone it N-1 times to get N total simulators</li><li>Boot all simulators</li></ol><pre>_clone-simulator:<br>  envs:<br>    - SIMULATORS_COUNT: &quot;4&quot;<br>  steps:<br>    - script@1:<br>        title: Clone Active Simulator<br>        inputs:<br>          - content: |-<br>              #!/usr/bin/env bash<br>              set -euxo pipefail<br><br>              envman add -key SIMULATORS_COUNT --value $SIMULATORS_COUNT<br><br>              # Get the UDID of the currently booted simulator<br>              SOURCE_SIMULATOR_UDID=$(xcrun simctl list devices | grep &quot;(Booted)&quot; | head -n 1 | awk -F &#39;[()]&#39; &#39;{print $2}&#39;)<br><br>              if [ -z &quot;$SOURCE_SIMULATOR_UDID&quot; ]; then<br>                  echo &quot;No booted simulator found to clone.&quot;<br>                  exit 1<br>              fi<br><br>              echo &quot;Source simulator UDID: $SOURCE_SIMULATOR_UDID&quot;<br><br>              if [ &quot;$SIMULATORS_COUNT&quot; -eq 1 ]; then<br>                  echo &quot;SIMULATORS_COUNT is 1, no cloning needed.&quot;<br>              else<br>                  # Shutdown before cloning (simulators cannot be cloned while booted)<br>                  xcrun simctl shutdown $SOURCE_SIMULATOR_UDID<br><br>                  SIMULATOR_UDIDS=($SOURCE_SIMULATOR_UDID)<br><br>                  # Clone the simulator (SIMULATORS_COUNT - 1) times<br>                  for i in $(seq 2 $SIMULATORS_COUNT); do<br>                    CLONE_NAME=&quot;Shard - $i&quot;<br>                    CLONE_ID=$(xcrun simctl clone $SOURCE_SIMULATOR_UDID &quot;$CLONE_NAME&quot;)<br>                    echo &quot;Cloned simulator: $CLONE_NAME with ID: $CLONE_ID&quot;<br>                    SIMULATOR_UDIDS+=($CLONE_ID)<br>                  done<br><br>                  # Boot all simulators<br>                  for UDID in &quot;${SIMULATOR_UDIDS[@]}&quot;; do<br>                    xcrun simctl boot $UDID<br>                    xcrun simctl bootstatus $UDID -b<br>                  done<br>              fi<br><br>              xcrun simctl list devices | grep &quot;(Booted)&quot;</pre><p>The iOS main workflow then looks like this:</p><pre>run-maestro-ui-tests:<br>  meta:<br>    bitrise.io:<br>      machine_type_id: g2.mac.4x-large  # 14 vCPU, 54 GB RAM<br>  before_run:<br>    - _setup<br>    - _install-maestro<br>    - _build-for-maestro<br>    - _start-simulator           # Start ONE simulator<br>    - _install-ipa-on-simulator  # Install app and configure settings<br>    - _clone-simulator           # Clone to create multiple identical simulators<br>    - _start-wiremock-servers<br>    - _start-screen-recording<br>  after_run:<br>    - _stop-screen-recording<br>    - _clean-up-maestro-artifacts-parallel<br>    - _report-maestro-ui-test-results<br>  steps:<br>    - script@1:<br>        title: Run all Maestro Tests in Parallel<br>        inputs:<br>          - content: |-<br>              #!/usr/bin/env bash<br>              set -euxo pipefail<br><br>              SHARD_COUNT=&quot;${SIMULATORS_COUNT:-1}&quot;<br>              python3 Scripts/Maestro/shard_and_update_ports.py --shards $SHARD_COUNT --port 4000 --dir MaestroTests/flows --exclude-tags staging,disabled,production,tracking<br>              maestro test --env APP_ID=FLINK_APP_ID --exclude-tags=staging,disabled,production,tracking --shard-split=$SHARD_COUNT --format junit --output $BITRISE_DEPLOY_DIR/test_run.xml --flatten-debug-output --debug-output $BITRISE_DEPLOY_DIR MaestroTests/</pre><p>This clone-based approach reduced the flakiness we were seeing with multiple simulators on CI. When you create simulators from scratch in parallel, they occasionally step on each other’s toes during initialization. Cloning avoids that because the heavy lifting (app installation, initial setup) happens once on a single simulator before any cloning begins.</p><h3>The Results</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8FzmjB9S0hjOVuvsVAJgnA.png" /></figure><p>The pipeline runs on more expensive machines (2–4x per minute), but because it finishes 60–80% faster, the total cost is roughly the same. Actually slightly cheaper, but we’re talking cents here.</p><p>The real win is the hidden benefit: <strong>test execution time now scales with shards, not test count</strong>. On Android, we can add 13 more tests before the pipeline gets any slower (because execution time equals the slowest running shard). On iOS, we have room for 3 more tests per shard.</p><p>We still get occasional emulator crashes or flaky runs, but the frequency is low enough that the gains far outweigh the occasional retry.</p><h3>Bonus: Better Failure Reporting</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/320/0*2C1-QC-7LxCMIDcO.gif" /><figcaption>Live recording of announcing test video recording to the team at Flink</figcaption></figure><p>Running tests in parallel creates a new problem: when something fails, you have 14 devices&#39; worth of logs and recordings to sift through. Nobody wants to download 14 video files and watch them like a detective solving a crime. We built additional tooling to make debugging actually feasible.</p><h3>Screen Recording All Devices</h3><p>On Android, we use <a href="https://github.com/Genymobile/scrcpy">scrcpy</a> to record every emulator’s screen during the test run. On iOS, we use the built-in xcrun simctl io recordVideo command. The key is starting recordings in parallel, one per device:</p><p><strong>Android (using scrcpy):</strong></p><pre>_start-screen-recording:<br>  steps:<br>    - script:<br>        title: Start screen recording<br>        inputs:<br>          - content: |-<br>              #!/usr/bin/env bash<br>              set -euxo pipefail<br>              <br>              # install scrcpy<br>              wget https://github.com/Genymobile/scrcpy/releases/download/v3.3.1/scrcpy-linux-x86_64-v3.3.1.tar.gz<br>              tar -xvzf scrcpy-linux-x86_64-v3.3.1.tar.gz<br>              sudo cp -r scrcpy-linux-x86_64-v3.3.1/* /usr/local/bin/<br>              # get list of all active emulators<br>              emulators=($(adb devices | grep emulator | awk &#39;{print $1}&#39;))<br>              emulator_count=${#emulators[@]}<br>              # start recording the screen for each emulator<br>              shard_num=1<br>              for emulator_id in &quot;${emulators[@]}&quot;; do<br>                echo &quot;Starting screen recording for $emulator_id (shard $shard_num)&quot;<br>                scrcpy --serial=&quot;$emulator_id&quot; --no-audio --no-window --no-playback --no-control --max-size=1080 --max-fps=30 --record=$BITRISE_DEPLOY_DIR/screen-recording-shard-$shard_num.mp4 &gt; $BITRISE_DEPLOY_DIR/scrcpy-shard-$shard_num.log 2&gt;&amp;1 &amp;<br>                shard_num=$((shard_num + 1))<br>              done<br>              # save the timestamp when recording started (used later to generate video timestamps)<br>              envman add --key SCREEN_RECORDING_START --value $(date +%s)</pre><p><strong>iOS (using simctl):</strong></p><pre>_start-screen-recording:<br>  steps:<br>    - script:<br>        title: Start screen recording<br>        inputs:<br>          - content: |-<br>              #!/usr/bin/env bash<br>              set -euxo pipefail<br>              <br>              # get list of all booted simulators<br>              simulators=($(xcrun simctl list devices | grep &quot;(Booted)&quot; | grep -oE &#39;[0-9A-F]{8}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{12}&#39;))<br>              simulator_count=${#simulators[@]}<br>              # start recording the screen for each simulator in the background<br>              shard_num=1<br>              for simulator_id in &quot;${simulators[@]}&quot;; do<br>                echo &quot;Starting screen recording for $simulator_id (shard $shard_num)&quot;<br>                xcrun simctl io &quot;$simulator_id&quot; recordVideo --codec=h264 -f $BITRISE_DEPLOY_DIR/screen-recording-shard-$shard_num.mp4 &gt; $BITRISE_DEPLOY_DIR/screen-recording-shard-$shard_num.log 2&gt;&amp;1 &amp;<br>                shard_num=$((shard_num + 1))<br>              done<br>              envman add --key SCREEN_RECORDING_START --value $(date +%s)</pre><p>To stop the recordings, we send termination signals to the recording processes. On Android, we pkill the scrcpy processes. On iOS, we send SIGINT to the simctl processes:</p><p><strong>Android:</strong></p><pre>_stop-screen-recording:<br>  steps:<br>    - script:<br>        title: Stop screen recording<br>        is_always_run: true<br>        inputs:<br>          - content: |-<br>              #!/usr/bin/env bash<br>              set -exo pipefail<br>  <br>              echo &quot;Stopping all scrcpy processes...&quot;<br>              pkill -SIGTERM scrcpy || true<br>              # wait until all scrcpy processes terminate<br>              TIMER=60<br>              start_time=$(date +%s)<br>              while pgrep -x &quot;scrcpy&quot; &gt; /dev/null; do<br>                current_time=$(date +%s)<br>                elapsed_time=$((current_time - start_time))<br>                if [ &quot;$elapsed_time&quot; -ge &quot;$TIMER&quot; ]; then<br>                  echo &quot;Timeout: scrcpy still running after $TIMER seconds&quot;<br>                  exit 1<br>                fi<br>                sleep 1<br>              done<br>              echo &quot;All recordings stopped.&quot;<br></pre><p><strong>iOS:</strong></p><pre>_stop-screen-recording:<br>  steps:<br>    - script:<br>        title: Stop screen recording<br>        is_always_run: true<br>        inputs:<br>          - content: |-<br>              #!/usr/bin/env bash<br>              set -exo pipefail<br><br>              echo &quot;Stopping all simctl recording processes...&quot;<br>              killall -SIGINT simctl || true<br>              # wait until all simctl processes terminate<br>              TIMER=60<br>              start_time=$(date +%s)<br>              while pgrep -x &quot;simctl&quot; &gt; /dev/null; do<br>                current_time=$(date +%s)<br>                elapsed_time=$((current_time - start_time))<br>                if [ &quot;$elapsed_time&quot; -ge &quot;$TIMER&quot; ]; then<br>                  echo &quot;Timeout: simctl still running after $TIMER seconds&quot;<br>                  exit 1<br>                fi<br>                sleep 1<br>              done<br>              echo &quot;All recordings stopped.&quot;</pre><h3>Smart Artifact Cleanup</h3><p>Here’s the thing about 14 parallel recordings: most of them are useless. If 13 shards pass and 1 fails, we only care about that one failure. Uploading 14 video files to CI artifacts is wasteful and makes finding the relevant one annoying.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/220/0*gyQkvt_f3Xgd0X1v.gif" /><figcaption>Cleaning up 10s of files from CI so devs don’t scream at me when debugging</figcaption></figure><p>We built a cleanup script that:</p><ol><li>Analyzes Maestro’s output JSON to identify which tests failed and which shards they ran on</li><li>Deletes recordings from successful shards</li><li>Compresses recordings from failed shards (smaller files, faster uploads)</li><li>Keeps all the relevant logs for debugging</li></ol><pre>_clean-up-maestro-artifacts:<br>  steps:<br>    - script@1:<br>        title: Clean up artifacts from successful shards<br>        is_always_run: true<br>        inputs:<br>          - content: |-<br>              #!/usr/bin/env bash<br>              set -eo pipefail<br><br>              # Analyze test failures to identify which shards had failures<br>              eval &quot;$(python3 scripts/maestro/analyze_test_failures.py $BITRISE_DEPLOY_DIR)&quot;<br>              echo &quot;Failed tests: $FAILED_TESTS&quot;<br>              echo &quot;Failed shards: $FAILED_SHARDS&quot;<br>              if [ -z &quot;$FAILED_SHARDS&quot; ]; then<br>                echo &quot;All tests passed. Deleting all recordings...&quot;<br>                rm -f $BITRISE_DEPLOY_DIR/screen-recording*.mp4<br>              else<br>                echo &quot;Compressing screen recordings from failed shards...&quot;<br>                sudo apt-get install ffmpeg -y<br>                IFS=&#39;,&#39; read -ra shards &lt;&lt;&lt; &quot;$FAILED_SHARDS&quot;<br>                for file in $BITRISE_DEPLOY_DIR/screen-recording*.mp4; do<br>                  [ -e &quot;$file&quot; ] || continue<br>                  match_found=0<br>                  for shard in &quot;${shards[@]}&quot;; do<br>                    if [[ &quot;$file&quot; == *&quot;$shard&quot;* ]]; then<br>                      match_found=1<br>                      echo &quot;Compressing recording for $shard...&quot;<br>                      ffmpeg -i &quot;$file&quot; -vf scale=1280:720 -vcodec libx264 -crf 28 -preset fast -y &quot;${file%.mp4}-compressed.mp4&quot;<br>                      rm -f &quot;$file&quot;<br>                      break<br>                    fi<br>                  done<br>                  # Delete recordings from successful shards<br>                  if [ $match_found -eq 0 ]; then<br>                    rm -f &quot;$file&quot;<br>                  fi<br>                done<br>              fi<br>              # Clean up other artifacts from successful shards<br>              python3 scripts/maestro/cleanup_shard_artifacts.py $BITRISE_DEPLOY_DIR --keep-shards &quot;$FAILED_SHARDS&quot; --keep-tests &quot;$FAILED_TESTS&quot; --mode compress</pre><p><a href="https://gist.github.com/yuseiatlas/3746f8efbdd4c12c86ff8af4742bc946#file-analyze_test_failures-py">analyze_test_failures.py</a> parses Maestro’s command JSON files to figure out what went wrong</p><p>And <a href="https://gist.github.com/yuseiatlas/a0cb59b5699624e2e2b972e8f3832649#file-cleanup_shard_artifacts-py">cleanup_shard_artifacts.py</a> handles compressing/deleting artifacts based on the shard.</p><h3>Stacktrace Extraction and Slack Reporting</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*E-JYw0hU4B-oPXehWKrfdA.png" /><figcaption>Testing on prod all day everyday</figcaption></figure><p>When a test fails, Maestro produces a JSON file with all the commands that ran and their results. We parse this to build a human-readable stacktrace and post it to Slack along with the failure screenshot, thanks to <a href="https://gist.github.com/yuseiatlas/c6563519345924cfaf4d3f2058c87549#file-reportmaestrotestfailures-kt">ReportMaestroTestFailures.kt</a>.</p><p>The result is a Slack message that shows exactly which test failed, what the error was, and includes the screenshot of the failure state. No more digging through logs.</p><h3>Lessons Learned</h3><ol><li><strong>Sometimes the hack is the solution.</strong> Instead of waiting for Maestro to add shard-aware environment variables, we worked around it.</li><li><strong>Parallelization isn’t free</strong>. More parallel workers means more resources, and there’s always a point of diminishing returns. Finding the sweet spot requires experimentation.</li><li><strong>Cost and speed aren’t always tradeoffs</strong>. By running on fewer, more powerful machines instead of many small ones, we got the same speed at roughly the same cost.</li><li><strong>Tooling matters</strong>. Fast tests with poor failure visibility aren’t that useful. Invest in making failures easy to diagnose.</li><li><strong>AI agents are (unsurprisingly) good at this</strong>. We used AI coding agents extensively to generate and refine these scripts. Tasks like “write a Python script that parses YAML files and injects environment variables based on a sharding algorithm” are exactly the kind of well-defined problems where AI assistants shine. We were able to iterate much faster than if we’d written everything from scratch.</li></ol><h3>What’s Next</h3><p>We’re exploring a few improvements:</p><ul><li>Smarter test distribution based on historical execution time (instead of just alphabetical order)</li><li>Automatic retry for flaky infrastructure failures</li><li>Extending this approach to other test suites</li></ul><p>If you’re struggling with slow Maestro tests, hopefully this gives you some ideas. The code isn’t complicated; the hard part was realizing we could manipulate the test files before Maestro sees them.</p><p>Feel free to reach out if you have questions or want to share your own Maestro war stories.</p><h3>Want to Learn More?</h3><p>Interested to learn more about tech at Flink? Check our other posts on the <a href="https://tech-blog.goflink.com/"><em>Flink Engineering Blog</em></a>!</p><p>Don’t forget to download our <a href="https://apps.apple.com/de/app/flink-dein-einkauf-in-minuten/id1531321108">iOS</a> and <a href="https://play.google.com/store/apps/details?id=com.pickery.app&amp;hl=en">Android</a> apps to get your groceries delivered to you in minutes!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ef0e073fc009" width="1" height="1" alt=""><hr><p><a href="https://tech-blog.goflink.com/how-we-reduced-our-maestro-test-time-by-80-and-saved-money-ef0e073fc009">How We Reduced Our Maestro Test Time by 80% (And Saved Money)</a> was originally published in <a href="https://tech-blog.goflink.com/">Flink</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How We Ship Our Mobile Apps Every Week (Without Losing Our Sanity)]]></title>
            <link>https://tech-blog.goflink.com/how-we-ship-our-mobile-apps-every-week-without-losing-our-sanity-1d23f3c23814?source=rss-c5ed3134b266------2</link>
            <guid isPermaLink="false">https://medium.com/p/1d23f3c23814</guid>
            <category><![CDATA[mobile-app-development]]></category>
            <category><![CDATA[automation]]></category>
            <category><![CDATA[testing]]></category>
            <category><![CDATA[release-management]]></category>
            <category><![CDATA[tech]]></category>
            <dc:creator><![CDATA[Jawad Mashhadiea]]></dc:creator>
            <pubDate>Mon, 22 Sep 2025 06:57:58 GMT</pubDate>
            <atom:updated>2025-09-22T07:37:52.161Z</atom:updated>
            <content:encoded><![CDATA[<p>Once upon a time, we used to ship our mobile apps every other week. It was a much simpler time. We did a lot of things manually. From testing to communication to uploading release binaries. With hundreds of releases and a lot of automation later, we’re able to release 4 iOS and Android apps <strong>every single week</strong> with little to no manual involvement.</p><p>Unless explicitly mentioned, <strong>everything you will read below is automated</strong>. So, if you’re wondering how we make it work (and how we don’t break everything in the process), here’s a peek behind the curtain.</p><h3>TL;DR</h3><ul><li>Release trains, not planes.</li><li>Managing release using <a href="https://bitrise.io/">Bitrise</a>, <a href="https://runway.team/">Runway</a> and a dedicated release pilot.</li><li>Code freeze on a Friday and ship on the next Tuesday.</li><li>Regression test powered by <a href="https://maestro.mobile.dev/">Maestro</a> and <a href="https://wiremock.org/">WireMock</a></li><li>Beta testers and staged rollout.</li><li>Monitors, alerts, metrics, and a lot of other fun stuff using <a href="https://firebase.google.com/docs/crashlytics">Crashlytics</a> and <a href="https://www.datadoghq.com/">Datadog</a>.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/335/1*T3Z9nuKcBb2i_vbJsvhUzA.gif" /><figcaption>Engineers at Flink advocating for automation</figcaption></figure><h3>🛠️ Building Blocks</h3><p>Our release starts from code and ends at the customer’s hands. At Flink, we follow <strong>Gitflow</strong>, meaning:</p><ul><li>Developers work on feature branches.</li><li>When a feature is ready, it gets rebased into develop.</li><li>On <strong>code-freeze day</strong>, we create a release branch.</li><li>Once the app is live, we tag the release and merge it back into develop (making <strong>hotfixes</strong> easier).</li></ul><h3>✈️ A Runway and a Pilot Without Planes</h3><p>We follow a somewhat strict <strong>Release train 🚆</strong>. Release trains are, simply, a method to ship releases regularly and at fixed intervals. Each “train” contains a set of features, fixes, and improvements, and once a release train starts, it follows a predetermined schedule, regardless of whether all features are ready. Unlike what I like to call “release planes” where the release waits until all intended features make it. Release trains allow us to have a predictable release schedule. This helps our teams and stakeholders plan releases better and gives the engineer the flexibility to push incomplete features to the next release, which reduces the stress. E.g. instead of going into “Crunch Mode” because the time between releases is too long, in most cases, one week is a reasonable compromise.</p><p>We use <a href="https://bitrise.io/">Bitrise</a> and <a href="https://runway.team/">Runway</a> for CI/CD and release management. Each release is led by a <strong>Release pilot 👨‍✈️,</strong> which is a rotating role between engineers within a domain (e.g. 1 iOS and 1 Android engineer).</p><h3>🫸 Hold the Code</h3><p>The <strong>Code-freeze Day 🥶</strong> is the “cutoff” day or the last day in which you can add commits to the release. If a feature is in development and partially merged, then we hide it behind <strong>Feature flags.</strong> This lets us ship incomplete features <strong>without blocking a release</strong> — a game-changer for iterative development.</p><p>At 16:30 every Friday, our release is kicked off and a series of automations is triggered that looks as follows:</p><ul><li>The release is created on the Google Play and App Stores.</li><li>The release branch is opened from the develop branch.</li><li>A PR is opened to the develop branch, increasing the app version.</li><li>Bitrise workflows are triggered to build and deploy a production<strong>-signed</strong> app version (the one that will be deployed to the store) alongside a build pointing to our testing (staging) environment.</li><li>Builds are shared with internal and beta testers.</li><li>Regression test workflows are triggered.</li><li>A message is sent to Slack to notify stakeholders that the release has been kicked off.</li><li>Release notes and screenshots are updated by a marketing stakeholder or the default release notes.</li></ul><p>All of the previous steps happen AT THE SAME TIME 😮.</p><h3>🧙Orchestrating Regression Testing with Maestro</h3><p>While our app is well-covered with <strong>unit tests</strong>, that’s just the start. We also have an extensive suite of regression and smoke tests using Maestro and WireMock that we run for every merged PR and for every release.</p><ul><li><strong>Regression tests</strong> run on a mocked environment using WireMock and cover 150+ critical test cases.</li><li><strong>Smoke tests</strong> that run on <strong>staging and production</strong> environments, just in case.</li></ul><p>We run all of this on Bitrise with a heavy layer of scripts to generate video recordings of the test runs, stack traces of failures, relevant logs (app, WireMock…etc), and a summary of the test run with its status to Slack.</p><p>If something breaks, it’s usually <strong>before</strong> we release — not after. (Usually. We’re not perfect.)</p><h3>🧪 A Trial Run</h3><p>Before we unleash a new version on the world, we let our <strong>beta testers</strong> take it for a spin. Typically, this happens over the weekend from Friday (code-freeze) until Tuesday (release day). Our beta testers help us to get a feel of how the Release Candidate is performing. We keep a very close eye on our health metrics, and we’re alerted if they’re facing any crashes or are unable to place orders.</p><h3>🚀 Going Live</h3><p>Tuesday evening is here, and everything is green? Start the rollout! Well, the staged rollout that is. We submit the app to the stores and start a <strong>4-day staged rollout for Android</strong> and a <strong>7-day staged rollout for iOS</strong> (because we can’t control the length on the App Store). During this time, Runway handles the staged rollout for us by checking the health metrics we define (e.g. crash-free session rate) and increasing the percentage every day. If our health metrics dip, then the release is halted and we’re notified. In parallel, the release pilot is checking <strong>Firebase Crashlytics</strong>, <strong>Datadog</strong>, and our app review channel for any anomalies.</p><h3>🚨 Sound the Alarm!</h3><p>Sometimes, despite all our precautions, things break. When that happens:</p><ol><li><strong>We stop the rollout.</strong></li><li><strong>We investigate.</strong> Is it a widespread issue? A device-specific bug?</li><li><strong>We fix it.</strong> A hotfix branch is created from the last tagged commit.</li><li><strong>We test it.</strong> Automated smoke tests ensure we don’t make things worse.</li><li><strong>We release.</strong> Fast, but safe.</li></ol><p>Thanks to <strong>automated monitors</strong>, we often catch issues <strong>before users even report them</strong>.</p><h3>Releasing Weekly Without Losing Sleep</h3><p>Releasing a mobile app every week might sound chaotic, but with the <strong>right automation, testing, and monitoring</strong>, it’s <strong>surprisingly stress-free</strong>.</p><p>Our goal? <strong>Keep shipping, keep improving, and keep making our users happy.</strong></p><p>And hey, if you ever find a bug, let us know — we’ll probably have it fixed before the next release. 😉</p><h3>Want to Learn More?</h3><p>Interested to learn more about tech at Flink? Check our other posts!</p><p>Don’t forget to download our <a href="https://apps.apple.com/de/app/flink-dein-einkauf-in-minuten/id1531321108">iOS</a> and <a href="https://play.google.com/store/apps/details?id=com.pickery.app&amp;hl=en">Android</a> apps to get your groceries delivered to you in minutes!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1d23f3c23814" width="1" height="1" alt=""><hr><p><a href="https://tech-blog.goflink.com/how-we-ship-our-mobile-apps-every-week-without-losing-our-sanity-1d23f3c23814">How We Ship Our Mobile Apps Every Week (Without Losing Our Sanity)</a> was originally published in <a href="https://tech-blog.goflink.com/">Flink</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>