Skip to content

Issue 3289 semaphore ci f1 - #3292

Merged
DenBond7 merged 11 commits into
masterfrom
issue_3289_semaphore_ci_f1
Sep 28, 2026
Merged

DenBond7 merged 11 commits into
masterfrom
issue_3289_semaphore_ci_f1

Conversation

@DenBond7

@DenBond7 DenBond7 commented Sep 24, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

This PR migrates the Semaphore CI pipeline from legacy e1-standard-2 machine types to modern f1-standard-2 instances (#3289) and implements a series of CI optimizations (parallel blocks, slim SDK caching, test matrix expansion, build artifact sharing & cleanup, and Gradle wrapper upgrade).

Together, these changes reduce overall wall-clock CI runtime by 26.5% (from ~34m 19s to ~25m 14s) and cut total CI execution costs by 33.8% (from ~$1.74 to ~$1.15 per run).


Why Migrate to f1-standard-2?

  1. Hardware Modernization & Provider Lifecycle:

    • e1-standard-2 is an older generation instance type on Semaphore that is being phased out / deprecated in favor of newer machine families.
    • f1-standard-2 is powered by modern AMD EPYC processors offering significantly higher single-core IPC, faster memory bandwidth, and higher NVMe/SSD I/O throughput.
  2. KVM & Nested Virtualization for Android Emulators:

    • Android instrumentation tests rely heavily on KVM hardware acceleration. On e1 instances, cold emulator boot times were inconsistent, often taking 90–150 seconds and causing sporadic startup hangs or timeout failures.
    • On f1-standard-2, emulator initialization and snapshot restores are significantly faster (~30–45s) and more predictable, dramatically reducing flaky test failures caused by emulator sluggishness.
  3. Cost vs. Performance Balance:

    • While f1-standard-2 carries a higher nominal per-minute rate ($0.015/min vs $0.0075/min for e1), running on faster hardware combined with the pipeline optimizations below reduced overall cumulative machine time from 172m 31s to 153m 41s, and wall-clock execution time from 34m 19s to 25m 14s.
    • As a direct result, the total CI cost per run dropped by 33.8% ($1.15 vs $1.74), making f1-standard-2 both faster and cheaper overall.

Benchmark Results

Metric Baseline (e1 / unoptimized) Optimized (f1-standard-2) Delta
Wall-Clock Time 34m 19s 25m 14s -9m 05s (-26.5%)
Total Pipeline Cost $1.7424 $1.1526 -$0.5898 (-33.8%)
Cumulative Machine Time 172m 31s 153m 41s -18m 50s (-10.9%)
Slowest UI Test Shard ~23m 15s ~15m 10s -8m 05s (-34.7%)
Build Project Duration ~5m 50s ~3m 47s -2m 03s (-35.1%)

Key Changes & Optimizations

1. CI Pipeline & Concurrency

  • Migrate Machine Type: Updated all pipeline jobs across .semaphore/semaphore.yml to f1-standard-2 on ubuntu2404.
  • Parallel Pipeline Stages: Decoupled Code Quality & Unit Tests (Lint, JUnit) to run concurrently alongside Build Project, eliminating unnecessary sequential wait time on the critical path.
  • Scale UI Test Shards (4 → 6): Increased the No email server test matrix from 4 to 6 parallel shards (EMULATOR=0..5). This distributes the test load evenly and drops the slowest shard runtime from ~23m to ~15m.

2. Caching & Startup Overhead

  • Slim Android SDK Cache (android-sdk-slim):
    • Split SDK caching: Non-emulator jobs (Build Project, Lint, JUnit) now restore a lightweight SDK (~250 MB / 70–90 MB compressed) containing only platforms;android-36, build-tools, and platform-tools.
    • Cache restore drops from ~20s to ~2–3s. Heavy emulator system images are only restored on actual instrumentation test jobs (android-sdk-full).
  • Fast-path DNS & KVM Setup:
    • script/ci-setup-DNS.sh: Checks for existing dnsmasq configuration before attempting redundant installs and restarts.
    • Skips emulator/KVM initialization entirely on jobs where INSTALL_EMULATOR=0.

3. Artifact Sharing & Automatic Cleanup

  • Inter-job Artifact Sharing:
    • Added script/ci-push-build-artifacts.sh and script/ci-pull-build-artifacts.sh to package and pass compiled APKs and Gradle build cache between Build Project and downstream test jobs.
  • Automatic Workflow Artifact Yank:
    • In after_pipeline (Publish Results), added artifact yank workflow build-cache.tar and apks.tar. This automatically frees storage immediately after pipeline completion, preventing ongoing artifact storage charges.

4. Stability & Build Tooling

  • Fail-safe Debug Info Collection:
    • In script/ci-get-and-publish-debug-info-as-artifact.sh, added pre-flight ADB check (adb get-state | grep -q device) and bounded commands with ADB_COMMAND_TIMEOUT (15s) to prevent jobs from hanging during teardown if an emulator is absent or unresponsive.
  • Gradle Heap:
    • Increased org.gradle.jvmargs in gradle.properties to -Xmx4096m -XX:MaxMetaspaceSize=1024m for smoother Kotlin compilation, KSP, and dexing.
  • Gradle Wrapper 9.8.0:
    • Updated Gradle Wrapper from 9.7.1 to 9.8.0 to satisfy Android Lint's AndroidGradlePluginVersion check.

close #3289


Tests (delete all except exactly one):

  • Does not need tests (refactor only, docs or internal changes)

To be filled by reviewers

I have reviewed that this PR... (tick whichever items you personally focused on during this review):

  • addresses the issue it closes (if any)
  • code is readable and understandable
  • is accompanied with tests, or tests are not needed
  • is free of vulnerabilities

@DenBond7
DenBond7 marked this pull request as ready for review September 25, 2026 17:45
@DenBond7
DenBond7 requested a review from sosnovsky as a code owner September 25, 2026 17:45

@sosnovsky sosnovsky left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

well done 👍

@sosnovsky
sosnovsky enabled auto-merge (squash) September 28, 2026 11:28
@DenBond7
DenBond7 disabled auto-merge September 28, 2026 12:42
@DenBond7
DenBond7 merged commit 70f60b1 into master Sep 28, 2026
8 checks passed
@DenBond7
DenBond7 deleted the issue_3289_semaphore_ci_f1 branch September 28, 2026 12:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Check if we can use f1 machine on Semaphore CI

2 participants