Skip to content

Commit

Permalink
Try to run android tests on simulator (#2680)
Browse files Browse the repository at this point in the history
  • Loading branch information
nirinchev committed Oct 19, 2021
1 parent 162c9d5 commit 611ec59
Show file tree
Hide file tree
Showing 19 changed files with 265 additions and 594 deletions.
59 changes: 55 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 @@ -341,6 +390,7 @@ name: main
pull_request:
env:
REALM_DISABLE_ANALYTICS: true
DOTNET_NOLOGO: true
jobs:
build-wrappers-macos:
runs-on: macos-latest
Expand Down Expand Up @@ -463,6 +513,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
131 changes: 127 additions & 4 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ name: main
pull_request: null
env:
REALM_DISABLE_ANALYTICS: true
DOTNET_NOLOGO: true
jobs:
build-wrappers-macos:
runs-on: macos-latest
Expand Down Expand Up @@ -460,7 +461,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 @@ -693,7 +694,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 @@ -778,7 +779,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 @@ -808,6 +809,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 @@ -950,7 +1073,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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
* iOS wrappers are now built with the "new build system" introduced by Xcode 10 and used as default by Xcode 12. More info can be found in cmake's [docs](https://cmake.org/cmake/help/git-stage/variable/CMAKE_XCODE_BUILD_SYSTEM.html#variable:CMAKE_XCODE_BUILD_SYSTEM).
* We now refresh the resulting Realm instance when opening a synchronized Realm with `GetInstanceAsync`. (Issue [#2256](https://github.com/realm/realm-dotnet/issues/2256))
* Added Sync tests for all platforms running on cloud-dev. (Issue [#2049](https://github.com/realm/realm-dotnet/issues/2049))
* Added Android tests running on the emulator. (Issue [#2680](https://github.com/realm/realm-dotnet/pull/2680))

## 10.6.0 (2021-09-30)

Expand Down
Loading

0 comments on commit 611ec59

Please sign in to comment.