From b90e5f60dfadd7c47281bd3e41baa0ad64d2b0f1 Mon Sep 17 00:00:00 2001 From: Jheng-Hao Lin Date: Fri, 13 Oct 2023 23:04:03 +0100 Subject: [PATCH] Add UI test GHA flow --- .github/workflows/codeql-analysis.yml | 7 ++++ .github/workflows/ui-test.yml | 47 +++++++++++++++++++++++++ .github/workflows/verify-pr.yml | 7 ++++ scripts/android-sdk-packages | 5 +++ scripts/install-android-sdk-packages.sh | 12 +++++++ 5 files changed, 78 insertions(+) create mode 100644 .github/workflows/ui-test.yml create mode 100644 scripts/android-sdk-packages create mode 100644 scripts/install-android-sdk-packages.sh diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index fce8dab35..a893a819d 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -7,6 +7,13 @@ on: # The branches below must be a subset of the branches above types: [ opened, synchronize, reopened ] branches: [ master, "bugfix/*", "feature/*", "release/*" ] + paths: + - 'checkout/**' + - 'example_app_frames/**' + - 'app/**' + - 'frames/**' + - 'buildSrc/**' + - 'build.gradle.kt' schedule: - cron: '34 2 * * 0' diff --git a/.github/workflows/ui-test.yml b/.github/workflows/ui-test.yml new file mode 100644 index 000000000..1be56f8e9 --- /dev/null +++ b/.github/workflows/ui-test.yml @@ -0,0 +1,47 @@ +name: UI Test + +on: + pull_request: + types: [ opened, synchronize, reopened ] + branches: [ "**" ] + +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: true + +jobs: + ui-test: + name: UI Test + runs-on: ubuntu-latest + strategy: + fail-fast: true + + steps: + - name: Checkout Code + uses: actions/checkout@v3 + with: + fetch-depth: 0 + + - name: Set up JDK 11 + uses: actions/setup-java@v3 + with: + java-version: '11' + distribution: 'temurin' + cache: gradle + + - name: Grant execute permission for gradlew + run: chmod +x gradlew + + - name: Cache Gradle and wrapper + uses: actions/cache@v3 + with: + path: | + ~/.gradle/caches + ~/.gradle/wrapper + key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*') }} + + - name: Install Android SDK Packages and Launch Emulator + run: chmod +x ./scripts/install-android-sdk-packages.sh && ./scripts/install-android-sdk-packages.sh + + - name: UI Test + run: ./gradlew :frames:connectedDebugAndroidTest \ No newline at end of file diff --git a/.github/workflows/verify-pr.yml b/.github/workflows/verify-pr.yml index a8c535cfa..886a9e56d 100644 --- a/.github/workflows/verify-pr.yml +++ b/.github/workflows/verify-pr.yml @@ -7,6 +7,13 @@ on: # The branches below must be a subset of the branches above types: [ opened, synchronize, reopened ] branches: [ master, "bugfix/*", "feature/*", "release/*" ] + paths: + - 'checkout/**' + - 'example_app_frames/**' + - 'app/**' + - 'frames/**' + - 'buildSrc/**' + - 'build.gradle.kt' concurrency: group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} diff --git a/scripts/android-sdk-packages b/scripts/android-sdk-packages new file mode 100644 index 000000000..74c3207f7 --- /dev/null +++ b/scripts/android-sdk-packages @@ -0,0 +1,5 @@ +platform-tools +platforms;android-29 +build-tools;29.0.3 +emulator +system-images;android-29;google_apis;x86_64 \ No newline at end of file diff --git a/scripts/install-android-sdk-packages.sh b/scripts/install-android-sdk-packages.sh new file mode 100644 index 000000000..bc6484eb1 --- /dev/null +++ b/scripts/install-android-sdk-packages.sh @@ -0,0 +1,12 @@ +#!/bin/sh + +# Please run this AFTER running scripts/setup-android-env.sh +yes | $ANDROID_SDK_ROOT/cmdline-tools/latest/bin/sdkmanager --package_file=./scripts/android-sdk-packages --sdk_root=$ANDROID_SDK_ROOT + +# Create an AVD +$ANDROID_SDK_ROOT/cmdline-tools/latest/bin/avdmanager create avd -n testingAVD -d pixel --package "system-images;android-29;google_apis;x86_64" + +# Start an emulator +$ANDROID_SDK_ROOT/emulator/emulator -avd testingAVD -no-window -no-audio -no-snapshot -no-boot-anim -camera-back none -camera-front none +#$ANDROID_SDK_ROOT/emulator/emulator -avd testingAVD -no-audio -no-window -no-boot-anim -no-snapshot -camera-back none -camera-front none -selinux permissive -qemu -vnc :0 +