Skip to content

Commit 555767c

Browse files
authored
ci: add android (#1106)
* ci: add android * use prebuilt one * tune task * use bundle exec rake * use pushd and popd * run one script * modify rake
1 parent 59a27af commit 555767c

4 files changed

Lines changed: 105 additions & 6 deletions

File tree

.github/workflows/functional-test.yml

Lines changed: 92 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,16 +58,22 @@ jobs:
5858
appium plugin install execute-driver
5959
nohup appium --use-plugins=images,execute-driver --relaxed-security --log-timestamp --log-no-colors > appium.log &
6060
61+
- run: |
62+
npx appium driver run xcuitest download-wda-sim --platform=ios --outdir=${{ github.workspace }}/wda
63+
name: Downloading prebuilt WDA
64+
6165
- name: Set up Ruby
6266
uses: ruby/setup-ruby@v1
6367
with:
6468
ruby-version: 4.0
6569
- run: |
6670
bundle install
67-
rake ios
71+
bundle exec rake ios
6872
name: Run tests
6973
timeout-minutes: 60
7074
working-directory: ios_tests
75+
env:
76+
LOCAL_PREBUILT_WDA: ${{ github.workspace }}/wda/WebDriverAgentRunner-Runner.app
7177
7278
- name: Save server output
7379
if: ${{ always() }}
@@ -77,3 +83,88 @@ jobs:
7783
path: |
7884
appium.log
7985
test/report/
86+
87+
android_test:
88+
runs-on: ubuntu-latest
89+
timeout-minutes: 90
90+
env:
91+
API_LEVEL: 35
92+
ARCH: x86_64
93+
94+
steps:
95+
- uses: actions/checkout@v6
96+
97+
- name: Set up Java
98+
uses: actions/setup-java@v5
99+
with:
100+
distribution: temurin
101+
java-version: '17'
102+
103+
- name: Install Node.js
104+
uses: actions/setup-node@v6
105+
with:
106+
node-version: 'lts/*'
107+
108+
- name: Set up Ruby
109+
uses: ruby/setup-ruby@v1
110+
with:
111+
ruby-version: 4.0
112+
113+
- name: Install appium
114+
run: |
115+
npm install -g appium
116+
npm install -g mjpeg-consumer
117+
118+
- name: Start appium
119+
run: |
120+
appium driver install uiautomator2
121+
appium plugin install images
122+
appium plugin install execute-driver
123+
nohup appium --use-plugins=images,execute-driver --relaxed-security --log-timestamp --log-no-colors > appium.log &
124+
125+
- name: Enable KVM group perms
126+
run: |
127+
echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules
128+
sudo udevadm control --reload-rules
129+
sudo udevadm trigger --name-match=kvm
130+
131+
- name: AVD cache
132+
uses: actions/cache@v4
133+
id: avd-cache
134+
with:
135+
path: |
136+
~/.android/avd/*
137+
~/.android/adb*
138+
key: avd-${{ env.API_LEVEL }}
139+
140+
- name: Create AVD snapshot for cache
141+
if: steps.avd-cache.outputs.cache-hit != 'true'
142+
uses: reactivecircus/android-emulator-runner@v2
143+
with:
144+
api-level: ${{ env.API_LEVEL }}
145+
arch: ${{ env.ARCH }}
146+
target: google_apis
147+
force-avd-creation: false
148+
emulator-options: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
149+
disable-animations: false
150+
script: echo "Generated AVD snapshot for caching."
151+
152+
- name: run tests
153+
uses: reactivecircus/android-emulator-runner@v2
154+
with:
155+
api-level: ${{ env.API_LEVEL }}
156+
arch: ${{ env.ARCH }}
157+
script: cd android_tests;bundle install;bundle exec rake --tasks;bundle exec rake android
158+
target: google_apis
159+
profile: Nexus 5X
160+
disable-spellchecker: true
161+
disable-animations: true
162+
163+
- name: Save server output
164+
if: ${{ always() }}
165+
uses: actions/upload-artifact@master
166+
with:
167+
name: appium-android_test_with_other_deps.log
168+
path: |
169+
appium.log
170+
test/report/

android_tests/Rakefile

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,12 @@ end
2929
def bash(cmd)
3030
sh cmd do |successful, result|
3131
# exitstatus 7 means bundle install failed
32-
# exitstatus 1 means the test failed
32+
# non-zero (except 7 retry path) means the test failed
3333
if !successful && result.exitstatus == 7
3434
Rake::Task['install'].execute
35-
run_sh cmd
35+
sh cmd
36+
elsif !successful
37+
raise "Command failed with status #{result.exitstatus}: #{cmd}"
3638
end
3739
end
3840
end

android_tests/lib/run.rb

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,11 @@ def start_driver(caps)
6565
else
6666
caps.merge(appium_lib: { debug: true, wait: 1 })
6767
end
68-
caps[:app] = ENV.fetch('SAUCE_PATH', nil) if ENV.fetch('SAUCE_USERNAME', nil) && ENV.fetch('SAUCE_ACCESS_KEY', nil)
68+
69+
if ENV['LOCAL_PREBUILT_WDA']
70+
caps[:caps][:usePreinstalledWDA] = true
71+
caps[:caps][:prebuiltWDAPath] = ENV['LOCAL_PREBUILT_WDA']
72+
end
6973

7074
trace_files = []
7175

ios_tests/Rakefile

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,12 @@ end
2929
def bash(cmd)
3030
sh cmd do |successful, result|
3131
# exitstatus 7 means bundle install failed
32-
# exitstatus 1 means the test failed
32+
# non-zero (except 7 retry path) means the test failed
3333
if !successful && result.exitstatus == 7
3434
Rake::Task['install'].execute
35-
run_sh cmd
35+
sh cmd
36+
elsif !successful
37+
raise "Command failed with status #{result.exitstatus}: #{cmd}"
3638
end
3739
end
3840
end

0 commit comments

Comments
 (0)