diff --git a/.github/workflows/functional-test.yml b/.github/workflows/functional-test.yml index 2fbbc528..089ceb9b 100644 --- a/.github/workflows/functional-test.yml +++ b/.github/workflows/functional-test.yml @@ -58,16 +58,22 @@ jobs: appium plugin install execute-driver nohup appium --use-plugins=images,execute-driver --relaxed-security --log-timestamp --log-no-colors > appium.log & + - run: | + npx appium driver run xcuitest download-wda-sim --platform=ios --outdir=${{ github.workspace }}/wda + name: Downloading prebuilt WDA + - name: Set up Ruby uses: ruby/setup-ruby@v1 with: ruby-version: 4.0 - run: | bundle install - rake ios + bundle exec rake ios name: Run tests timeout-minutes: 60 working-directory: ios_tests + env: + LOCAL_PREBUILT_WDA: ${{ github.workspace }}/wda/WebDriverAgentRunner-Runner.app - name: Save server output if: ${{ always() }} @@ -77,3 +83,88 @@ jobs: path: | appium.log test/report/ + + android_test: + runs-on: ubuntu-latest + timeout-minutes: 90 + env: + API_LEVEL: 35 + ARCH: x86_64 + + steps: + - uses: actions/checkout@v6 + + - name: Set up Java + uses: actions/setup-java@v5 + with: + distribution: temurin + java-version: '17' + + - name: Install Node.js + uses: actions/setup-node@v6 + with: + node-version: 'lts/*' + + - name: Set up Ruby + uses: ruby/setup-ruby@v1 + with: + ruby-version: 4.0 + + - name: Install appium + run: | + npm install -g appium + npm install -g mjpeg-consumer + + - name: Start appium + run: | + appium driver install uiautomator2 + appium plugin install images + appium plugin install execute-driver + nohup appium --use-plugins=images,execute-driver --relaxed-security --log-timestamp --log-no-colors > appium.log & + + - name: Enable KVM group perms + 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: AVD cache + uses: actions/cache@v4 + id: avd-cache + with: + path: | + ~/.android/avd/* + ~/.android/adb* + key: avd-${{ env.API_LEVEL }} + + - name: Create AVD snapshot for cache + if: steps.avd-cache.outputs.cache-hit != 'true' + uses: reactivecircus/android-emulator-runner@v2 + with: + api-level: ${{ env.API_LEVEL }} + arch: ${{ env.ARCH }} + target: google_apis + 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: run tests + uses: reactivecircus/android-emulator-runner@v2 + with: + api-level: ${{ env.API_LEVEL }} + arch: ${{ env.ARCH }} + script: cd android_tests;bundle install;bundle exec rake --tasks;bundle exec rake android + target: google_apis + profile: Nexus 5X + disable-spellchecker: true + disable-animations: true + + - name: Save server output + if: ${{ always() }} + uses: actions/upload-artifact@master + with: + name: appium-android_test_with_other_deps.log + path: | + appium.log + test/report/ diff --git a/android_tests/Rakefile b/android_tests/Rakefile index b9fab19c..89cf6593 100644 --- a/android_tests/Rakefile +++ b/android_tests/Rakefile @@ -29,10 +29,12 @@ end def bash(cmd) sh cmd do |successful, result| # exitstatus 7 means bundle install failed - # exitstatus 1 means the test failed + # non-zero (except 7 retry path) means the test failed if !successful && result.exitstatus == 7 Rake::Task['install'].execute - run_sh cmd + sh cmd + elsif !successful + raise "Command failed with status #{result.exitstatus}: #{cmd}" end end end diff --git a/android_tests/lib/run.rb b/android_tests/lib/run.rb index b83fd5f3..b97505f4 100644 --- a/android_tests/lib/run.rb +++ b/android_tests/lib/run.rb @@ -65,7 +65,11 @@ def start_driver(caps) else caps.merge(appium_lib: { debug: true, wait: 1 }) end -caps[:app] = ENV.fetch('SAUCE_PATH', nil) if ENV.fetch('SAUCE_USERNAME', nil) && ENV.fetch('SAUCE_ACCESS_KEY', nil) + +if ENV['LOCAL_PREBUILT_WDA'] + caps[:caps][:usePreinstalledWDA] = true + caps[:caps][:prebuiltWDAPath] = ENV['LOCAL_PREBUILT_WDA'] +end trace_files = [] diff --git a/ios_tests/Rakefile b/ios_tests/Rakefile index 8cde5a3a..ba135d24 100644 --- a/ios_tests/Rakefile +++ b/ios_tests/Rakefile @@ -29,10 +29,12 @@ end def bash(cmd) sh cmd do |successful, result| # exitstatus 7 means bundle install failed - # exitstatus 1 means the test failed + # non-zero (except 7 retry path) means the test failed if !successful && result.exitstatus == 7 Rake::Task['install'].execute - run_sh cmd + sh cmd + elsif !successful + raise "Command failed with status #{result.exitstatus}: #{cmd}" end end end