Skip to content

Ci#4614

Open
MilosKozak wants to merge 16 commits intodevfrom
ci
Open

Ci#4614
MilosKozak wants to merge 16 commits intodevfrom
ci

Conversation

@MilosKozak
Copy link
Copy Markdown
Contributor

No description provided.

jwoglom and others added 16 commits March 15, 2026 17:24
Add CI via Github Actions for PRs
Implements several build speed improvements:

**gradle.properties (#1, #2, #8, #9):**
- Add org.gradle.caching=true (local build cache for all environments)
- Add org.gradle.configuration-cache=true (Gradle 9+ compatible)
- Fix -Xss1024m → -Xss4m (was 1GB per thread stack; 4MB is standard)
- Add -XX:+HeapDumpOnOutOfMemoryError and -XX:MaxMetaspaceSize=512m
- Add kotlin.incremental=true and kotlin.incremental.useClasspathSnapshot=true

**GH Actions workflows (#4, #8) — aaps-ci.yml, pr-ci.yml, cherry-pick-ci.yml:**
- Replace actions/setup-java cache:gradle with gradle/actions/setup-gradle@v4
  for better Gradle dependency and build output caching
- Fix -Xss1024m → -Xss4m in all Build APKs steps
- Remove redundant -Dorg.gradle.caching=true CLI flag (now in gradle.properties)

**CircleCI config (#6, #8):**
- Fix -Xss1024m → -Xss4m in all gradlew invocations
- Restructure single build-and-test job into parallel pipeline:
  compile → unit-test + instrumented-test (parallel) → coverage
  Reduces wall time ~3 min by overlapping unit and instrumented tests

https://claude.ai/code/session_01GskFzaoUj9aa5LEz86NjKb
Replace ProcessBuilder calls with Gradle's providers.exec() API to
make git commands compatible with configuration cache in Gradle 9.

https://claude.ai/code/session_01GskFzaoUj9aa5LEz86NjKb
Include app/build/reports/androidTests/** so the HTML test report
from connectedFullDebugAndroidTest is available as a CI artifact.

https://claude.ai/code/session_01GskFzaoUj9aa5LEz86NjKb
Split the single sequential build-and-test job into two parallel jobs:
- unit-tests: runs testFullDebugUnitTest (~11min)
- connected-tests: runs connectedFullDebugAndroidTest + jacoco (~14min)

Previously these ran sequentially with a redundant
compileFullDebugAndroidTestSources step, totaling ~37min.
Now they run in parallel, so wall-clock time drops to ~14min.

Also fix flaky LoopTest by increasing waitFor timeout from 40s to 120s
at step4, which was timing out on slow CI emulators.

https://claude.ai/code/session_01GskFzaoUj9aa5LEz86NjKb
The parallel unit-tests and connected-tests jobs only compile code in
their dependency graphs, leaving a gap where production code with no
test coverage could silently have compile errors.

Add a parallel compile job that runs assembleFullDebug (validates all
production code, resources, and manifests) plus
compileFullDebugAndroidTestSources (validates all instrumentation test
code). This runs in ~7min alongside the test jobs, so wall-clock time
remains ~15min.

https://claude.ai/code/session_01GskFzaoUj9aa5LEz86NjKb
Switch to gradle/actions/setup-gradle for cross-job build cache sharing.
The compile job writes all task outputs to the cache; unit-tests and
connected-tests restore it with cache-read-only: true, so all compile
tasks are cache hits — no recompilation on the test runners.

Timeline: compile (~7min) → unit-tests + connected-tests in parallel
(~3min and ~8min respectively, compile tasks skipped via cache).
Same ~15min wall-clock as before but 1x compile work instead of 3x.

https://claude.ai/code/session_01GskFzaoUj9aa5LEz86NjKb
Adds continue-on-error: true so the check doesn't block PRs for
developers who don't have CLAUDE_CODE_OAUTH_TOKEN credentials.
The first cold build can exceed the 30m limit before the Gradle
build cache is populated. Once warm, subsequent runs should be
well under 30 minutes.
- Add -Dkotlin.compiler.execution.strategy=in-process: runs Kotlin
  compiler inside the Gradle daemon instead of a separate Kotlin
  daemon process, eliminating IPC overhead (matching aaps-ci.yml)
- Add -Dorg.gradle.workers.max=4: matches GitHub runner CPU count
  instead of the gradle.properties value of 12 which causes
  context-switching overhead on 4-core runners
- Add gradle-home-cache-cleanup: true to prevent Gradle cache from
  growing unboundedly and slowing cache restore over time
- Increase timeout-minutes from 20 to 30: cold builds with cache
  restore overhead were timing out at 21m, below the hard limit
- Remove sdkmanager "platforms;android-36" from unit-tests: unit
  tests are pure JVM; they don't need the Android platform SDK
  downloaded since compilation already occurred in the compile job.
  setup-android still runs to set ANDROID_HOME for Gradle config.
gradle.properties:
- Remove MaxMetaspaceSize=512m: in-process Kotlin compilation loads
  the entire compiler into the Gradle daemon's metaspace. 512m was
  exhausted during kaptFullDebugKotlin, causing the daemon to expire
  mid-build and likely contributing to the QEMU emulator crash.
  Removing the cap lets the JVM manage metaspace naturally.
- Remove kotlin.incremental.useClasspathSnapshot: deprecated and
  removed in Gradle 9.0 (was generating warnings each build).

pr-ci-untrusted.yml (connected-tests):
- Pass -Dorg.gradle.jvmargs=-Xmx5g for connected tests instead of
  inheriting the 8g gradle.properties default. The Android emulator
  needs ~3-4g of RAM on the same runner; 8g Gradle heap + emulator
  was causing QEMU to hang.
- Drop in-process Kotlin compiler for connected tests: most tasks
  should be FROM-CACHE; running in-process on a memory-constrained
  runner (with emulator active) adds unnecessary risk. Use the
  separate Kotlin daemon (2g cap) instead.
By default gradle/actions/setup-gradle@v4 is read-only on non-default
branches, so the cache was completely non-functional on PRs: 0 entries
restored, 0 entries saved, every run a full cold build.

Set cache-read-only: false on the compile job so it saves the Gradle
user home (including the build cache) after each run. Unit-tests and
connected-tests remain read-only and restore via the broad fallback
restore key, sharing the compile job's cached artifacts.

This means the first run on a PR branch pays full compile cost; all
subsequent pushes to that PR get most tasks FROM-CACHE.
…e-Nor95

Gradle/CI build optimizations: enable gradle caching, fix jvm settings, produce test reports
@sonarqubecloud
Copy link
Copy Markdown

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.

3 participants