-
Notifications
You must be signed in to change notification settings - Fork 43
143 lines (128 loc) · 5.91 KB
/
ci-android.yml
File metadata and controls
143 lines (128 loc) · 5.91 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
name: CI Android
on:
push:
branches-ignore:
- '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.84
BUILDER_SOURCE: releases
BUILDER_HOST: https://d19elf31gohf1l.cloudfront.net
PACKAGE_NAME: aws-crt-java
RUN: ${{ github.run_id }}-${{ github.run_number }}
CRT_CI_ROLE: ${{ secrets.CRT_CI_ROLE_ARN }}
AWS_DEFAULT_REGION: us-east-1
AWS_REGION: us-east-1
AWS_DEVICE_FARM_REGION: us-west-2 # Device Farm only available in us-west-2 region
permissions:
id-token: write # This is required for requesting the JWT
jobs:
android:
# ubuntu-24.04 comes with Android tooling
name: Android
runs-on: ubuntu-24.04 # latest
steps:
- uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: ${{ env.CRT_CI_ROLE }}
aws-region: ${{ env.AWS_DEFAULT_REGION }}
- name: Checkout Sources
uses: actions/checkout@v4
with:
submodules: true
# Setup JDK 17
- name: set up JDK 17
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'temurin'
# Ensure Gradle uses this JDK (important when toolchains are present)
- name: Point Gradle at JDK 17
run: echo "ORG_GRADLE_JAVA_HOME=$JAVA_HOME" >> $GITHUB_ENV
- name: Mirror ANDROID_HOME → ANDROID_SDK_ROOT
run: echo "ANDROID_SDK_ROOT=$ANDROID_HOME" >> "$GITHUB_ENV"
# Install required Android components & accept licenses (NDK r28 + compileSdk 35)
- name: Install Android SDK packages
shell: bash
run: |
set -euo pipefail
SDKROOT="${ANDROID_SDK_ROOT:-$ANDROID_HOME}"
SDKMANAGER="$SDKROOT/cmdline-tools/latest/bin/sdkmanager"
# Some images have cmdline-tools already; ensure path exists
if [[ ! -x "$SDKMANAGER" ]]; then
echo "cmdline-tools not found; installing…"
mkdir -p "$SDKROOT/cmdline-tools"
curl -sSL -o /tmp/clt.zip https://dl.google.com/android/repository/commandlinetools-linux-11076708_latest.zip
sudo unzip -q /tmp/clt.zip -d "$SDKROOT/cmdline-tools"
sudo mv "$SDKROOT/cmdline-tools/cmdline-tools" "$SDKROOT/cmdline-tools/latest"
SDKMANAGER="$SDKROOT/cmdline-tools/latest/bin/sdkmanager"
fi
echo "Installing platform-tools, Build-Tools 35, platform android-35, NDK r28, and CMake…"
# Avoid 'yes' SIGPIPE killing the step: turn off pipefail just for these lines
set +o pipefail
yes | sudo "$SDKMANAGER" --install \
"platform-tools" \
"build-tools;35.0.0" \
"platforms;android-35" \
"ndk;28.0.12433566" \
"cmake;3.22.1"
yes | "$SDKMANAGER" --licenses
set -o pipefail
# Quick sanity prints (non-fatal)
"$SDKROOT/ndk/28.0.12433566/ndk-build" -v >/dev/null 2>&1 || true
"$SDKMANAGER" --list | sed -n '1,80p' || true
# Build and publish locally for the test app to find the SNAPSHOT version
- name: Build ${{ env.PACKAGE_NAME }}
run: |
# 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
run: |
cd src/test/android/testapp/src/main/assets
python3 -m pip install boto3
python3 ./android_file_creation.py
- name: Set Android keystore home
run: |
echo "ANDROID_SDK_HOME=$GITHUB_WORKSPACE/.android-home" >> "$GITHUB_ENV"
echo "ANDROID_PREFS_ROOT=$GITHUB_WORKSPACE/.android-home" >> "$GITHUB_ENV"
mkdir -p "$GITHUB_WORKSPACE/.android-home/.android"
- name: Create debug keystore
run: |
keytool -genkeypair \
-keystore "$ANDROID_SDK_HOME/.android/debug.keystore" \
-storepass android -keypass android \
-alias androiddebugkey \
-dname "CN=Android Debug,O=Android,C=US" \
-keyalg RSA -keysize 2048 -validity 14000
- name: Build Test App
run: |
cd src/test/android/testapp
../../../../gradlew assembledebug
../../../../gradlew assembleAndroidTest
- name: Device Farm Tests Highly Available
run: |
echo "Running Device Farm Python Script"
python3 ./.github/workflows/run_android_ci.py \
--run_id ${{ github.run_id }} \
--run_attempt ${{ github.run_attempt }} \
--project_arn $(aws secretsmanager get-secret-value --region us-east-1 --secret-id "ci/DeviceFarm/ProjectArn" --query "SecretString" | cut -f5 -d\" | cut -f1 -d'\') \
--device_pool_arn $(aws secretsmanager get-secret-value --region us-east-1 --secret-id "ci/DeviceFarm/DevicePoolArn" --query "SecretString" | cut -f5 -d\" | cut -f1 -d'\') \
--device_pool highly_available
- name: Device Farm Tests Android 8.0.0
run: |
echo "Running Device Farm Python Script"
python3 ./.github/workflows/run_android_ci.py \
--run_id ${{ github.run_id }} \
--run_attempt ${{ github.run_attempt }} \
--project_arn $(aws secretsmanager get-secret-value --region us-east-1 --secret-id "ci/DeviceFarm/ProjectArn" --query "SecretString" | cut -f5 -d\" | cut -f1 -d'\') \
--device_pool_arn $(aws secretsmanager get-secret-value --region us-east-1 --secret-id "ci/DeviceFarm/DevicePoolArnAndroid8" --query "SecretString" | cut -f5 -d\" | cut -f1 -d'\') \
--device_pool android_8