diff --git a/.github/templates/main.yml b/.github/templates/main.yml index 485eb3bdae..ab1c7f5f89 100644 --- a/.github/templates/main.yml +++ b/.github/templates/main.yml @@ -44,7 +44,7 @@ jobs: - #@ template.replace(uploadPackagesToSleet("needs.build-packages.outputs.package_version", True)) _: #@ template.replace(buildUnity()) _: #@ template.replace(runTests(".NET Framework")) - _: #@ template.replace(runTests("UWP Managed", additionalSecrets = ["Pfx_Password", "Base64_Encoded_Pfx"])) + _: #@ template.replace(runTests("Windows")) _: #@ template.replace(runNetCoreTests("[\"net6.0\", \"net7.0\"]")) _: #@ template.replace(runTests("macOS")) _: #@ template.replace(runTests("iOS")) diff --git a/.github/templates/pr.yml b/.github/templates/pr.yml index bf13a0a110..8551475382 100644 --- a/.github/templates/pr.yml +++ b/.github/templates/pr.yml @@ -42,7 +42,7 @@ jobs: _: #@ template.replace(buildUnity()) _: #@ template.replace(testUnity('["Mono-Net4"]', '[{ "os": "windows", "testPlatform": "Windows64" }, { "os": "linux", "testPlatform": "Linux64" }]')) _: #@ template.replace(runTests(".NET Framework", runSyncTests = False)) - _: #@ template.replace(runTests("UWP Managed", runSyncTests = False, additionalSecrets = ["Pfx_Password", "Base64_Encoded_Pfx"])) + _: #@ template.replace(runTests("Windows", runSyncTests = False)) _: #@ template.replace(runNetCoreTests('["net7.0"]')) _: #@ template.replace(runTests("macOS", runSyncTests = False)) _: #@ template.replace(runTests("iOS", runSyncTests = False)) diff --git a/.github/templates/test-android.yml b/.github/templates/test-android.yml index 10d93348b5..9a3f4aa549 100644 --- a/.github/templates/test-android.yml +++ b/.github/templates/test-android.yml @@ -34,13 +34,13 @@ jobs: - #@ template.replace(fetchPackageArtifacts()) - #@ setupWorkloads() - name: Build the tests - run: #@ "dotnet publish Tests/Tests.Maui -c Release -f net6.0-android -p:RestoreConfigFile=Tests/Test.NuGet.Config -p:UseRealmNupkgsWithVersion=${{ inputs.version }}" + run: #@ "dotnet publish Tests/Tests.Maui -c Release -f net7.0-android -p:RestoreConfigFile=Tests/Test.NuGet.Config -p:UseRealmNupkgsWithVersion=${{ inputs.version }}" - #@ template.replace(configureAWSCredentials("AWS_DEVICEFARM_ACCESS_KEY_ID", "AWS_DEVICEFARM_SECRET_ACCESS_KEY", "us-west-2")) - name: Run the tests uses: ./.github/actions/run-android-device-farm-test id: run_tests with: - apk-path: ${{ github.workspace }}/Tests/Tests.Maui/bin/Release/net6.0-android/publish/io.realm.mauitests-Signed.apk + apk-path: ${{ github.workspace }}/Tests/Tests.Maui/bin/Release/net7.0-android/publish/io.realm.mauitests-Signed.apk app-id: io.realm.mauitests project-arn: ${{ secrets.DEVICEFARM_PROJECT_ARN }} device-pool-arn: ${{ secrets.DEVICEFARM_ANDROID_POOL_ARN }} diff --git a/.github/templates/test-ios.yml b/.github/templates/test-ios.yml index b06fedfeb5..9c9d8bedf9 100644 --- a/.github/templates/test-ios.yml +++ b/.github/templates/test-ios.yml @@ -36,11 +36,11 @@ jobs: echo "MD_APPLE_SDK_ROOT=/Applications/Xcode_14.3.app" >> $GITHUB_ENV - #@ setupWorkloads() - name: Build the tests - run: #@ "dotnet build Tests/Tests.Maui -c " + configuration + " -f net6.0-ios -p:RestoreConfigFile=Tests/Test.NuGet.Config -p:UseRealmNupkgsWithVersion=${{ inputs.version }}" + run: #@ "dotnet build Tests/Tests.Maui -c " + configuration + " -f net7.0-ios -p:RestoreConfigFile=Tests/Test.NuGet.Config -p:UseRealmNupkgsWithVersion=${{ inputs.version }}" - name: Run the tests uses: #@ actionRuniOSSimulator with: - appPath: #@ "Tests/Tests.Maui/bin/" + configuration + "/net6.0-ios/iossimulator-x64/Tests.Maui.app" + appPath: #@ "Tests/Tests.Maui/bin/" + configuration + "/net7.0-ios/iossimulator-x64/Tests.Maui.app" bundleId: 'io.realm.mauitests' iphoneToSimulate: 'iPhone-8' arguments: #@ "--headless --result=${{ github.workspace }}/TestResults.iOS.xml --labels=After" diff --git a/.github/templates/test-macos.yml b/.github/templates/test-macos.yml index 2b3cda6266..3a19e78f64 100644 --- a/.github/templates/test-macos.yml +++ b/.github/templates/test-macos.yml @@ -25,7 +25,7 @@ jobs: - #@ template.replace(fetchPackageArtifacts()) - #@ setupWorkloads() - name: Build the tests - run: #@ "dotnet build Tests/Tests.Maui -c " + configuration + " -f net6.0-maccatalyst -p:RestoreConfigFile=Tests/Test.NuGet.Config -p:UseRealmNupkgsWithVersion=${{ inputs.version }}" + run: #@ "dotnet build Tests/Tests.Maui -c " + configuration + " -f net7.0-maccatalyst -p:RestoreConfigFile=Tests/Test.NuGet.Config -p:UseRealmNupkgsWithVersion=${{ inputs.version }}" - name: Run the tests - run: #@ "Tests/Tests.Maui/bin/" + configuration + "/net6.0-maccatalyst/maccatalyst-x64/Tests.Maui.app/Contents/MacOS/Tests.Maui --headless --result=${{ github.workspace }}/TestResults.MacCatalyst.xml --labels=All" + baasTestArgs("maccatalyst") + run: #@ "Tests/Tests.Maui/bin/" + configuration + "/net7.0-maccatalyst/maccatalyst-x64/Tests.Maui.app/Contents/MacOS/Tests.Maui --headless --result=${{ github.workspace }}/TestResults.MacCatalyst.xml --labels=All" + baasTestArgs("maccatalyst") - #@ publishTestsResults("TestResults.MacCatalyst.xml", "Maui.MacCatalyst") \ No newline at end of file diff --git a/.github/templates/test-uwp-managed.yml b/.github/templates/test-uwp-managed.yml deleted file mode 100644 index 10dbbc65e6..0000000000 --- a/.github/templates/test-uwp-managed.yml +++ /dev/null @@ -1,26 +0,0 @@ -#@ load("@ytt:template", "template") -#@ load("common.lib.yml", "checkoutCode") -#@ load("test.lib.yml", "baasTestArgs", "publishTestsResults", "testDefinition", "buildTests", "prepareTest") - ---- -name: test-uwp-managed -_: #@ template.replace(testDefinition(["Base64_Encoded_Pfx", "Pfx_Password"])) -jobs: - run-tests: - runs-on: windows-2019 - name: UWP - timeout-minutes: 45 - steps: - - #@ template.replace(prepareTest()) - - name: Import test certificate - run: | - $pfx_cert_byte = [System.Convert]::FromBase64String("${{ secrets.Base64_Encoded_Pfx }}") - $currentDirectory = Get-Location - [IO.File]::WriteAllBytes("${{ github.workspace }}\Tests\Tests.UWP\Tests.UWP_TemporaryKey.pfx", $pfx_cert_byte) - certutil -f -p "${{ secrets.Pfx_Password }}" -importpfx my ${{ github.workspace }}\Tests\Tests.UWP\Tests.UWP_TemporaryKey.pfx - shell: powershell - - #@ template.replace(buildTests("Tests/Tests.UWP", AppxBundle="Always", PackageCertificateKeyFile="${{ github.workspace }}\Tests\Tests.UWP\Tests.UWP_TemporaryKey.pfx", PackageCertificatePassword='"${{ secrets.Pfx_Password }}"', UseDotNetNativeToolchain="false", AppxBundlePlatforms="x64")) - - name: Run the tests - run: #@ "./Tests/Tests.UWP/RunTests.ps1 -ExtraAppArgs '" + baasTestArgs("uwp-managed") + "'" - shell: powershell - - #@ publishTestsResults("${{ env.TEST_RESULTS }}", "UWP Managed") diff --git a/.github/templates/test-windows.yml b/.github/templates/test-windows.yml new file mode 100644 index 0000000000..e6a27a95ed --- /dev/null +++ b/.github/templates/test-windows.yml @@ -0,0 +1,54 @@ +#@ load("@ytt:template", "template") +#@ load("common.lib.yml", "checkoutCode", "setupDotnet", "setupWorkloads") +#@ load("test.lib.yml", "baasTestArgs", "publishTestsResults", "testDefinition", "buildTests", "dotnetBuildTests", "prepareTest") + +#@ def importPfx(id): +name: Import test certificate +id: #@ id +#@yaml/text-templated-strings +run: | + $cert = New-SelfSignedCertificate -Type Custom -Subject "CN=RealmTests" -KeyUsage DigitalSignature -CertStoreLocation "Cert:\CurrentUser\My" -TextExtension @("2.5.29.37={text}1.3.6.1.5.5.7.3.3", "2.5.29.19={text}") + echo "::set-output name=thumbprint::$($cert.Thumbprint)" +shell: powershell +#@ end + +--- +name: test-windows +_: #@ template.replace(testDefinition()) +jobs: + test-uwp: + runs-on: windows-2019 + name: UWP + timeout-minutes: 45 + steps: + - #@ template.replace(prepareTest()) + - #@ importPfx("import-pfx") + - #@ template.replace(buildTests("Tests/Tests.UWP", AppxBundle="Always", PackageCertificateThumbprint="${{ steps.import-pfx.outputs.thumbprint }}", UseDotNetNativeToolchain="false", AppxBundlePlatforms="x64")) + - name: Run the tests + run: #@ "./Tests/Tests.UWP/RunTests.ps1 -ExtraAppArgs '" + baasTestArgs("uwp-managed") + "'" + shell: powershell + - #@ publishTestsResults("${{ env.TEST_RESULTS }}", "UWP Managed") + test-maui: + runs-on: windows-latest + name: Maui.Windows + timeout-minutes: 45 + steps: + - #@ template.replace(prepareTest()) + - #@ setupWorkloads() + - #@ importPfx("import-pfx") + - #@ template.replace(dotnetBuildTests("Tests/Tests.Maui", "net7.0-windows10.0.19041", "win10-x64", GenerateAppxPackageOnBuild="true", PackageCertificateThumbprint="${{ steps.import-pfx.outputs.thumbprint }}", AppxPackageTestDir="Output/")) + - name: Run the tests + #@yaml/text-templated-strings + run: | + .\Tests\Tests.Maui\Output\Install.ps1 -Force + # Tests.Maui --headless --labels=After --result=TestResults.Windows.xml (@= baasTestArgs('Maui.Windows') @) + + $package = Get-AppxPackage -Name realm.maui.tests + Start-Process "shell:AppsFolder\$($package.PackageFamilyName)!App" -ArgumentList "--headless --labels=After --result=$(pwd)\TestResults.Windows.xml --output=$(pwd)\test.log (@= baasTestArgs('Maui.Windows') @)" + Start-Sleep 5 + echo "Waiting for tests to finish" + $(Get-Process Tests.Maui).WaitForExit(900000) + Get-Content test.log + shell: powershell + - #@ publishTestsResults("TestResults.Windows.xml", "Maui.Windows") + diff --git a/.github/templates/test.lib.yml b/.github/templates/test.lib.yml index fde049e7ed..7af87ed223 100644 --- a/.github/templates/test.lib.yml +++ b/.github/templates/test.lib.yml @@ -62,12 +62,12 @@ env: #@ return msbuild(projectPath, RestoreConfigFile="Tests/Test.NuGet.Config", UseRealmNupkgsWithVersion="${{ inputs.version }}", **properties) #@ end -#@ def dotnetBuildTests(projectPath, framework, runtime, version = "inputs.version"): -#@ properties = { +#@ def dotnetBuildTests(projectPath, framework, runtime, version = "inputs.version", **properties): +#@ properties.update({ #@ "RestoreConfigFile": "Tests/Test.NuGet.Config", #@ "UseRealmNupkgsWithVersion": "${{ " + version + " }}", #@ "RealmTestsStandaloneExe": "true" -#@ } +#@ }) #@ return dotnetPublish(projectPath, framework, runtime, properties) #@ end diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 4f35d9d063..10f9ae848d 100755 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -97,8 +97,8 @@ jobs: AtlasProjectId: ${{ secrets.ATLAS_QA_PROJECT_ID }} AtlasPublicKey: ${{ secrets.ATLAS_QA_PUBLIC_API_KEY }} AtlasPrivateKey: ${{ secrets.ATLAS_QA_PRIVATE_API_KEY }} - test-uwp-managed: - uses: ./.github/workflows/test-uwp-managed.yml + test-windows: + uses: ./.github/workflows/test-windows.yml name: Test if: always() && !cancelled() && !contains(needs.*.result, 'failure') && !contains(needs.*.result, 'cancelled') needs: @@ -113,8 +113,6 @@ jobs: AtlasProjectId: ${{ secrets.ATLAS_QA_PROJECT_ID }} AtlasPublicKey: ${{ secrets.ATLAS_QA_PUBLIC_API_KEY }} AtlasPrivateKey: ${{ secrets.ATLAS_QA_PRIVATE_API_KEY }} - Pfx_Password: ${{ secrets.Pfx_Password }} - Base64_Encoded_Pfx: ${{ secrets.Base64_Encoded_Pfx }} test-net-core: if: always() && !cancelled() && !contains(needs.*.result, 'failure') && !contains(needs.*.result, 'cancelled') name: Test diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index 292272d05e..bc1861f288 100755 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -70,17 +70,15 @@ jobs: with: version: ${{ needs.build-packages.outputs.package_version }} secrets: {} - test-uwp-managed: - uses: ./.github/workflows/test-uwp-managed.yml + test-windows: + uses: ./.github/workflows/test-windows.yml name: Test if: always() && !cancelled() && !contains(needs.*.result, 'failure') && !contains(needs.*.result, 'cancelled') needs: - build-packages with: version: ${{ needs.build-packages.outputs.package_version }} - secrets: - Pfx_Password: ${{ secrets.Pfx_Password }} - Base64_Encoded_Pfx: ${{ secrets.Base64_Encoded_Pfx }} + secrets: {} test-net-core: if: always() && !cancelled() && !contains(needs.*.result, 'failure') && !contains(needs.*.result, 'cancelled') name: Test diff --git a/.github/workflows/test-android.yml b/.github/workflows/test-android.yml index 8e9353c80f..7269a9f726 100755 --- a/.github/workflows/test-android.yml +++ b/.github/workflows/test-android.yml @@ -124,7 +124,7 @@ jobs: - name: Setup workloads run: dotnet workload install maui - name: Build the tests - run: dotnet publish Tests/Tests.Maui -c Release -f net6.0-android -p:RestoreConfigFile=Tests/Test.NuGet.Config -p:UseRealmNupkgsWithVersion=${{ inputs.version }} + run: dotnet publish Tests/Tests.Maui -c Release -f net7.0-android -p:RestoreConfigFile=Tests/Test.NuGet.Config -p:UseRealmNupkgsWithVersion=${{ inputs.version }} - name: Configure AWS Credentials uses: aws-actions/configure-aws-credentials@v1-node16 with: @@ -135,7 +135,7 @@ jobs: uses: ./.github/actions/run-android-device-farm-test id: run_tests with: - apk-path: ${{ github.workspace }}/Tests/Tests.Maui/bin/Release/net6.0-android/publish/io.realm.mauitests-Signed.apk + apk-path: ${{ github.workspace }}/Tests/Tests.Maui/bin/Release/net7.0-android/publish/io.realm.mauitests-Signed.apk app-id: io.realm.mauitests project-arn: ${{ secrets.DEVICEFARM_PROJECT_ARN }} device-pool-arn: ${{ secrets.DEVICEFARM_ANDROID_POOL_ARN }} diff --git a/.github/workflows/test-ios.yml b/.github/workflows/test-ios.yml index 1f498a3f09..f580f39061 100755 --- a/.github/workflows/test-ios.yml +++ b/.github/workflows/test-ios.yml @@ -113,11 +113,11 @@ jobs: - name: Setup workloads run: dotnet workload install maui - name: Build the tests - run: dotnet build Tests/Tests.Maui -c Release -f net6.0-ios -p:RestoreConfigFile=Tests/Test.NuGet.Config -p:UseRealmNupkgsWithVersion=${{ inputs.version }} + run: dotnet build Tests/Tests.Maui -c Release -f net7.0-ios -p:RestoreConfigFile=Tests/Test.NuGet.Config -p:UseRealmNupkgsWithVersion=${{ inputs.version }} - name: Run the tests uses: realm/ci-actions/run-ios-simulator@729a80d203351eab7df4eca564daa275e76ec52f with: - appPath: Tests/Tests.Maui/bin/Release/net6.0-ios/iossimulator-x64/Tests.Maui.app + appPath: Tests/Tests.Maui/bin/Release/net7.0-ios/iossimulator-x64/Tests.Maui.app bundleId: io.realm.mauitests iphoneToSimulate: iPhone-8 arguments: --headless --result=${{ github.workspace }}/TestResults.iOS.xml --labels=After diff --git a/.github/workflows/test-macos.yml b/.github/workflows/test-macos.yml index c279d1e753..c4e0bdaf35 100755 --- a/.github/workflows/test-macos.yml +++ b/.github/workflows/test-macos.yml @@ -103,9 +103,9 @@ jobs: - name: Setup workloads run: dotnet workload install maui - name: Build the tests - run: dotnet build Tests/Tests.Maui -c Release -f net6.0-maccatalyst -p:RestoreConfigFile=Tests/Test.NuGet.Config -p:UseRealmNupkgsWithVersion=${{ inputs.version }} + run: dotnet build Tests/Tests.Maui -c Release -f net7.0-maccatalyst -p:RestoreConfigFile=Tests/Test.NuGet.Config -p:UseRealmNupkgsWithVersion=${{ inputs.version }} - name: Run the tests - run: Tests/Tests.Maui/bin/Release/net6.0-maccatalyst/maccatalyst-x64/Tests.Maui.app/Contents/MacOS/Tests.Maui --headless --result=${{ github.workspace }}/TestResults.MacCatalyst.xml --labels=All --baasurl=${{ inputs.realmUrl }} --baascluster=${{ inputs.clusterName }} --baasapikey=${{ secrets.AtlasPublicKey}} --baasprivateapikey=${{ secrets.AtlasPrivateKey}} --baasprojectid=${{ secrets.AtlasProjectId }} --baasdifferentiator=maccatalyst + run: Tests/Tests.Maui/bin/Release/net7.0-maccatalyst/maccatalyst-x64/Tests.Maui.app/Contents/MacOS/Tests.Maui --headless --result=${{ github.workspace }}/TestResults.MacCatalyst.xml --labels=All --baasurl=${{ inputs.realmUrl }} --baascluster=${{ inputs.clusterName }} --baasapikey=${{ secrets.AtlasPublicKey}} --baasprivateapikey=${{ secrets.AtlasPrivateKey}} --baasprojectid=${{ secrets.AtlasProjectId }} --baasdifferentiator=maccatalyst - name: Publish Unit Test Results uses: LaPeste/test-reporter@510caf50a955b1003bec48a6494be4d6537f3a0b if: always() diff --git a/.github/workflows/test-uwp-managed.yml b/.github/workflows/test-uwp-managed.yml deleted file mode 100755 index 0559637d6a..0000000000 --- a/.github/workflows/test-uwp-managed.yml +++ /dev/null @@ -1,90 +0,0 @@ -name: test-uwp-managed -"on": - workflow_call: - inputs: - version: - required: true - type: string - clusterName: - required: false - type: string - realmUrl: - required: false - type: string - atlasUrl: - required: false - type: string - secrets: - AtlasProjectId: - required: false - AtlasPublicKey: - required: false - AtlasPrivateKey: - required: false - Base64_Encoded_Pfx: - required: true - Pfx_Password: - required: true -env: - REALM_DISABLE_ANALYTICS: true - DOTNET_NOLOGO: true -jobs: - run-tests: - runs-on: windows-2019 - name: UWP - timeout-minutes: 45 - steps: - - name: Checkout code - uses: actions/checkout@v3 - 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.PlatformHelpers - uses: actions/download-artifact@v3 - with: - name: Realm.PlatformHelpers.${{ inputs.version }} - path: ${{ github.workspace }}/Realm/packages/ - - name: Fetch Realm - uses: actions/download-artifact@v3 - with: - name: Realm.${{ inputs.version }} - path: ${{ github.workspace }}/Realm/packages/ - - uses: realm/ci-actions/mdb-realm/deploy@729a80d203351eab7df4eca564daa275e76ec52f - if: ${{ inputs.realmUrl }} - with: - projectId: ${{ secrets.AtlasProjectId}} - realmUrl: ${{ inputs.realmUrl }} - atlasUrl: ${{ inputs.atlasUrl}} - apiKey: ${{ secrets.AtlasPublicKey}} - privateApiKey: ${{ secrets.AtlasPrivateKey }} - clusterSize: M10 - - name: Import test certificate - run: | - $pfx_cert_byte = [System.Convert]::FromBase64String("${{ secrets.Base64_Encoded_Pfx }}") - $currentDirectory = Get-Location - [IO.File]::WriteAllBytes("${{ github.workspace }}\Tests\Tests.UWP\Tests.UWP_TemporaryKey.pfx", $pfx_cert_byte) - certutil -f -p "${{ secrets.Pfx_Password }}" -importpfx my ${{ github.workspace }}\Tests\Tests.UWP\Tests.UWP_TemporaryKey.pfx - shell: powershell - - name: Add msbuild to PATH - uses: microsoft/setup-msbuild@0b44c6745b7e81956596964100aadb92d667c497 - if: ${{ runner.os == 'Windows' }} - - name: Build Tests/Tests.UWP - run: msbuild Tests/Tests.UWP -p:Configuration=Release -restore -p:RestoreConfigFile=Tests/Test.NuGet.Config -p:UseRealmNupkgsWithVersion=${{ inputs.version }} -p:AppxBundle=Always -p:PackageCertificateKeyFile=${{ github.workspace }}\Tests\Tests.UWP\Tests.UWP_TemporaryKey.pfx -p:PackageCertificatePassword="${{ secrets.Pfx_Password }}" -p:UseDotNetNativeToolchain=false -p:AppxBundlePlatforms=x64 - - name: Run the tests - run: ./Tests/Tests.UWP/RunTests.ps1 -ExtraAppArgs ' --baasurl=${{ inputs.realmUrl }} --baascluster=${{ inputs.clusterName }} --baasapikey=${{ secrets.AtlasPublicKey}} --baasprivateapikey=${{ secrets.AtlasPrivateKey}} --baasprojectid=${{ secrets.AtlasProjectId }} --baasdifferentiator=uwp-managed' - shell: powershell - - name: Publish Unit Test Results - uses: LaPeste/test-reporter@510caf50a955b1003bec48a6494be4d6537f3a0b - if: always() - with: - name: Results UWP Managed - path: ${{ env.TEST_RESULTS }} - reporter: java-junit - list-suites: failed - list-tests: failed - path-replace-backslashes: true - fail-on-error: false diff --git a/.github/workflows/test-windows.yml b/.github/workflows/test-windows.yml new file mode 100755 index 0000000000..6d5f4754c8 --- /dev/null +++ b/.github/workflows/test-windows.yml @@ -0,0 +1,155 @@ +name: test-windows +"on": + workflow_call: + inputs: + version: + required: true + type: string + clusterName: + required: false + type: string + realmUrl: + required: false + type: string + atlasUrl: + required: false + type: string + secrets: + AtlasProjectId: + required: false + AtlasPublicKey: + required: false + AtlasPrivateKey: + required: false +env: + REALM_DISABLE_ANALYTICS: true + DOTNET_NOLOGO: true +jobs: + test-uwp: + runs-on: windows-2019 + name: UWP + timeout-minutes: 45 + steps: + - name: Checkout code + uses: actions/checkout@v3 + 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.PlatformHelpers + uses: actions/download-artifact@v3 + with: + name: Realm.PlatformHelpers.${{ inputs.version }} + path: ${{ github.workspace }}/Realm/packages/ + - name: Fetch Realm + uses: actions/download-artifact@v3 + with: + name: Realm.${{ inputs.version }} + path: ${{ github.workspace }}/Realm/packages/ + - uses: realm/ci-actions/mdb-realm/deploy@729a80d203351eab7df4eca564daa275e76ec52f + if: ${{ inputs.realmUrl }} + with: + projectId: ${{ secrets.AtlasProjectId}} + realmUrl: ${{ inputs.realmUrl }} + atlasUrl: ${{ inputs.atlasUrl}} + apiKey: ${{ secrets.AtlasPublicKey}} + privateApiKey: ${{ secrets.AtlasPrivateKey }} + clusterSize: M10 + - name: Import test certificate + id: import-pfx + run: | + $cert = New-SelfSignedCertificate -Type Custom -Subject "CN=RealmTests" -KeyUsage DigitalSignature -CertStoreLocation "Cert:\CurrentUser\My" -TextExtension @("2.5.29.37={text}1.3.6.1.5.5.7.3.3", "2.5.29.19={text}") + echo "::set-output name=thumbprint::$($cert.Thumbprint)" + shell: powershell + - name: Add msbuild to PATH + uses: microsoft/setup-msbuild@0b44c6745b7e81956596964100aadb92d667c497 + if: ${{ runner.os == 'Windows' }} + - name: Build Tests/Tests.UWP + run: msbuild Tests/Tests.UWP -p:Configuration=Release -restore -p:RestoreConfigFile=Tests/Test.NuGet.Config -p:UseRealmNupkgsWithVersion=${{ inputs.version }} -p:AppxBundle=Always -p:PackageCertificateThumbprint=${{ steps.import-pfx.outputs.thumbprint }} -p:UseDotNetNativeToolchain=false -p:AppxBundlePlatforms=x64 + - name: Run the tests + run: ./Tests/Tests.UWP/RunTests.ps1 -ExtraAppArgs ' --baasurl=${{ inputs.realmUrl }} --baascluster=${{ inputs.clusterName }} --baasapikey=${{ secrets.AtlasPublicKey}} --baasprivateapikey=${{ secrets.AtlasPrivateKey}} --baasprojectid=${{ secrets.AtlasProjectId }} --baasdifferentiator=uwp-managed' + shell: powershell + - name: Publish Unit Test Results + uses: LaPeste/test-reporter@510caf50a955b1003bec48a6494be4d6537f3a0b + if: always() + with: + name: Results UWP Managed + path: ${{ env.TEST_RESULTS }} + reporter: java-junit + list-suites: failed + list-tests: failed + path-replace-backslashes: true + fail-on-error: false + test-maui: + runs-on: windows-latest + name: Maui.Windows + timeout-minutes: 45 + steps: + - name: Checkout code + uses: actions/checkout@v3 + 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.PlatformHelpers + uses: actions/download-artifact@v3 + with: + name: Realm.PlatformHelpers.${{ inputs.version }} + path: ${{ github.workspace }}/Realm/packages/ + - name: Fetch Realm + uses: actions/download-artifact@v3 + with: + name: Realm.${{ inputs.version }} + path: ${{ github.workspace }}/Realm/packages/ + - uses: realm/ci-actions/mdb-realm/deploy@729a80d203351eab7df4eca564daa275e76ec52f + if: ${{ inputs.realmUrl }} + with: + projectId: ${{ secrets.AtlasProjectId}} + realmUrl: ${{ inputs.realmUrl }} + atlasUrl: ${{ inputs.atlasUrl}} + apiKey: ${{ secrets.AtlasPublicKey}} + privateApiKey: ${{ secrets.AtlasPrivateKey }} + clusterSize: M10 + - name: Setup workloads + run: dotnet workload install maui + - name: Import test certificate + id: import-pfx + run: | + $cert = New-SelfSignedCertificate -Type Custom -Subject "CN=RealmTests" -KeyUsage DigitalSignature -CertStoreLocation "Cert:\CurrentUser\My" -TextExtension @("2.5.29.37={text}1.3.6.1.5.5.7.3.3", "2.5.29.19={text}") + echo "::set-output name=thumbprint::$($cert.Thumbprint)" + shell: powershell + - name: Publish Tests/Tests.Maui + run: dotnet publish Tests/Tests.Maui -c Release -f net7.0-windows10.0.19041 -r win10-x64 -p:GenerateAppxPackageOnBuild=true -p:PackageCertificateThumbprint=${{ steps.import-pfx.outputs.thumbprint }} -p:AppxPackageTestDir=Output/ -p:RestoreConfigFile=Tests/Test.NuGet.Config -p:UseRealmNupkgsWithVersion=${{ inputs.version }} -p:RealmTestsStandaloneExe=true --no-self-contained + - name: Output executable path + id: dotnet-publish + run: echo 'executable-path=./Tests/Tests.Maui/bin/Release/net7.0-windows10.0.19041/win10-x64' >> $GITHUB_OUTPUT + shell: bash + - name: Run the tests + run: | + .\Tests\Tests.Maui\Output\Install.ps1 -Force + # Tests.Maui --headless --labels=After --result=TestResults.Windows.xml --baasurl=${{ inputs.realmUrl }} --baascluster=${{ inputs.clusterName }} --baasapikey=${{ secrets.AtlasPublicKey}} --baasprivateapikey=${{ secrets.AtlasPrivateKey}} --baasprojectid=${{ secrets.AtlasProjectId }} --baasdifferentiator=Maui.Windows + + $package = Get-AppxPackage -Name realm.maui.tests + Start-Process "shell:AppsFolder\$($package.PackageFamilyName)!App" -ArgumentList "--headless --labels=After --result=$(pwd)\TestResults.Windows.xml --output=$(pwd)\test.log --baasurl=${{ inputs.realmUrl }} --baascluster=${{ inputs.clusterName }} --baasapikey=${{ secrets.AtlasPublicKey}} --baasprivateapikey=${{ secrets.AtlasPrivateKey}} --baasprojectid=${{ secrets.AtlasProjectId }} --baasdifferentiator=Maui.Windows" + Start-Sleep 5 + echo "Waiting for tests to finish" + $(Get-Process Tests.Maui).WaitForExit(900000) + Get-Content test.log + shell: powershell + - name: Publish Unit Test Results + uses: LaPeste/test-reporter@510caf50a955b1003bec48a6494be4d6537f3a0b + if: always() + with: + name: Results Maui.Windows + path: TestResults.Windows.xml + reporter: java-junit + list-suites: failed + list-tests: failed + path-replace-backslashes: true + fail-on-error: false diff --git a/Tests/Tests.Maui/MainPage.xaml.cs b/Tests/Tests.Maui/MainPage.xaml.cs index 5776457dd2..b09162eb2e 100644 --- a/Tests/Tests.Maui/MainPage.xaml.cs +++ b/Tests/Tests.Maui/MainPage.xaml.cs @@ -69,31 +69,43 @@ private async Task RunTests() var autorun = new AutoRun(typeof(TestHelpers).Assembly); var arguments = Realms.Tests.Sync.SyncTestHelpers.ExtractBaasSettings(MauiProgram.Args); - using var reader = new StringReader(string.Empty); - using var writer = new DebugWriter((msg, style, newLine) => + int failed = default; + + var nunitArgs = arguments.Except(new[] { "--headless" }).ToArray(); +#if !__IOS__ && !__ANDROID__ + if (nunitArgs.Length != arguments.Length) // arguments contained --headless + { + failed = autorun.Execute(nunitArgs); + } + else +#endif { - Dispatcher.Dispatch(() => + using var reader = new StringReader(string.Empty); + using var writer = new DebugWriter((msg, style, newLine) => { - var span = GetSpan(msg, style); - var label = LogsStack.Children.LastOrDefault() as Label; - if (label == null) + Dispatcher.Dispatch(() => { - label = new Label { FormattedText = new FormattedString() }; - LogsStack.Children.Add(label); - } - label.FormattedText.Spans.Add(span); - if (newLine) - { - LogsStack.Children.Add(new Label { FormattedText = new FormattedString() }); - } - - if (ScrollLogsToggle.IsToggled) - { - _ = LogsScrollView.ScrollToAsync(0, 999999, false); - } + var span = GetSpan(msg, style); + var label = LogsStack.Children.LastOrDefault() as Label; + if (label == null) + { + label = new Label { FormattedText = new FormattedString() }; + LogsStack.Children.Add(label); + } + label.FormattedText.Spans.Add(span); + if (newLine) + { + LogsStack.Children.Add(new Label { FormattedText = new FormattedString() }); + } + + if (ScrollLogsToggle.IsToggled) + { + _ = LogsScrollView.ScrollToAsync(0, 999999, false); + } + }); }); - }); - var failed = autorun.Execute(arguments.Where(a => a != "--headless").ToArray(), writer, reader); + failed = autorun.Execute(nunitArgs, writer, reader); + } var resultPath = TestHelpers.GetResultsPath(MauiProgram.Args); if (!string.IsNullOrEmpty(resultPath)) diff --git a/Tests/Tests.Maui/Platforms/Windows/App.xaml.cs b/Tests/Tests.Maui/Platforms/Windows/App.xaml.cs index 35679364bd..dc9f2b3e1e 100644 --- a/Tests/Tests.Maui/Platforms/Windows/App.xaml.cs +++ b/Tests/Tests.Maui/Platforms/Windows/App.xaml.cs @@ -16,6 +16,8 @@ // //////////////////////////////////////////////////////////////////////////// +using System; +using System.IO; using Microsoft.UI.Xaml; namespace Tests.Maui.WinUI; @@ -29,12 +31,17 @@ public App() protected override void OnLaunched(LaunchActivatedEventArgs args) { + File.AppendAllText(@"D:\a\realm-dotnet\realm-dotnet\args.txt", args.Arguments); + base.OnLaunched(args); + + // Try to attach to a parent process's console, for logging + PInvoke.Kernel32.AttachConsole(-1); } protected override MauiApp CreateMauiApp() { - var args = Environment.GetCommandLineArgs(); + var args = Environment.GetCommandLineArgs().Skip(1).ToArray(); return MauiProgram.CreateMauiApp(args); } diff --git a/Tests/Tests.Maui/Platforms/Windows/Package.appxmanifest b/Tests/Tests.Maui/Platforms/Windows/Package.appxmanifest index 0cb469c4dc..9cf6121503 100644 --- a/Tests/Tests.Maui/Platforms/Windows/Package.appxmanifest +++ b/Tests/Tests.Maui/Platforms/Windows/Package.appxmanifest @@ -2,13 +2,19 @@ - + - User Name + Tests.Maui + Realm @@ -23,6 +29,14 @@ + + + + + + + diff --git a/Tests/Tests.Maui/Tests.Maui.csproj b/Tests/Tests.Maui/Tests.Maui.csproj index 13047ffd2b..5048dc90af 100644 --- a/Tests/Tests.Maui/Tests.Maui.csproj +++ b/Tests/Tests.Maui/Tests.Maui.csproj @@ -1,8 +1,8 @@ - net6.0-android;net6.0-ios;net6.0-maccatalyst - $(TargetFrameworks);net6.0-windows10.0.19041 + net7.0-android;net7.0-ios;net7.0-maccatalyst + $(TargetFrameworks);net7.0-windows10.0.19041 Exe Tests.Maui true @@ -25,15 +25,20 @@ True - 11.0 - 13.2 - 21.0 + 11.0 + 13.2 + 21.0 10.0.17763.0 10.0.17763.0 + + True + + + @@ -59,7 +64,7 @@ - + Framework False @@ -70,7 +75,7 @@ - + Framework False @@ -82,7 +87,7 @@ - + lib\x86\librealm-wrappers.so PreserveNewest @@ -101,9 +106,4 @@ - - WinExe - win10-x64 - -