Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Try to run android tests on simulator #2680

Merged
merged 24 commits into from
Oct 19, 2021
Merged
Show file tree
Hide file tree
Changes from 19 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 54 additions & 4 deletions .github/templates/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ steps:
#@ def netFrameworkTestSteps():
- #@ template.replace(msbuildOnWin("Tests/Realm.Tests", TargetFramework="net461"))
- name: Run the tests
run: #@ "./Tests/Realm.Tests/bin/" + configuration + "/net461/Realm.Tests.exe --result=TestResults.Windows.xml --labels=After --baasurl ${{ secrets.REALM_BASE_URL }}"
run: #@ "./Tests/Realm.Tests/bin/" + configuration + "/net461/Realm.Tests.exe --result=TestResults.Windows.xml --labels=After --baasurl=${{ secrets.REALM_BASE_URL }}"
- #@ publishTestsResults("TestResults.Windows.xml", ".NET Framework")
#@ end

Expand All @@ -161,7 +161,7 @@ steps:
#@ def xamarinMacTestSteps():
- #@ msbuild("Tests/Tests.XamarinMac", TargetFrameworkVersion="v2.0", RestoreConfigFile="Tests/Test.NuGet.Config", UseRealmNupkgsWithVersion="${{ needs.build-packages.outputs.package_version }}")
- name: Run the tests
run: #@ "Tests/Tests.XamarinMac/bin/" + configuration + "/Tests.XamarinMac.app/Contents/MacOS/Tests.XamarinMac --headless --labels=All --baasurl ${{ secrets.REALM_BASE_URL }} --result=${{ github.workspace }}/TestResults.macOS.xml"
run: #@ "Tests/Tests.XamarinMac/bin/" + configuration + "/Tests.XamarinMac.app/Contents/MacOS/Tests.XamarinMac --headless --labels=All --baasurl=${{ secrets.REALM_BASE_URL }} --result=${{ github.workspace }}/TestResults.macOS.xml"
- #@ publishTestsResults("TestResults.macOS.xml", "Xamarin.macOS")
#@ end

Expand All @@ -173,10 +173,59 @@ steps:
appPath: 'Tests/Tests.iOS/bin/iPhoneSimulator/Release/Tests.iOS.app'
bundleId: 'io.realm.dotnettests'
iphoneToSimulate: 'iPhone-8'
arguments: "--headless --resultpath ${{ github.workspace }}/TestResults.iOS.xml --baasurl ${{ secrets.REALM_BASE_URL }} --baasapps ${{ env.APPS_CONFIG }}"
arguments: "--headless --result=${{ github.workspace }}/TestResults.iOS.xml --baasurl=${{ secrets.REALM_BASE_URL }} --baasapps=${{ env.APPS_CONFIG }}"
- #@ publishTestsResults("TestResults.iOS.xml", "Xamarin.iOS")
#@ end

#@ def xamarinAndroidTestSteps():
- #@ msbuild("Tests/Tests.Android", target="SignAndroidPackage", AndroidSupportedAbis="x86_64", AndroidUseSharedRuntime="False", EmbedAssembliesIntoApk="True", RestoreConfigFile="Tests/Test.NuGet.Config", UseRealmNupkgsWithVersion="${{ needs.build-packages.outputs.package_version }}")
- name: AVD cache
uses: actions/cache@v2
id: avd-cache
with:
path: |
~/.android/avd/*
~/.android/adb*
key: android-avd
- name: Create AVD for caching
if: steps.avd-cache.outputs.cache-hit != 'true'
uses: reactivecircus/android-emulator-runner@v2
with:
api-level: 29
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: Run the tests
uses: reactivecircus/android-emulator-runner@v2
with:
api-level: 29
arch: x86_64
force-avd-creation: false
emulator-options: -no-snapshot-save -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
disable-animations: true
script: |
adb devices
adb logcat -c
adb logcat -v time > "${{ github.workspace }}/logcat.txt" &

adb install ${{ github.workspace }}/Tests/Tests.Android/bin/Release/io.realm.xamarintests-Signed.apk
adb shell pm grant io.realm.xamarintests android.permission.READ_EXTERNAL_STORAGE
adb shell pm grant io.realm.xamarintests android.permission.WRITE_EXTERNAL_STORAGE

echo "--baasurl=${{ secrets.REALM_BASE_URL }} --baasapps=${{ env.APPS_CONFIG }}" > ${{ github.workspace }}/testargs.txt
adb push ${{ github.workspace }}/testargs.txt /storage/emulated/0/RealmTests/testargs.txt

adb shell am instrument -w -r io.realm.xamarintests/.TestRunner
adb pull /storage/emulated/0/RealmTests/TestResults.Android.xml ${{ github.workspace }}/TestResults.Android.xml
adb shell rm /sdcard/Realmtests/TestResults.Android.xml
- name: Output logcat
if: always()
run: cat logcat.txt
- #@ publishTestsResults("TestResults.Android.xml", "Xamarin.Android")
#@ end

#@ def codeCoverageTestSteps():
- uses: #@ actionSetupDotnet
with:
Expand All @@ -188,7 +237,7 @@ steps:
echo "${{ github.workspace }}/tools" >> $GITHUB_PATH
- #@ template.replace(dotnetPublish("Tests/Realm.Tests", "net5.0", { "AdditionalFrameworks": "net5.0" }))
- name: Run the tests
run: ./tools/coverlet ${{ steps.dotnet-publish.outputs.executable-path }} -t ${{ steps.dotnet-publish.outputs.executable-path }}/Realm.Tests -a "--result=TestResults.Linux.xml --labels=After --baasurl ${{ secrets.REALM_BASE_URL }}" -f lcov -o ./report.lcov --exclude '[Realm.Tests]*' --exclude '[Realm.Fody]*'
run: ./tools/coverlet ${{ steps.dotnet-publish.outputs.executable-path }} -t ${{ steps.dotnet-publish.outputs.executable-path }}/Realm.Tests -a "--result=TestResults.Linux.xml --labels=After --baasurl=${{ secrets.REALM_BASE_URL }}" -f lcov -o ./report.lcov --exclude '[Realm.Tests]*' --exclude '[Realm.Fody]*'
- name: Publish Coverage
id: publish-coveralls
uses: #@ actionCoveralls
Expand Down Expand Up @@ -463,6 +512,7 @@ jobs:
- #@ publishTestsResults("TestResults.xml", ".NET (${{ matrix.os }}, ${{ matrix.targetFramework }})")
_: #@ template.replace(testJob("Xamarin.macOS", "macos-latest", xamarinMacTestSteps()))
_: #@ template.replace(testJob("Xamarin.iOS", "macos-latest", xamariniOSTestSteps()))
_: #@ template.replace(testJob("Xamarin.Android", "macos-latest", xamarinAndroidTestSteps()))
run-tests-weaver:
runs-on: windows-latest
name: Test Weaver
Expand Down
130 changes: 126 additions & 4 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -460,7 +460,7 @@ jobs:
- name: Build Tests/Realm.Tests
run: msbuild Tests/Realm.Tests -p:Configuration=Release -restore -p:RestoreConfigFile=Tests/Test.NuGet.Config -p:UseRealmNupkgsWithVersion=${{ needs.build-packages.outputs.package_version }} -p:TargetFramework=net461
- name: Run the tests
run: ./Tests/Realm.Tests/bin/Release/net461/Realm.Tests.exe --result=TestResults.Windows.xml --labels=After --baasurl ${{ secrets.REALM_BASE_URL }}
run: ./Tests/Realm.Tests/bin/Release/net461/Realm.Tests.exe --result=TestResults.Windows.xml --labels=After --baasurl=${{ secrets.REALM_BASE_URL }}
- name: Publish Unit Test Results
uses: LaPeste/test-reporter@b8a650f4490e7472b930f56bbb92c7b42dc5db15
if: always()
Expand Down Expand Up @@ -692,7 +692,7 @@ jobs:
- name: Build Tests/Tests.XamarinMac
run: msbuild Tests/Tests.XamarinMac -p:Configuration=Release -restore -p:TargetFrameworkVersion=v2.0 -p:RestoreConfigFile=Tests/Test.NuGet.Config -p:UseRealmNupkgsWithVersion=${{ needs.build-packages.outputs.package_version }}
- name: Run the tests
run: Tests/Tests.XamarinMac/bin/Release/Tests.XamarinMac.app/Contents/MacOS/Tests.XamarinMac --headless --labels=All --baasurl ${{ secrets.REALM_BASE_URL }} --result=${{ github.workspace }}/TestResults.macOS.xml
run: Tests/Tests.XamarinMac/bin/Release/Tests.XamarinMac.app/Contents/MacOS/Tests.XamarinMac --headless --labels=All --baasurl=${{ secrets.REALM_BASE_URL }} --result=${{ github.workspace }}/TestResults.macOS.xml
- name: Publish Unit Test Results
uses: LaPeste/test-reporter@b8a650f4490e7472b930f56bbb92c7b42dc5db15
if: always()
Expand Down Expand Up @@ -777,7 +777,7 @@ jobs:
appPath: Tests/Tests.iOS/bin/iPhoneSimulator/Release/Tests.iOS.app
bundleId: io.realm.dotnettests
iphoneToSimulate: iPhone-8
arguments: --headless --resultpath ${{ github.workspace }}/TestResults.iOS.xml --baasurl ${{ secrets.REALM_BASE_URL }} --baasapps ${{ env.APPS_CONFIG }}
arguments: --headless --result=${{ github.workspace }}/TestResults.iOS.xml --baasurl=${{ secrets.REALM_BASE_URL }} --baasapps=${{ env.APPS_CONFIG }}
- name: Publish Unit Test Results
uses: LaPeste/test-reporter@b8a650f4490e7472b930f56bbb92c7b42dc5db15
if: always()
Expand Down Expand Up @@ -807,6 +807,128 @@ jobs:
apiKey: ${{ secrets.ATLAS_PUBLIC_API_KEY }}
privateApiKey: ${{ secrets.ATLAS_PRIVATE_API_KEY }}
differentiator: Xamarin.iOS
baas-xamarinandroid:
runs-on: ubuntu-latest
name: Deploy MDB Realm for Xamarin.Android
outputs:
deployedApps: ${{ steps.deploy-mdb-apps.outputs.deployedApps }}
steps:
- name: Checkout code
uses: actions/checkout@v2
with:
submodules: false
ref: ${{ github.event.pull_request.head.sha }}
- uses: realm/ci-actions/mdb-realm/deployApps@fe278fedebba5508c052e970fffa099de1285dff
id: deploy-mdb-apps
with:
projectId: ${{ secrets.ATLAS_PROJECT_ID }}
apiKey: ${{ secrets.ATLAS_PUBLIC_API_KEY }}
privateApiKey: ${{ secrets.ATLAS_PRIVATE_API_KEY }}
appsPath: ${{ github.workspace }}/Tests/TestApps
differentiator: Xamarin.Android
test-xamarinandroid:
runs-on: macos-latest
name: Test Xamarin.Android
needs:
- build-packages
- baas-xamarinandroid
env:
APPS_CONFIG: ${{ needs.baas-xamarinandroid.outputs.deployedApps }}
steps:
- name: Checkout code
uses: actions/checkout@v2
with:
submodules: false
ref: ${{ github.event.pull_request.head.sha }}
- name: Register csc problem matcher
run: echo "::add-matcher::.github/problem-matchers/csc.json"
- name: Register msvc problem matcher
run: echo "::add-matcher::.github/problem-matchers/msvc.json"
- name: Fetch Realm
uses: actions/download-artifact@v2
with:
name: Realm.${{ needs.build-packages.outputs.package_version }}
path: ${{ github.workspace }}/Realm/packages/
- name: Fetch Realm.Fody
uses: actions/download-artifact@v2
with:
name: Realm.Fody.${{ needs.build-packages.outputs.package_version }}
path: ${{ github.workspace }}/Realm/packages/
- name: Build Tests/Tests.Android
run: msbuild Tests/Tests.Android -t:SignAndroidPackage -p:Configuration=Release -restore -p:AndroidSupportedAbis=x86_64 -p:AndroidUseSharedRuntime=False -p:EmbedAssembliesIntoApk=True -p:RestoreConfigFile=Tests/Test.NuGet.Config -p:UseRealmNupkgsWithVersion=${{ needs.build-packages.outputs.package_version }}
# - name: AVD cache
# uses: actions/cache@v2
# id: avd-cache
# with:
# path: |
# ~/.android/avd/*
# ~/.android/adb*
# key: android-avd
# - name: Create AVD for caching
# if: steps.avd-cache.outputs.cache-hit != 'true'
# uses: reactivecircus/android-emulator-runner@v2
# with:
# api-level: 29
# 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: Run the tests
uses: reactivecircus/android-emulator-runner@v2
with:
api-level: 29
arch: x86_64
force-avd-creation: false
emulator-options: -no-snapshot-save -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
disable-animations: true
script: |
adb devices
adb logcat -c
adb logcat -v time > "${{ github.workspace }}/logcat.txt" &

adb install ${{ github.workspace }}/Tests/Tests.Android/bin/Release/io.realm.xamarintests-Signed.apk
adb shell pm grant io.realm.xamarintests android.permission.READ_EXTERNAL_STORAGE
adb shell pm grant io.realm.xamarintests android.permission.WRITE_EXTERNAL_STORAGE

echo "--baasurl=${{ secrets.REALM_BASE_URL }} --baasapps=${{ env.APPS_CONFIG }}" > ${{ github.workspace }}/testargs.txt
adb push ${{ github.workspace }}/testargs.txt /storage/emulated/0/RealmTests/testargs.txt

adb shell am instrument -w -r io.realm.xamarintests/.TestRunner
adb pull /storage/emulated/0/RealmTests/TestResults.Android.xml ${{ github.workspace }}/TestResults.Android.xml
adb shell rm /sdcard/Realmtests/TestResults.Android.xml
- name: Output logcat
if: always()
run: cat logcat.txt
- name: Publish Unit Test Results
uses: LaPeste/test-reporter@b8a650f4490e7472b930f56bbb92c7b42dc5db15
if: always()
with:
name: Results Xamarin.Android
path: TestResults.Android.xml
reporter: java-junit
list-suites: failed
list-tests: failed
path-replace-backslashes: true
fail-on-error: false
cleanup-xamarinandroid:
runs-on: ubuntu-latest
name: Cleanup Xamarin.Android
needs:
- test-xamarinandroid
if: always()
steps:
- name: Checkout code
uses: actions/checkout@v2
with:
submodules: false
ref: ${{ github.event.pull_request.head.sha }}
- uses: realm/ci-actions/mdb-realm/cleanup@fe278fedebba5508c052e970fffa099de1285dff
with:
projectId: ${{ secrets.ATLAS_PROJECT_ID }}
apiKey: ${{ secrets.ATLAS_PUBLIC_API_KEY }}
privateApiKey: ${{ secrets.ATLAS_PRIVATE_API_KEY }}
differentiator: Xamarin.Android
run-tests-weaver:
runs-on: windows-latest
name: Test Weaver
Expand Down Expand Up @@ -949,7 +1071,7 @@ jobs:
id: dotnet-publish
run: echo '::set-output name=executable-path::./Tests/Realm.Tests/bin/Release/net5.0/${{ (runner.os == 'macOS' && 'osx-x64') || (runner.os == 'Windows' && 'win-x64') || (runner.os == 'Linux' && 'linux-x64') || '???' }}'
- name: Run the tests
run: ./tools/coverlet ${{ steps.dotnet-publish.outputs.executable-path }} -t ${{ steps.dotnet-publish.outputs.executable-path }}/Realm.Tests -a "--result=TestResults.Linux.xml --labels=After --baasurl ${{ secrets.REALM_BASE_URL }}" -f lcov -o ./report.lcov --exclude '[Realm.Tests]*' --exclude '[Realm.Fody]*'
run: ./tools/coverlet ${{ steps.dotnet-publish.outputs.executable-path }} -t ${{ steps.dotnet-publish.outputs.executable-path }}/Realm.Tests -a "--result=TestResults.Linux.xml --labels=After --baasurl=${{ secrets.REALM_BASE_URL }}" -f lcov -o ./report.lcov --exclude '[Realm.Tests]*' --exclude '[Realm.Fody]*'
- name: Publish Coverage
id: publish-coveralls
uses: coverallsapp/github-action@9ba913c152ae4be1327bfb9085dc806cedb44057
Expand Down
Loading