From 1efc569c59e6c701116b2c57d968b7af475038d4 Mon Sep 17 00:00:00 2001 From: Ferdinando Papale <4850119+papafe@users.noreply.github.com> Date: Fri, 15 Sep 2023 09:44:58 +0200 Subject: [PATCH] Starting one cluster per platform on CI (#3426) --- .github/templates/build.lib.yml | 12 ++++++++++-- .github/templates/main.yml | 2 +- .github/templates/pr.yml | 2 +- .github/templates/test-android.yml | 2 +- .github/templates/test-code-coverage.yml | 2 +- .github/templates/test-ios.yml | 2 +- .github/templates/test-macos.yml | 6 +++--- .github/templates/test-net-core.yml | 2 +- .github/templates/test-net-framework.yml | 2 +- .github/templates/test-uwp-managed.yml | 2 +- .github/templates/test-woven-classes.yml | 2 +- .github/templates/test.lib.yml | 9 +++++++-- .github/workflows/cleanup-baas.yml | 12 +++++++++++- .github/workflows/deploy-baas.yml | 15 ++++++++++++--- .github/workflows/main.yml | 3 +++ .github/workflows/pr.yml | 3 +++ .github/workflows/test-android.yml | 4 +++- .github/workflows/test-code-coverage.yml | 4 +++- .github/workflows/test-ios.yml | 4 +++- .github/workflows/test-macos.yml | 10 ++++++---- .github/workflows/test-net-core.yml | 11 +---------- .github/workflows/test-net-framework.yml | 4 +++- .github/workflows/test-tvos.yml | 11 +---------- .github/workflows/test-uwp-managed.yml | 4 +++- .github/workflows/test-woven-classes.yml | 2 +- Tools/DeployApps/BaasClient.cs | 16 ++++++---------- 26 files changed, 88 insertions(+), 60 deletions(-) diff --git a/.github/templates/build.lib.yml b/.github/templates/build.lib.yml index 5721c6ec87..c5a4b710a1 100644 --- a/.github/templates/build.lib.yml +++ b/.github/templates/build.lib.yml @@ -43,17 +43,25 @@ deploy-cluster: AtlasPrivateKey: #@ secret_AtlasPrivateKey #@ end -#@ def cleanupBaas(dependencies = []): -#@ needs = [] +#! We need to have two input arrays because there is not a 1-to-1 correspondence between dependencies +#! and targets, for example for macOS. +#@ def cleanupBaas(dependencies = [], targets = []): +#@ needs = ["deploy-cluster"] +#@ differentiators = [] #@ for dependency in dependencies: #@ needs.append(getJobName("test", dependency)) #@ end +#@ for target in targets: +#@ differentiators.append('"' + getJobName("", target) + '"') +#@ end cleanup-cluster: uses: ./.github/workflows/cleanup-baas.yml if: always() name: Cleanup needs: #@ needs with: + differentiators: #@ '[' + ", ".join(differentiators) + ']' + clusterName: ${{ needs.deploy-cluster.outputs.clusterName }} BaseUrl: #@ realm_BaseUrl AtlasBaseUrl: #@ atlas_BaseUrl secrets: diff --git a/.github/templates/main.yml b/.github/templates/main.yml index 485eb3bdae..71e090cc35 100644 --- a/.github/templates/main.yml +++ b/.github/templates/main.yml @@ -95,4 +95,4 @@ jobs: dashboard-path: dashboard.charts nuget-package: ${{ github.workspace }}/Realm/packages/Realm.${{ needs.build-packages.outputs.package_version }}.nupkg - #@ uploadArtifacts("dashboard.charts", "dashboard.charts", 30) - _: #@ template.replace(cleanupBaas([".NET Framework", "Code Coverage", "UWP Managed", "MacOS", "iOS", "Android"])) + _: #@ template.replace(cleanupBaas(dependencies = [".NET Framework", "Code Coverage", "UWP Managed", "MacOS", "iOS", "Android"], targets=[".NET Framework", "Code Coverage", "UWP Managed", "Xamarin.macOS", "iOS", "Android", "MacCatalyst"])) diff --git a/.github/templates/pr.yml b/.github/templates/pr.yml index a871f6b95f..1b0cde52e7 100644 --- a/.github/templates/pr.yml +++ b/.github/templates/pr.yml @@ -54,7 +54,7 @@ jobs: uses: ./.github/workflows/test-weaver.yml name: Test _: #@ template.replace(runTests("Code Coverage")) - _: #@ template.replace(cleanupBaas(["Code Coverage"])) + _: #@ template.replace(cleanupBaas(dependencies = ["Code Coverage"], targets = ["Code Coverage"])) verify-namespaces: runs-on: ubuntu-latest name: Verify Namespaces diff --git a/.github/templates/test-android.yml b/.github/templates/test-android.yml index 10d93348b5..4d6e619170 100644 --- a/.github/templates/test-android.yml +++ b/.github/templates/test-android.yml @@ -11,7 +11,7 @@ jobs: name: Xamarin.Android timeout-minutes: 60 steps: - - #@ template.replace(prepareTest()) + - #@ template.replace(prepareTest("android")) - #@ template.replace(buildTests("Tests/Tests.Android", target="SignAndroidPackage", AndroidUseSharedRuntime="False", EmbedAssembliesIntoApk="True")) - #@ template.replace(configureAWSCredentials("AWS_DEVICEFARM_ACCESS_KEY_ID", "AWS_DEVICEFARM_SECRET_ACCESS_KEY", "us-west-2")) - name: Run the tests diff --git a/.github/templates/test-code-coverage.yml b/.github/templates/test-code-coverage.yml index 12214b1aa8..8c934b378c 100644 --- a/.github/templates/test-code-coverage.yml +++ b/.github/templates/test-code-coverage.yml @@ -11,7 +11,7 @@ jobs: name: Code Coverage timeout-minutes: 90 steps: - - #@ template.replace(prepareTest(fetchWrappers=True)) + - #@ template.replace(prepareTest("code-coverage", fetchWrappers=True)) - name: Setup Coverlet & Report Generator run: | dotnet tool install coverlet.console --tool-path tools diff --git a/.github/templates/test-ios.yml b/.github/templates/test-ios.yml index b06fedfeb5..06893d0466 100644 --- a/.github/templates/test-ios.yml +++ b/.github/templates/test-ios.yml @@ -11,7 +11,7 @@ jobs: name: Xamarin.iOS timeout-minutes: 90 steps: - - #@ template.replace(prepareTest()) + - #@ template.replace(prepareTest("ios")) - #@ template.replace(buildTests("Tests/Tests.iOS", Platform="iPhoneSimulator")) - name: Run the tests uses: #@ actionRuniOSSimulator diff --git a/.github/templates/test-macos.yml b/.github/templates/test-macos.yml index 2b3cda6266..a1a654ef50 100644 --- a/.github/templates/test-macos.yml +++ b/.github/templates/test-macos.yml @@ -9,9 +9,9 @@ jobs: test-xamarin: runs-on: macos-latest name: Xamarin.macOS - timeout-minutes: 45 + timeout-minutes: 60 steps: - - #@ template.replace(prepareTest()) + - #@ template.replace(prepareTest("xamarinmacos")) - #@ template.replace(buildTests("Tests/Tests.XamarinMac")) - name: Run the tests run: #@ "Tests/Tests.XamarinMac/bin/" + configuration + "/Tests.XamarinMac.app/Contents/MacOS/Tests.XamarinMac --headless --result=${{ github.workspace }}/TestResults.XamarinMac.xml --labels=All" + baasTestArgs("xamarinmacos") @@ -19,7 +19,7 @@ jobs: test-maui: runs-on: macos-12 name: Maui.MacCatalyst - timeout-minutes: 45 + timeout-minutes: 60 steps: - #@ template.replace(checkoutCode()) - #@ template.replace(fetchPackageArtifacts()) diff --git a/.github/templates/test-net-core.yml b/.github/templates/test-net-core.yml index 71d00c207c..39302f9f23 100644 --- a/.github/templates/test-net-core.yml +++ b/.github/templates/test-net-core.yml @@ -38,7 +38,7 @@ jobs: env: DOTNET_DbgEnableMiniDump: 1 DOTNET_EnableCrashReport: 1 - run: #@ "${{ steps.dotnet-publish.outputs.executable-path }}/Realm.Tests --result=TestResults.xml --labels=After" + baasTestArgs("net-core-${{ matrix.runner }}-${{ matrix.runtime }}") + run: #@ "${{ steps.dotnet-publish.outputs.executable-path }}/Realm.Tests --result=TestResults.xml --labels=After" - name: Archive core dump uses: actions/upload-artifact@v3 if: failure() diff --git a/.github/templates/test-net-framework.yml b/.github/templates/test-net-framework.yml index 16ae0e3bc8..21e5d5946e 100644 --- a/.github/templates/test-net-framework.yml +++ b/.github/templates/test-net-framework.yml @@ -11,7 +11,7 @@ jobs: name: .NET Framework timeout-minutes: 45 steps: - - #@ template.replace(prepareTest()) + - #@ template.replace(prepareTest("net-framework")) - #@ template.replace(buildTests("Tests/Realm.Tests", TargetFramework="net461", RealmTestsStandaloneExe="true")) - name: Run the tests run: #@ "./Tests/Realm.Tests/bin/" + configuration + "/net461/Realm.Tests.exe --result=TestResults.Windows.xml --labels=After" + baasTestArgs("net-framework") diff --git a/.github/templates/test-uwp-managed.yml b/.github/templates/test-uwp-managed.yml index 10dbbc65e6..40887279aa 100644 --- a/.github/templates/test-uwp-managed.yml +++ b/.github/templates/test-uwp-managed.yml @@ -11,7 +11,7 @@ jobs: name: UWP timeout-minutes: 45 steps: - - #@ template.replace(prepareTest()) + - #@ template.replace(prepareTest("uwp-managed")) - name: Import test certificate run: | $pfx_cert_byte = [System.Convert]::FromBase64String("${{ secrets.Base64_Encoded_Pfx }}") diff --git a/.github/templates/test-woven-classes.yml b/.github/templates/test-woven-classes.yml index ab33fb2a12..3343b9587d 100644 --- a/.github/templates/test-woven-classes.yml +++ b/.github/templates/test-woven-classes.yml @@ -15,5 +15,5 @@ jobs: - #@ template.replace(fetchPackageArtifacts()) - #@ template.replace(wovenClassesBuildTests("Tests/Realm.Tests", "net7.0", "win-x64")) - name: Run the tests - run: #@ "${{ steps.dotnet-publish.outputs.executable-path }}/Realm.Tests --result=TestResults.WovenClasses.xml --labels=After" + baasTestArgs("weaved-classes") + run: #@ "${{ steps.dotnet-publish.outputs.executable-path }}/Realm.Tests --result=TestResults.WovenClasses.xml --labels=After" - #@ publishTestsResults("TestResults.WovenClasses.xml", "Woven classes") diff --git a/.github/templates/test.lib.yml b/.github/templates/test.lib.yml index ae5fb3ce8c..549eba9f17 100644 --- a/.github/templates/test.lib.yml +++ b/.github/templates/test.lib.yml @@ -2,7 +2,7 @@ #@ load("common.lib.yml", "actionDownloadArtifact", "msbuild", "dotnetPublish", "fetchWrapperBinaries", "checkoutCode", "fetchPackageArtifacts") #@ def baasTestArgs(differentiator): -#@ return " --baasurl=${{ inputs.realmUrl }} --baascluster=${{ inputs.clusterName }} --baasapikey=${{ secrets.AtlasPublicKey}} --baasprivateapikey=${{ secrets.AtlasPrivateKey}} --baasprojectid=${{ secrets.AtlasProjectId }} --baasdifferentiator=" + differentiator +#@ return " --baasurl=${{ inputs.realmUrl }} --baascluster=${{ inputs.clusterName }}-"+ differentiator +" --baasapikey=${{ secrets.AtlasPublicKey}} --baasprivateapikey=${{ secrets.AtlasPrivateKey}} --baasprojectid=${{ secrets.AtlasProjectId }} --baasdifferentiator=" + differentiator #@ end --- #@ def publishTestsResults(files, test_title): @@ -81,7 +81,7 @@ env: #@ return dotnetPublish(projectPath, framework, runtime, properties) #@ end --- -#@ def prepareTest(fetchWrappers = False, cleanupWorkspace = False): +#@ def prepareTest(differentiator = "", fetchWrappers = False, cleanupWorkspace = False): - #@ template.replace(checkoutCode()) #@ if cleanupWorkspace: - name: Cleanup Workspace @@ -92,7 +92,10 @@ env: #@ else: - #@ template.replace(fetchPackageArtifacts()) #@ end +#@ if (differentiator != ""): +#! The following is used in case we need to re-run the action and the main deploy cluster job is not re-run too (because successful) - uses: realm/ci-actions/mdb-realm/deploy@fa20eb972b9f018654fdb4e2c7afb52b0532f907 + name: Deploy Cluster (alternative) if: ${{ inputs.realmUrl }} with: projectId: ${{ secrets.AtlasProjectId}} @@ -100,5 +103,7 @@ env: atlasUrl: ${{ inputs.atlasUrl}} apiKey: ${{ secrets.AtlasPublicKey}} privateApiKey: ${{ secrets.AtlasPrivateKey }} + clusterName: #@ "${{ inputs.clusterName }}-" + differentiator clusterSize: M10 +#@ end #@ end \ No newline at end of file diff --git a/.github/workflows/cleanup-baas.yml b/.github/workflows/cleanup-baas.yml index 1f3074653e..2a4fbd9113 100755 --- a/.github/workflows/cleanup-baas.yml +++ b/.github/workflows/cleanup-baas.yml @@ -2,6 +2,12 @@ name: cleanup-baas "on": workflow_call: inputs: + differentiators: + required: true + type: string + clusterName: + required: true + type: string BaseUrl: required: true type: string @@ -20,8 +26,11 @@ env: DOTNET_NOLOGO: true jobs: cleanup-baas: - runs-on: ubuntu-latest name: Cleanup Cluster + runs-on: ubuntu-latest + strategy: + matrix: + differentiator: ${{ fromJson(inputs.differentiators) }} timeout-minutes: 5 steps: - name: Checkout code @@ -36,3 +45,4 @@ jobs: atlasUrl: ${{ inputs.AtlasBaseUrl}} apiKey: ${{ secrets.AtlasPublicKey}} privateApiKey: ${{ secrets.AtlasPrivateKey }} + clusterName: ${{ inputs.clusterName }}-${{ matrix.differentiator }} diff --git a/.github/workflows/deploy-baas.yml b/.github/workflows/deploy-baas.yml index 442b07f2f1..3008c6d486 100755 --- a/.github/workflows/deploy-baas.yml +++ b/.github/workflows/deploy-baas.yml @@ -26,12 +26,20 @@ env: DOTNET_NOLOGO: true jobs: deploy-baas: - runs-on: ubuntu-latest name: Deploy Cluster + runs-on: ubuntu-latest + strategy: + matrix: + differentiator: ${{ fromJson(inputs.differentiators) }} outputs: - clusterName: ${{ steps.deploy-cluster.outputs.clusterName }} + clusterName: ${{ steps.generate-cluster-name.outputs.clusterName }} timeout-minutes: 20 steps: + - name: Generate cluster name + id: generate-cluster-name + run: | + name=$( echo ${{ github.run_id }}-${{ github.run_attempt }} | md5sum | cut -c1-7) + echo "clusterName=$name" >> "$GITHUB_OUTPUT" - name: Checkout code uses: actions/checkout@v3 with: @@ -45,6 +53,7 @@ jobs: atlasUrl: ${{ inputs.AtlasBaseUrl}} apiKey: ${{ secrets.AtlasPublicKey}} privateApiKey: ${{ secrets.AtlasPrivateKey }} + clusterName: ${{ steps.generate-cluster-name.outputs.clusterName }}-${{ matrix.differentiator }} clusterSize: M20 deploy-apps: name: Deploy Apps @@ -64,5 +73,5 @@ jobs: with: dotnet-version: 6.0.x - name: Deploy Apps - run: dotnet run . --baasurl=${{ inputs.BaseUrl }} --baascluster=${{ needs.deploy-baas.outputs.clusterName }} --baasapikey=${{ secrets.AtlasPublicKey }} --baasprivateapikey=${{ secrets.AtlasPrivateKey }} --baasprojectid=${{ secrets.AtlasProjectId }} --baasdifferentiator=${{ matrix.differentiator }} + run: dotnet run . --baasurl=${{ inputs.BaseUrl }} --baascluster=${{ needs.deploy-baas.outputs.clusterName }}-${{ matrix.differentiator }} --baasapikey=${{ secrets.AtlasPublicKey }} --baasprivateapikey=${{ secrets.AtlasPrivateKey }} --baasprojectid=${{ secrets.AtlasProjectId }} --baasdifferentiator=${{ matrix.differentiator }} working-directory: Tools/DeployApps \ No newline at end of file diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 4f35d9d063..9b4d63b7b0 100755 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -301,6 +301,7 @@ jobs: if: always() name: Cleanup needs: + - deploy-cluster - test-net-framework - test-code-coverage - test-uwp-managed @@ -308,6 +309,8 @@ jobs: - test-ios - test-android with: + differentiators: '["net-framework", "code-coverage", "uwp-managed", "xamarinmacos", "ios", "android", "maccatalyst"]' + clusterName: ${{ needs.deploy-cluster.outputs.clusterName }} BaseUrl: https://realm-qa.mongodb.com AtlasBaseUrl: https://cloud-qa.mongodb.com secrets: diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index 8f19cac171..6a3ccb3bdc 100755 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -166,8 +166,11 @@ jobs: if: always() name: Cleanup needs: + - deploy-cluster - test-code-coverage with: + differentiators: '["code-coverage"]' + clusterName: ${{ needs.deploy-cluster.outputs.clusterName }} BaseUrl: https://realm-qa.mongodb.com AtlasBaseUrl: https://cloud-qa.mongodb.com secrets: diff --git a/.github/workflows/test-android.yml b/.github/workflows/test-android.yml index 0fbe11f500..7522fb8381 100755 --- a/.github/workflows/test-android.yml +++ b/.github/workflows/test-android.yml @@ -58,6 +58,7 @@ jobs: name: Realm.${{ inputs.version }} path: ${{ github.workspace }}/Realm/packages/ - uses: realm/ci-actions/mdb-realm/deploy@fa20eb972b9f018654fdb4e2c7afb52b0532f907 + name: Deploy Cluster (alternative) if: ${{ inputs.realmUrl }} with: projectId: ${{ secrets.AtlasProjectId}} @@ -65,6 +66,7 @@ jobs: atlasUrl: ${{ inputs.atlasUrl}} apiKey: ${{ secrets.AtlasPublicKey}} privateApiKey: ${{ secrets.AtlasPrivateKey }} + clusterName: ${{ inputs.clusterName }}-android clusterSize: M10 - name: Add msbuild to PATH uses: microsoft/setup-msbuild@0b44c6745b7e81956596964100aadb92d667c497 @@ -85,7 +87,7 @@ jobs: app-id: io.realm.xamarintests project-arn: ${{ secrets.DEVICEFARM_PROJECT_ARN }} device-pool-arn: ${{ secrets.DEVICEFARM_ANDROID_POOL_ARN }} - arguments: ' --baasurl=${{ inputs.realmUrl }} --baascluster=${{ inputs.clusterName }} --baasapikey=${{ secrets.AtlasPublicKey}} --baasprivateapikey=${{ secrets.AtlasPrivateKey}} --baasprojectid=${{ secrets.AtlasProjectId }} --baasdifferentiator=android' + arguments: ' --baasurl=${{ inputs.realmUrl }} --baascluster=${{ inputs.clusterName }}-android --baasapikey=${{ secrets.AtlasPublicKey}} --baasprivateapikey=${{ secrets.AtlasPrivateKey}} --baasprojectid=${{ secrets.AtlasProjectId }} --baasdifferentiator=android' - name: Publish Unit Test Results uses: LaPeste/test-reporter@510caf50a955b1003bec48a6494be4d6537f3a0b if: always() diff --git a/.github/workflows/test-code-coverage.yml b/.github/workflows/test-code-coverage.yml index 3430828f20..66205ea979 100755 --- a/.github/workflows/test-code-coverage.yml +++ b/.github/workflows/test-code-coverage.yml @@ -140,6 +140,7 @@ jobs: name: wrappers-windows-uwp-ARM64 path: wrappers/build - uses: realm/ci-actions/mdb-realm/deploy@fa20eb972b9f018654fdb4e2c7afb52b0532f907 + name: Deploy Cluster (alternative) if: ${{ inputs.realmUrl }} with: projectId: ${{ secrets.AtlasProjectId}} @@ -147,6 +148,7 @@ jobs: atlasUrl: ${{ inputs.atlasUrl}} apiKey: ${{ secrets.AtlasPublicKey}} privateApiKey: ${{ secrets.AtlasPrivateKey }} + clusterName: ${{ inputs.clusterName }}-code-coverage clusterSize: M10 - name: Setup Coverlet & Report Generator run: | @@ -163,7 +165,7 @@ jobs: env: DOTNET_DbgEnableMiniDump: 1 DOTNET_EnableCrashReport: 1 - 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=${{ inputs.realmUrl }} --baascluster=${{ inputs.clusterName }} --baasapikey=${{ secrets.AtlasPublicKey}} --baasprivateapikey=${{ secrets.AtlasPrivateKey}} --baasprojectid=${{ secrets.AtlasProjectId }} --baasdifferentiator=code-coverage' -f lcov -o ./report.lcov --exclude '[Realm.Tests]*' --exclude '[Realm.Fody]*' --exclude '[Realm.PlatformHelpers]*' + 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=${{ inputs.realmUrl }} --baascluster=${{ inputs.clusterName }}-code-coverage --baasapikey=${{ secrets.AtlasPublicKey}} --baasprivateapikey=${{ secrets.AtlasPrivateKey}} --baasprojectid=${{ secrets.AtlasProjectId }} --baasdifferentiator=code-coverage' -f lcov -o ./report.lcov --exclude '[Realm.Tests]*' --exclude '[Realm.Fody]*' --exclude '[Realm.PlatformHelpers]*' - name: Archive core dump uses: actions/upload-artifact@v3 if: failure() diff --git a/.github/workflows/test-ios.yml b/.github/workflows/test-ios.yml index a6e0998ecb..cd3b1f0804 100755 --- a/.github/workflows/test-ios.yml +++ b/.github/workflows/test-ios.yml @@ -50,6 +50,7 @@ jobs: name: Realm.${{ inputs.version }} path: ${{ github.workspace }}/Realm/packages/ - uses: realm/ci-actions/mdb-realm/deploy@fa20eb972b9f018654fdb4e2c7afb52b0532f907 + name: Deploy Cluster (alternative) if: ${{ inputs.realmUrl }} with: projectId: ${{ secrets.AtlasProjectId}} @@ -57,6 +58,7 @@ jobs: atlasUrl: ${{ inputs.atlasUrl}} apiKey: ${{ secrets.AtlasPublicKey}} privateApiKey: ${{ secrets.AtlasPrivateKey }} + clusterName: ${{ inputs.clusterName }}-ios clusterSize: M10 - name: Add msbuild to PATH uses: microsoft/setup-msbuild@0b44c6745b7e81956596964100aadb92d667c497 @@ -69,7 +71,7 @@ jobs: appPath: Tests/Tests.iOS/bin/iPhoneSimulator/Release/Tests.iOS.app bundleId: io.realm.dotnettests iphoneToSimulate: iPhone-8 - arguments: --headless --result=${{ github.workspace }}/TestResults.iOS.xml --baasurl=${{ inputs.realmUrl }} --baascluster=${{ inputs.clusterName }} --baasapikey=${{ secrets.AtlasPublicKey}} --baasprivateapikey=${{ secrets.AtlasPrivateKey}} --baasprojectid=${{ secrets.AtlasProjectId }} --baasdifferentiator=ios + arguments: --headless --result=${{ github.workspace }}/TestResults.iOS.xml --baasurl=${{ inputs.realmUrl }} --baascluster=${{ inputs.clusterName }}-ios --baasapikey=${{ secrets.AtlasPublicKey}} --baasprivateapikey=${{ secrets.AtlasPrivateKey}} --baasprojectid=${{ secrets.AtlasProjectId }} --baasdifferentiator=ios - name: Publish Unit Test Results uses: LaPeste/test-reporter@510caf50a955b1003bec48a6494be4d6537f3a0b if: always() diff --git a/.github/workflows/test-macos.yml b/.github/workflows/test-macos.yml index 193a95e255..f01c7c06eb 100755 --- a/.github/workflows/test-macos.yml +++ b/.github/workflows/test-macos.yml @@ -28,7 +28,7 @@ jobs: test-xamarin: runs-on: macos-latest name: Xamarin.macOS - timeout-minutes: 45 + timeout-minutes: 60 steps: - name: Checkout code uses: actions/checkout@v3 @@ -50,6 +50,7 @@ jobs: name: Realm.${{ inputs.version }} path: ${{ github.workspace }}/Realm/packages/ - uses: realm/ci-actions/mdb-realm/deploy@fa20eb972b9f018654fdb4e2c7afb52b0532f907 + name: Deploy Cluster (alternative) if: ${{ inputs.realmUrl }} with: projectId: ${{ secrets.AtlasProjectId}} @@ -57,6 +58,7 @@ jobs: atlasUrl: ${{ inputs.atlasUrl}} apiKey: ${{ secrets.AtlasPublicKey}} privateApiKey: ${{ secrets.AtlasPrivateKey }} + clusterName: ${{ inputs.clusterName }}-xamarinmacos clusterSize: M10 - name: Add msbuild to PATH uses: microsoft/setup-msbuild@0b44c6745b7e81956596964100aadb92d667c497 @@ -64,7 +66,7 @@ jobs: - name: Build Tests/Tests.XamarinMac run: msbuild Tests/Tests.XamarinMac -p:Configuration=Release -restore -p:RestoreConfigFile=Tests/Test.NuGet.Config -p:UseRealmNupkgsWithVersion=${{ inputs.version }} - name: Run the tests - run: Tests/Tests.XamarinMac/bin/Release/Tests.XamarinMac.app/Contents/MacOS/Tests.XamarinMac --headless --result=${{ github.workspace }}/TestResults.XamarinMac.xml --labels=All --baasurl=${{ inputs.realmUrl }} --baascluster=${{ inputs.clusterName }} --baasapikey=${{ secrets.AtlasPublicKey}} --baasprivateapikey=${{ secrets.AtlasPrivateKey}} --baasprojectid=${{ secrets.AtlasProjectId }} --baasdifferentiator=xamarinmacos + run: Tests/Tests.XamarinMac/bin/Release/Tests.XamarinMac.app/Contents/MacOS/Tests.XamarinMac --headless --result=${{ github.workspace }}/TestResults.XamarinMac.xml --labels=All --baasurl=${{ inputs.realmUrl }} --baascluster=${{ inputs.clusterName }}-xamarinmacos --baasapikey=${{ secrets.AtlasPublicKey}} --baasprivateapikey=${{ secrets.AtlasPrivateKey}} --baasprojectid=${{ secrets.AtlasProjectId }} --baasdifferentiator=xamarinmacos - name: Publish Unit Test Results uses: LaPeste/test-reporter@510caf50a955b1003bec48a6494be4d6537f3a0b if: always() @@ -79,7 +81,7 @@ jobs: test-maui: runs-on: macos-12 name: Maui.MacCatalyst - timeout-minutes: 45 + timeout-minutes: 60 steps: - name: Checkout code uses: actions/checkout@v3 @@ -105,7 +107,7 @@ jobs: - 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 }} - 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/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 }}-maccatalyst --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-net-core.yml b/.github/workflows/test-net-core.yml index 48d79d8e4e..7af144a1b7 100755 --- a/.github/workflows/test-net-core.yml +++ b/.github/workflows/test-net-core.yml @@ -74,15 +74,6 @@ jobs: with: name: Realm.${{ inputs.version }} path: ${{ github.workspace }}/Realm/packages/ - - uses: realm/ci-actions/mdb-realm/deploy@fa20eb972b9f018654fdb4e2c7afb52b0532f907 - if: ${{ inputs.realmUrl }} - with: - projectId: ${{ secrets.AtlasProjectId}} - realmUrl: ${{ inputs.realmUrl }} - atlasUrl: ${{ inputs.atlasUrl}} - apiKey: ${{ secrets.AtlasPublicKey}} - privateApiKey: ${{ secrets.AtlasPrivateKey }} - clusterSize: M10 - name: Publish Tests/Realm.Tests run: dotnet publish Tests/Realm.Tests -c Release -f ${{ matrix.framework }} -r ${{ matrix.os.runtime }} -p:RestoreConfigFile=Tests/Test.NuGet.Config -p:UseRealmNupkgsWithVersion=${{ inputs.version }} -p:RealmTestsStandaloneExe=true --no-self-contained - name: Output executable path @@ -93,7 +84,7 @@ jobs: env: DOTNET_DbgEnableMiniDump: 1 DOTNET_EnableCrashReport: 1 - run: ${{ steps.dotnet-publish.outputs.executable-path }}/Realm.Tests --result=TestResults.xml --labels=After --baasurl=${{ inputs.realmUrl }} --baascluster=${{ inputs.clusterName }} --baasapikey=${{ secrets.AtlasPublicKey}} --baasprivateapikey=${{ secrets.AtlasPrivateKey}} --baasprojectid=${{ secrets.AtlasProjectId }} --baasdifferentiator=net-core-${{ matrix.runner }}-${{ matrix.runtime }} + run: ${{ steps.dotnet-publish.outputs.executable-path }}/Realm.Tests --result=TestResults.xml --labels=After - name: Archive core dump uses: actions/upload-artifact@v3 if: failure() diff --git a/.github/workflows/test-net-framework.yml b/.github/workflows/test-net-framework.yml index 8ffc6d49de..aed0a68395 100755 --- a/.github/workflows/test-net-framework.yml +++ b/.github/workflows/test-net-framework.yml @@ -50,6 +50,7 @@ jobs: name: Realm.${{ inputs.version }} path: ${{ github.workspace }}/Realm/packages/ - uses: realm/ci-actions/mdb-realm/deploy@fa20eb972b9f018654fdb4e2c7afb52b0532f907 + name: Deploy Cluster (alternative) if: ${{ inputs.realmUrl }} with: projectId: ${{ secrets.AtlasProjectId}} @@ -57,6 +58,7 @@ jobs: atlasUrl: ${{ inputs.atlasUrl}} apiKey: ${{ secrets.AtlasPublicKey}} privateApiKey: ${{ secrets.AtlasPrivateKey }} + clusterName: ${{ inputs.clusterName }}-net-framework clusterSize: M10 - name: Add msbuild to PATH uses: microsoft/setup-msbuild@0b44c6745b7e81956596964100aadb92d667c497 @@ -64,7 +66,7 @@ jobs: - name: Build Tests/Realm.Tests run: msbuild Tests/Realm.Tests -p:Configuration=Release -restore -p:RestoreConfigFile=Tests/Test.NuGet.Config -p:UseRealmNupkgsWithVersion=${{ inputs.version }} -p:TargetFramework=net461 -p:RealmTestsStandaloneExe=true - name: Run the tests - run: ./Tests/Realm.Tests/bin/Release/net461/Realm.Tests.exe --result=TestResults.Windows.xml --labels=After --baasurl=${{ inputs.realmUrl }} --baascluster=${{ inputs.clusterName }} --baasapikey=${{ secrets.AtlasPublicKey}} --baasprivateapikey=${{ secrets.AtlasPrivateKey}} --baasprojectid=${{ secrets.AtlasProjectId }} --baasdifferentiator=net-framework + run: ./Tests/Realm.Tests/bin/Release/net461/Realm.Tests.exe --result=TestResults.Windows.xml --labels=After --baasurl=${{ inputs.realmUrl }} --baascluster=${{ inputs.clusterName }}-net-framework --baasapikey=${{ secrets.AtlasPublicKey}} --baasprivateapikey=${{ secrets.AtlasPrivateKey}} --baasprojectid=${{ secrets.AtlasProjectId }} --baasdifferentiator=net-framework - name: Publish Unit Test Results uses: LaPeste/test-reporter@510caf50a955b1003bec48a6494be4d6537f3a0b if: always() diff --git a/.github/workflows/test-tvos.yml b/.github/workflows/test-tvos.yml index d44a402e98..da2c3f0132 100755 --- a/.github/workflows/test-tvos.yml +++ b/.github/workflows/test-tvos.yml @@ -49,15 +49,6 @@ jobs: with: name: Realm.${{ inputs.version }} path: ${{ github.workspace }}/Realm/packages/ - - uses: realm/ci-actions/mdb-realm/deploy@fa20eb972b9f018654fdb4e2c7afb52b0532f907 - if: ${{ inputs.realmUrl }} - with: - projectId: ${{ secrets.AtlasProjectId}} - realmUrl: ${{ inputs.realmUrl }} - atlasUrl: ${{ inputs.atlasUrl}} - apiKey: ${{ secrets.AtlasPublicKey}} - privateApiKey: ${{ secrets.AtlasPrivateKey }} - clusterSize: M10 - name: Add msbuild to PATH uses: microsoft/setup-msbuild@0b44c6745b7e81956596964100aadb92d667c497 if: ${{ runner.os == 'Windows' }} @@ -69,7 +60,7 @@ jobs: appPath: Tests/Tests.XamarinTVOS/bin/iPhoneSimulator/Release/Tests.XamarinTVOS.app bundleId: io.realm.Tests-XamarinTVOS iphoneToSimulate: Apple-TV-1080p - arguments: --headless --result=${{ github.workspace }}/TestResults.tvOS.xml --labels=All --baasurl=${{ inputs.realmUrl }} --baascluster=${{ inputs.clusterName }} --baasapikey=${{ secrets.AtlasPublicKey}} --baasprivateapikey=${{ secrets.AtlasPrivateKey}} --baasprojectid=${{ secrets.AtlasProjectId }} --baasdifferentiator=tvos + arguments: --headless --result=${{ github.workspace }}/TestResults.tvOS.xml --labels=All --baasurl=${{ inputs.realmUrl }} --baascluster=${{ inputs.clusterName }}-tvos --baasapikey=${{ secrets.AtlasPublicKey}} --baasprivateapikey=${{ secrets.AtlasPrivateKey}} --baasprojectid=${{ secrets.AtlasProjectId }} --baasdifferentiator=tvos os: tvOS - name: Publish Unit Test Results uses: LaPeste/test-reporter@510caf50a955b1003bec48a6494be4d6537f3a0b diff --git a/.github/workflows/test-uwp-managed.yml b/.github/workflows/test-uwp-managed.yml index b9ffe0b6e0..88f515e4db 100755 --- a/.github/workflows/test-uwp-managed.yml +++ b/.github/workflows/test-uwp-managed.yml @@ -54,6 +54,7 @@ jobs: name: Realm.${{ inputs.version }} path: ${{ github.workspace }}/Realm/packages/ - uses: realm/ci-actions/mdb-realm/deploy@fa20eb972b9f018654fdb4e2c7afb52b0532f907 + name: Deploy Cluster (alternative) if: ${{ inputs.realmUrl }} with: projectId: ${{ secrets.AtlasProjectId}} @@ -61,6 +62,7 @@ jobs: atlasUrl: ${{ inputs.atlasUrl}} apiKey: ${{ secrets.AtlasPublicKey}} privateApiKey: ${{ secrets.AtlasPrivateKey }} + clusterName: ${{ inputs.clusterName }}-uwp-managed clusterSize: M10 - name: Import test certificate run: | @@ -75,7 +77,7 @@ jobs: - 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' + run: ./Tests/Tests.UWP/RunTests.ps1 -ExtraAppArgs ' --baasurl=${{ inputs.realmUrl }} --baascluster=${{ inputs.clusterName }}-uwp-managed --baasapikey=${{ secrets.AtlasPublicKey}} --baasprivateapikey=${{ secrets.AtlasPrivateKey}} --baasprojectid=${{ secrets.AtlasProjectId }} --baasdifferentiator=uwp-managed' shell: powershell - name: Publish Unit Test Results uses: LaPeste/test-reporter@510caf50a955b1003bec48a6494be4d6537f3a0b diff --git a/.github/workflows/test-woven-classes.yml b/.github/workflows/test-woven-classes.yml index b9670c41c9..3531864b5e 100644 --- a/.github/workflows/test-woven-classes.yml +++ b/.github/workflows/test-woven-classes.yml @@ -56,7 +56,7 @@ jobs: run: echo 'executable-path=./Tests/Realm.Tests/bin/Release/net7.0/win-x64' >> $GITHUB_OUTPUT shell: bash - name: Run the tests - run: ${{ steps.dotnet-publish.outputs.executable-path }}/Realm.Tests --result=TestResults.WovenClasses.xml --labels=After --baasurl=${{ inputs.realmUrl }} --baascluster=${{ inputs.clusterName }} --baasapikey=${{ secrets.AtlasPublicKey}} --baasprivateapikey=${{ secrets.AtlasPrivateKey}} --baasprojectid=${{ secrets.AtlasProjectId }} --baasdifferentiator=weaved-classes + run: ${{ steps.dotnet-publish.outputs.executable-path }}/Realm.Tests --result=TestResults.WovenClasses.xml --labels=After - name: Publish Unit Test Results uses: LaPeste/test-reporter@510caf50a955b1003bec48a6494be4d6537f3a0b if: always() diff --git a/Tools/DeployApps/BaasClient.cs b/Tools/DeployApps/BaasClient.cs index 6729bad2ed..fa3ece4eee 100644 --- a/Tools/DeployApps/BaasClient.cs +++ b/Tools/DeployApps/BaasClient.cs @@ -135,17 +135,18 @@ public class FunctionReturn private string _groupId = null!; private string? _refreshToken; - private string _shortDifferentiator + private string _shortSuffix { get { - if (Differentiator.Length < 8) + var completeSuffix = $"{Differentiator}-{_clusterName}"; + if (completeSuffix.Length < 8) { - return Differentiator; + return completeSuffix; } using var sha = SHA256.Create(); - var inputBytes = Encoding.ASCII.GetBytes(Differentiator); + var inputBytes = Encoding.ASCII.GetBytes(completeSuffix); var hashBytes = sha.ComputeHash(inputBytes); var sb = new StringBuilder(); @@ -158,7 +159,7 @@ private string _shortDifferentiator } } - private string _appSuffix => $"-{_shortDifferentiator}-{_clusterName}"; + private string _appSuffix => $"-{_shortSuffix}"; public string Differentiator { get; } @@ -535,11 +536,6 @@ private async Task GetApps() { var name = doc["name"].AsString; - if (!name.EndsWith(_appSuffix)) - { - return null; - } - var appName = name[..^_appSuffix.Length]; return new BaasApp(doc["_id"].AsString, doc["client_app_id"].AsString, appName); })