Test Packaged SDKs #58
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Test Packaged SDKs | |
on: | |
pull_request: | |
paths: | |
- ufc/** | |
push: | |
branches: | |
- main | |
workflow_dispatch: | |
jobs: | |
# test-php-sdk: | |
# strategy: | |
# fail-fast: false | |
# matrix: | |
# platform: ['linux'] | |
# uses: ./.github/workflows/test-server-sdk.yml | |
# with: | |
# platform: ${{ matrix.platform }} | |
# sdkName: 'eppo/php-sdk' | |
# sdkRelayDir: 'php-sdk-relay' | |
# secrets: inherit | |
test-android-sdk: | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
api-level: [26] | |
# Allow other tests to continue if one fails | |
fail-fast: false | |
name: Test API Level ${{ matrix.api-level }} | |
env: | |
EPPO_API_HOST: localhost | |
SDK_RELAY_HOST: localhost | |
TEST_RUNNER_HOST: localhost | |
EPPO_SDK_PLATFORM: linux | |
PROJECT_ID: ${{ vars.SDK_TESTING_PROJECT_ID }} | |
REGION: ${{ vars.SDK_TESTING_REGION }} | |
GAR_LOCATION: ${{ vars.SDK_TESTING_REGION }}-docker.pkg.dev/${{ vars.SDK_TESTING_PROJECT_ID }}/sdk-testing | |
steps: | |
- name: Display Testing Details | |
run: | | |
echo "Running SDK Test using" | |
echo "Test Data: sdk-test-data@${TEST_DATA_BRANCH}" | |
echo "SDK Branch: android-sdk@${SDK_BRANCH}" | |
echo "API Level: ${{ matrix.api-level }}" | |
- uses: actions/checkout@v4 | |
with: | |
repository: Eppo-exp/sdk-test-data | |
- name: Set up JDK 17 | |
uses: actions/setup-java@v3 | |
with: | |
java-version: '17' | |
distribution: 'adopt' | |
- name: Restore gradle.properties | |
shell: bash | |
run: | | |
mkdir -p ~/.gradle/ | |
echo "GRADLE_USER_HOME=${HOME}/.gradle" >> $GITHUB_ENV | |
- 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 | |
- name: Gradle cache | |
uses: gradle/actions/setup-gradle@v3 | |
- name: AVD cache | |
uses: actions/cache@v4 | |
id: avd-cache | |
with: | |
path: | | |
~/.android/avd/* | |
~/.android/adb* | |
key: avd-api-${{ matrix.api-level }}-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }} | |
- name: create AVD and generate snapshot for caching | |
if: steps.avd-cache.outputs.cache-hit != 'true' | |
uses: reactivecircus/android-emulator-runner@v2 | |
with: | |
api-level: ${{ matrix.api-level }} | |
target: google_apis | |
arch: x86_64 | |
force-avd-creation: false | |
emulator-options: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none | |
disable-animations: false | |
script: echo "Generated AVD snapshot for caching." | |
# Set up gCloud | |
- id: "auth" | |
uses: "google-github-actions/auth@v1" | |
with: | |
credentials_json: "${{ secrets.SERVICE_ACCOUNT_KEY }}" | |
- name: "Set up Cloud SDK" | |
uses: "google-github-actions/setup-gcloud@v1" | |
# Allow docker access to the GAR | |
- name: "Docker auth" | |
run: gcloud auth configure-docker ${{ env.REGION }}-docker.pkg.dev --quiet | |
# Pull test runner and testing api images for GCP Artifact Registry (GAR) and | |
# retag them locally as expected by the runner script. | |
- name: Pull Test Runner image | |
run: | | |
docker pull ${{ env.GAR_LOCATION }}/sdk-test-runner:latest | |
docker tag ${{ env.GAR_LOCATION }}/sdk-test-runner:latest Eppo-exp/sdk-test-runner:latest | |
docker pull ${{ env.GAR_LOCATION }}/testing-api:latest | |
docker tag ${{ env.GAR_LOCATION }}/testing-api:latest Eppo-exp/testing-api:latest | |
- name: Spin up emulator and run tests | |
id: testing | |
uses: ReactiveCircus/android-emulator-runner@v2 | |
with: | |
api-level: ${{ matrix.api-level }} | |
target: google_apis | |
arch: x86_64 | |
force-avd-creation: false | |
emulator-options: -no-snapshot-save -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none -netdelay none -netspeed full -dns-server 8.8.8.8 | |
disable-animations: true | |
script: | | |
echo "Emulator started" | |
mkdir -p app/ # create directory | |
touch app/emulator.log # create log file | |
chmod 777 app/emulator.log # allow writing to log file | |
adb logcat >> app/emulator.log & # pipe all logcat messages into log file as a background process | |
cd package-testing/sdk-test-runner && ./test-sdk.sh client android | |
- name: Upload Emulator Logs | |
if: always() | |
uses: actions/upload-artifact@v4 | |
with: | |
name: emulator-logs-api-level-${{ matrix.api-level }} | |
path: app/emulator.log | |
- name: Upload Test Report | |
if: always() | |
uses: actions/upload-artifact@v4 | |
with: | |
name: report-api-level-${{ matrix.api-level }} | |
path: /Users/runner/work/android-sdk/android-sdk/eppo/build/reports/androidTests/connected/index.html |