-
Notifications
You must be signed in to change notification settings - Fork 1
140 lines (123 loc) · 4.52 KB
/
test.yaml
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
name: Test
on:
push:
branches:
- main
pull_request:
paths:
- '**/*'
workflow_dispatch:
workflow_call:
inputs:
test_data_branch:
type: string
description: The branch in sdk-test-data to target for testcase files
required: false
default: main
sdk_branch:
type: string
description: The branch of the SDK to test
required: false
env:
SDK_BRANCH_NAME: ${{ inputs.sdk_branch || github.head_ref || github.ref_name }}
TEST_DATA_BRANCH_NAME: ${{ inputs.test_data_branch || 'main' }}
ORG_GRADLE_PROJECT_ossrhUsername: ${{ secrets.OSSRH_USERNAME }}
ORG_GRADLE_PROJECT_ossrhPassword: ${{ secrets.OSSRH_PASSWORD }}
CI: true
jobs:
test-android-sdk:
runs-on: ubuntu-latest
steps:
- name: Display Testing Details
run: |
echo "Running SDK Test using"
echo "Test Data: sdk-test-data@${TEST_DATA_BRANCH_NAME}"
echo "SDK Branch: android-sdk@${SDK_BRANCH_NAME}"
- name: Check out Java SDK
uses: actions/checkout@v4
with:
repository: Eppo-exp/android-sdk
ref: ${{ env.SDK_BRANCH_NAME}}
- 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: Set up test data
run: make test-data branchName=${{env.TEST_DATA_BRANCH_NAME}}
- name: Wait for mock UFC DNS to resolve
run: |
for i in {1..15}
do
ip=$(dig +short us-central1-eppo-prod-312905.cloudfunctions.net)
if [[ -n "$ip" ]]; then
echo "Domain resolved to $ip after $i seconds"
exit 0
fi
sleep 1
done
echo "Failed to resolve after 15 seconds"
exit 1
- 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: Run tests
run: ./gradlew check --no-daemon
- name: AVD cache
uses: actions/cache@v4
id: avd-cache
with:
path: |
~/.android/avd/*
~/.android/adb*
key: avd-api-33-${{ 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: 33
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."
- name: Spin up emulator and run tests
id: testing
uses: ReactiveCircus/android-emulator-runner@v2
with:
api-level: 33
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"
adb logcat -c # clear logs
mkdir -p app/ # create directory
touch app/emulator.log # create log file
chmod 777 app/emulator.log # allow writing to log file
adb logcat | grep EppoSDK >> app/emulator.log & # pipe all logcat messages into log file as a background process
./gradlew connectedCheck --no-daemon # run tests
- name: Upload Emulator Logs
if: always()
uses: actions/upload-artifact@v2
with:
name: emulator logs
path: app/emulator.log
- name: Upload Test Report
if: always()
uses: actions/upload-artifact@v2
with:
name: report
path: /Users/runner/work/android-sdk/android-sdk/eppo/build/reports/androidTests/connected/index.html