From d76fdba766f5e8894be64742d26390ab7223f9f8 Mon Sep 17 00:00:00 2001 From: Michael Graeb Date: Fri, 1 Nov 2024 11:05:08 -0700 Subject: [PATCH] Fix Android CI (#839) **Issue:** The Android CI started failing due to: ``` Daemon will be stopped at the end of the build after running out of JVM memory > Task :android:crt:lintAnalyzeDebug FAILED ``` This has been a recurring issue since we updated a bunch of build stuff as part of updating CMake https://github.com/awslabs/aws-crt-java/pull/837. **Description of changes:** Manually set -Xmx (max heap size) to something huge (tested 2g and that works, but why not go bigger) via the cmdline when invoking gradle in CI. Only in CI, gradle daemon runs out of memory during "lintAnalyzeDebug" task, unless you specify it this way. You'd think that Java's default of 25% RAM (ubuntu24 runner has 12g, so max 4g) would be sufficient, but no. You'd think setting -Xmx via gradle.properties would help, but no. Also, make it so a new commit cancels any old in-progress builds. It's a waste of energy to continue these builds, some of which take a looooooong time. --- .github/workflows/ci.yml | 12 ++++++++++-- android/gradle.properties | 2 +- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1d76a29de..4b987e6f3 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -6,6 +6,11 @@ on: - 'main' - 'docs' +# cancel in-progress builds after a new commit +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + env: BUILDER_VERSION: v0.9.67 BUILDER_SOURCE: releases @@ -235,11 +240,14 @@ jobs: with: java-version: '11' distribution: 'temurin' - cache: 'gradle' # Build and publish locally for the test app to find the SNAPSHOT version - name: Build ${{ env.PACKAGE_NAME }} run: | - ./gradlew :android:crt:build + # Manually set -Xmx (max heap size) to something huge (tested 2g and that works, but why not go bigger). + # Only in CI, gradle daemon runs out of memory during "lintAnalyzeDebug" task, unless you specify it this way. + # You'd think Java's default of 25% RAM (ubuntu24 runner has 12g, so max 4g) would be sufficient, but no. + # You'd think setting -Xmx via gradle.properties would help, but no. + ./gradlew :android:crt:build -Dorg.gradle.jvmargs="-Xmx8g" ./gradlew -PnewVersion="1.0.0-SNAPSHOT" :android:crt:publishToMavenLocal # Setup files required by test app for Device Farm testing - name: Setup Android Test Files diff --git a/android/gradle.properties b/android/gradle.properties index ef2459899..a96951e7d 100644 --- a/android/gradle.properties +++ b/android/gradle.properties @@ -6,7 +6,7 @@ # http://www.gradle.org/docs/current/userguide/build_environment.html # Specifies the JVM arguments used for the daemon process. # The setting is particularly useful for tweaking memory settings. -org.gradle.jvmargs=-Xmx2G +# org.gradle.jvmargs=-Xmx2G # When configured, Gradle will run in incubating parallel mode. # This option should only be used with decoupled projects. More details, visit # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects