GitHub Actions: run Android tests on emulator in CI
parent
5851347609
commit
caf55f87de
|
|
@ -1,21 +1,18 @@
|
|||
name: Android Gradle Build test logic
|
||||
name: Android Gradle Build and Test
|
||||
|
||||
on:
|
||||
workflow_call:
|
||||
inputs:
|
||||
os:
|
||||
required: true
|
||||
type: string
|
||||
jdk_distro:
|
||||
required: true
|
||||
type: string
|
||||
jdk_version:
|
||||
required: true
|
||||
type: string
|
||||
push:
|
||||
branches: [ 'master', 'main', 'release/**' ]
|
||||
pull_request:
|
||||
branches: [ 'master' ]
|
||||
|
||||
concurrency:
|
||||
group: android-${{ github.head_ref || github.ref }}
|
||||
cancel-in-progress: true
|
||||
|
||||
jobs:
|
||||
build_wolfssljni:
|
||||
runs-on: ${{ inputs.os }}
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Clone wolfssljni
|
||||
uses: actions/checkout@v4
|
||||
|
|
@ -31,22 +28,89 @@ jobs:
|
|||
- name: Create blank options.h
|
||||
run: cp IDE/Android/app/src/main/cpp/wolfssl/wolfssl/options.h.in IDE/Android/app/src/main/cpp/wolfssl/wolfssl/options.h
|
||||
|
||||
# Setup Java
|
||||
# Setup Java with Gradle caching
|
||||
- name: Setup java
|
||||
uses: actions/setup-java@v4
|
||||
with:
|
||||
distribution: ${{ inputs.jdk_distro }}
|
||||
java-version: ${{ inputs.jdk_version }}
|
||||
distribution: 'zulu'
|
||||
java-version: '21'
|
||||
cache: 'gradle'
|
||||
|
||||
# Gradle assembleDebug
|
||||
- name: Gradle assembleDebug
|
||||
run: cd IDE/Android && ls && ./gradlew assembleDebug
|
||||
# Build all targets in single Gradle invocation
|
||||
- name: Gradle Build
|
||||
run: cd IDE/Android && ./gradlew --build-cache assembleDebug assembleDebugUnitTest assembleDebugAndroidTest
|
||||
|
||||
# Gradle assembleDebugUnitTest
|
||||
- name: Gradle assembleDebugUnitTest
|
||||
run: cd IDE/Android && ls && ./gradlew assembleDebugUnitTest
|
||||
# Download Bouncy Castle provider for BKS conversion
|
||||
- name: Download Bouncy Castle Provider
|
||||
run: |
|
||||
wget -q https://repo1.maven.org/maven2/org/bouncycastle/bcprov-jdk18on/1.78.1/bcprov-jdk18on-1.78.1.jar -O /tmp/bcprov.jar
|
||||
|
||||
# Gradle assembleDebugAndroidTest
|
||||
- name: Gradle assembleDebugAndroidTest
|
||||
run: cd IDE/Android && ls && ./gradlew assembleDebugAndroidTest
|
||||
# Convert JKS keystores to BKS format for Android
|
||||
- name: Convert JKS to BKS
|
||||
run: |
|
||||
cd examples/provider
|
||||
./convert-to-bks.sh /tmp/bcprov.jar
|
||||
|
||||
# Enable KVM for hardware acceleration (required for emulator)
|
||||
- name: Enable KVM
|
||||
run: |
|
||||
echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules
|
||||
sudo udevadm control --reload-rules
|
||||
sudo udevadm trigger --name-match=kvm
|
||||
|
||||
# Cache AVD snapshot for faster emulator boot
|
||||
- name: AVD cache
|
||||
uses: actions/cache@v4
|
||||
id: avd-cache
|
||||
with:
|
||||
path: |
|
||||
~/.android/avd/*
|
||||
~/.android/adb*
|
||||
key: avd-30-x86_64-atd-v1
|
||||
|
||||
# Create AVD and generate snapshot for caching
|
||||
- name: Create AVD and generate snapshot
|
||||
if: steps.avd-cache.outputs.cache-hit != 'true'
|
||||
uses: reactivecircus/android-emulator-runner@v2
|
||||
with:
|
||||
api-level: 30
|
||||
arch: x86_64
|
||||
target: aosp_atd
|
||||
force-avd-creation: false
|
||||
emulator-options: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
|
||||
disable-animations: true
|
||||
script: echo "Generated AVD snapshot for caching"
|
||||
|
||||
# Run instrumented tests on Android emulator
|
||||
- name: Run Android Instrumented Tests
|
||||
uses: reactivecircus/android-emulator-runner@v2
|
||||
timeout-minutes: 15
|
||||
with:
|
||||
api-level: 30
|
||||
arch: x86_64
|
||||
target: aosp_atd
|
||||
force-avd-creation: false
|
||||
emulator-options: -no-snapshot-save -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
|
||||
disable-animations: true
|
||||
script: |
|
||||
adb wait-for-device
|
||||
adb shell mkdir -p /data/local/tmp/examples/provider
|
||||
adb shell mkdir -p /data/local/tmp/examples/certs/intermediate
|
||||
adb push ./examples/provider/*.bks /data/local/tmp/examples/provider/
|
||||
adb push ./examples/certs/ /data/local/tmp/examples/
|
||||
adb logcat -c
|
||||
cd IDE/Android && ./gradlew connectedDebugAndroidTest --info || { adb logcat -d > /tmp/logcat.txt; echo "=== LOGCAT (errors) ==="; grep -i "exception\|error\|fatal" /tmp/logcat.txt || true; exit 1; }
|
||||
adb logcat -d > /tmp/logcat.txt
|
||||
|
||||
# Upload test reports even on failure
|
||||
- name: Upload Test Reports
|
||||
uses: actions/upload-artifact@v4
|
||||
if: always()
|
||||
timeout-minutes: 5
|
||||
with:
|
||||
name: android-test-reports
|
||||
path: |
|
||||
IDE/Android/app/build/reports/androidTests/
|
||||
/tmp/logcat.txt
|
||||
retention-days: 14
|
||||
|
||||
|
|
|
|||
|
|
@ -173,21 +173,6 @@ jobs:
|
|||
jdk_version: ${{ matrix.jdk_version }}
|
||||
wolfssl_configure: ${{ matrix.wolfssl_configure }}
|
||||
|
||||
# ----------------------- Android Gradle build ------------------------
|
||||
# Run Android gradle build over PR code, only running on Linux with one
|
||||
# JDK/version for now.
|
||||
android-gradle:
|
||||
strategy:
|
||||
matrix:
|
||||
os: [ 'ubuntu-latest' ]
|
||||
jdk_version: [ '21' ]
|
||||
name: Android Gradle (${{ matrix.os }} Zulu JDK ${{ matrix.jdk_version }})
|
||||
uses: ./.github/workflows/android_gradle.yml
|
||||
with:
|
||||
os: ${{ matrix.os }}
|
||||
jdk_distro: "zulu"
|
||||
jdk_version: ${{ matrix.jdk_version }}
|
||||
|
||||
# --------------------- Maven build - test pom.xml --------------------
|
||||
# Run Maven build over PR code, running on Linux and Mac with only one
|
||||
# JDK/version for now.
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@
|
|||
/.idea/workspace.xml
|
||||
/.idea/navEditor.xml
|
||||
/.idea/assetWizardSettings.xml
|
||||
/.idea/androidTestResultsUserPreferences.xml
|
||||
.DS_Store
|
||||
/build
|
||||
/captures
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ import org.junit.runners.Suite;
|
|||
WolfSSLSessionContextTest.class,
|
||||
WolfSSLX509Test.class,
|
||||
WolfSSLKeyX509Test.class,
|
||||
WolfSSLServiceLoaderTest.class,
|
||||
WolfSSLServiceLoaderTest.class
|
||||
})
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -50,12 +50,6 @@ public class WolfSSLServiceLoaderTest {
|
|||
@BeforeClass
|
||||
public static void setUpClass() {
|
||||
System.out.println("JSSE WolfSSLProvider ServiceLoader Test");
|
||||
|
||||
/* Skip all tests on Android - ServiceLoader relies on
|
||||
* META-INF/services which is a JAR/module system mechanism
|
||||
* not available in Android builds */
|
||||
Assume.assumeFalse("Skipping on Android",
|
||||
WolfSSLTestFactory.isAndroid());
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -65,6 +59,11 @@ public class WolfSSLServiceLoaderTest {
|
|||
*/
|
||||
@Test
|
||||
public void testProviderDiscoverableViaServiceLoader() {
|
||||
|
||||
/* Skip on Android - ServiceLoader relies on META-INF/services
|
||||
* which is a JAR/module system mechanism not available on Android */
|
||||
Assume.assumeFalse("Skipping on Android",
|
||||
WolfSSLTestFactory.isAndroid());
|
||||
ServiceLoader<Provider> serviceLoader =
|
||||
ServiceLoader.load(Provider.class);
|
||||
|
||||
|
|
@ -104,6 +103,12 @@ public class WolfSSLServiceLoaderTest {
|
|||
*/
|
||||
@Test
|
||||
public void testServiceLoaderProviderIsFunctional() throws Exception {
|
||||
|
||||
/* Skip on Android - ServiceLoader relies on META-INF/services
|
||||
* which is a JAR/module system mechanism not available on Android */
|
||||
Assume.assumeFalse("Skipping on Android",
|
||||
WolfSSLTestFactory.isAndroid());
|
||||
|
||||
ServiceLoader<Provider> serviceLoader =
|
||||
ServiceLoader.load(Provider.class);
|
||||
|
||||
|
|
@ -147,6 +152,12 @@ public class WolfSSLServiceLoaderTest {
|
|||
*/
|
||||
@Test
|
||||
public void testServiceLoaderProviderMatchesDirectInstance() {
|
||||
|
||||
/* Skip on Android - ServiceLoader relies on META-INF/services
|
||||
* which is a JAR/module system mechanism not available on Android */
|
||||
Assume.assumeFalse("Skipping on Android",
|
||||
WolfSSLTestFactory.isAndroid());
|
||||
|
||||
ServiceLoader<Provider> serviceLoader =
|
||||
ServiceLoader.load(Provider.class);
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue