From bf5187b5ccd4f73031af03eb583c06d42b8d46b1 Mon Sep 17 00:00:00 2001 From: Andrea Catalini Date: Fri, 25 Jun 2021 16:37:04 +0200 Subject: [PATCH] Run iOS tests on CI (#2405) * Added building ios tests * First ios run attempt * First ios run attempt - 0 * Check iphoneToSimulate value * Check iphoneToSimulate value - 0 * Removed toString from runtimeId * Properly handled promises * Check command * Fixed string for commands * Fixed string for commands - 0 * Fixed string for commands - 1 * Try to get output out of bash command * action/exec has a broken parser, fall back to default one * Fixed UUID generation * Try to create ios simulator * Fixed path to Test.iOS.app * Changed runtime format for simctl * Try to run ios sim * Fixed regexp * Add a bunch of console writelines * Fix for simulator that wasn't starting * Fixed merge issue * Fix again parameter passing for simulator * Cleanup for review * More cleanup * Forgotten await * Fix uninfered id in simulator command * Revert console writelines * Ready for review * PR feedback * Fixed test name * Removed unused import from action * Minor fix * Forgotten part of the minor fix * More PR feedback * Final PR feedback * Removed local action and set the template to point to remote action * First test with remote custom js GH action Co-authored-by: Nikola Irinchev --- .github/templates/main.yml | 18 ++++++++++++++- .github/workflows/main.yml | 40 ++++++++++++++++++++++++++++++++++ Tests/Tests.iOS/AppDelegate.cs | 2 +- 3 files changed, 58 insertions(+), 2 deletions(-) diff --git a/.github/templates/main.yml b/.github/templates/main.yml index 85c6f87448..c209fdbaf4 100644 --- a/.github/templates/main.yml +++ b/.github/templates/main.yml @@ -374,6 +374,22 @@ jobs: - name: Run the tests run: #@ "Tests/Tests.XamarinMac/bin/" + configuration + "/Tests.XamarinMac.app/Contents/MacOS/Tests.XamarinMac --headless --labels=All --result=${{ github.workspace }}/TestResults.macOS.xml" - #@ publishTestsResults("TestResults.macOS.xml", "Xamarin.macOS") + run-tests-xamarin-ios: + runs-on: macos-latest + name: Test Xamarin.iOS + needs: build-packages + steps: + - #@ template.replace(checkoutCode()) + - #@ template.replace(fetchPackageArtifacts()) + - #@ msbuild("Tests/Tests.iOS", TargetFrameworkVersion="v1.0", Platform="iPhoneSimulator", RestoreConfigFile="Tests/Test.NuGet.Config", UseRealmNupkgsWithVersion="${{ needs.build-packages.outputs.package_version }}") + - name: Run the tests + uses: realm/ci-actions/run-ios-simulator@v1 + with: + 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' + - #@ publishTestsResults("TestResults.iOS.xml", "Xamarin.iOS") run-tests-weaver: runs-on: windows-latest name: Test Weaver @@ -384,7 +400,7 @@ jobs: run-cleanup: runs-on: ubuntu-latest name: Workflow cleanup - needs: [ run-tests-net-framework, run-tests-uwp, run-tests-netcore-net5, run-tests-xamarin-macos, run-tests-weaver, build-packages ] + needs: [ run-tests-net-framework, run-tests-uwp, run-tests-netcore-net5, run-tests-xamarin-macos, run-tests-xamarin-ios, run-tests-weaver, build-packages ] if: always() steps: - #@ template.replace(deleteWrapperBinaries()) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index c53c8780f9..5da45f9293 100755 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -546,6 +546,45 @@ jobs: files: TestResults.macOS.xml comment_mode: "off" check_name: Results Xamarin.macOS + run-tests-xamarin-ios: + runs-on: macos-latest + name: Test Xamarin.iOS + needs: build-packages + steps: + - name: Checkout code + uses: actions/checkout@v2 + with: + submodules: recursive + - 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 }}.nupkg + path: ${{ github.workspace }}/Realm/packages/ + - name: Fetch Realm.Fody + uses: actions/download-artifact@v2 + with: + name: Realm.Fody.${{ needs.build-packages.outputs.package_version }}.nupkg + path: ${{ github.workspace }}/Realm/packages/ + - name: Build Tests/Tests.iOS + run: msbuild Tests/Tests.iOS -p:Configuration=Release -restore -p:TargetFrameworkVersion=v1.0 -p:Platform=iPhoneSimulator -p:RestoreConfigFile=Tests/Test.NuGet.Config -p:UseRealmNupkgsWithVersion=${{ needs.build-packages.outputs.package_version }} + - name: Run the tests + uses: realm/ci-actions/run-ios-simulator@v1 + with: + 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 + - name: Publish Unit Test Results + uses: EnricoMi/publish-unit-test-result-action/composite@v1 + if: always() + with: + files: TestResults.iOS.xml + comment_mode: "off" + check_name: Results Xamarin.iOS run-tests-weaver: runs-on: windows-latest name: Test Weaver @@ -579,6 +618,7 @@ jobs: - run-tests-uwp - run-tests-netcore-net5 - run-tests-xamarin-macos + - run-tests-xamarin-ios - run-tests-weaver - build-packages if: always() diff --git a/Tests/Tests.iOS/AppDelegate.cs b/Tests/Tests.iOS/AppDelegate.cs index c6628d9cfe..dcbc1b6e34 100644 --- a/Tests/Tests.iOS/AppDelegate.cs +++ b/Tests/Tests.iOS/AppDelegate.cs @@ -45,6 +45,7 @@ public override bool FinishedLaunching(UIApplication uiApplication, NSDictionary var arguments = NSProcessInfo.ProcessInfo.Arguments .Select(a => a.Replace("-app-arg=", string.Empty)) .ToArray(); + if (arguments.Any("--headless".Equals)) { options.AutoRun = true; @@ -75,7 +76,6 @@ public override bool FinishedLaunching(UIApplication uiApplication, NSDictionary return Task.CompletedTask; }; - } nunit.Options = options;