Skip to content

Commit 4583f44

Browse files
Enhance Android PR CI with Concurrent JDK Matrix (#4301)
* Enhance Android PR CI to run concurrently with JDK 8, 11, 17, 21, and 25. - Updated `.github/workflows/scripts-android.yml` to use a matrix strategy for JDK versions. - Modified `scripts/build-android-app.sh` and `scripts/run-android-instrumentation-tests.sh` to respect `JDK_HOME` env var. - Updated `scripts/lib/cn1ss.sh` to support failing on screenshot mismatch and skipping PR comments via env vars `CN1SS_FAIL_ON_MISMATCH` and `CN1SS_SKIP_COMMENT`. - Configured matrix jobs to fail on mismatch and skip comments for non-default JDKs. * Update Android PR CI matrix to run on Default: 8, 17, and 21. - Renamed 'current' matrix entry to 'Default: 8'. - Removed JDK 11 and 25 from the matrix as requested. - Updated conditional logic to skip artifact uploads (screenshots, coverage) for non-default runs to prevent conflicts. - Updated test runner script block to skip coverage generation for non-default runs. - Preserved existing logic for JDK setup and env vars for non-default runs. * Fix Android PR CI Matrix logic and artifacts. - Refactored matrix to use `include` with `id`, `name`, and `java_version` to avoid string quoting issues and provide robust logic. - Removed JDK 11 and 25 from the matrix as requested. - Updated conditional logic to use `matrix.id` for checking default vs. custom jobs. - Fixed artifact conflict by strictly limiting uploads to the `default` job using the robust `matrix.id == 'default'` check. - Added explicit job name `Build Android ${{ matrix.name }}` for better visibility in PR checks. * Fix syntax error in Android PR workflow and simplify coverage logic. - Removed malformed shell script block in `scripts-android.yml` that caused syntax errors in the emulator runner. - Moved logic to skip coverage report generation into `run-android-instrumentation-tests.sh` using the `CN1SS_SKIP_COVERAGE` env var. - Updated workflow to set `CN1SS_SKIP_COVERAGE=1` for non-default matrix jobs. - Simplified `android-emulator-runner` script input to a single line command. * Fix Android emulator disk space issue by cleaning up runner. - Added "Free Disk Space" step for non-default matrix jobs to remove unused large packages (dotnet, ndk, ghc, swift) and prevent `Not enough space to create userdata partition` errors during emulator creation. - Verified that `mvnw` Java version mismatch is non-blocking for the build process. * Updated screenshots --------- Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com> Co-authored-by: Shai Almog <[email protected]>
1 parent e257e6b commit 4583f44

12 files changed

+69
-21
lines changed

.github/workflows/scripts-android.yml

Lines changed: 38 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,19 @@ name: Test Android build scripts
7272

7373
jobs:
7474
build-android:
75+
name: Build Android ${{ matrix.name }}
76+
strategy:
77+
fail-fast: false
78+
matrix:
79+
include:
80+
- name: "Default: 8"
81+
id: default
82+
- name: "JDK 17"
83+
id: jdk17
84+
java_version: '17'
85+
- name: "JDK 21"
86+
id: jdk21
87+
java_version: '21'
7588
permissions:
7689
contents: read
7790
pull-requests: write
@@ -82,6 +95,28 @@ jobs:
8295
GH_TOKEN: ${{ secrets.CN1SS_GH_TOKEN }}
8396
steps:
8497
- uses: actions/checkout@v4
98+
- name: Free Disk Space
99+
if: matrix.id != 'default'
100+
run: |
101+
sudo rm -rf /usr/share/dotnet
102+
sudo rm -rf /usr/local/lib/android/sdk/ndk
103+
sudo rm -rf /opt/ghc
104+
sudo rm -rf /usr/share/swift
105+
- name: Setup JDK
106+
if: matrix.id != 'default'
107+
uses: actions/setup-java@v4
108+
with:
109+
java-version: ${{ matrix.java_version }}
110+
distribution: 'zulu'
111+
- name: Set JDK_HOME
112+
if: matrix.id != 'default'
113+
run: echo "JDK_HOME=${JAVA_HOME}" >> $GITHUB_ENV
114+
- name: Configure CN1SS options
115+
if: matrix.id != 'default'
116+
run: |
117+
echo "CN1SS_SKIP_COMMENT=1" >> $GITHUB_ENV
118+
echo "CN1SS_FAIL_ON_MISMATCH=1" >> $GITHUB_ENV
119+
echo "CN1SS_SKIP_COVERAGE=1" >> $GITHUB_ENV
85120
- name: Setup workspace
86121
run: ./scripts/setup-workspace.sh -q -DskipTests
87122
- name: Build Android port
@@ -100,11 +135,9 @@ jobs:
100135
api-level: 31
101136
arch: x86_64
102137
target: google_apis
103-
script: |
104-
./scripts/run-android-instrumentation-tests.sh "${{ steps.build-android-app.outputs.gradle_project_dir }}"
105-
./scripts/generate-android-coverage-report.sh "${{ steps.build-android-app.outputs.gradle_project_dir }}"
138+
script: ./scripts/run-android-instrumentation-tests.sh "${{ steps.build-android-app.outputs.gradle_project_dir }}"
106139
- name: Upload emulator screenshot
107-
if: always() # still collect it if tests fail
140+
if: always() && matrix.id == 'default'
108141
uses: actions/upload-artifact@v4
109142
with:
110143
name: emulator-screenshot
@@ -113,7 +146,7 @@ jobs:
113146
retention-days: 14
114147
compression-level: 6
115148
- name: Upload Android Jacoco coverage report
116-
if: always()
149+
if: always() && matrix.id == 'default'
117150
uses: actions/upload-artifact@v4
118151
with:
119152
name: android-jacoco-coverage
-32.7 KB
Binary file not shown.
-24.6 KB
Binary file not shown.
-12.9 KB
Binary file not shown.
-13.8 KB
Binary file not shown.
98 Bytes
Loading
39 Bytes
Loading
46 Bytes
Loading
6.04 KB
Loading

scripts/build-android-app.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -131,9 +131,9 @@ if [ ! -f "$PATCH_GRADLE_SOURCE_PATH/$PATCH_GRADLE_MAIN_CLASS.java" ]; then
131131
exit 1
132132
fi
133133

134-
PATCH_GRADLE_JAVA="${JAVA17_HOME}/bin/java"
134+
PATCH_GRADLE_JAVA="${JDK_HOME:-$JAVA17_HOME}/bin/java"
135135
if [ ! -x "$PATCH_GRADLE_JAVA" ]; then
136-
ba_log "JDK 17 java binary missing at $PATCH_GRADLE_JAVA" >&2
136+
ba_log "JDK java binary missing at $PATCH_GRADLE_JAVA" >&2
137137
exit 1
138138
fi
139139

@@ -151,7 +151,7 @@ echo "---------------------------------"
151151
ba_log "Invoking Gradle build in $GRADLE_PROJECT_DIR"
152152
chmod +x "$GRADLE_PROJECT_DIR/gradlew"
153153
ORIGINAL_JAVA_HOME="$JAVA_HOME"
154-
export JAVA_HOME="$JAVA17_HOME"
154+
export JAVA_HOME="${JDK_HOME:-$JAVA17_HOME}"
155155
(
156156
cd "$GRADLE_PROJECT_DIR"
157157
if command -v sdkmanager >/dev/null 2>&1; then

0 commit comments

Comments
 (0)