Skip to content

Improved Semaphore CI configuration#3210

Merged
sosnovsky merged 56 commits into
masterfrom
3209_improve_semaphore_ci_configuration
May 21, 2026
Merged

Improved Semaphore CI configuration#3210
sosnovsky merged 56 commits into
masterfrom
3209_improve_semaphore_ci_configuration

Conversation

@DenBond7

@DenBond7 DenBond7 commented May 10, 2026

Copy link
Copy Markdown
Collaborator

close #3209

PR: Improve Semaphore CI Emulator/DNS Stability and Add Reproducible Test Docker Environment

Summary

This PR hardens Android CI test execution by stabilizing emulator networking/DNS setup, improving cache strategy, adding richer failure diagnostics, and introducing Dockerized test environment images/scripts for reproducibility.

What Changed

CI Pipeline (.semaphore/semaphore.yml)

  • Replaced inline DNS setup with reusable script/ci-setup-DNS.sh.
  • Simplified cache strategy:
    • Added separate cache keys for Gradle config vs SDK installer changes.
    • Kept/stored wrapper and Gradle caches with hash-aware keys.
  • Updated Gradle build invocation to use --no-daemon --build-cache.
  • Added failure debug hook: script/ci-after-fail-debug.sh.

Emulator + Networking Scripts

  • Added script/ci-setup-DNS.sh:
    • Installs/configures dnsmasq + resolver.
    • Routes *.test and *.localhost to localhost.
    • Performs DNS health checks (dig, ping).
  • Heavily improved script/ci-wait-for-emulator.sh:
    • Structured wait/retry functions.
    • Robust adb root handling with retries.
    • Post-root network readiness checks.
    • More deterministic iptables redirect for 127.0.0.1:443 -> :1212.
    • Extensive network diagnostics on failure.
  • Added reusable emulator helpers:
    • script/create-avd.sh
    • script/run-emulator.sh

Dockerized Test Environment

  • Added docker/TestEnvironment/*:
    • Ubuntu 24.04-based Android test image (JDK 21, SDK tools, emulator).
    • Build/run docs and helper scripts.
  • Added docker/HttpsTestWebServer/*:
    • Containerized dnsmasq + nginx setup for *.flowcrypt.test/*.localhost support.(just for local testing)

Docs + Minor Updates

  • Updated README.md test setup to use script/ci-setup-DNS.sh.
  • Updated Gradle wrapper to 9.5.1 in gradle/wrapper/gradle-wrapper.properties.
  • Cleaned unused imports in FlowCrypt/build.gradle.kts.
  • Temporarily disabled flaky test:
    • FlowCrypt/src/androidTest/java/com/flowcrypt/email/ui/gmailapi/passwordprotected/ComposeScreenPasswordProtectedDisallowedTermsReFetchConfigurationFlowTest.kt with @Ignore("temporary disabled").

Impact

  • Expected: fewer CI flakes from emulator DNS/networking instability.
  • Faster/more predictable pipeline behavior via cleaner cache keys and shared scripts.
  • Easier local/CI reproduction via Dockerized environment.

Risks / Notes

  • DNS changes write /etc/resolv.conf and rely on dnsmasq; environment assumptions must hold on CI agents.
  • iptables and adb root flow is stricter; failures should now fail fast with diagnostics.

Tests (delete all except exactly one):

  • Tests added or updated

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 added 30 commits May 10, 2026 16:59
- Updated shebangs to `#!/usr/bin/env bash` and added `set -euo pipefail` for better error handling.
- Improved emulator setup in `ci-setup-and-run-emulator.sh` by ensuring a fresh AVD state and configuring hardware parameters like RAM and GPU.
- Optimized `ci-wait-for-emulator.sh` with more reliable boot completion checks and a retry loop for internet connectivity.
- Added existence checks for directories and files in artifact and test result publishing scripts to prevent errors when files are missing.
- Cleaned up redundant script headers and refactored argument handling in instrumentation test scripts.
@DenBond7 DenBond7 marked this pull request as ready for review May 21, 2026 17:44
@DenBond7

Copy link
Copy Markdown
Collaborator Author

@sosnovsky Please, review this one.

@sosnovsky sosnovsky self-requested a review May 21, 2026 19:58

@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.

quite big PR, but looks good 👍

@sosnovsky sosnovsky merged commit 04bda68 into master May 21, 2026
7 checks passed
@sosnovsky sosnovsky deleted the 3209_improve_semaphore_ci_configuration branch May 21, 2026 20:07
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.

Improve Semaphore CI usage

2 participants