From f6794642e556537318be47d667daa9aec9d20473 Mon Sep 17 00:00:00 2001 From: Nikola Irinchev Date: Mon, 13 May 2024 17:12:21 +0200 Subject: [PATCH 01/39] Replace pr.yml with one generated from pkl --- .github/workflows/pr.yml | 112 +++++++++++++++++++-------------------- 1 file changed, 55 insertions(+), 57 deletions(-) diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index 6529e3a712..086bb2ba54 100755 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -1,5 +1,8 @@ +# Do not modify! +# This file was generated from a template using https://github.com/apple/pkl + name: PR Build -"on": +'on': pull_request: paths: - '**.cs' @@ -24,8 +27,8 @@ concurrency: cancel-in-progress: true jobs: build-wrappers: - uses: ./.github/workflows/wrappers.yml name: Wrappers + uses: ./.github/workflows/wrappers.yml deploy-baas: uses: ./.github/workflows/deploy-baas.yml with: @@ -33,93 +36,88 @@ jobs: secrets: BaaSaasApiKey: ${{ secrets.BAASAAS_API_KEY }} build-packages: - uses: ./.github/workflows/build-packages.yml name: Package needs: - build-wrappers + uses: ./.github/workflows/build-packages.yml with: build-docs: ${{ contains(github.head_ref, 'release') }} build-unity: - uses: ./.github/workflows/build-unity.yml name: Package - with: - version: ${{ needs.build-packages.outputs.package_version }} needs: - build-packages if: always() && !cancelled() && !contains(needs.*.result, 'failure') && !contains(needs.*.result, 'cancelled') + uses: ./.github/workflows/build-unity.yml + with: + version: ${{ needs.build-packages.outputs.package_version }} test-unity: - uses: ./.github/workflows/test-unity.yml name: Test + needs: + - build-unity + if: always() && !cancelled() && !contains(needs.*.result, 'failure') && !contains(needs.*.result, 'cancelled') + uses: ./.github/workflows/test-unity.yml with: version: ${{ needs.build-packages.outputs.package_version }} settings: '["Mono-Net4"]' platform: '[{ "os": "windows", "testPlatform": "Windows64" }, { "os": "linux", "testPlatform": "Linux64" }]' - needs: - - build-packages - - build-unity - if: always() && !cancelled() && !contains(needs.*.result, 'failure') && !contains(needs.*.result, 'cancelled') test-net-framework: - uses: ./.github/workflows/test-net-framework.yml name: Test - if: always() && !cancelled() && !contains(needs.*.result, 'failure') && !contains(needs.*.result, 'cancelled') needs: - build-packages + if: always() && !cancelled() && !contains(needs.*.result, 'failure') && !contains(needs.*.result, 'cancelled') + uses: ./.github/workflows/test-net-framework.yml with: version: ${{ needs.build-packages.outputs.package_version }} - secrets: {} test-uwp-managed: - uses: ./.github/workflows/test-uwp-managed.yml name: Test - if: always() && !cancelled() && !contains(needs.*.result, 'failure') && !contains(needs.*.result, 'cancelled') needs: - build-packages + if: always() && !cancelled() && !contains(needs.*.result, 'failure') && !contains(needs.*.result, 'cancelled') + uses: ./.github/workflows/test-uwp-managed.yml with: version: ${{ needs.build-packages.outputs.package_version }} secrets: 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 needs: - build-packages + if: always() && !cancelled() && !contains(needs.*.result, 'failure') && !contains(needs.*.result, 'cancelled') uses: ./.github/workflows/test-net-core.yml with: version: ${{ needs.build-packages.outputs.package_version }} framework: '["net8.0"]' test-macos: - uses: ./.github/workflows/test-macos.yml name: Test - if: always() && !cancelled() && !contains(needs.*.result, 'failure') && !contains(needs.*.result, 'cancelled') needs: - build-packages + if: always() && !cancelled() && !contains(needs.*.result, 'failure') && !contains(needs.*.result, 'cancelled') + uses: ./.github/workflows/test-macos.yml with: version: ${{ needs.build-packages.outputs.package_version }} - secrets: {} test-ios: - uses: ./.github/workflows/test-ios.yml name: Test - if: always() && !cancelled() && !contains(needs.*.result, 'failure') && !contains(needs.*.result, 'cancelled') needs: - build-packages + if: always() && !cancelled() && !contains(needs.*.result, 'failure') && !contains(needs.*.result, 'cancelled') + uses: ./.github/workflows/test-ios.yml with: version: ${{ needs.build-packages.outputs.package_version }} - secrets: {} test-tvos: - uses: ./.github/workflows/test-tvos.yml name: Test - if: always() && !cancelled() && !contains(needs.*.result, 'failure') && !contains(needs.*.result, 'cancelled') needs: - build-packages + if: always() && !cancelled() && !contains(needs.*.result, 'failure') && !contains(needs.*.result, 'cancelled') + uses: ./.github/workflows/test-tvos.yml with: version: ${{ needs.build-packages.outputs.package_version }} - secrets: {} test-android: - uses: ./.github/workflows/test-android.yml name: Test - if: always() && !cancelled() && !contains(needs.*.result, 'failure') && !contains(needs.*.result, 'cancelled') needs: - build-packages + if: always() && !cancelled() && !contains(needs.*.result, 'failure') && !contains(needs.*.result, 'cancelled') + uses: ./.github/workflows/test-android.yml with: version: ${{ needs.build-packages.outputs.package_version }} secrets: @@ -127,63 +125,63 @@ jobs: AWS_DEVICEFARM_SECRET_ACCESS_KEY: ${{ secrets.AWS_DEVICEFARM_SECRET_ACCESS_KEY }} DEVICEFARM_PROJECT_ARN: ${{ secrets.DEVICEFARM_PROJECT_ARN }} DEVICEFARM_ANDROID_POOL_ARN: ${{ secrets.DEVICEFARM_ANDROID_POOL_ARN }} - test-weaved-classes: - if: always() && !cancelled() && !contains(needs.*.result, 'failure') && !contains(needs.*.result, 'cancelled') + test-woven-classes: name: Test needs: - build-packages + if: always() && !cancelled() && !contains(needs.*.result, 'failure') && !contains(needs.*.result, 'cancelled') uses: ./.github/workflows/test-woven-classes.yml with: version: ${{ needs.build-packages.outputs.package_version }} test-source-generation: - if: always() && !cancelled() && !contains(needs.*.result, 'failure') && !contains(needs.*.result, 'cancelled') name: Test + if: always() && !cancelled() && !contains(needs.*.result, 'failure') && !contains(needs.*.result, 'cancelled') uses: ./.github/workflows/test-source-generation.yml test-weaver: - uses: ./.github/workflows/test-weaver.yml name: Test + if: always() && !cancelled() && !contains(needs.*.result, 'failure') && !contains(needs.*.result, 'cancelled') + uses: ./.github/workflows/test-weaver.yml test-code-coverage: - uses: ./.github/workflows/test-code-coverage.yml name: Test - if: always() && !cancelled() && !contains(needs.*.result, 'failure') && !contains(needs.*.result, 'cancelled') needs: - build-packages - deploy-baas + if: always() && !cancelled() && !contains(needs.*.result, 'failure') && !contains(needs.*.result, 'cancelled') + uses: ./.github/workflows/test-code-coverage.yml with: version: ${{ needs.build-packages.outputs.package_version }} secrets: BaaSaasApiKey: ${{ secrets.BAASAAS_API_KEY }} cleanup-baas: - uses: ./.github/workflows/cleanup-baas.yml - if: always() name: Cleanup needs: - - deploy-baas - test-code-coverage + if: always() + uses: ./.github/workflows/cleanup-baas.yml with: differentiators: '["code-coverage"]' secrets: BaaSaasApiKey: ${{ secrets.BAASAAS_API_KEY }} verify-namespaces: - runs-on: ubuntu-latest name: Verify Namespaces needs: - build-packages + runs-on: ubuntu-latest steps: - - name: Checkout code + - name: Checkout Code uses: actions/checkout@v3 with: submodules: recursive ref: ${{ github.event.pull_request.head.sha }} - - name: Fetch Realm.PlatformHelpers + - name: Fetch Realm uses: actions/download-artifact@v3 with: - name: Realm.PlatformHelpers.${{ needs.build-packages.outputs.package_version }} + name: Realm.${{ needs.build-packages.outputs.package_version }} path: ${{ github.workspace }}/Realm/packages/ - - name: Fetch Realm + - name: Fetch Realm.PlatformHelpers uses: actions/download-artifact@v3 with: - name: Realm.${{ needs.build-packages.outputs.package_version }} + name: Realm.PlatformHelpers.${{ needs.build-packages.outputs.package_version }} path: ${{ github.workspace }}/Realm/packages/ - name: Fetch Realm.UnityUtils uses: actions/download-artifact@v3 @@ -197,29 +195,29 @@ jobs: path: ${{ github.workspace }}/Realm/packages/ - run: dotnet tool install ilspycmd -g --version 8.0.0.7345 - name: Verify Namespaces - run: | + run: |- $isFailure = $false Get-ChildItem ./Realm/packages -Filter *.nupkg | Foreach-Object { - $targetPath = Join-Path ./Realm/packages $_.BaseName - Expand-Archive $_.FullName -DestinationPath $targetPath + $targetPath = Join-Path ./Realm/packages $_.BaseName + Expand-Archive $_.FullName -DestinationPath $targetPath - Get-ChildItem $targetPath -Filter *.dll -Recurse | ForEach-Object { - if (-not ($_.FullName -match "runtimes")) { - $ilspyOutput = ilspycmd $_.FullName + Get-ChildItem $targetPath -Filter *.dll -Recurse | ForEach-Object { + if (-not ($_.FullName -match "runtimes")) { + $ilspyOutput = ilspycmd $_.FullName - $parentDll = $_.FullName + $parentDll = $_.FullName - $ilspyOutput | ForEach-Object { - if ($_ -match "namespace.*Realm(\.|$)") { - Write-Output "::error file=$parentDll::Realm present in namespace - $($_)" - Set-Variable "isFailure" -Value $true - } - } + $ilspyOutput | ForEach-Object { + if ($_ -match "namespace.*Realm(\.|$)") { + Write-Output "::error file=$parentDll::Realm present in namespace - $($_)" + Set-Variable "isFailure" -Value $true } + } } + } } if ($isFailure) { - exit 1 + exit 1 } shell: pwsh From e6b532d2c79cf0cd47ef7dbd0b2e51219a7298af Mon Sep 17 00:00:00 2001 From: Nikola Irinchev Date: Mon, 13 May 2024 23:35:16 +0200 Subject: [PATCH 02/39] Generate wrappers.yml using pkl --- .../GithubAction/GithubAction.pkl | 687 ++++++++++++++++++ .github/pkl-workflows/GithubAction/PklProject | 8 + .../GithubAction/PklProject.deps.json | 4 + .github/pkl-workflows/PklProject | 5 + .github/pkl-workflows/PklProject.deps.json | 10 + .github/pkl-workflows/helpers/Common.pkl | 26 + .github/pkl-workflows/helpers/Steps.pkl | 39 + .github/pkl-workflows/pr.pkl | 227 ++++++ .../pkl-workflows/temp-outputs/wrappers.yml | 42 ++ .github/pkl-workflows/wrappers.pkl | 204 ++++++ .github/workflows/wrappers.yml | 654 +++++++++-------- 11 files changed, 1578 insertions(+), 328 deletions(-) create mode 100644 .github/pkl-workflows/GithubAction/GithubAction.pkl create mode 100644 .github/pkl-workflows/GithubAction/PklProject create mode 100644 .github/pkl-workflows/GithubAction/PklProject.deps.json create mode 100644 .github/pkl-workflows/PklProject create mode 100644 .github/pkl-workflows/PklProject.deps.json create mode 100644 .github/pkl-workflows/helpers/Common.pkl create mode 100644 .github/pkl-workflows/helpers/Steps.pkl create mode 100644 .github/pkl-workflows/pr.pkl create mode 100644 .github/pkl-workflows/temp-outputs/wrappers.yml create mode 100644 .github/pkl-workflows/wrappers.pkl diff --git a/.github/pkl-workflows/GithubAction/GithubAction.pkl b/.github/pkl-workflows/GithubAction/GithubAction.pkl new file mode 100644 index 0000000000..0ef56b492e --- /dev/null +++ b/.github/pkl-workflows/GithubAction/GithubAction.pkl @@ -0,0 +1,687 @@ +// This is based on https://github.com/StefMa/pkl-gha with modifications +// to add missing GHA options + +module com.github.GitHubAction + +// JSON Schema definition for GitHub Actions workflow files: +// https://json.schemastore.org/github-workflow.json + +// GitHub Action lint: +// https://rhysd.github.io/actionlint/ + +// Definitions + +// Trigger +abstract class Trigger { + paths: Listing? + `paths-ignore`: Listing? + branches: Listing? + `branches-ignore`: Listing? +} + +/// Runs your workflow anytime the branch_protection_rule event occurs. More than one activity type triggers this event. +/// +/// https://docs.github.com/en/actions/learn-github-actions/events-that-trigger-workflows#branch_protection_rule +class BranchProtectionRule extends Trigger { + types: Listing? +} +typealias BranchProtectionRuleType = + "created" + |"edited" + |"deleted" + +/// Runs your workflow anytime the check_run event occurs. More than one activity type triggers this event. +/// For information about the REST API, see https://developer.github.com/v3/checks/runs. +/// +/// https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#check_run +class CheckRun extends Trigger { + types: Listing? +} +typealias CheckRunType = + "created" + |"rerequested" + |"completed" + |"requested_action" + +/// Runs your workflow anytime the check_suite event occurs. More than one activity type triggers this event. +/// For information about the REST API, see https://developer.github.com/v3/checks/suites/ +/// +/// https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#check_suite +class CheckSuite extends Trigger { + types: Listing? +} +typealias CheckSuiteType = + "completed" + |"requested" + |"rerequested" + +/// Runs your workflow anytime someone creates a branch or tag, which triggers the create event. +/// For information about the REST API, see https://developer.github.com/v3/git/refs/#create-a-reference. +/// +/// https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#create +class Create extends Trigger + +// Runs your workflow anytime someone deletes a branch or tag, which triggers the delete event. +/// For information about the REST API, see https://developer.github.com/v3/git/refs/#delete-a-reference. +/// +/// https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#delete +class Delete extends Trigger + +/// Runs your workflow anytime someone creates a deployment, which triggers the deployment event. +/// Deployments created with a commit SHA may not have a Git ref. +/// For information about the REST API, see https://developer.github.com/v3/repos/deployments/. +/// +/// https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#deployment +class Deployment extends Trigger + +/// Runs your workflow anytime a third party provides a deployment status, which triggers the deployment_status event. +/// Deployments created with a commit SHA may not have a Git ref. +/// For information about the REST API, see https://developer.github.com/v3/repos/deployments/#create-a-deployment-status. +/// +/// https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#deployment_status +class DeploymentStatus extends Trigger + +/// Runs your workflow anytime the discussion event occurs. More than one activity type triggers this event. +/// For information about the GraphQL API, see https://docs.github.com/en/graphql/guides/using-the-graphql-api-for-discussions +/// +/// https://docs.github.com/en/actions/learn-github-actions/events-that-trigger-workflows#discussion +class Discussion extends Trigger { + types: Listing? +} +typealias DiscussionType = + "created" + |"edited" + |"deleted" + |"transferred" + |"pinned" + |"unpinned" + |"labeled" + |"unlabeled" + |"locked" + |"unlocked" + |"category_changed" + |"answered" + |"unanswered" + +/// Runs your workflow anytime the discussion_comment event occurs. More than one activity type triggers this event. +/// For information about the GraphQL API, see https://docs.github.com/en/graphql/guides/using-the-graphql-api-for-discussions +/// +/// https://docs.github.com/en/actions/learn-github-actions/events-that-trigger-workflows#discussion_comment +class DiscussionComment extends Trigger { + types: Listing? +} +typealias DiscussionCommentType = + "created" + |"edited" + |"deleted" + +/// Runs your workflow anytime when someone forks a repository, which triggers the fork event. +/// For information about the REST API, see https://developer.github.com/v3/repos/forks/#create-a-fork +/// +/// https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#fork +class Fork extends Trigger + +/// Runs your workflow when someone creates or updates a Wiki page, which triggers the gollum event. +/// +/// https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#gollum +class Gollum extends Trigger + +/// Runs your workflow anytime the issue_comment event occurs. More than one activity type triggers this event. +/// For information about the REST API, see https://developer.github.com/v3/issues/comments/. +/// +/// https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#issue_comment +class IssueComment extends Trigger { + types: Listing? +} +typealias IssueCommentType = + "created" + |"edited" + |"deleted" + +/// Runs your workflow anytime the issues event occurs. More than one activity type triggers this event. +/// For information about the REST API, see https://developer.github.com/v3/issues. +/// +/// https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#issues +class Issues extends Trigger { + types: Listing? +} +typealias IssuesType = + "opened" + |"edited" + |"deleted" + |"transferred" + |"pinned" + |"unpinned" + |"closed" + |"reopened" + |"assigned" + |"unassigned" + |"labeled" + |"unlabeled" + |"locked" + |"unlocked" + |"milestoned" + |"demilestoned" + +/// Runs your workflow anytime the label event occurs. More than one activity type triggers this event. +/// For information about the REST API, see https://developer.github.com/v3/issues/labels/. +/// +/// https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#label +class Label extends Trigger { + types: Listing? +} +typealias LabelType = + "created" + |"edited" + |"deleted" + +/// Runs your workflow when a pull request is added to a merge queue, which adds the pull request to a merge group. +/// For information about the merge queue, see https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/incorporating-changes-from-a-pull-request/merging-a-pull-request-with-a-merge-queue. +/// +/// https://help.github.com/en/github/automating-your-workflow-with-github-actions/events-that-trigger-workflows#merge_group +class MergeGroup extends Trigger { + types: Listing? +} +typealias MergeGroupType = + "checked_requested" + +/// Runs your workflow anytime the milestone event occurs. More than one activity type triggers this event. +/// For information about the REST API, see https://developer.github.com/v3/issues/milestones/. +/// +/// https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#milestone +class Milestone extends Trigger { + types: Listing? +} +typealias MilestoneType = + "created" + |"closed" + |"opened" + |"edited" + |"deleted" + +/// Runs your workflow anytime someone pushes to a GitHub Pages-enabled branch, which triggers the page_build event. +/// For information about the REST API, see https://developer.github.com/v3/repos/pages/. +/// +/// https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#page_build +class PageBuild extends Trigger + +/// Runs your workflow anytime the project event occurs. More than one activity type triggers this event. +/// For information about the REST API, see https://developer.github.com/v3/projects/. +/// +/// https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#project +class Project extends Trigger { + types: Listing? +} +typealias ProjectType = + "created" + |"updated" + |"closed" + |"reopened" + |"edited" + |"deleted" + +/// Runs your workflow anytime the project_card event occurs. More than one activity type triggers this event. +/// For information about the REST API, see https://developer.github.com/v3/projects/cards. +/// +/// https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#project_card +class ProjectCard extends Trigger { + types: Listing? +} +typealias ProjectCardType = + "created" + |"moved" + |"converted" + |"edited" + |"deleted" + +/// Runs your workflow anytime the project_column event occurs. More than one activity type triggers this event. +/// For information about the REST API, see https://developer.github.com/v3/projects/columns. +/// +/// https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#project_column +class ProjectColumn extends Trigger { + types: Listing? +} +typealias ProjectColumnType = + "created" + |"updated" + |"moved" + |"deleted" + +/// Runs your workflow anytime someone makes a private repository public, which triggers the public event. +/// For information about the REST API, see https://developer.github.com/v3/repos/#edit. +/// +/// https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#public +class Public extends Trigger + +/// Runs your workflow anytime the pull_request event occurs. More than one activity type triggers this event. +/// For information about the REST API, see https://developer.github.com/v3/pulls. +/// Note: Workflows do not run on private base repositories when you open a pull request from a forked repository. +/// When you create a pull request from a forked repository to the base repository, +/// GitHub sends the pull_request event to the base repository and no pull request events occur on the forked repository. +/// Workflows don't run on forked repositories by default. +/// You must enable GitHub Actions in the Actions tab of the forked repository. +/// The permissions for the GITHUB_TOKEN in forked repositories is read-only. +/// For more information about the GITHUB_TOKEN, see https://help.github.com/en/articles/virtual-environments-for-github-actions. +/// +/// https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#pull_request +class PullRequest extends Trigger { + types: Listing? +} +typealias PullRequestType = + "assigned" + |"unassigned" + |"review_requested" + |"review_request_removed" + |"labeled" + |"unlabeled" + |"opened" + |"edited" + |"closed" + |"reopened" + |"synchronize" + |"ready_for_review" + |"locked" + |"unlocked" + |"ready_for_review" + |"converted_to_draft" + |"demilestoned" + |"milestoned" + |"review_requested" + |"review_request_removed" + |"auto_merge_enabled" + |"auto_merge_disabled" + +/// Runs your workflow anytime the pull_request_review event occurs. More than one activity type triggers this event. +/// For information about the REST API, see https://developer.github.com/v3/pulls/reviews. +/// Note: Workflows do not run on private base repositories when you open a pull request from a forked repository. +/// When you create a pull request from a forked repository to the base repository, +/// GitHub sends the pull_request event to the base repository and no pull request events occur on the forked repository. +/// Workflows don't run on forked repositories by default. +/// You must enable GitHub Actions in the Actions tab of the forked repository. +/// The permissions for the GITHUB_TOKEN in forked repositories is read-only. +/// For more information about the GITHUB_TOKEN, see https://help.github.com/en/articles/virtual-environments-for-github-actions. +/// +/// https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#pull_request_review +class PullRequestReview extends Trigger { + types: Listing? +} +typealias PullRequestReviewType = + "submitted" + |"edited" + |"dismissed" + +/// Runs your workflow anytime a comment on a pull request's unified diff is modified, which triggers the pull_request_review_comment event. +/// More than one activity type triggers this event. +/// For information about the REST API, see https://developer.github.com/v3/pulls/comments. +/// Note: Workflows do not run on private base repositories when you open a pull request from a forked repository. +/// When you create a pull request from a forked repository to the base repository, +/// GitHub sends the pull_request event to the base repository and no pull request events occur on the forked repository. +/// Workflows don't run on forked repositories by default. +/// You must enable GitHub Actions in the Actions tab of the forked repository. +/// The permissions for the GITHUB_TOKEN in forked repositories is read-only. +/// For more information about the GITHUB_TOKEN, see https://help.github.com/en/articles/virtual-environments-for-github-actions. +/// +/// https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#pull_request_review_comment +class PullRequestReviewComment extends Trigger { + types: Listing? +} +typealias PullRequestReviewCommentType = + "created" + |"edited" + |"deleted" + +/// This event is similar to pull_request, except that it runs in the context of the base repository of the pull request, +/// rather than in the merge commit. +/// This means that you can more safely make your secrets available to the workflows triggered by the pull request, +/// because only workflows defined in the commit on the base repository are run. +/// For example, this event allows you to create workflows that label and comment on pull requests, +/// based on the contents of the event payload. +/// +/// https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#pull_request_target +class PullRequestTarget extends Trigger { + types: Listing? +} +typealias PullRequestTargetType = + "assigned" + |"unassigned" + |"labeled" + |"unlabeled" + |"opened" + |"edited" + |"closed" + |"reopened" + |"synchronize" + |"converted_to_draft" + |"ready_for_review" + |"locked" + |"unlocked" + |"review_requested" + |"review_request_removed" + |"auto_merge_enabled" + |"auto_merge_disabled" + +/// Runs your workflow when someone pushes to a repository branch, which triggers the push event. +/// Note: The webhook payload available to GitHub Actions does not include the added, removed, and modified attributes in the commit object. +/// You can retrieve the full commit object using the REST API. +/// For more information, see https://developer.github.com/v3/repos/commits/#get-a-single-commit. +/// +/// https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#push +class Push extends Trigger { + tags: Listing? + `tags-ignore`: Listing? +} + +/// Runs your workflow anytime a package is published or updated. +/// For more information, see https://help.github.com/en/github/managing-packages-with-github-packages +/// +/// https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#registry_package +class RegistryPackage extends Trigger { + types: Listing? +} +typealias RegistryPackageType = + "published" + |"updated" + +/// Runs your workflow anytime the release event occurs. More than one activity type triggers this event. +/// For information about the REST API, see https://developer.github.com/v3/repos/releases/ in the GitHub Developer documentation. +/// +/// https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#release +class Release extends Trigger { + types: Listing? +} +typealias ReleaseType = + "published" + |"unpublished" + |"created" + |"edited" + |"deleted" + |"prereleased" + |"released" + +/// You can use the GitHub API to trigger a webhook event called repository_dispatch +/// when you want to trigger a workflow for activity that happens outside of GitHub. +/// For more information, see https://developer.github.com/v3/repos/#create-a-repository-dispatch-event. +/// To trigger the custom repository_dispatch webhook event, you must send a POST request to a GitHub API endpoint +/// and provide an event_type name to describe the activity type. +/// To trigger a workflow run, you must also configure your workflow to use the repository_dispatch event. +/// +/// https://docs.github.com/en/actions/learn-github-actions/events-that-trigger-workflows#repository_dispatch +class RepositoryDispatch extends Trigger { + types: Listing? +} + +/// You can schedule a workflow to run at specific UTC times using POSIX cron syntax (https://pubs.opengroup.org/onlinepubs/9699919799/utilities/crontab.html#tag_20_25_07). +/// Scheduled workflows run on the latest commit on the default or base branch. +/// The shortest interval you can run scheduled workflows is once every 5 minutes. +/// Note: GitHub Actions does not support the non-standard syntax @yearly, @monthly, @weekly, @daily, @hourly, and @reboot. +/// You can use crontab guru (https://crontab.guru/) to help generate your cron syntax and confirm what time it will run. +/// To help you get started, there is also a list of crontab guru examples (https://crontab.guru/examples.html). +/// +/// https://docs.github.com/en/actions/learn-github-actions/events-that-trigger-workflows#schedule +class Schedule extends Trigger { + cron: Listing(length > 0) +} +typealias ScheduleCron = String + +/// Runs your workflow anytime the status of a Git commit changes, which triggers the status event. +/// For information about the REST API, see https://developer.github.com/v3/repos/statuses/. +/// +/// https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#status +class Status extends Trigger + +/// Runs your workflow anytime the watch event occurs. More than one activity type triggers this event. +/// For information about the REST API, see https://developer.github.com/v3/activity/starring/ +/// +/// https://docs.github.com/en/actions/learn-github-actions/events-that-trigger-workflows#watch +class Watch extends Trigger + +/// Allows workflows to be reused by other workflows. +/// +/// https://docs.github.com/en/actions/learn-github-actions/events-that-trigger-workflows#workflow_call +class WorkflowCall extends Trigger { + inputs: Mapping? + outputs: Mapping? + secrets: Listing? +} +class WorkflowCallOutput { + description: String? + value: Any +} +class WorkflowCallSecrets { + description: String? + required: Boolean +} + +/// You can now create workflows that are manually triggered with the new workflow_dispatch event. +/// You will then see a 'Run workflow' button on the Actions tab, enabling you to easily trigger a run. +/// +/// https://docs.github.com/en/actions/learn-github-actions/events-that-trigger-workflows#workflow_dispatch +class WorkflowDispatch extends Trigger { + inputs: Mapping? +} + +class WorkflowInput { + description: String + deprecatedMessage: String? + required: Boolean? + default: String? + type: WorkflowInputType? + options: Listing? +} +typealias WorkflowInputType = "boolean"|"string"|"choice"|"environment"|"number" + +/// This event occurs when a workflow run is requested or completed, +/// and allows you to execute a workflow based on the finished result of another workflow. +/// For example, if your pull_request workflow generates build artifacts, +/// you can create a new workflow that uses workflow_run to analyze the results and add a comment to the original pull request. +/// +/// https://docs.github.com/en/actions/learn-github-actions/events-that-trigger-workflows#workflow_run +class WorkflowRun extends Trigger { + types: Listing? + workflows: Listing(length > 0) +} +typealias WorkflowRunType = + "requested" + |"completed" + |"in_progress" + +// On +class On { + branch_protection_rule: BranchProtectionRule? + check_run: CheckRun? + check_suite: CheckSuite? + create: Create? + `delete`: Delete? + deployment: Deployment? + deployment_status: DeploymentStatus? + discussion: Discussion? + discussion_comment: DiscussionComment? + fork: Fork? + gollum: Gollum? + issue_comment: IssueComment? + issues: Issues? + label: Label? + merge_group: MergeGroup? + milestone: Milestone? + page_build: PageBuild? + project: Project? + project_card: ProjectCard? + project_column: ProjectColumn? + public: Public? + pull_request: PullRequest? + pull_request_review: PullRequestReview? + pull_request_review_comment: PullRequestReviewComment? + pull_request_target: PullRequestTarget? + push: Push? + registry_package: RegistryPackage? + release: Release? + repository_dispatch: RepositoryDispatch? + schedule: Schedule? + status: Status? + watch: Watch? + workflow_call: WorkflowCall? + workflow_dispatch: WorkflowDispatch? + workflow_run: WorkflowRun? +} + +// Environment Variables +typealias EnvironmentVariables = Mapping + +// Permissions +class Permissions { + actions: Permission? + checks: Permission? + contents: Permission? + deployments: Permission? + `id-token`: Permission? + issues: Permission? + discussions: Permission? + packages: Permission? + pages: Permission? + `pull-requests`: Permission? + `repository-projects`: Permission? + `security-events`: Permission? + statuses: Permission? +} +typealias Permission = "read"|"write"|"none" + +// Concurrency +class Concurrency { + group: String + `cancel-in-progress`: Boolean +} + +// Strategies +abstract class Strategy + +class MatrixStrategy extends Strategy { + matrix: Mapping +} + +// Jobs +abstract class JobBase { + name: String? + needs: Listing? + `if`: String? + concurrency: Concurrency? + env: EnvironmentVariables? + outputs: Mapping? + `timeout-minutes`: Int? +} + +abstract class StepJobBase extends JobBase { + `runs-on`: Machine|String + steps: Listing(stepsHasOnlyRunOrUses(this)) +} + +class Job extends StepJobBase + +class MatrixJob extends StepJobBase { + strategy: MatrixStrategy +} + +class ReusableWorkflowJob extends JobBase { + uses: String + with: Mapping? + secrets: Mapping? +} + +// Machines, part of Jobs +abstract class Machine { + name: String +} +class UbuntuLatest extends Machine { + name = "ubuntu-latest" +} +class MacOsLatest extends Machine { + name = "macos-latest" +} +class WindowsLatest extends Machine { + name = "windows-latest" +} + +typealias Shell = "pwsh" | "bash" | "sh" | "cmd" | "PowerShell" | "python" + +// Step, part of Jobs +class Step { + name: String? + id: String? + `if`: String? + env: EnvironmentVariables? + `working-directory`: String? + run: String? + uses: String? + with: Mapping? + shell: Shell? +} + +// Templating + +name: String + +local const onIsSet = (on: On) -> + on.branch_protection_rule != null || + on.check_run != null || + on.check_suite != null || + on.create != null || + on.`delete` != null || + on.deployment != null || + on.deployment_status != null || + on.discussion != null || + on.discussion_comment != null || + on.fork != null || + on.gollum != null || + on.issue_comment != null || + on.issues != null || + on.label != null || + on.merge_group != null || + on.milestone != null || + on.page_build != null || + on.project != null || + on.project_card != null || + on.project_column != null || + on.public != null || + on.pull_request != null || + on.pull_request_review != null || + on.pull_request_review_comment != null || + on.pull_request_target != null || + on.push != null || + on.registry_package != null || + on.release != null || + on.repository_dispatch != null || + on.schedule != null || + on.status != null || + on.watch != null || + on.workflow_call != null || + on.workflow_dispatch != null || + on.workflow_run != null +on: On(onIsSet) + +env: EnvironmentVariables? + +concurrency: Concurrency? + +permissions: (*Permissions|"read-all"|"write-all")? + +local const jobIsSet = (jobs: Mapping) -> jobs.length > 0 +jobs: Mapping(jobIsSet) + +// Output +local jsonRenderer = new JsonRenderer {} +output { + text = "# Do not modify!\n# This file was generated from a template using https://github.com/apple/pkl\n\n\(super.text)" + renderer = new YamlRenderer { + converters { + ["runs-on"] = (runsOn: String|Machine) -> if (runsOn is Machine) runsOn.name else runsOn + ["schedule"] = (schedule: Schedule?) -> schedule.ifNonNull((_) -> + schedule.cron.toList().map((cr) -> Map("cron", new RenderDirective { text = " " + jsonRenderer.renderValue(cr) })) + ) + } + } +} + +const local function stepsHasOnlyRunOrUses(steps: Listing): Boolean = steps + .toList() + .every((step) -> !(containsRunAndUses(step) || containsNeitherRunNorUses(step))) +const local function containsRunAndUses(step: Step): Boolean = step.run != null && step.uses != null +const local function containsNeitherRunNorUses(step: Step): Boolean = step.run == null && step.uses == null \ No newline at end of file diff --git a/.github/pkl-workflows/GithubAction/PklProject b/.github/pkl-workflows/GithubAction/PklProject new file mode 100644 index 0000000000..4f9b4d558d --- /dev/null +++ b/.github/pkl-workflows/GithubAction/PklProject @@ -0,0 +1,8 @@ +amends "pkl:Project" + +package { + name = "realm-pkl-gha" + version = "1.0.0" + baseUri = "package://realm.io/realm-pkl-gha" + packageZipUrl = "https://realm.io/realm-pkl-gha@\(version).zip" +} \ No newline at end of file diff --git a/.github/pkl-workflows/GithubAction/PklProject.deps.json b/.github/pkl-workflows/GithubAction/PklProject.deps.json new file mode 100644 index 0000000000..836079aad1 --- /dev/null +++ b/.github/pkl-workflows/GithubAction/PklProject.deps.json @@ -0,0 +1,4 @@ +{ + "schemaVersion": 1, + "resolvedDependencies": {} +} \ No newline at end of file diff --git a/.github/pkl-workflows/PklProject b/.github/pkl-workflows/PklProject new file mode 100644 index 0000000000..b98672dbf6 --- /dev/null +++ b/.github/pkl-workflows/PklProject @@ -0,0 +1,5 @@ +amends "pkl:Project" + +dependencies { + ["realm-gha"] = import("GithubAction/PklProject") +} \ No newline at end of file diff --git a/.github/pkl-workflows/PklProject.deps.json b/.github/pkl-workflows/PklProject.deps.json new file mode 100644 index 0000000000..6a15a31b7e --- /dev/null +++ b/.github/pkl-workflows/PklProject.deps.json @@ -0,0 +1,10 @@ +{ + "schemaVersion": 1, + "resolvedDependencies": { + "package://realm.io/realm-pkl-gha@1": { + "type": "local", + "uri": "projectpackage://realm.io/realm-pkl-gha@1.0.0", + "path": "GithubAction" + } + } +} \ No newline at end of file diff --git a/.github/pkl-workflows/helpers/Common.pkl b/.github/pkl-workflows/helpers/Common.pkl new file mode 100644 index 0000000000..dfb61d8632 --- /dev/null +++ b/.github/pkl-workflows/helpers/Common.pkl @@ -0,0 +1,26 @@ +module common + +const configuration: String = "Release" + +const linuxArchs: List = List("x86_64", "armhf", "aarch64") +const applePlatforms: List = List("iOS", "tvOS") +const androidABIs: List = List("armeabi-v7a", "arm64-v8a", "x86", "x86_64") +const windowsArchs: List = List("Win32", "x64", "ARM64") +const uwpArchs: List = List("Win32", "x64", "ARM", "ARM64") + +const appleTargets: List = List("Device", "Simulator") + +const wrapperBinaryNames: List = + List("macos", "catalyst") + + linuxArchs.map((arch) -> "linux-\(arch)") + + androidABIs.map((abi) -> "android-\(abi)") + + windowsArchs.map((arch) -> "windows-\(arch)") + + uwpArchs.map((arch) -> "windows-uwp-\(arch)") + + applePlatformTargets((platform, target) -> "\(platform)-\(target)") + +const defaultEnv: Mapping = new { + ["REALM_DISABLE_ANALYTICS"] = true + ["DOTNET_NOLOGO"] = true +} + +const function applePlatformTargets(_transform: (String, String) -> String): List = applePlatforms.map((platform) -> appleTargets.map((target) -> _transform.apply(platform, target))).flatten() \ No newline at end of file diff --git a/.github/pkl-workflows/helpers/Steps.pkl b/.github/pkl-workflows/helpers/Steps.pkl new file mode 100644 index 0000000000..0e0e23a487 --- /dev/null +++ b/.github/pkl-workflows/helpers/Steps.pkl @@ -0,0 +1,39 @@ +import "../GithubAction/GithubAction.pkl" as gha + +const function checkout(): gha.Step = new { + name = "Checkout Code" + uses = "actions/checkout@v4" + with { + ["submodules"] = "recursive" + ["ref"] = "${{ github.event.pull_request.head.sha }}" + } +} + +const function restoreCache(): gha.Step = new { + +} + +const function uploadArtifacts(artifactName: String, relPath: String): gha.Step = new { + name = "Store artifacts for \(artifactName)" + uses = "actions/upload-artifact@v4" + with { + ["name"] = artifactName + ["path"] = "${{ github.workspace }}/\(relPath)" + ["retention-days"] = "${{ github.event_name != 'pull_request' && 30 || 1 }}" + ["if-no-files-found"] = "error" + } +} + +const function setupXcode(): gha.Step = new { + name = "Setup Xcode" + uses = "maxim-lobanov/setup-xcode@60606e260d2fc5762a71e64e74b2174e8ea3c8bd" + with { + ["xcode-version"] = "14" + } +} + +const function setupMSVC(edition: String): gha.Step = new { + name = "Setup MSVC" + run = "Start-Process \"C:\\Program Files (x86)\\Microsoft Visual Studio\\Installer\\vs_installer.exe\" -ArgumentList 'modify --installPath \"C:\\Program Files\\Microsoft Visual Studio\\2022\\Enterprise\" --quiet --add Microsoft.VisualStudio.Component.VC.14.35.17.5.\(edition)' -Wait -PassThru" + shell = "pwsh" +} \ No newline at end of file diff --git a/.github/pkl-workflows/pr.pkl b/.github/pkl-workflows/pr.pkl new file mode 100644 index 0000000000..904bcc518a --- /dev/null +++ b/.github/pkl-workflows/pr.pkl @@ -0,0 +1,227 @@ +module pr + +amends "GithubAction/GithubAction.pkl" + +import "helpers/common.pkl" + +local class JobNamesDefition { + const wrappers: String = "build-wrappers" + const packages: String = "build-packages" + const unity: String = "build-unity" + const baas: String = "deploy-baas" + const coverage: String = "test-code-coverage" +} + +local function createTestJob(workflow: String): ReusableWorkflowJob = new ReusableWorkflowJob { + uses = "./.github/workflows/\(workflow).yml" + name = "Test" + `if` = ifNotCanceledCondition + needs { + JobNames.packages + } + with { + ["version"] = "${{ needs.\(JobNames.packages).outputs.package_version }}" + } +} + +local function checkoutCode(): Step = new { + name = "Checkout Code" + uses = "actions/checkout@v3" + with { + ["submodules"] = "recursive" + ["ref"] = "${{ github.event.pull_request.head.sha }}" + } +} + +local JobNames = new JobNamesDefition{} +local ifNotCanceledCondition = "always() && !cancelled() && !contains(needs.*.result, 'failure') && !contains(needs.*.result, 'cancelled')" + +local packages = List("Realm", "Realm.PlatformHelpers", "Realm.UnityUtils", "Realm.UnityWeaver") + +name = "PR Build" +on { + pull_request { + paths { + "**.cs" + "**.cpp" + "**.hpp" + "**.csproj" + "**CMakeLists.txt" + "**.ps1" + "**.sh" + "**.props" + "wrappers/realm-core" + ".github/workflows/*.yml" + "!.github/workflows/main.yml" + "!.github/workflows/publish-*.yml" + ".github/actions/**" + "Tests/Tests.Android/Properties/AndroidManifest.xml" + } + } +} + +env = common.defaultEnv + +concurrency { + group = "${{ github.head_ref || github.run_id }}" + `cancel-in-progress` = true +} + +jobs { + [JobNames.wrappers] = new ReusableWorkflowJob { + uses = "./.github/workflows/wrappers.yml" + name = "Wrappers" + } + [JobNames.baas] = new ReusableWorkflowJob { + uses = "./.github/workflows/deploy-baas.yml" + with { + ["differentiators"] = "[\"code-coverage\"]" + } + secrets { + ["BaaSaasApiKey"] = "${{ secrets.BAASAAS_API_KEY }}" + } + } + [JobNames.packages] = new ReusableWorkflowJob { + uses = "./.github/workflows/build-packages.yml" + name = "Package" + needs { + JobNames.wrappers + } + with { + ["build-docs"] = "${{ contains(github.head_ref, 'release') }}" + } + } + [JobNames.unity] = new ReusableWorkflowJob { + uses = "./.github/workflows/build-unity.yml" + name = "Package" + with { + ["version"] = "${{ needs.build-packages.outputs.package_version }}" + } + needs { + JobNames.packages + } + `if` = ifNotCanceledCondition + } + ["test-unity"] = new ReusableWorkflowJob { + uses = "./.github/workflows/test-unity.yml" + name = "Test" + with { + ["version"] = "${{ needs.build-packages.outputs.package_version }}" + ["settings"] = "[\"Mono-Net4\"]" + ["platform"] = "[{ \"os\": \"windows\", \"testPlatform\": \"Windows64\" }, { \"os\": \"linux\", \"testPlatform\": \"Linux64\" }]" + } + needs { + JobNames.unity + } + `if` = ifNotCanceledCondition + } + ["test-net-framework"] = createTestJob("test-net-framework") + ["test-uwp-managed"] = (createTestJob("test-uwp-managed")) { + secrets { + ["Pfx_Password"] = "${{ secrets.Pfx_Password }}" + ["Base64_Encoded_Pfx"] = "${{ secrets.Base64_Encoded_Pfx }}" + } + } + ["test-net-core"] = (createTestJob("test-net-core")) { + with { + ["framework"] = "[\"net8.0\"]" + } + } + ["test-macos"] = createTestJob("test-macos") + ["test-ios"] = createTestJob("test-ios") + ["test-tvos"] = createTestJob("test-tvos") + ["test-android"] = (createTestJob("test-android")) { + secrets { + ["AWS_DEVICEFARM_ACCESS_KEY_ID"] = "${{ secrets.AWS_DEVICEFARM_ACCESS_KEY_ID }}" + ["AWS_DEVICEFARM_SECRET_ACCESS_KEY"] = "${{ secrets.AWS_DEVICEFARM_SECRET_ACCESS_KEY }}" + ["DEVICEFARM_PROJECT_ARN"] = "${{ secrets.DEVICEFARM_PROJECT_ARN }}" + ["DEVICEFARM_ANDROID_POOL_ARN"] = "${{ secrets.DEVICEFARM_ANDROID_POOL_ARN }}" + } + } + ["test-woven-classes"] = createTestJob("test-woven-classes") + ["test-source-generation"] = new ReusableWorkflowJob { + `if` = ifNotCanceledCondition + name = "Test" + uses = "./.github/workflows/test-source-generation.yml" + } + ["test-weaver"] = new ReusableWorkflowJob { + `if` = ifNotCanceledCondition + name = "Test" + uses = "./.github/workflows/test-weaver.yml" + } + ["test-code-coverage"] = (createTestJob("test-code-coverage")) { + needs { + JobNames.baas + } + secrets { + ["BaaSaasApiKey"] = "${{ secrets.BAASAAS_API_KEY }}" + } + } + ["cleanup-baas"] = new ReusableWorkflowJob { + name = "Cleanup" + uses = "./.github/workflows/cleanup-baas.yml" + `if` = "always()" + needs { + JobNames.coverage + } + with { + ["differentiators"] = "[\"code-coverage\"]" + } + secrets { + ["BaaSaasApiKey"] = "${{ secrets.BAASAAS_API_KEY }}" + } + } + ["verify-namespaces"] = new Job { + `runs-on` = new UbuntuLatest{} + name = "Verify Namespaces" + needs { + JobNames.packages + } + steps { + checkoutCode() + for (_package in packages) { + new { + name = "Fetch \(_package)" + uses = "actions/download-artifact@v3" + with { + ["name"] = "\(_package).${{ needs.\(JobNames.packages).outputs.package_version }}" + ["path"] = "${{ github.workspace }}/Realm/packages/" + } + } + } + new { + run = "dotnet tool install ilspycmd -g --version 8.0.0.7345" + } + new { + name = "Verify Namespaces" + run = """ + $isFailure = $false + Get-ChildItem ./Realm/packages -Filter *.nupkg | Foreach-Object { + $targetPath = Join-Path ./Realm/packages $_.BaseName + Expand-Archive $_.FullName -DestinationPath $targetPath + + Get-ChildItem $targetPath -Filter *.dll -Recurse | ForEach-Object { + if (-not ($_.FullName -match "runtimes")) { + $ilspyOutput = ilspycmd $_.FullName + + $parentDll = $_.FullName + + $ilspyOutput | ForEach-Object { + if ($_ -match "namespace.*Realm(\\.|$)") { + Write-Output "::error file=$parentDll::Realm present in namespace - $($_)" + Set-Variable "isFailure" -Value $true + } + } + } + } + } + + if ($isFailure) { + exit 1 + } + """ + shell = "pwsh" + } + } + } +} diff --git a/.github/pkl-workflows/temp-outputs/wrappers.yml b/.github/pkl-workflows/temp-outputs/wrappers.yml new file mode 100644 index 0000000000..31303025df --- /dev/null +++ b/.github/pkl-workflows/temp-outputs/wrappers.yml @@ -0,0 +1,42 @@ +# Do not modify! +# This file was generated from a template using https://github.com/apple/pkl + +name: wrappers +'on': + workflow_call: {} +env: + REALM_DISABLE_ANALYTICS: true + DOTNET_NOLOGO: true +jobs: + check-cache: + name: Check Cache + env: + CACHE_SKIP_SAVE: true + outputs: + wrappers-macos: ${{ steps.check-cache-macos.outputs.cache-hit }} + wrappers-catalyst: ${{ steps.check-cache-catalyst.outputs.cache-hit }} + wrappers-linux-x86_64: ${{ steps.check-cache-linux-x86_64.outputs.cache-hit }} + wrappers-linux-armhf: ${{ steps.check-cache-linux-armhf.outputs.cache-hit }} + wrappers-linux-aarch64: ${{ steps.check-cache-linux-aarch64.outputs.cache-hit }} + wrappers-android-armeabi-v7a: ${{ steps.check-cache-android-armeabi-v7a.outputs.cache-hit }} + wrappers-android-arm64-v8a: ${{ steps.check-cache-android-arm64-v8a.outputs.cache-hit }} + wrappers-android-x86: ${{ steps.check-cache-android-x86.outputs.cache-hit }} + wrappers-android-x86_64: ${{ steps.check-cache-android-x86_64.outputs.cache-hit }} + wrappers-windows-Win32: ${{ steps.check-cache-windows-Win32.outputs.cache-hit }} + wrappers-windows-x64: ${{ steps.check-cache-windows-x64.outputs.cache-hit }} + wrappers-windows-ARM64: ${{ steps.check-cache-windows-ARM64.outputs.cache-hit }} + wrappers-windows-upw-Win32: ${{ steps.check-cache-windows-upw-Win32.outputs.cache-hit }} + wrappers-windows-upw-x64: ${{ steps.check-cache-windows-upw-x64.outputs.cache-hit }} + wrappers-windows-upw-ARM: ${{ steps.check-cache-windows-upw-ARM.outputs.cache-hit }} + wrappers-windows-upw-ARM64: ${{ steps.check-cache-windows-upw-ARM64.outputs.cache-hit }} + wrappers-iOS-Device: ${{ steps.check-cache-iOS-Device.outputs.cache-hit }} + wrappers-tvOS-Device: ${{ steps.check-cache-tvOS-Device.outputs.cache-hit }} + wrappers-iOS-Simulator: ${{ steps.check-cache-iOS-Simulator.outputs.cache-hit }} + wrappers-tvOS-Simulator: ${{ steps.check-cache-tvOS-Simulator.outputs.cache-hit }} + strategy: + matrix: + os: + - ubuntu + - windows + runs-on: ${{ matrix.os }}-latest + steps: [] diff --git a/.github/pkl-workflows/wrappers.pkl b/.github/pkl-workflows/wrappers.pkl new file mode 100644 index 0000000000..094c7e659e --- /dev/null +++ b/.github/pkl-workflows/wrappers.pkl @@ -0,0 +1,204 @@ +module wrappers + +amends "GithubAction/GithubAction.pkl" + +import "helpers/Common.pkl" +import "helpers/Steps.pkl" + +local class JobNamesDefition { + const checkCache: String = "check-cache" +} +local JobNames = new JobNamesDefition{} + +local WrappersBuildTimeout = 90 +local WrappersCacheCondition = "steps.check-cache.outputs.cache-hit != 'true'" + +name = "wrappers" +on { + workflow_call {} +} +env = Common.defaultEnv + +jobs { + [JobNames.checkCache] = new MatrixJob { + strategy { + matrix { + ["os"] { + "ubuntu" + "windows" + } + } + } + `runs-on` = "${{ matrix.os }}-latest" + name = "Check Cache" + env { + ["CACHE_SKIP_SAVE"] = true + } + outputs = Common.wrapperBinaryNames + .toMap((platform) -> "wrappers-\(platform)",(platform) -> "${{ steps.check-cache-\(platform).outputs.cache-hit }}") + .toMapping() + steps { + Steps.checkout() + for (platform in Common.wrapperBinaryNames) { + restoreCache(platform) |> withCondition(platform, null) + Steps.uploadArtifacts("wrappers-\(platform)", "wrappers/build/**") |> withCondition(platform, "steps.check-cache-\(platform).outputs.cache-hit == 'true'") + new Step { + run = "git clean -fdx" + } |> withCondition(platform, null) + } + } + } + ["macos"] = new Job { + `runs-on` = "macos-12" + name = "MacOS" + } |> wrappersJob(new JobConfig { + cmd = "./wrappers/build-macos.sh" + platform = "macos" + }) + ["catalyst"] = new Job { + `runs-on` = "macos-12" + name = "Catalyst" + } |> wrappersJob(new JobConfig { + cmd = "pwsh ./wrappers/build-apple-platform.ps1 Catalyst" + platform = "catalyst" + }) + ["apple-platform"] = new MatrixJob { + strategy { + matrix { + ["platform"] = Common.applePlatforms.toListing() + ["target"] { "Device" "Simulator"} + } + } + `runs-on` = "macos-12" + name = "Apple Platform" + } |> wrappersJob(new JobConfig { + cmd = "pwsh ./wrappers/build-apple-platform.ps1 ${{ matrix.platform }} -Targets ${{ matrix.target }}" + enableLTO = false + platform = "${{ matrix.platform }}-${{ matrix.target }}" + intermediateSteps { + Steps.setupXcode() + } + ifCondition = "\(Common.applePlatformTargets((platform, target) -> "needs.\(JobNames.checkCache).outputs.wrappers-\(platform)-\(target) != 'true'").join(" || "))" + }) + ["linux"] = new MatrixJob { + `runs-on` = new UbuntuLatest {} + name = "Linux" + strategy { + matrix { + ["arch"] = Common.linuxArchs.toListing() + } + } + } |> wrappersJob(new JobConfig { + cmd = "./wrappers/build-linux.sh -a=${{ matrix.arch }}" + ifCondition = "\(Common.linuxArchs.map((arch) -> "needs.check-cache.outputs.wrappers-linux-\(arch) != 'true'").join(" || "))" + platform = "linux-${{ matrix.arch }}" + intermediateSteps { + new Step { + name = "Install Ninja" + run = "sudo apt install ninja-build" + `if` = WrappersCacheCondition + } + } + }) + ["android"] = new MatrixJob { + `runs-on` = "ubuntu-20.04" + name = "Android" + strategy { + matrix { + ["arch"] = Common.androidABIs.toListing() + } + } + } |> wrappersJob(new JobConfig { + cmd = "./wrappers/build-android.sh --ARCH=${{ matrix.arch }}" + platform = "android-${{ matrix.arch }}" + enableLTO = false + ifCondition = "\(Common.androidABIs.map((abi) -> "needs.check-cache.outputs.wrappers-android-\(abi) != 'true'").join(" || "))" + }) + ["windows"] = new MatrixJob { + `runs-on` = new WindowsLatest{} + name = "Windows" + strategy { + matrix { + ["arch"] = Common.windowsArchs.toListing() + } + } + } |> wrappersJob(new JobConfig { + cmd = "pwsh ./wrappers/build.ps1 Windows -Platforms ${{ matrix.arch }} -ExtraCMakeArgs \"-T v143,version=14.35\"" + platform = "windows-${{ matrix.arch }}" + intermediateSteps { + Steps.setupMSVC("${{ startswith(matrix.arch, 'ARM') && matrix.arch || 'x86.x64' }}") + } + ifCondition = "\(Common.windowsArchs.map((arch) -> "needs.check-cache.outputs.wrappers-windows-\(arch) != 'true'").join(" || "))" + }) + ["uwp"] = new MatrixJob { + `runs-on` = new WindowsLatest{} + name = "UWP" + strategy { + matrix { + ["arch"] = Common.uwpArchs.toListing() + } + } + } |> wrappersJob(new JobConfig { + cmd = "pwsh ./wrappers/build.ps1 WindowsStore -Platforms ${{ matrix.arch }} -ExtraCMakeArgs \"-T v143,version=14.35\"" + platform = "windows-${{ matrix.arch }}" + intermediateSteps { + Steps.setupMSVC("${{ startswith(matrix.arch, 'ARM') && matrix.arch || 'x86.x64' }}") + } + ifCondition = "\(Common.uwpArchs.map((arch) -> "needs.check-cache.outputs.wrappers-windows-uwp-\(arch) != 'true'").join(" || "))" + }) +} + +local function withCondition(platform: String, _conditionToAppend: String?) = new Mixin { + `if` = "matrix.os == \(if (platform.contains("windows")) "'windows'" else "'ubuntu'")\(if (_conditionToAppend == null) "" else " && \(_conditionToAppend)")" +} + +local function restoreCache(platform: String): Step = new Step { + uses = "actions/cache/restore@v4" +} |> cacheStep(platform, platform) + +local function checkCache(platform: String): Step = new Step { + uses = "actions/cache@v4" +} |> cacheStep(platform, null) + +local function cacheStep(platform: String, idSuffix: String?) = new Mixin { + name = "Check Cache for \(platform)" + id = "check-cache\(if (idSuffix == null) "" else "-\(idSuffix)")" + with { + ["path"] = "./wrappers/build/**" + ["key"] = "wrappers-\(platform)-\(Common.configuration)-${{hashFiles('./wrappers/**')}}" + } +} + +local function wrappersJob(config: JobConfig) = new Mixin { + `timeout-minutes` = WrappersBuildTimeout + needs { + JobNames.checkCache + } + `if` = config.ifCondition + steps { + Steps.checkout() + checkCache(config.platform) + ...config.intermediateSteps.toList().map((step) -> (step) { + `if` = WrappersCacheCondition + }) + new Step { + name = "Build Wrappers" + run = config.toString() + `if` = WrappersCacheCondition + } + Steps.uploadArtifacts("wrappers-\(config.platform)", "wrappers/build/**") + } +} + +local class JobConfig { + cmd: String + enableLTO: Boolean = true + platform: String + intermediateSteps: Listing + ifCondition: String = "needs.check-cache.outputs.wrappers-\(platform) != 'true'" + + function toString(): String = "\(cmd) \(configParam) \(ltoParam)" + + hidden configParam = "\(if (cmd.startsWith("pwsh")) "-Configuration" else "--configuration=")\(Common.configuration)" + hidden ltoParam = if (!enableLTO) "" else (if (cmd.startsWith("pwsh")) "-EnableLTO" else "-DCMAKE_INTERPROCEDURAL_OPTIMIZATION='ON'") +} \ No newline at end of file diff --git a/.github/workflows/wrappers.yml b/.github/workflows/wrappers.yml index ea7020c00f..ad72e04aa9 100755 --- a/.github/workflows/wrappers.yml +++ b/.github/workflows/wrappers.yml @@ -1,18 +1,15 @@ +# Do not modify! +# This file was generated from a template using https://github.com/apple/pkl + name: wrappers -"on": - workflow_call: null +'on': + workflow_call: {} env: REALM_DISABLE_ANALYTICS: true DOTNET_NOLOGO: true jobs: check-cache: - strategy: - matrix: - os: - - ubuntu - - windows - runs-on: ${{ matrix.os }}-latest - name: Check cache + name: Check Cache env: CACHE_SKIP_SAVE: true outputs: @@ -21,10 +18,6 @@ jobs: wrappers-linux-x86_64: ${{ steps.check-cache-linux-x86_64.outputs.cache-hit }} wrappers-linux-armhf: ${{ steps.check-cache-linux-armhf.outputs.cache-hit }} wrappers-linux-aarch64: ${{ steps.check-cache-linux-aarch64.outputs.cache-hit }} - wrappers-iOS-Device: ${{ steps.check-cache-iOS-Device.outputs.cache-hit }} - wrappers-iOS-Simulator: ${{ steps.check-cache-iOS-Simulator.outputs.cache-hit }} - wrappers-tvOS-Device: ${{ steps.check-cache-tvOS-Device.outputs.cache-hit }} - wrappers-tvOS-Simulator: ${{ steps.check-cache-tvOS-Simulator.outputs.cache-hit }} wrappers-android-armeabi-v7a: ${{ steps.check-cache-android-armeabi-v7a.outputs.cache-hit }} wrappers-android-arm64-v8a: ${{ steps.check-cache-android-arm64-v8a.outputs.cache-hit }} wrappers-android-x86: ${{ steps.check-cache-android-x86.outputs.cache-hit }} @@ -36,607 +29,612 @@ jobs: wrappers-windows-uwp-x64: ${{ steps.check-cache-windows-uwp-x64.outputs.cache-hit }} wrappers-windows-uwp-ARM: ${{ steps.check-cache-windows-uwp-ARM.outputs.cache-hit }} wrappers-windows-uwp-ARM64: ${{ steps.check-cache-windows-uwp-ARM64.outputs.cache-hit }} + wrappers-iOS-Device: ${{ steps.check-cache-iOS-Device.outputs.cache-hit }} + wrappers-iOS-Simulator: ${{ steps.check-cache-iOS-Simulator.outputs.cache-hit }} + wrappers-tvOS-Device: ${{ steps.check-cache-tvOS-Device.outputs.cache-hit }} + wrappers-tvOS-Simulator: ${{ steps.check-cache-tvOS-Simulator.outputs.cache-hit }} + runs-on: ${{ matrix.os }}-latest steps: - - name: Checkout code - uses: actions/checkout@v3 + - name: Checkout Code + uses: actions/checkout@v4 with: submodules: recursive ref: ${{ github.event.pull_request.head.sha }} - - name: Check cache for macos + - name: Check Cache for macos id: check-cache-macos - uses: nirinchev/cache@29e8e4dd9148ea81f9e188480132072cb6cc92d8 + if: matrix.os == 'ubuntu' + uses: actions/cache/restore@v4 with: path: ./wrappers/build/** key: wrappers-macos-Release-${{hashFiles('./wrappers/**')}} - if: matrix.os == 'ubuntu' - name: Store artifacts for wrappers-macos - uses: actions/upload-artifact@v3 + if: matrix.os == 'ubuntu' && steps.check-cache-macos.outputs.cache-hit == 'true' + uses: actions/upload-artifact@v4 with: name: wrappers-macos path: ${{ github.workspace }}/wrappers/build/** - retention-days: 1 + retention-days: ${{ github.event_name != 'pull_request' && 30 || 1 }} if-no-files-found: error - if: matrix.os == 'ubuntu' && steps.check-cache-macos.outputs.cache-hit == 'true' - - run: git clean -fdx - if: matrix.os == 'ubuntu' - - name: Check cache for catalyst + - if: matrix.os == 'ubuntu' + run: git clean -fdx + - name: Check Cache for catalyst id: check-cache-catalyst - uses: nirinchev/cache@29e8e4dd9148ea81f9e188480132072cb6cc92d8 + if: matrix.os == 'ubuntu' + uses: actions/cache/restore@v4 with: path: ./wrappers/build/** key: wrappers-catalyst-Release-${{hashFiles('./wrappers/**')}} - if: matrix.os == 'ubuntu' - name: Store artifacts for wrappers-catalyst - uses: actions/upload-artifact@v3 + if: matrix.os == 'ubuntu' && steps.check-cache-catalyst.outputs.cache-hit == 'true' + uses: actions/upload-artifact@v4 with: name: wrappers-catalyst path: ${{ github.workspace }}/wrappers/build/** - retention-days: 1 + retention-days: ${{ github.event_name != 'pull_request' && 30 || 1 }} if-no-files-found: error - if: matrix.os == 'ubuntu' && steps.check-cache-catalyst.outputs.cache-hit == 'true' - - run: git clean -fdx - if: matrix.os == 'ubuntu' - - name: Check cache for linux-x86_64 + - if: matrix.os == 'ubuntu' + run: git clean -fdx + - name: Check Cache for linux-x86_64 id: check-cache-linux-x86_64 - uses: nirinchev/cache@29e8e4dd9148ea81f9e188480132072cb6cc92d8 + if: matrix.os == 'ubuntu' + uses: actions/cache/restore@v4 with: path: ./wrappers/build/** key: wrappers-linux-x86_64-Release-${{hashFiles('./wrappers/**')}} - if: matrix.os == 'ubuntu' - name: Store artifacts for wrappers-linux-x86_64 - uses: actions/upload-artifact@v3 + if: matrix.os == 'ubuntu' && steps.check-cache-linux-x86_64.outputs.cache-hit == 'true' + uses: actions/upload-artifact@v4 with: name: wrappers-linux-x86_64 path: ${{ github.workspace }}/wrappers/build/** - retention-days: 1 + retention-days: ${{ github.event_name != 'pull_request' && 30 || 1 }} if-no-files-found: error - if: matrix.os == 'ubuntu' && steps.check-cache-linux-x86_64.outputs.cache-hit == 'true' - - run: git clean -fdx - if: matrix.os == 'ubuntu' - - name: Check cache for linux-armhf + - if: matrix.os == 'ubuntu' + run: git clean -fdx + - name: Check Cache for linux-armhf id: check-cache-linux-armhf - uses: nirinchev/cache@29e8e4dd9148ea81f9e188480132072cb6cc92d8 + if: matrix.os == 'ubuntu' + uses: actions/cache/restore@v4 with: path: ./wrappers/build/** key: wrappers-linux-armhf-Release-${{hashFiles('./wrappers/**')}} - if: matrix.os == 'ubuntu' - name: Store artifacts for wrappers-linux-armhf - uses: actions/upload-artifact@v3 + if: matrix.os == 'ubuntu' && steps.check-cache-linux-armhf.outputs.cache-hit == 'true' + uses: actions/upload-artifact@v4 with: name: wrappers-linux-armhf path: ${{ github.workspace }}/wrappers/build/** - retention-days: 1 + retention-days: ${{ github.event_name != 'pull_request' && 30 || 1 }} if-no-files-found: error - if: matrix.os == 'ubuntu' && steps.check-cache-linux-armhf.outputs.cache-hit == 'true' - - run: git clean -fdx - if: matrix.os == 'ubuntu' - - name: Check cache for linux-aarch64 + - if: matrix.os == 'ubuntu' + run: git clean -fdx + - name: Check Cache for linux-aarch64 id: check-cache-linux-aarch64 - uses: nirinchev/cache@29e8e4dd9148ea81f9e188480132072cb6cc92d8 + if: matrix.os == 'ubuntu' + uses: actions/cache/restore@v4 with: path: ./wrappers/build/** key: wrappers-linux-aarch64-Release-${{hashFiles('./wrappers/**')}} - if: matrix.os == 'ubuntu' - name: Store artifacts for wrappers-linux-aarch64 - uses: actions/upload-artifact@v3 - with: - name: wrappers-linux-aarch64 - path: ${{ github.workspace }}/wrappers/build/** - retention-days: 1 - if-no-files-found: error if: matrix.os == 'ubuntu' && steps.check-cache-linux-aarch64.outputs.cache-hit == 'true' - - run: git clean -fdx - if: matrix.os == 'ubuntu' - - name: Check cache for iOS-Device - id: check-cache-iOS-Device - uses: nirinchev/cache@29e8e4dd9148ea81f9e188480132072cb6cc92d8 - with: - path: ./wrappers/build/** - key: wrappers-iOS-Device-Release-${{hashFiles('./wrappers/**')}} - if: matrix.os == 'ubuntu' - - name: Store artifacts for wrappers-iOS-Device - uses: actions/upload-artifact@v3 - with: - name: wrappers-iOS-Device - path: ${{ github.workspace }}/wrappers/build/** - retention-days: 1 - if-no-files-found: error - if: matrix.os == 'ubuntu' && steps.check-cache-iOS-Device.outputs.cache-hit == 'true' - - run: git clean -fdx - if: matrix.os == 'ubuntu' - - name: Check cache for iOS-Simulator - id: check-cache-iOS-Simulator - uses: nirinchev/cache@29e8e4dd9148ea81f9e188480132072cb6cc92d8 - with: - path: ./wrappers/build/** - key: wrappers-iOS-Simulator-Release-${{hashFiles('./wrappers/**')}} - if: matrix.os == 'ubuntu' - - name: Store artifacts for wrappers-iOS-Simulator - uses: actions/upload-artifact@v3 - with: - name: wrappers-iOS-Simulator - path: ${{ github.workspace }}/wrappers/build/** - retention-days: 1 - if-no-files-found: error - if: matrix.os == 'ubuntu' && steps.check-cache-iOS-Simulator.outputs.cache-hit == 'true' - - run: git clean -fdx - if: matrix.os == 'ubuntu' - - name: Check cache for tvOS-Device - id: check-cache-tvOS-Device - uses: nirinchev/cache@29e8e4dd9148ea81f9e188480132072cb6cc92d8 - with: - path: ./wrappers/build/** - key: wrappers-tvOS-Device-Release-${{hashFiles('./wrappers/**')}} - if: matrix.os == 'ubuntu' - - name: Store artifacts for wrappers-tvOS-Device - uses: actions/upload-artifact@v3 - with: - name: wrappers-tvOS-Device - path: ${{ github.workspace }}/wrappers/build/** - retention-days: 1 - if-no-files-found: error - if: matrix.os == 'ubuntu' && steps.check-cache-tvOS-Device.outputs.cache-hit == 'true' - - run: git clean -fdx - if: matrix.os == 'ubuntu' - - name: Check cache for tvOS-Simulator - id: check-cache-tvOS-Simulator - uses: nirinchev/cache@29e8e4dd9148ea81f9e188480132072cb6cc92d8 + uses: actions/upload-artifact@v4 with: - path: ./wrappers/build/** - key: wrappers-tvOS-Simulator-Release-${{hashFiles('./wrappers/**')}} - if: matrix.os == 'ubuntu' - - name: Store artifacts for wrappers-tvOS-Simulator - uses: actions/upload-artifact@v3 - with: - name: wrappers-tvOS-Simulator + name: wrappers-linux-aarch64 path: ${{ github.workspace }}/wrappers/build/** - retention-days: 1 + retention-days: ${{ github.event_name != 'pull_request' && 30 || 1 }} if-no-files-found: error - if: matrix.os == 'ubuntu' && steps.check-cache-tvOS-Simulator.outputs.cache-hit == 'true' - - run: git clean -fdx - if: matrix.os == 'ubuntu' - - name: Check cache for android-armeabi-v7a + - if: matrix.os == 'ubuntu' + run: git clean -fdx + - name: Check Cache for android-armeabi-v7a id: check-cache-android-armeabi-v7a - uses: nirinchev/cache@29e8e4dd9148ea81f9e188480132072cb6cc92d8 + if: matrix.os == 'ubuntu' + uses: actions/cache/restore@v4 with: path: ./wrappers/build/** key: wrappers-android-armeabi-v7a-Release-${{hashFiles('./wrappers/**')}} - if: matrix.os == 'ubuntu' - name: Store artifacts for wrappers-android-armeabi-v7a - uses: actions/upload-artifact@v3 + if: matrix.os == 'ubuntu' && steps.check-cache-android-armeabi-v7a.outputs.cache-hit == 'true' + uses: actions/upload-artifact@v4 with: name: wrappers-android-armeabi-v7a path: ${{ github.workspace }}/wrappers/build/** - retention-days: 1 + retention-days: ${{ github.event_name != 'pull_request' && 30 || 1 }} if-no-files-found: error - if: matrix.os == 'ubuntu' && steps.check-cache-android-armeabi-v7a.outputs.cache-hit == 'true' - - run: git clean -fdx - if: matrix.os == 'ubuntu' - - name: Check cache for android-arm64-v8a + - if: matrix.os == 'ubuntu' + run: git clean -fdx + - name: Check Cache for android-arm64-v8a id: check-cache-android-arm64-v8a - uses: nirinchev/cache@29e8e4dd9148ea81f9e188480132072cb6cc92d8 + if: matrix.os == 'ubuntu' + uses: actions/cache/restore@v4 with: path: ./wrappers/build/** key: wrappers-android-arm64-v8a-Release-${{hashFiles('./wrappers/**')}} - if: matrix.os == 'ubuntu' - name: Store artifacts for wrappers-android-arm64-v8a - uses: actions/upload-artifact@v3 + if: matrix.os == 'ubuntu' && steps.check-cache-android-arm64-v8a.outputs.cache-hit == 'true' + uses: actions/upload-artifact@v4 with: name: wrappers-android-arm64-v8a path: ${{ github.workspace }}/wrappers/build/** - retention-days: 1 + retention-days: ${{ github.event_name != 'pull_request' && 30 || 1 }} if-no-files-found: error - if: matrix.os == 'ubuntu' && steps.check-cache-android-arm64-v8a.outputs.cache-hit == 'true' - - run: git clean -fdx - if: matrix.os == 'ubuntu' - - name: Check cache for android-x86 + - if: matrix.os == 'ubuntu' + run: git clean -fdx + - name: Check Cache for android-x86 id: check-cache-android-x86 - uses: nirinchev/cache@29e8e4dd9148ea81f9e188480132072cb6cc92d8 + if: matrix.os == 'ubuntu' + uses: actions/cache/restore@v4 with: path: ./wrappers/build/** key: wrappers-android-x86-Release-${{hashFiles('./wrappers/**')}} - if: matrix.os == 'ubuntu' - name: Store artifacts for wrappers-android-x86 - uses: actions/upload-artifact@v3 + if: matrix.os == 'ubuntu' && steps.check-cache-android-x86.outputs.cache-hit == 'true' + uses: actions/upload-artifact@v4 with: name: wrappers-android-x86 path: ${{ github.workspace }}/wrappers/build/** - retention-days: 1 + retention-days: ${{ github.event_name != 'pull_request' && 30 || 1 }} if-no-files-found: error - if: matrix.os == 'ubuntu' && steps.check-cache-android-x86.outputs.cache-hit == 'true' - - run: git clean -fdx - if: matrix.os == 'ubuntu' - - name: Check cache for android-x86_64 + - if: matrix.os == 'ubuntu' + run: git clean -fdx + - name: Check Cache for android-x86_64 id: check-cache-android-x86_64 - uses: nirinchev/cache@29e8e4dd9148ea81f9e188480132072cb6cc92d8 + if: matrix.os == 'ubuntu' + uses: actions/cache/restore@v4 with: path: ./wrappers/build/** key: wrappers-android-x86_64-Release-${{hashFiles('./wrappers/**')}} - if: matrix.os == 'ubuntu' - name: Store artifacts for wrappers-android-x86_64 - uses: actions/upload-artifact@v3 + if: matrix.os == 'ubuntu' && steps.check-cache-android-x86_64.outputs.cache-hit == 'true' + uses: actions/upload-artifact@v4 with: name: wrappers-android-x86_64 path: ${{ github.workspace }}/wrappers/build/** - retention-days: 1 + retention-days: ${{ github.event_name != 'pull_request' && 30 || 1 }} if-no-files-found: error - if: matrix.os == 'ubuntu' && steps.check-cache-android-x86_64.outputs.cache-hit == 'true' - - run: git clean -fdx - if: matrix.os == 'ubuntu' - - name: Check cache for windows-Win32 + - if: matrix.os == 'ubuntu' + run: git clean -fdx + - name: Check Cache for windows-Win32 id: check-cache-windows-Win32 - uses: nirinchev/cache@29e8e4dd9148ea81f9e188480132072cb6cc92d8 + if: matrix.os == 'windows' + uses: actions/cache/restore@v4 with: path: ./wrappers/build/** key: wrappers-windows-Win32-Release-${{hashFiles('./wrappers/**')}} - if: matrix.os == 'windows' - name: Store artifacts for wrappers-windows-Win32 - uses: actions/upload-artifact@v3 + if: matrix.os == 'windows' && steps.check-cache-windows-Win32.outputs.cache-hit == 'true' + uses: actions/upload-artifact@v4 with: name: wrappers-windows-Win32 path: ${{ github.workspace }}/wrappers/build/** - retention-days: 1 + retention-days: ${{ github.event_name != 'pull_request' && 30 || 1 }} if-no-files-found: error - if: matrix.os == 'windows' && steps.check-cache-windows-Win32.outputs.cache-hit == 'true' - - run: git clean -fdx - if: matrix.os == 'windows' - - name: Check cache for windows-x64 + - if: matrix.os == 'windows' + run: git clean -fdx + - name: Check Cache for windows-x64 id: check-cache-windows-x64 - uses: nirinchev/cache@29e8e4dd9148ea81f9e188480132072cb6cc92d8 + if: matrix.os == 'windows' + uses: actions/cache/restore@v4 with: path: ./wrappers/build/** key: wrappers-windows-x64-Release-${{hashFiles('./wrappers/**')}} - if: matrix.os == 'windows' - name: Store artifacts for wrappers-windows-x64 - uses: actions/upload-artifact@v3 + if: matrix.os == 'windows' && steps.check-cache-windows-x64.outputs.cache-hit == 'true' + uses: actions/upload-artifact@v4 with: name: wrappers-windows-x64 path: ${{ github.workspace }}/wrappers/build/** - retention-days: 1 + retention-days: ${{ github.event_name != 'pull_request' && 30 || 1 }} if-no-files-found: error - if: matrix.os == 'windows' && steps.check-cache-windows-x64.outputs.cache-hit == 'true' - - run: git clean -fdx - if: matrix.os == 'windows' - - name: Check cache for windows-ARM64 + - if: matrix.os == 'windows' + run: git clean -fdx + - name: Check Cache for windows-ARM64 id: check-cache-windows-ARM64 - uses: nirinchev/cache@29e8e4dd9148ea81f9e188480132072cb6cc92d8 + if: matrix.os == 'windows' + uses: actions/cache/restore@v4 with: path: ./wrappers/build/** key: wrappers-windows-ARM64-Release-${{hashFiles('./wrappers/**')}} - if: matrix.os == 'windows' - name: Store artifacts for wrappers-windows-ARM64 - uses: actions/upload-artifact@v3 + if: matrix.os == 'windows' && steps.check-cache-windows-ARM64.outputs.cache-hit == 'true' + uses: actions/upload-artifact@v4 with: name: wrappers-windows-ARM64 path: ${{ github.workspace }}/wrappers/build/** - retention-days: 1 + retention-days: ${{ github.event_name != 'pull_request' && 30 || 1 }} if-no-files-found: error - if: matrix.os == 'windows' && steps.check-cache-windows-ARM64.outputs.cache-hit == 'true' - - run: git clean -fdx - if: matrix.os == 'windows' - - name: Check cache for windows-uwp-Win32 + - if: matrix.os == 'windows' + run: git clean -fdx + - name: Check Cache for windows-uwp-Win32 id: check-cache-windows-uwp-Win32 - uses: nirinchev/cache@29e8e4dd9148ea81f9e188480132072cb6cc92d8 + if: matrix.os == 'windows' + uses: actions/cache/restore@v4 with: path: ./wrappers/build/** key: wrappers-windows-uwp-Win32-Release-${{hashFiles('./wrappers/**')}} - if: matrix.os == 'windows' - name: Store artifacts for wrappers-windows-uwp-Win32 - uses: actions/upload-artifact@v3 + if: matrix.os == 'windows' && steps.check-cache-windows-uwp-Win32.outputs.cache-hit == 'true' + uses: actions/upload-artifact@v4 with: name: wrappers-windows-uwp-Win32 path: ${{ github.workspace }}/wrappers/build/** - retention-days: 1 + retention-days: ${{ github.event_name != 'pull_request' && 30 || 1 }} if-no-files-found: error - if: matrix.os == 'windows' && steps.check-cache-windows-uwp-Win32.outputs.cache-hit == 'true' - - run: git clean -fdx - if: matrix.os == 'windows' - - name: Check cache for windows-uwp-x64 + - if: matrix.os == 'windows' + run: git clean -fdx + - name: Check Cache for windows-uwp-x64 id: check-cache-windows-uwp-x64 - uses: nirinchev/cache@29e8e4dd9148ea81f9e188480132072cb6cc92d8 + if: matrix.os == 'windows' + uses: actions/cache/restore@v4 with: path: ./wrappers/build/** key: wrappers-windows-uwp-x64-Release-${{hashFiles('./wrappers/**')}} - if: matrix.os == 'windows' - name: Store artifacts for wrappers-windows-uwp-x64 - uses: actions/upload-artifact@v3 + if: matrix.os == 'windows' && steps.check-cache-windows-uwp-x64.outputs.cache-hit == 'true' + uses: actions/upload-artifact@v4 with: name: wrappers-windows-uwp-x64 path: ${{ github.workspace }}/wrappers/build/** - retention-days: 1 + retention-days: ${{ github.event_name != 'pull_request' && 30 || 1 }} if-no-files-found: error - if: matrix.os == 'windows' && steps.check-cache-windows-uwp-x64.outputs.cache-hit == 'true' - - run: git clean -fdx - if: matrix.os == 'windows' - - name: Check cache for windows-uwp-ARM + - if: matrix.os == 'windows' + run: git clean -fdx + - name: Check Cache for windows-uwp-ARM id: check-cache-windows-uwp-ARM - uses: nirinchev/cache@29e8e4dd9148ea81f9e188480132072cb6cc92d8 + if: matrix.os == 'windows' + uses: actions/cache/restore@v4 with: path: ./wrappers/build/** key: wrappers-windows-uwp-ARM-Release-${{hashFiles('./wrappers/**')}} - if: matrix.os == 'windows' - name: Store artifacts for wrappers-windows-uwp-ARM - uses: actions/upload-artifact@v3 + if: matrix.os == 'windows' && steps.check-cache-windows-uwp-ARM.outputs.cache-hit == 'true' + uses: actions/upload-artifact@v4 with: name: wrappers-windows-uwp-ARM path: ${{ github.workspace }}/wrappers/build/** - retention-days: 1 + retention-days: ${{ github.event_name != 'pull_request' && 30 || 1 }} if-no-files-found: error - if: matrix.os == 'windows' && steps.check-cache-windows-uwp-ARM.outputs.cache-hit == 'true' - - run: git clean -fdx - if: matrix.os == 'windows' - - name: Check cache for windows-uwp-ARM64 + - if: matrix.os == 'windows' + run: git clean -fdx + - name: Check Cache for windows-uwp-ARM64 id: check-cache-windows-uwp-ARM64 - uses: nirinchev/cache@29e8e4dd9148ea81f9e188480132072cb6cc92d8 + if: matrix.os == 'windows' + uses: actions/cache/restore@v4 with: path: ./wrappers/build/** key: wrappers-windows-uwp-ARM64-Release-${{hashFiles('./wrappers/**')}} - if: matrix.os == 'windows' - name: Store artifacts for wrappers-windows-uwp-ARM64 - uses: actions/upload-artifact@v3 + if: matrix.os == 'windows' && steps.check-cache-windows-uwp-ARM64.outputs.cache-hit == 'true' + uses: actions/upload-artifact@v4 with: name: wrappers-windows-uwp-ARM64 path: ${{ github.workspace }}/wrappers/build/** - retention-days: 1 + retention-days: ${{ github.event_name != 'pull_request' && 30 || 1 }} if-no-files-found: error - if: matrix.os == 'windows' && steps.check-cache-windows-uwp-ARM64.outputs.cache-hit == 'true' - - run: git clean -fdx - if: matrix.os == 'windows' + - if: matrix.os == 'windows' + run: git clean -fdx + - name: Check Cache for iOS-Device + id: check-cache-iOS-Device + if: matrix.os == 'ubuntu' + uses: actions/cache/restore@v4 + with: + path: ./wrappers/build/** + key: wrappers-iOS-Device-Release-${{hashFiles('./wrappers/**')}} + - name: Store artifacts for wrappers-iOS-Device + if: matrix.os == 'ubuntu' && steps.check-cache-iOS-Device.outputs.cache-hit == 'true' + uses: actions/upload-artifact@v4 + with: + name: wrappers-iOS-Device + path: ${{ github.workspace }}/wrappers/build/** + retention-days: ${{ github.event_name != 'pull_request' && 30 || 1 }} + if-no-files-found: error + - if: matrix.os == 'ubuntu' + run: git clean -fdx + - name: Check Cache for iOS-Simulator + id: check-cache-iOS-Simulator + if: matrix.os == 'ubuntu' + uses: actions/cache/restore@v4 + with: + path: ./wrappers/build/** + key: wrappers-iOS-Simulator-Release-${{hashFiles('./wrappers/**')}} + - name: Store artifacts for wrappers-iOS-Simulator + if: matrix.os == 'ubuntu' && steps.check-cache-iOS-Simulator.outputs.cache-hit == 'true' + uses: actions/upload-artifact@v4 + with: + name: wrappers-iOS-Simulator + path: ${{ github.workspace }}/wrappers/build/** + retention-days: ${{ github.event_name != 'pull_request' && 30 || 1 }} + if-no-files-found: error + - if: matrix.os == 'ubuntu' + run: git clean -fdx + - name: Check Cache for tvOS-Device + id: check-cache-tvOS-Device + if: matrix.os == 'ubuntu' + uses: actions/cache/restore@v4 + with: + path: ./wrappers/build/** + key: wrappers-tvOS-Device-Release-${{hashFiles('./wrappers/**')}} + - name: Store artifacts for wrappers-tvOS-Device + if: matrix.os == 'ubuntu' && steps.check-cache-tvOS-Device.outputs.cache-hit == 'true' + uses: actions/upload-artifact@v4 + with: + name: wrappers-tvOS-Device + path: ${{ github.workspace }}/wrappers/build/** + retention-days: ${{ github.event_name != 'pull_request' && 30 || 1 }} + if-no-files-found: error + - if: matrix.os == 'ubuntu' + run: git clean -fdx + - name: Check Cache for tvOS-Simulator + id: check-cache-tvOS-Simulator + if: matrix.os == 'ubuntu' + uses: actions/cache/restore@v4 + with: + path: ./wrappers/build/** + key: wrappers-tvOS-Simulator-Release-${{hashFiles('./wrappers/**')}} + - name: Store artifacts for wrappers-tvOS-Simulator + if: matrix.os == 'ubuntu' && steps.check-cache-tvOS-Simulator.outputs.cache-hit == 'true' + uses: actions/upload-artifact@v4 + with: + name: wrappers-tvOS-Simulator + path: ${{ github.workspace }}/wrappers/build/** + retention-days: ${{ github.event_name != 'pull_request' && 30 || 1 }} + if-no-files-found: error + - if: matrix.os == 'ubuntu' + run: git clean -fdx + strategy: + matrix: + os: + - ubuntu + - windows macos: - runs-on: macos-12 - name: macOS - timeout-minutes: 90 + name: MacOS needs: - check-cache if: needs.check-cache.outputs.wrappers-macos != 'true' + timeout-minutes: 90 + runs-on: macos-12 steps: - - name: Checkout code - uses: actions/checkout@v3 + - name: Checkout Code + uses: actions/checkout@v4 with: submodules: recursive ref: ${{ github.event.pull_request.head.sha }} - - name: Check cache + - name: Check Cache for macos id: check-cache - uses: nirinchev/cache@29e8e4dd9148ea81f9e188480132072cb6cc92d8 + uses: actions/cache@v4 with: path: ./wrappers/build/** key: wrappers-macos-Release-${{hashFiles('./wrappers/**')}} - - name: Build wrappers - run: ./wrappers/build-macos.sh --configuration=Release -DCMAKE_INTERPROCEDURAL_OPTIMIZATION='ON' + - name: Build Wrappers if: steps.check-cache.outputs.cache-hit != 'true' + run: ./wrappers/build-macos.sh --configuration=Release -DCMAKE_INTERPROCEDURAL_OPTIMIZATION='ON' - name: Store artifacts for wrappers-macos - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: wrappers-macos path: ${{ github.workspace }}/wrappers/build/** - retention-days: 1 + retention-days: ${{ github.event_name != 'pull_request' && 30 || 1 }} if-no-files-found: error catalyst: - runs-on: macos-12 name: Catalyst - timeout-minutes: 90 needs: - check-cache if: needs.check-cache.outputs.wrappers-catalyst != 'true' + timeout-minutes: 90 + runs-on: macos-12 steps: - - name: Checkout code - uses: actions/checkout@v3 + - name: Checkout Code + uses: actions/checkout@v4 with: submodules: recursive ref: ${{ github.event.pull_request.head.sha }} - - name: Check cache + - name: Check Cache for catalyst id: check-cache - uses: nirinchev/cache@29e8e4dd9148ea81f9e188480132072cb6cc92d8 + uses: actions/cache@v4 with: path: ./wrappers/build/** key: wrappers-catalyst-Release-${{hashFiles('./wrappers/**')}} - - name: Build wrappers - run: pwsh ./wrappers/build-apple-platform.ps1 Catalyst -Configuration Release -EnableLTO + - name: Build Wrappers if: steps.check-cache.outputs.cache-hit != 'true' + run: pwsh ./wrappers/build-apple-platform.ps1 Catalyst -ConfigurationRelease -EnableLTO - name: Store artifacts for wrappers-catalyst - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: wrappers-catalyst path: ${{ github.workspace }}/wrappers/build/** - retention-days: 1 + retention-days: ${{ github.event_name != 'pull_request' && 30 || 1 }} if-no-files-found: error - apple-platforms: - runs-on: macos-12 + apple-platform: name: Apple Platform - strategy: - matrix: - platform: - - iOS - - tvOS - target: - - Device - - Simulator - timeout-minutes: 90 needs: - check-cache + if: needs.check-cache.outputs.wrappers-iOS-Device != 'true' || needs.check-cache.outputs.wrappers-iOS-Simulator != 'true' || needs.check-cache.outputs.wrappers-tvOS-Device != 'true' || needs.check-cache.outputs.wrappers-tvOS-Simulator != 'true' + timeout-minutes: 90 + runs-on: macos-12 steps: - - name: Checkout code - uses: actions/checkout@v3 + - name: Checkout Code + uses: actions/checkout@v4 with: submodules: recursive ref: ${{ github.event.pull_request.head.sha }} - - name: Check cache + - name: Check Cache for ${{ matrix.platform }}-${{ matrix.target }} id: check-cache - uses: nirinchev/cache@29e8e4dd9148ea81f9e188480132072cb6cc92d8 + uses: actions/cache@v4 with: path: ./wrappers/build/** key: wrappers-${{ matrix.platform }}-${{ matrix.target }}-Release-${{hashFiles('./wrappers/**')}} - name: Setup Xcode + if: steps.check-cache.outputs.cache-hit != 'true' uses: maxim-lobanov/setup-xcode@60606e260d2fc5762a71e64e74b2174e8ea3c8bd with: - xcode-version: 14.0.1 - - name: Build wrappers - run: pwsh ./wrappers/build-apple-platform.ps1 ${{ matrix.platform }} -Targets ${{ matrix.target }} -Configuration Release + xcode-version: '14' + - name: Build Wrappers if: steps.check-cache.outputs.cache-hit != 'true' + run: 'pwsh ./wrappers/build-apple-platform.ps1 ${{ matrix.platform }} -Targets ${{ matrix.target }} -ConfigurationRelease ' - name: Store artifacts for wrappers-${{ matrix.platform }}-${{ matrix.target }} - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: wrappers-${{ matrix.platform }}-${{ matrix.target }} path: ${{ github.workspace }}/wrappers/build/** - retention-days: 1 + retention-days: ${{ github.event_name != 'pull_request' && 30 || 1 }} if-no-files-found: error - if: needs.check-cache.outputs.wrappers-iOS-Device != 'true' || needs.check-cache.outputs.wrappers-tvOS-Device != 'true' || needs.check-cache.outputs.wrappers-iOS-Simulator != 'true' || needs.check-cache.outputs.wrappers-tvOS-Simulator != 'true' - linux: - runs-on: ubuntu-latest - name: Linux strategy: matrix: - arch: - - x86_64 - - armhf - - aarch64 - timeout-minutes: 90 + platform: + - iOS + - tvOS + target: + - Device + - Simulator + linux: + name: Linux needs: - check-cache if: needs.check-cache.outputs.wrappers-linux-x86_64 != 'true' || needs.check-cache.outputs.wrappers-linux-armhf != 'true' || needs.check-cache.outputs.wrappers-linux-aarch64 != 'true' + timeout-minutes: 90 + runs-on: ubuntu-latest steps: - - name: Checkout code - uses: actions/checkout@v3 + - name: Checkout Code + uses: actions/checkout@v4 with: submodules: recursive 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: Check cache + - name: Check Cache for linux-${{ matrix.arch }} id: check-cache - uses: nirinchev/cache@29e8e4dd9148ea81f9e188480132072cb6cc92d8 + uses: actions/cache@v4 with: path: ./wrappers/build/** key: wrappers-linux-${{ matrix.arch }}-Release-${{hashFiles('./wrappers/**')}} - name: Install Ninja + if: steps.check-cache.outputs.cache-hit != 'true' run: sudo apt install ninja-build + - name: Build Wrappers if: steps.check-cache.outputs.cache-hit != 'true' - - name: Build wrappers run: ./wrappers/build-linux.sh -a=${{ matrix.arch }} --configuration=Release -DCMAKE_INTERPROCEDURAL_OPTIMIZATION='ON' - if: steps.check-cache.outputs.cache-hit != 'true' - name: Store artifacts for wrappers-linux-${{ matrix.arch }} - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: wrappers-linux-${{ matrix.arch }} path: ${{ github.workspace }}/wrappers/build/** - retention-days: 1 + retention-days: ${{ github.event_name != 'pull_request' && 30 || 1 }} if-no-files-found: error - android: - runs-on: ubuntu-20.04 - name: Android strategy: matrix: arch: - - armeabi-v7a - - arm64-v8a - - x86 - x86_64 - timeout-minutes: 90 + - armhf + - aarch64 + android: + name: Android needs: - check-cache + if: needs.check-cache.outputs.wrappers-android-armeabi-v7a != 'true' || needs.check-cache.outputs.wrappers-android-arm64-v8a != 'true' || needs.check-cache.outputs.wrappers-android-x86 != 'true' || needs.check-cache.outputs.wrappers-android-x86_64 != 'true' + timeout-minutes: 90 + runs-on: ubuntu-20.04 steps: - - name: Checkout code - uses: actions/checkout@v3 + - name: Checkout Code + uses: actions/checkout@v4 with: submodules: recursive ref: ${{ github.event.pull_request.head.sha }} - - name: Check cache + - name: Check Cache for android-${{ matrix.arch }} id: check-cache - uses: nirinchev/cache@29e8e4dd9148ea81f9e188480132072cb6cc92d8 + uses: actions/cache@v4 with: path: ./wrappers/build/** key: wrappers-android-${{ matrix.arch }}-Release-${{hashFiles('./wrappers/**')}} - - name: Build wrappers - run: ./wrappers/build-android.sh --ARCH=${{ matrix.arch }} --configuration=Release + - name: Build Wrappers if: steps.check-cache.outputs.cache-hit != 'true' + run: './wrappers/build-android.sh --ARCH=${{ matrix.arch }} --configuration=Release ' - name: Store artifacts for wrappers-android-${{ matrix.arch }} - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: wrappers-android-${{ matrix.arch }} path: ${{ github.workspace }}/wrappers/build/** - retention-days: 1 + retention-days: ${{ github.event_name != 'pull_request' && 30 || 1 }} if-no-files-found: error - if: needs.check-cache.outputs.wrappers-android-armeabi-v7a != 'true' || needs.check-cache.outputs.wrappers-android-arm64-v8a != 'true' || needs.check-cache.outputs.wrappers-android-x86 != 'true' || needs.check-cache.outputs.wrappers-android-x86_64 != 'true' - windows: - runs-on: windows-latest - name: Windows strategy: matrix: arch: - - Win32 - - x64 - - ARM64 - timeout-minutes: 90 + - armeabi-v7a + - arm64-v8a + - x86 + - x86_64 + windows: + name: Windows needs: - check-cache + if: needs.check-cache.outputs.wrappers-windows-Win32 != 'true' || needs.check-cache.outputs.wrappers-windows-x64 != 'true' || needs.check-cache.outputs.wrappers-windows-ARM64 != 'true' + timeout-minutes: 90 + runs-on: windows-latest steps: - - name: Checkout code - uses: actions/checkout@v3 + - name: Checkout Code + uses: actions/checkout@v4 with: submodules: recursive ref: ${{ github.event.pull_request.head.sha }} - - name: Check cache + - name: Check Cache for windows-${{ matrix.arch }} id: check-cache - uses: nirinchev/cache@29e8e4dd9148ea81f9e188480132072cb6cc92d8 + uses: actions/cache@v4 with: path: ./wrappers/build/** key: wrappers-windows-${{ matrix.arch }}-Release-${{hashFiles('./wrappers/**')}} - name: Setup MSVC - run: | - Start-Process "C:\Program Files (x86)\Microsoft Visual Studio\Installer\vs_installer.exe" -ArgumentList 'modify --installPath "C:\Program Files\Microsoft Visual Studio\2022\Enterprise" --quiet --add Microsoft.VisualStudio.Component.VC.14.35.17.5.${{ startswith(matrix.arch, 'ARM') && matrix.arch || 'x86.x64' }}' -Wait -PassThru - shell: pwsh if: steps.check-cache.outputs.cache-hit != 'true' - - name: Build wrappers - run: pwsh ./wrappers/build.ps1 Windows -Platforms ${{ matrix.arch }} -ExtraCMakeArgs "-T v143,version=14.35" -Configuration Release -EnableLTO + run: Start-Process "C:\Program Files (x86)\Microsoft Visual Studio\Installer\vs_installer.exe" -ArgumentList 'modify --installPath "C:\Program Files\Microsoft Visual Studio\2022\Enterprise" --quiet --add Microsoft.VisualStudio.Component.VC.14.35.17.5.${{ startswith(matrix.arch, 'ARM') && matrix.arch || 'x86.x64' }}' -Wait -PassThru + shell: pwsh + - name: Build Wrappers if: steps.check-cache.outputs.cache-hit != 'true' + run: pwsh ./wrappers/build.ps1 Windows -Platforms ${{ matrix.arch }} -ExtraCMakeArgs "-T v143,version=14.35" -ConfigurationRelease -EnableLTO - name: Store artifacts for wrappers-windows-${{ matrix.arch }} - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: wrappers-windows-${{ matrix.arch }} path: ${{ github.workspace }}/wrappers/build/** - retention-days: 1 + retention-days: ${{ github.event_name != 'pull_request' && 30 || 1 }} if-no-files-found: error - if: needs.check-cache.outputs.wrappers-windows-Win32 != 'true' || needs.check-cache.outputs.wrappers-windows-x64 != 'true' || needs.check-cache.outputs.wrappers-windows-ARM64 != 'true' - uwp: - runs-on: windows-latest - name: UWP strategy: matrix: arch: - Win32 - x64 - - ARM - ARM64 - timeout-minutes: 90 + uwp: + name: UWP needs: - check-cache + if: needs.check-cache.outputs.wrappers-windows-uwp-Win32 != 'true' || needs.check-cache.outputs.wrappers-windows-uwp-x64 != 'true' || needs.check-cache.outputs.wrappers-windows-uwp-ARM != 'true' || needs.check-cache.outputs.wrappers-windows-uwp-ARM64 != 'true' + timeout-minutes: 90 + runs-on: windows-latest steps: - - name: Checkout code - uses: actions/checkout@v3 + - name: Checkout Code + uses: actions/checkout@v4 with: submodules: recursive ref: ${{ github.event.pull_request.head.sha }} - - name: Check cache + - name: Check Cache for windows-${{ matrix.arch }} id: check-cache - uses: nirinchev/cache@29e8e4dd9148ea81f9e188480132072cb6cc92d8 + uses: actions/cache@v4 with: path: ./wrappers/build/** - key: wrappers-windows-uwp-${{ matrix.arch }}-Release-${{hashFiles('./wrappers/**')}} + key: wrappers-windows-${{ matrix.arch }}-Release-${{hashFiles('./wrappers/**')}} - name: Setup MSVC - run: | - Start-Process "C:\Program Files (x86)\Microsoft Visual Studio\Installer\vs_installer.exe" -ArgumentList 'modify --installPath "C:\Program Files\Microsoft Visual Studio\2022\Enterprise" --quiet --add Microsoft.VisualStudio.Component.VC.14.35.17.5.${{ startswith(matrix.arch, 'ARM') && matrix.arch || 'x86.x64' }}' -Wait -PassThru - shell: pwsh if: steps.check-cache.outputs.cache-hit != 'true' - - name: Build wrappers - run: pwsh ./wrappers/build.ps1 WindowsStore -Platforms ${{ matrix.arch }} -ExtraCMakeArgs "-T v143,version=14.35" -Configuration Release -EnableLTO + run: Start-Process "C:\Program Files (x86)\Microsoft Visual Studio\Installer\vs_installer.exe" -ArgumentList 'modify --installPath "C:\Program Files\Microsoft Visual Studio\2022\Enterprise" --quiet --add Microsoft.VisualStudio.Component.VC.14.35.17.5.${{ startswith(matrix.arch, 'ARM') && matrix.arch || 'x86.x64' }}' -Wait -PassThru + shell: pwsh + - name: Build Wrappers if: steps.check-cache.outputs.cache-hit != 'true' - - name: Store artifacts for wrappers-windows-uwp-${{ matrix.arch }} - uses: actions/upload-artifact@v3 + run: pwsh ./wrappers/build.ps1 WindowsStore -Platforms ${{ matrix.arch }} -ExtraCMakeArgs "-T v143,version=14.35" -ConfigurationRelease -EnableLTO + - name: Store artifacts for wrappers-windows-${{ matrix.arch }} + uses: actions/upload-artifact@v4 with: - name: wrappers-windows-uwp-${{ matrix.arch }} + name: wrappers-windows-${{ matrix.arch }} path: ${{ github.workspace }}/wrappers/build/** - retention-days: 1 + retention-days: ${{ github.event_name != 'pull_request' && 30 || 1 }} if-no-files-found: error - if: needs.check-cache.outputs.wrappers-windows-uwp-Win32 != 'true' || needs.check-cache.outputs.wrappers-windows-uwp-x64 != 'true' || needs.check-cache.outputs.wrappers-windows-uwp-ARM != 'true' || needs.check-cache.outputs.wrappers-windows-uwp-ARM64 != 'true' + strategy: + matrix: + arch: + - Win32 + - x64 + - ARM + - ARM64 From f94d0ff8a38b6465c7720b077f7ca268264e5629 Mon Sep 17 00:00:00 2001 From: Nikola Irinchev Date: Mon, 13 May 2024 23:43:24 +0200 Subject: [PATCH 03/39] Add a space --- .github/pkl-workflows/wrappers.pkl | 2 +- .github/workflows/wrappers.yml | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/pkl-workflows/wrappers.pkl b/.github/pkl-workflows/wrappers.pkl index 094c7e659e..ec2931bd7b 100644 --- a/.github/pkl-workflows/wrappers.pkl +++ b/.github/pkl-workflows/wrappers.pkl @@ -199,6 +199,6 @@ local class JobConfig { function toString(): String = "\(cmd) \(configParam) \(ltoParam)" - hidden configParam = "\(if (cmd.startsWith("pwsh")) "-Configuration" else "--configuration=")\(Common.configuration)" + hidden configParam = "\(if (cmd.startsWith("pwsh")) "-Configuration " else "--configuration=")\(Common.configuration)" hidden ltoParam = if (!enableLTO) "" else (if (cmd.startsWith("pwsh")) "-EnableLTO" else "-DCMAKE_INTERPROCEDURAL_OPTIMIZATION='ON'") } \ No newline at end of file diff --git a/.github/workflows/wrappers.yml b/.github/workflows/wrappers.yml index ad72e04aa9..ca5617c7ab 100755 --- a/.github/workflows/wrappers.yml +++ b/.github/workflows/wrappers.yml @@ -435,7 +435,7 @@ jobs: key: wrappers-catalyst-Release-${{hashFiles('./wrappers/**')}} - name: Build Wrappers if: steps.check-cache.outputs.cache-hit != 'true' - run: pwsh ./wrappers/build-apple-platform.ps1 Catalyst -ConfigurationRelease -EnableLTO + run: pwsh ./wrappers/build-apple-platform.ps1 Catalyst -Configuration Release -EnableLTO - name: Store artifacts for wrappers-catalyst uses: actions/upload-artifact@v4 with: @@ -469,7 +469,7 @@ jobs: xcode-version: '14' - name: Build Wrappers if: steps.check-cache.outputs.cache-hit != 'true' - run: 'pwsh ./wrappers/build-apple-platform.ps1 ${{ matrix.platform }} -Targets ${{ matrix.target }} -ConfigurationRelease ' + run: 'pwsh ./wrappers/build-apple-platform.ps1 ${{ matrix.platform }} -Targets ${{ matrix.target }} -Configuration Release ' - name: Store artifacts for wrappers-${{ matrix.platform }}-${{ matrix.target }} uses: actions/upload-artifact@v4 with: @@ -584,7 +584,7 @@ jobs: shell: pwsh - name: Build Wrappers if: steps.check-cache.outputs.cache-hit != 'true' - run: pwsh ./wrappers/build.ps1 Windows -Platforms ${{ matrix.arch }} -ExtraCMakeArgs "-T v143,version=14.35" -ConfigurationRelease -EnableLTO + run: pwsh ./wrappers/build.ps1 Windows -Platforms ${{ matrix.arch }} -ExtraCMakeArgs "-T v143,version=14.35" -Configuration Release -EnableLTO - name: Store artifacts for wrappers-windows-${{ matrix.arch }} uses: actions/upload-artifact@v4 with: @@ -623,7 +623,7 @@ jobs: shell: pwsh - name: Build Wrappers if: steps.check-cache.outputs.cache-hit != 'true' - run: pwsh ./wrappers/build.ps1 WindowsStore -Platforms ${{ matrix.arch }} -ExtraCMakeArgs "-T v143,version=14.35" -ConfigurationRelease -EnableLTO + run: pwsh ./wrappers/build.ps1 WindowsStore -Platforms ${{ matrix.arch }} -ExtraCMakeArgs "-T v143,version=14.35" -Configuration Release -EnableLTO - name: Store artifacts for wrappers-windows-${{ matrix.arch }} uses: actions/upload-artifact@v4 with: From 573ff3ebfeb5babf64a73c3158a543184a28463c Mon Sep 17 00:00:00 2001 From: Nikola Irinchev Date: Tue, 14 May 2024 01:30:13 +0200 Subject: [PATCH 04/39] Fix platform name for uwp --- .github/pkl-workflows/wrappers.pkl | 2 +- .github/workflows/wrappers.yml | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/pkl-workflows/wrappers.pkl b/.github/pkl-workflows/wrappers.pkl index ec2931bd7b..de2f628ca0 100644 --- a/.github/pkl-workflows/wrappers.pkl +++ b/.github/pkl-workflows/wrappers.pkl @@ -140,7 +140,7 @@ jobs { } } |> wrappersJob(new JobConfig { cmd = "pwsh ./wrappers/build.ps1 WindowsStore -Platforms ${{ matrix.arch }} -ExtraCMakeArgs \"-T v143,version=14.35\"" - platform = "windows-${{ matrix.arch }}" + platform = "windows-uwp-${{ matrix.arch }}" intermediateSteps { Steps.setupMSVC("${{ startswith(matrix.arch, 'ARM') && matrix.arch || 'x86.x64' }}") } diff --git a/.github/workflows/wrappers.yml b/.github/workflows/wrappers.yml index ca5617c7ab..edd27f0cc8 100755 --- a/.github/workflows/wrappers.yml +++ b/.github/workflows/wrappers.yml @@ -611,12 +611,12 @@ jobs: with: submodules: recursive ref: ${{ github.event.pull_request.head.sha }} - - name: Check Cache for windows-${{ matrix.arch }} + - name: Check Cache for windows-uwp-${{ matrix.arch }} id: check-cache uses: actions/cache@v4 with: path: ./wrappers/build/** - key: wrappers-windows-${{ matrix.arch }}-Release-${{hashFiles('./wrappers/**')}} + key: wrappers-windows-uwp-${{ matrix.arch }}-Release-${{hashFiles('./wrappers/**')}} - name: Setup MSVC if: steps.check-cache.outputs.cache-hit != 'true' run: Start-Process "C:\Program Files (x86)\Microsoft Visual Studio\Installer\vs_installer.exe" -ArgumentList 'modify --installPath "C:\Program Files\Microsoft Visual Studio\2022\Enterprise" --quiet --add Microsoft.VisualStudio.Component.VC.14.35.17.5.${{ startswith(matrix.arch, 'ARM') && matrix.arch || 'x86.x64' }}' -Wait -PassThru @@ -624,10 +624,10 @@ jobs: - name: Build Wrappers if: steps.check-cache.outputs.cache-hit != 'true' run: pwsh ./wrappers/build.ps1 WindowsStore -Platforms ${{ matrix.arch }} -ExtraCMakeArgs "-T v143,version=14.35" -Configuration Release -EnableLTO - - name: Store artifacts for wrappers-windows-${{ matrix.arch }} + - name: Store artifacts for wrappers-windows-uwp-${{ matrix.arch }} uses: actions/upload-artifact@v4 with: - name: wrappers-windows-${{ matrix.arch }} + name: wrappers-windows-uwp-${{ matrix.arch }} path: ${{ github.workspace }}/wrappers/build/** retention-days: ${{ github.event_name != 'pull_request' && 30 || 1 }} if-no-files-found: error From 9f0f484be7e5c0f7fdac4a1b76179dbb3ef8f6b7 Mon Sep 17 00:00:00 2001 From: Nikola Irinchev Date: Tue, 14 May 2024 14:29:21 +0200 Subject: [PATCH 05/39] Move deploy baas to pr.yml --- .github/pkl-workflows/{pr.pkl => PR.pkl} | 38 +- .../{wrappers.pkl => Wrappers.pkl} | 0 .github/pkl-workflows/helpers/BaaS.pkl | 25 + .github/pkl-workflows/helpers/Common.pkl | 4 +- .github/pkl-workflows/helpers/Steps.pkl | 11 +- .github/pkl-workflows/temp-outputs/PR.yml | 237 +++++++ .../pkl-workflows/temp-outputs/Wrappers.yml | 640 ++++++++++++++++++ .../pkl-workflows/temp-outputs/wrappers.yml | 42 -- .github/templates/pr.yml | 95 --- .github/workflows/deploy-baas.yml | 33 - .github/workflows/pr.yml | 26 +- 11 files changed, 943 insertions(+), 208 deletions(-) rename .github/pkl-workflows/{pr.pkl => PR.pkl} (87%) rename .github/pkl-workflows/{wrappers.pkl => Wrappers.pkl} (100%) create mode 100644 .github/pkl-workflows/helpers/BaaS.pkl create mode 100644 .github/pkl-workflows/temp-outputs/PR.yml create mode 100644 .github/pkl-workflows/temp-outputs/Wrappers.yml delete mode 100644 .github/pkl-workflows/temp-outputs/wrappers.yml delete mode 100644 .github/templates/pr.yml delete mode 100755 .github/workflows/deploy-baas.yml diff --git a/.github/pkl-workflows/pr.pkl b/.github/pkl-workflows/PR.pkl similarity index 87% rename from .github/pkl-workflows/pr.pkl rename to .github/pkl-workflows/PR.pkl index 904bcc518a..2ca95ce080 100644 --- a/.github/pkl-workflows/pr.pkl +++ b/.github/pkl-workflows/PR.pkl @@ -2,7 +2,9 @@ module pr amends "GithubAction/GithubAction.pkl" -import "helpers/common.pkl" +import "helpers/Common.pkl" +import "helpers/Steps.pkl" +import "helpers/BaaS.pkl" local class JobNamesDefition { const wrappers: String = "build-wrappers" @@ -15,7 +17,7 @@ local class JobNamesDefition { local function createTestJob(workflow: String): ReusableWorkflowJob = new ReusableWorkflowJob { uses = "./.github/workflows/\(workflow).yml" name = "Test" - `if` = ifNotCanceledCondition + `if` = Common.ifNotCanceledCondition needs { JobNames.packages } @@ -24,17 +26,7 @@ local function createTestJob(workflow: String): ReusableWorkflowJob = new Reusab } } -local function checkoutCode(): Step = new { - name = "Checkout Code" - uses = "actions/checkout@v3" - with { - ["submodules"] = "recursive" - ["ref"] = "${{ github.event.pull_request.head.sha }}" - } -} - local JobNames = new JobNamesDefition{} -local ifNotCanceledCondition = "always() && !cancelled() && !contains(needs.*.result, 'failure') && !contains(needs.*.result, 'cancelled')" local packages = List("Realm", "Realm.PlatformHelpers", "Realm.UnityUtils", "Realm.UnityWeaver") @@ -60,7 +52,7 @@ on { } } -env = common.defaultEnv +env = Common.defaultEnv concurrency { group = "${{ github.head_ref || github.run_id }}" @@ -72,15 +64,7 @@ jobs { uses = "./.github/workflows/wrappers.yml" name = "Wrappers" } - [JobNames.baas] = new ReusableWorkflowJob { - uses = "./.github/workflows/deploy-baas.yml" - with { - ["differentiators"] = "[\"code-coverage\"]" - } - secrets { - ["BaaSaasApiKey"] = "${{ secrets.BAASAAS_API_KEY }}" - } - } + [JobNames.baas] = BaaS.deploy(new Listing { "code-coverage"}) // TODO: run baasaas tests for more targets [JobNames.packages] = new ReusableWorkflowJob { uses = "./.github/workflows/build-packages.yml" name = "Package" @@ -100,7 +84,7 @@ jobs { needs { JobNames.packages } - `if` = ifNotCanceledCondition + `if` = Common.ifNotCanceledCondition } ["test-unity"] = new ReusableWorkflowJob { uses = "./.github/workflows/test-unity.yml" @@ -113,7 +97,7 @@ jobs { needs { JobNames.unity } - `if` = ifNotCanceledCondition + `if` = Common.ifNotCanceledCondition } ["test-net-framework"] = createTestJob("test-net-framework") ["test-uwp-managed"] = (createTestJob("test-uwp-managed")) { @@ -140,12 +124,12 @@ jobs { } ["test-woven-classes"] = createTestJob("test-woven-classes") ["test-source-generation"] = new ReusableWorkflowJob { - `if` = ifNotCanceledCondition + `if` = Common.ifNotCanceledCondition name = "Test" uses = "./.github/workflows/test-source-generation.yml" } ["test-weaver"] = new ReusableWorkflowJob { - `if` = ifNotCanceledCondition + `if` = Common.ifNotCanceledCondition name = "Test" uses = "./.github/workflows/test-weaver.yml" } @@ -178,7 +162,7 @@ jobs { JobNames.packages } steps { - checkoutCode() + Steps.checkout() for (_package in packages) { new { name = "Fetch \(_package)" diff --git a/.github/pkl-workflows/wrappers.pkl b/.github/pkl-workflows/Wrappers.pkl similarity index 100% rename from .github/pkl-workflows/wrappers.pkl rename to .github/pkl-workflows/Wrappers.pkl diff --git a/.github/pkl-workflows/helpers/BaaS.pkl b/.github/pkl-workflows/helpers/BaaS.pkl new file mode 100644 index 0000000000..b36fcb762a --- /dev/null +++ b/.github/pkl-workflows/helpers/BaaS.pkl @@ -0,0 +1,25 @@ +module baas + +import "../GithubAction/GithubAction.pkl" as gha +import "Common.pkl" +import "Steps.pkl" + +function deploy(differentiators: Listing): gha.MatrixJob = new { + name = "Deploy BaaS" + `runs-on` = new gha.UbuntuLatest{} + strategy { + matrix { + ["differentiator"] = differentiators + } + } + `if` = Common.ifNotCanceledCondition + steps { + Steps.checkout() + Steps.setupDotnet() + new gha.Step { + name = "Deploy Apps" + run = "dotnet run deploy-apps --baasaas-api-key=${{ secrets.BAASAAS_API_KEY }} --baas-differentiator=${{ matrix.differentiator }}-${{ github.run_id }}-${{ github.run_attempt }}" + `working-directory` = "Tools/DeployApps" + } + } +} \ No newline at end of file diff --git a/.github/pkl-workflows/helpers/Common.pkl b/.github/pkl-workflows/helpers/Common.pkl index dfb61d8632..da848f2cf2 100644 --- a/.github/pkl-workflows/helpers/Common.pkl +++ b/.github/pkl-workflows/helpers/Common.pkl @@ -23,4 +23,6 @@ const defaultEnv: Mapping = new { ["DOTNET_NOLOGO"] = true } -const function applePlatformTargets(_transform: (String, String) -> String): List = applePlatforms.map((platform) -> appleTargets.map((target) -> _transform.apply(platform, target))).flatten() \ No newline at end of file +const function applePlatformTargets(_transform: (String, String) -> String): List = applePlatforms.map((platform) -> appleTargets.map((target) -> _transform.apply(platform, target))).flatten() + +const ifNotCanceledCondition = "always() && !cancelled() && !contains(needs.*.result, 'failure') && !contains(needs.*.result, 'cancelled')" diff --git a/.github/pkl-workflows/helpers/Steps.pkl b/.github/pkl-workflows/helpers/Steps.pkl index 0e0e23a487..43089292d0 100644 --- a/.github/pkl-workflows/helpers/Steps.pkl +++ b/.github/pkl-workflows/helpers/Steps.pkl @@ -9,10 +9,6 @@ const function checkout(): gha.Step = new { } } -const function restoreCache(): gha.Step = new { - -} - const function uploadArtifacts(artifactName: String, relPath: String): gha.Step = new { name = "Store artifacts for \(artifactName)" uses = "actions/upload-artifact@v4" @@ -36,4 +32,11 @@ const function setupMSVC(edition: String): gha.Step = new { name = "Setup MSVC" run = "Start-Process \"C:\\Program Files (x86)\\Microsoft Visual Studio\\Installer\\vs_installer.exe\" -ArgumentList 'modify --installPath \"C:\\Program Files\\Microsoft Visual Studio\\2022\\Enterprise\" --quiet --add Microsoft.VisualStudio.Component.VC.14.35.17.5.\(edition)' -Wait -PassThru" shell = "pwsh" +} + +const function setupDotnet(): gha.Step = new { + uses = "actions/setup-dotnet@607fce577a46308457984d59e4954e075820f10a" + with { + ["dotnet-version"] = "6.0.x" + } } \ No newline at end of file diff --git a/.github/pkl-workflows/temp-outputs/PR.yml b/.github/pkl-workflows/temp-outputs/PR.yml new file mode 100644 index 0000000000..f884b8225a --- /dev/null +++ b/.github/pkl-workflows/temp-outputs/PR.yml @@ -0,0 +1,237 @@ +# Do not modify! +# This file was generated from a template using https://github.com/apple/pkl + +name: PR Build +'on': + pull_request: + paths: + - '**.cs' + - '**.cpp' + - '**.hpp' + - '**.csproj' + - '**CMakeLists.txt' + - '**.ps1' + - '**.sh' + - '**.props' + - wrappers/realm-core + - .github/workflows/*.yml + - '!.github/workflows/main.yml' + - '!.github/workflows/publish-*.yml' + - .github/actions/** + - Tests/Tests.Android/Properties/AndroidManifest.xml +env: + REALM_DISABLE_ANALYTICS: true + DOTNET_NOLOGO: true +concurrency: + group: ${{ github.head_ref || github.run_id }} + cancel-in-progress: true +jobs: + build-wrappers: + name: Wrappers + uses: ./.github/workflows/wrappers.yml + deploy-baas: + name: Deploy BaaS + if: always() && !cancelled() && !contains(needs.*.result, 'failure') && !contains(needs.*.result, 'cancelled') + runs-on: ubuntu-latest + steps: + - name: Checkout Code + uses: actions/checkout@v4 + with: + submodules: recursive + ref: ${{ github.event.pull_request.head.sha }} + - uses: actions/setup-dotnet@607fce577a46308457984d59e4954e075820f10a + with: + dotnet-version: 6.0.x + - name: Deploy Apps + working-directory: Tools/DeployApps + run: dotnet run deploy-apps --baasaas-api-key=${{ secrets.BAASAAS_API_KEY }} --baas-differentiator=${{ matrix.differentiator }}-${{ github.run_id }}-${{ github.run_attempt }} + strategy: + matrix: + differentiator: + - code-coverage + build-packages: + name: Package + needs: + - build-wrappers + uses: ./.github/workflows/build-packages.yml + with: + build-docs: ${{ contains(github.head_ref, 'release') }} + build-unity: + name: Package + needs: + - build-packages + if: always() && !cancelled() && !contains(needs.*.result, 'failure') && !contains(needs.*.result, 'cancelled') + uses: ./.github/workflows/build-unity.yml + with: + version: ${{ needs.build-packages.outputs.package_version }} + test-unity: + name: Test + needs: + - build-unity + if: always() && !cancelled() && !contains(needs.*.result, 'failure') && !contains(needs.*.result, 'cancelled') + uses: ./.github/workflows/test-unity.yml + with: + version: ${{ needs.build-packages.outputs.package_version }} + settings: '["Mono-Net4"]' + platform: '[{ "os": "windows", "testPlatform": "Windows64" }, { "os": "linux", "testPlatform": "Linux64" }]' + test-net-framework: + name: Test + needs: + - build-packages + if: always() && !cancelled() && !contains(needs.*.result, 'failure') && !contains(needs.*.result, 'cancelled') + uses: ./.github/workflows/test-net-framework.yml + with: + version: ${{ needs.build-packages.outputs.package_version }} + test-uwp-managed: + name: Test + needs: + - build-packages + if: always() && !cancelled() && !contains(needs.*.result, 'failure') && !contains(needs.*.result, 'cancelled') + uses: ./.github/workflows/test-uwp-managed.yml + with: + version: ${{ needs.build-packages.outputs.package_version }} + secrets: + Pfx_Password: ${{ secrets.Pfx_Password }} + Base64_Encoded_Pfx: ${{ secrets.Base64_Encoded_Pfx }} + test-net-core: + name: Test + needs: + - build-packages + if: always() && !cancelled() && !contains(needs.*.result, 'failure') && !contains(needs.*.result, 'cancelled') + uses: ./.github/workflows/test-net-core.yml + with: + version: ${{ needs.build-packages.outputs.package_version }} + framework: '["net8.0"]' + test-macos: + name: Test + needs: + - build-packages + if: always() && !cancelled() && !contains(needs.*.result, 'failure') && !contains(needs.*.result, 'cancelled') + uses: ./.github/workflows/test-macos.yml + with: + version: ${{ needs.build-packages.outputs.package_version }} + test-ios: + name: Test + needs: + - build-packages + if: always() && !cancelled() && !contains(needs.*.result, 'failure') && !contains(needs.*.result, 'cancelled') + uses: ./.github/workflows/test-ios.yml + with: + version: ${{ needs.build-packages.outputs.package_version }} + test-tvos: + name: Test + needs: + - build-packages + if: always() && !cancelled() && !contains(needs.*.result, 'failure') && !contains(needs.*.result, 'cancelled') + uses: ./.github/workflows/test-tvos.yml + with: + version: ${{ needs.build-packages.outputs.package_version }} + test-android: + name: Test + needs: + - build-packages + if: always() && !cancelled() && !contains(needs.*.result, 'failure') && !contains(needs.*.result, 'cancelled') + uses: ./.github/workflows/test-android.yml + with: + version: ${{ needs.build-packages.outputs.package_version }} + secrets: + AWS_DEVICEFARM_ACCESS_KEY_ID: ${{ secrets.AWS_DEVICEFARM_ACCESS_KEY_ID }} + AWS_DEVICEFARM_SECRET_ACCESS_KEY: ${{ secrets.AWS_DEVICEFARM_SECRET_ACCESS_KEY }} + DEVICEFARM_PROJECT_ARN: ${{ secrets.DEVICEFARM_PROJECT_ARN }} + DEVICEFARM_ANDROID_POOL_ARN: ${{ secrets.DEVICEFARM_ANDROID_POOL_ARN }} + test-woven-classes: + name: Test + needs: + - build-packages + if: always() && !cancelled() && !contains(needs.*.result, 'failure') && !contains(needs.*.result, 'cancelled') + uses: ./.github/workflows/test-woven-classes.yml + with: + version: ${{ needs.build-packages.outputs.package_version }} + test-source-generation: + name: Test + if: always() && !cancelled() && !contains(needs.*.result, 'failure') && !contains(needs.*.result, 'cancelled') + uses: ./.github/workflows/test-source-generation.yml + test-weaver: + name: Test + if: always() && !cancelled() && !contains(needs.*.result, 'failure') && !contains(needs.*.result, 'cancelled') + uses: ./.github/workflows/test-weaver.yml + test-code-coverage: + name: Test + needs: + - build-packages + - deploy-baas + if: always() && !cancelled() && !contains(needs.*.result, 'failure') && !contains(needs.*.result, 'cancelled') + uses: ./.github/workflows/test-code-coverage.yml + with: + version: ${{ needs.build-packages.outputs.package_version }} + secrets: + BaaSaasApiKey: ${{ secrets.BAASAAS_API_KEY }} + cleanup-baas: + name: Cleanup + needs: + - test-code-coverage + if: always() + uses: ./.github/workflows/cleanup-baas.yml + with: + differentiators: '["code-coverage"]' + secrets: + BaaSaasApiKey: ${{ secrets.BAASAAS_API_KEY }} + verify-namespaces: + name: Verify Namespaces + needs: + - build-packages + runs-on: ubuntu-latest + steps: + - name: Checkout Code + uses: actions/checkout@v4 + with: + submodules: recursive + ref: ${{ github.event.pull_request.head.sha }} + - name: Fetch Realm + uses: actions/download-artifact@v3 + with: + name: Realm.${{ needs.build-packages.outputs.package_version }} + path: ${{ github.workspace }}/Realm/packages/ + - name: Fetch Realm.PlatformHelpers + uses: actions/download-artifact@v3 + with: + name: Realm.PlatformHelpers.${{ needs.build-packages.outputs.package_version }} + path: ${{ github.workspace }}/Realm/packages/ + - name: Fetch Realm.UnityUtils + uses: actions/download-artifact@v3 + with: + name: Realm.UnityUtils.${{ needs.build-packages.outputs.package_version }} + path: ${{ github.workspace }}/Realm/packages/ + - name: Fetch Realm.UnityWeaver + uses: actions/download-artifact@v3 + with: + name: Realm.UnityWeaver.${{ needs.build-packages.outputs.package_version }} + path: ${{ github.workspace }}/Realm/packages/ + - run: dotnet tool install ilspycmd -g --version 8.0.0.7345 + - name: Verify Namespaces + run: |- + $isFailure = $false + Get-ChildItem ./Realm/packages -Filter *.nupkg | Foreach-Object { + $targetPath = Join-Path ./Realm/packages $_.BaseName + Expand-Archive $_.FullName -DestinationPath $targetPath + + Get-ChildItem $targetPath -Filter *.dll -Recurse | ForEach-Object { + if (-not ($_.FullName -match "runtimes")) { + $ilspyOutput = ilspycmd $_.FullName + + $parentDll = $_.FullName + + $ilspyOutput | ForEach-Object { + if ($_ -match "namespace.*Realm(\.|$)") { + Write-Output "::error file=$parentDll::Realm present in namespace - $($_)" + Set-Variable "isFailure" -Value $true + } + } + } + } + } + + if ($isFailure) { + exit 1 + } + shell: pwsh diff --git a/.github/pkl-workflows/temp-outputs/Wrappers.yml b/.github/pkl-workflows/temp-outputs/Wrappers.yml new file mode 100644 index 0000000000..edd27f0cc8 --- /dev/null +++ b/.github/pkl-workflows/temp-outputs/Wrappers.yml @@ -0,0 +1,640 @@ +# Do not modify! +# This file was generated from a template using https://github.com/apple/pkl + +name: wrappers +'on': + workflow_call: {} +env: + REALM_DISABLE_ANALYTICS: true + DOTNET_NOLOGO: true +jobs: + check-cache: + name: Check Cache + env: + CACHE_SKIP_SAVE: true + outputs: + wrappers-macos: ${{ steps.check-cache-macos.outputs.cache-hit }} + wrappers-catalyst: ${{ steps.check-cache-catalyst.outputs.cache-hit }} + wrappers-linux-x86_64: ${{ steps.check-cache-linux-x86_64.outputs.cache-hit }} + wrappers-linux-armhf: ${{ steps.check-cache-linux-armhf.outputs.cache-hit }} + wrappers-linux-aarch64: ${{ steps.check-cache-linux-aarch64.outputs.cache-hit }} + wrappers-android-armeabi-v7a: ${{ steps.check-cache-android-armeabi-v7a.outputs.cache-hit }} + wrappers-android-arm64-v8a: ${{ steps.check-cache-android-arm64-v8a.outputs.cache-hit }} + wrappers-android-x86: ${{ steps.check-cache-android-x86.outputs.cache-hit }} + wrappers-android-x86_64: ${{ steps.check-cache-android-x86_64.outputs.cache-hit }} + wrappers-windows-Win32: ${{ steps.check-cache-windows-Win32.outputs.cache-hit }} + wrappers-windows-x64: ${{ steps.check-cache-windows-x64.outputs.cache-hit }} + wrappers-windows-ARM64: ${{ steps.check-cache-windows-ARM64.outputs.cache-hit }} + wrappers-windows-uwp-Win32: ${{ steps.check-cache-windows-uwp-Win32.outputs.cache-hit }} + wrappers-windows-uwp-x64: ${{ steps.check-cache-windows-uwp-x64.outputs.cache-hit }} + wrappers-windows-uwp-ARM: ${{ steps.check-cache-windows-uwp-ARM.outputs.cache-hit }} + wrappers-windows-uwp-ARM64: ${{ steps.check-cache-windows-uwp-ARM64.outputs.cache-hit }} + wrappers-iOS-Device: ${{ steps.check-cache-iOS-Device.outputs.cache-hit }} + wrappers-iOS-Simulator: ${{ steps.check-cache-iOS-Simulator.outputs.cache-hit }} + wrappers-tvOS-Device: ${{ steps.check-cache-tvOS-Device.outputs.cache-hit }} + wrappers-tvOS-Simulator: ${{ steps.check-cache-tvOS-Simulator.outputs.cache-hit }} + runs-on: ${{ matrix.os }}-latest + steps: + - name: Checkout Code + uses: actions/checkout@v4 + with: + submodules: recursive + ref: ${{ github.event.pull_request.head.sha }} + - name: Check Cache for macos + id: check-cache-macos + if: matrix.os == 'ubuntu' + uses: actions/cache/restore@v4 + with: + path: ./wrappers/build/** + key: wrappers-macos-Release-${{hashFiles('./wrappers/**')}} + - name: Store artifacts for wrappers-macos + if: matrix.os == 'ubuntu' && steps.check-cache-macos.outputs.cache-hit == 'true' + uses: actions/upload-artifact@v4 + with: + name: wrappers-macos + path: ${{ github.workspace }}/wrappers/build/** + retention-days: ${{ github.event_name != 'pull_request' && 30 || 1 }} + if-no-files-found: error + - if: matrix.os == 'ubuntu' + run: git clean -fdx + - name: Check Cache for catalyst + id: check-cache-catalyst + if: matrix.os == 'ubuntu' + uses: actions/cache/restore@v4 + with: + path: ./wrappers/build/** + key: wrappers-catalyst-Release-${{hashFiles('./wrappers/**')}} + - name: Store artifacts for wrappers-catalyst + if: matrix.os == 'ubuntu' && steps.check-cache-catalyst.outputs.cache-hit == 'true' + uses: actions/upload-artifact@v4 + with: + name: wrappers-catalyst + path: ${{ github.workspace }}/wrappers/build/** + retention-days: ${{ github.event_name != 'pull_request' && 30 || 1 }} + if-no-files-found: error + - if: matrix.os == 'ubuntu' + run: git clean -fdx + - name: Check Cache for linux-x86_64 + id: check-cache-linux-x86_64 + if: matrix.os == 'ubuntu' + uses: actions/cache/restore@v4 + with: + path: ./wrappers/build/** + key: wrappers-linux-x86_64-Release-${{hashFiles('./wrappers/**')}} + - name: Store artifacts for wrappers-linux-x86_64 + if: matrix.os == 'ubuntu' && steps.check-cache-linux-x86_64.outputs.cache-hit == 'true' + uses: actions/upload-artifact@v4 + with: + name: wrappers-linux-x86_64 + path: ${{ github.workspace }}/wrappers/build/** + retention-days: ${{ github.event_name != 'pull_request' && 30 || 1 }} + if-no-files-found: error + - if: matrix.os == 'ubuntu' + run: git clean -fdx + - name: Check Cache for linux-armhf + id: check-cache-linux-armhf + if: matrix.os == 'ubuntu' + uses: actions/cache/restore@v4 + with: + path: ./wrappers/build/** + key: wrappers-linux-armhf-Release-${{hashFiles('./wrappers/**')}} + - name: Store artifacts for wrappers-linux-armhf + if: matrix.os == 'ubuntu' && steps.check-cache-linux-armhf.outputs.cache-hit == 'true' + uses: actions/upload-artifact@v4 + with: + name: wrappers-linux-armhf + path: ${{ github.workspace }}/wrappers/build/** + retention-days: ${{ github.event_name != 'pull_request' && 30 || 1 }} + if-no-files-found: error + - if: matrix.os == 'ubuntu' + run: git clean -fdx + - name: Check Cache for linux-aarch64 + id: check-cache-linux-aarch64 + if: matrix.os == 'ubuntu' + uses: actions/cache/restore@v4 + with: + path: ./wrappers/build/** + key: wrappers-linux-aarch64-Release-${{hashFiles('./wrappers/**')}} + - name: Store artifacts for wrappers-linux-aarch64 + if: matrix.os == 'ubuntu' && steps.check-cache-linux-aarch64.outputs.cache-hit == 'true' + uses: actions/upload-artifact@v4 + with: + name: wrappers-linux-aarch64 + path: ${{ github.workspace }}/wrappers/build/** + retention-days: ${{ github.event_name != 'pull_request' && 30 || 1 }} + if-no-files-found: error + - if: matrix.os == 'ubuntu' + run: git clean -fdx + - name: Check Cache for android-armeabi-v7a + id: check-cache-android-armeabi-v7a + if: matrix.os == 'ubuntu' + uses: actions/cache/restore@v4 + with: + path: ./wrappers/build/** + key: wrappers-android-armeabi-v7a-Release-${{hashFiles('./wrappers/**')}} + - name: Store artifacts for wrappers-android-armeabi-v7a + if: matrix.os == 'ubuntu' && steps.check-cache-android-armeabi-v7a.outputs.cache-hit == 'true' + uses: actions/upload-artifact@v4 + with: + name: wrappers-android-armeabi-v7a + path: ${{ github.workspace }}/wrappers/build/** + retention-days: ${{ github.event_name != 'pull_request' && 30 || 1 }} + if-no-files-found: error + - if: matrix.os == 'ubuntu' + run: git clean -fdx + - name: Check Cache for android-arm64-v8a + id: check-cache-android-arm64-v8a + if: matrix.os == 'ubuntu' + uses: actions/cache/restore@v4 + with: + path: ./wrappers/build/** + key: wrappers-android-arm64-v8a-Release-${{hashFiles('./wrappers/**')}} + - name: Store artifacts for wrappers-android-arm64-v8a + if: matrix.os == 'ubuntu' && steps.check-cache-android-arm64-v8a.outputs.cache-hit == 'true' + uses: actions/upload-artifact@v4 + with: + name: wrappers-android-arm64-v8a + path: ${{ github.workspace }}/wrappers/build/** + retention-days: ${{ github.event_name != 'pull_request' && 30 || 1 }} + if-no-files-found: error + - if: matrix.os == 'ubuntu' + run: git clean -fdx + - name: Check Cache for android-x86 + id: check-cache-android-x86 + if: matrix.os == 'ubuntu' + uses: actions/cache/restore@v4 + with: + path: ./wrappers/build/** + key: wrappers-android-x86-Release-${{hashFiles('./wrappers/**')}} + - name: Store artifacts for wrappers-android-x86 + if: matrix.os == 'ubuntu' && steps.check-cache-android-x86.outputs.cache-hit == 'true' + uses: actions/upload-artifact@v4 + with: + name: wrappers-android-x86 + path: ${{ github.workspace }}/wrappers/build/** + retention-days: ${{ github.event_name != 'pull_request' && 30 || 1 }} + if-no-files-found: error + - if: matrix.os == 'ubuntu' + run: git clean -fdx + - name: Check Cache for android-x86_64 + id: check-cache-android-x86_64 + if: matrix.os == 'ubuntu' + uses: actions/cache/restore@v4 + with: + path: ./wrappers/build/** + key: wrappers-android-x86_64-Release-${{hashFiles('./wrappers/**')}} + - name: Store artifacts for wrappers-android-x86_64 + if: matrix.os == 'ubuntu' && steps.check-cache-android-x86_64.outputs.cache-hit == 'true' + uses: actions/upload-artifact@v4 + with: + name: wrappers-android-x86_64 + path: ${{ github.workspace }}/wrappers/build/** + retention-days: ${{ github.event_name != 'pull_request' && 30 || 1 }} + if-no-files-found: error + - if: matrix.os == 'ubuntu' + run: git clean -fdx + - name: Check Cache for windows-Win32 + id: check-cache-windows-Win32 + if: matrix.os == 'windows' + uses: actions/cache/restore@v4 + with: + path: ./wrappers/build/** + key: wrappers-windows-Win32-Release-${{hashFiles('./wrappers/**')}} + - name: Store artifacts for wrappers-windows-Win32 + if: matrix.os == 'windows' && steps.check-cache-windows-Win32.outputs.cache-hit == 'true' + uses: actions/upload-artifact@v4 + with: + name: wrappers-windows-Win32 + path: ${{ github.workspace }}/wrappers/build/** + retention-days: ${{ github.event_name != 'pull_request' && 30 || 1 }} + if-no-files-found: error + - if: matrix.os == 'windows' + run: git clean -fdx + - name: Check Cache for windows-x64 + id: check-cache-windows-x64 + if: matrix.os == 'windows' + uses: actions/cache/restore@v4 + with: + path: ./wrappers/build/** + key: wrappers-windows-x64-Release-${{hashFiles('./wrappers/**')}} + - name: Store artifacts for wrappers-windows-x64 + if: matrix.os == 'windows' && steps.check-cache-windows-x64.outputs.cache-hit == 'true' + uses: actions/upload-artifact@v4 + with: + name: wrappers-windows-x64 + path: ${{ github.workspace }}/wrappers/build/** + retention-days: ${{ github.event_name != 'pull_request' && 30 || 1 }} + if-no-files-found: error + - if: matrix.os == 'windows' + run: git clean -fdx + - name: Check Cache for windows-ARM64 + id: check-cache-windows-ARM64 + if: matrix.os == 'windows' + uses: actions/cache/restore@v4 + with: + path: ./wrappers/build/** + key: wrappers-windows-ARM64-Release-${{hashFiles('./wrappers/**')}} + - name: Store artifacts for wrappers-windows-ARM64 + if: matrix.os == 'windows' && steps.check-cache-windows-ARM64.outputs.cache-hit == 'true' + uses: actions/upload-artifact@v4 + with: + name: wrappers-windows-ARM64 + path: ${{ github.workspace }}/wrappers/build/** + retention-days: ${{ github.event_name != 'pull_request' && 30 || 1 }} + if-no-files-found: error + - if: matrix.os == 'windows' + run: git clean -fdx + - name: Check Cache for windows-uwp-Win32 + id: check-cache-windows-uwp-Win32 + if: matrix.os == 'windows' + uses: actions/cache/restore@v4 + with: + path: ./wrappers/build/** + key: wrappers-windows-uwp-Win32-Release-${{hashFiles('./wrappers/**')}} + - name: Store artifacts for wrappers-windows-uwp-Win32 + if: matrix.os == 'windows' && steps.check-cache-windows-uwp-Win32.outputs.cache-hit == 'true' + uses: actions/upload-artifact@v4 + with: + name: wrappers-windows-uwp-Win32 + path: ${{ github.workspace }}/wrappers/build/** + retention-days: ${{ github.event_name != 'pull_request' && 30 || 1 }} + if-no-files-found: error + - if: matrix.os == 'windows' + run: git clean -fdx + - name: Check Cache for windows-uwp-x64 + id: check-cache-windows-uwp-x64 + if: matrix.os == 'windows' + uses: actions/cache/restore@v4 + with: + path: ./wrappers/build/** + key: wrappers-windows-uwp-x64-Release-${{hashFiles('./wrappers/**')}} + - name: Store artifacts for wrappers-windows-uwp-x64 + if: matrix.os == 'windows' && steps.check-cache-windows-uwp-x64.outputs.cache-hit == 'true' + uses: actions/upload-artifact@v4 + with: + name: wrappers-windows-uwp-x64 + path: ${{ github.workspace }}/wrappers/build/** + retention-days: ${{ github.event_name != 'pull_request' && 30 || 1 }} + if-no-files-found: error + - if: matrix.os == 'windows' + run: git clean -fdx + - name: Check Cache for windows-uwp-ARM + id: check-cache-windows-uwp-ARM + if: matrix.os == 'windows' + uses: actions/cache/restore@v4 + with: + path: ./wrappers/build/** + key: wrappers-windows-uwp-ARM-Release-${{hashFiles('./wrappers/**')}} + - name: Store artifacts for wrappers-windows-uwp-ARM + if: matrix.os == 'windows' && steps.check-cache-windows-uwp-ARM.outputs.cache-hit == 'true' + uses: actions/upload-artifact@v4 + with: + name: wrappers-windows-uwp-ARM + path: ${{ github.workspace }}/wrappers/build/** + retention-days: ${{ github.event_name != 'pull_request' && 30 || 1 }} + if-no-files-found: error + - if: matrix.os == 'windows' + run: git clean -fdx + - name: Check Cache for windows-uwp-ARM64 + id: check-cache-windows-uwp-ARM64 + if: matrix.os == 'windows' + uses: actions/cache/restore@v4 + with: + path: ./wrappers/build/** + key: wrappers-windows-uwp-ARM64-Release-${{hashFiles('./wrappers/**')}} + - name: Store artifacts for wrappers-windows-uwp-ARM64 + if: matrix.os == 'windows' && steps.check-cache-windows-uwp-ARM64.outputs.cache-hit == 'true' + uses: actions/upload-artifact@v4 + with: + name: wrappers-windows-uwp-ARM64 + path: ${{ github.workspace }}/wrappers/build/** + retention-days: ${{ github.event_name != 'pull_request' && 30 || 1 }} + if-no-files-found: error + - if: matrix.os == 'windows' + run: git clean -fdx + - name: Check Cache for iOS-Device + id: check-cache-iOS-Device + if: matrix.os == 'ubuntu' + uses: actions/cache/restore@v4 + with: + path: ./wrappers/build/** + key: wrappers-iOS-Device-Release-${{hashFiles('./wrappers/**')}} + - name: Store artifacts for wrappers-iOS-Device + if: matrix.os == 'ubuntu' && steps.check-cache-iOS-Device.outputs.cache-hit == 'true' + uses: actions/upload-artifact@v4 + with: + name: wrappers-iOS-Device + path: ${{ github.workspace }}/wrappers/build/** + retention-days: ${{ github.event_name != 'pull_request' && 30 || 1 }} + if-no-files-found: error + - if: matrix.os == 'ubuntu' + run: git clean -fdx + - name: Check Cache for iOS-Simulator + id: check-cache-iOS-Simulator + if: matrix.os == 'ubuntu' + uses: actions/cache/restore@v4 + with: + path: ./wrappers/build/** + key: wrappers-iOS-Simulator-Release-${{hashFiles('./wrappers/**')}} + - name: Store artifacts for wrappers-iOS-Simulator + if: matrix.os == 'ubuntu' && steps.check-cache-iOS-Simulator.outputs.cache-hit == 'true' + uses: actions/upload-artifact@v4 + with: + name: wrappers-iOS-Simulator + path: ${{ github.workspace }}/wrappers/build/** + retention-days: ${{ github.event_name != 'pull_request' && 30 || 1 }} + if-no-files-found: error + - if: matrix.os == 'ubuntu' + run: git clean -fdx + - name: Check Cache for tvOS-Device + id: check-cache-tvOS-Device + if: matrix.os == 'ubuntu' + uses: actions/cache/restore@v4 + with: + path: ./wrappers/build/** + key: wrappers-tvOS-Device-Release-${{hashFiles('./wrappers/**')}} + - name: Store artifacts for wrappers-tvOS-Device + if: matrix.os == 'ubuntu' && steps.check-cache-tvOS-Device.outputs.cache-hit == 'true' + uses: actions/upload-artifact@v4 + with: + name: wrappers-tvOS-Device + path: ${{ github.workspace }}/wrappers/build/** + retention-days: ${{ github.event_name != 'pull_request' && 30 || 1 }} + if-no-files-found: error + - if: matrix.os == 'ubuntu' + run: git clean -fdx + - name: Check Cache for tvOS-Simulator + id: check-cache-tvOS-Simulator + if: matrix.os == 'ubuntu' + uses: actions/cache/restore@v4 + with: + path: ./wrappers/build/** + key: wrappers-tvOS-Simulator-Release-${{hashFiles('./wrappers/**')}} + - name: Store artifacts for wrappers-tvOS-Simulator + if: matrix.os == 'ubuntu' && steps.check-cache-tvOS-Simulator.outputs.cache-hit == 'true' + uses: actions/upload-artifact@v4 + with: + name: wrappers-tvOS-Simulator + path: ${{ github.workspace }}/wrappers/build/** + retention-days: ${{ github.event_name != 'pull_request' && 30 || 1 }} + if-no-files-found: error + - if: matrix.os == 'ubuntu' + run: git clean -fdx + strategy: + matrix: + os: + - ubuntu + - windows + macos: + name: MacOS + needs: + - check-cache + if: needs.check-cache.outputs.wrappers-macos != 'true' + timeout-minutes: 90 + runs-on: macos-12 + steps: + - name: Checkout Code + uses: actions/checkout@v4 + with: + submodules: recursive + ref: ${{ github.event.pull_request.head.sha }} + - name: Check Cache for macos + id: check-cache + uses: actions/cache@v4 + with: + path: ./wrappers/build/** + key: wrappers-macos-Release-${{hashFiles('./wrappers/**')}} + - name: Build Wrappers + if: steps.check-cache.outputs.cache-hit != 'true' + run: ./wrappers/build-macos.sh --configuration=Release -DCMAKE_INTERPROCEDURAL_OPTIMIZATION='ON' + - name: Store artifacts for wrappers-macos + uses: actions/upload-artifact@v4 + with: + name: wrappers-macos + path: ${{ github.workspace }}/wrappers/build/** + retention-days: ${{ github.event_name != 'pull_request' && 30 || 1 }} + if-no-files-found: error + catalyst: + name: Catalyst + needs: + - check-cache + if: needs.check-cache.outputs.wrappers-catalyst != 'true' + timeout-minutes: 90 + runs-on: macos-12 + steps: + - name: Checkout Code + uses: actions/checkout@v4 + with: + submodules: recursive + ref: ${{ github.event.pull_request.head.sha }} + - name: Check Cache for catalyst + id: check-cache + uses: actions/cache@v4 + with: + path: ./wrappers/build/** + key: wrappers-catalyst-Release-${{hashFiles('./wrappers/**')}} + - name: Build Wrappers + if: steps.check-cache.outputs.cache-hit != 'true' + run: pwsh ./wrappers/build-apple-platform.ps1 Catalyst -Configuration Release -EnableLTO + - name: Store artifacts for wrappers-catalyst + uses: actions/upload-artifact@v4 + with: + name: wrappers-catalyst + path: ${{ github.workspace }}/wrappers/build/** + retention-days: ${{ github.event_name != 'pull_request' && 30 || 1 }} + if-no-files-found: error + apple-platform: + name: Apple Platform + needs: + - check-cache + if: needs.check-cache.outputs.wrappers-iOS-Device != 'true' || needs.check-cache.outputs.wrappers-iOS-Simulator != 'true' || needs.check-cache.outputs.wrappers-tvOS-Device != 'true' || needs.check-cache.outputs.wrappers-tvOS-Simulator != 'true' + timeout-minutes: 90 + runs-on: macos-12 + steps: + - name: Checkout Code + uses: actions/checkout@v4 + with: + submodules: recursive + ref: ${{ github.event.pull_request.head.sha }} + - name: Check Cache for ${{ matrix.platform }}-${{ matrix.target }} + id: check-cache + uses: actions/cache@v4 + with: + path: ./wrappers/build/** + key: wrappers-${{ matrix.platform }}-${{ matrix.target }}-Release-${{hashFiles('./wrappers/**')}} + - name: Setup Xcode + if: steps.check-cache.outputs.cache-hit != 'true' + uses: maxim-lobanov/setup-xcode@60606e260d2fc5762a71e64e74b2174e8ea3c8bd + with: + xcode-version: '14' + - name: Build Wrappers + if: steps.check-cache.outputs.cache-hit != 'true' + run: 'pwsh ./wrappers/build-apple-platform.ps1 ${{ matrix.platform }} -Targets ${{ matrix.target }} -Configuration Release ' + - name: Store artifacts for wrappers-${{ matrix.platform }}-${{ matrix.target }} + uses: actions/upload-artifact@v4 + with: + name: wrappers-${{ matrix.platform }}-${{ matrix.target }} + path: ${{ github.workspace }}/wrappers/build/** + retention-days: ${{ github.event_name != 'pull_request' && 30 || 1 }} + if-no-files-found: error + strategy: + matrix: + platform: + - iOS + - tvOS + target: + - Device + - Simulator + linux: + name: Linux + needs: + - check-cache + if: needs.check-cache.outputs.wrappers-linux-x86_64 != 'true' || needs.check-cache.outputs.wrappers-linux-armhf != 'true' || needs.check-cache.outputs.wrappers-linux-aarch64 != 'true' + timeout-minutes: 90 + runs-on: ubuntu-latest + steps: + - name: Checkout Code + uses: actions/checkout@v4 + with: + submodules: recursive + ref: ${{ github.event.pull_request.head.sha }} + - name: Check Cache for linux-${{ matrix.arch }} + id: check-cache + uses: actions/cache@v4 + with: + path: ./wrappers/build/** + key: wrappers-linux-${{ matrix.arch }}-Release-${{hashFiles('./wrappers/**')}} + - name: Install Ninja + if: steps.check-cache.outputs.cache-hit != 'true' + run: sudo apt install ninja-build + - name: Build Wrappers + if: steps.check-cache.outputs.cache-hit != 'true' + run: ./wrappers/build-linux.sh -a=${{ matrix.arch }} --configuration=Release -DCMAKE_INTERPROCEDURAL_OPTIMIZATION='ON' + - name: Store artifacts for wrappers-linux-${{ matrix.arch }} + uses: actions/upload-artifact@v4 + with: + name: wrappers-linux-${{ matrix.arch }} + path: ${{ github.workspace }}/wrappers/build/** + retention-days: ${{ github.event_name != 'pull_request' && 30 || 1 }} + if-no-files-found: error + strategy: + matrix: + arch: + - x86_64 + - armhf + - aarch64 + android: + name: Android + needs: + - check-cache + if: needs.check-cache.outputs.wrappers-android-armeabi-v7a != 'true' || needs.check-cache.outputs.wrappers-android-arm64-v8a != 'true' || needs.check-cache.outputs.wrappers-android-x86 != 'true' || needs.check-cache.outputs.wrappers-android-x86_64 != 'true' + timeout-minutes: 90 + runs-on: ubuntu-20.04 + steps: + - name: Checkout Code + uses: actions/checkout@v4 + with: + submodules: recursive + ref: ${{ github.event.pull_request.head.sha }} + - name: Check Cache for android-${{ matrix.arch }} + id: check-cache + uses: actions/cache@v4 + with: + path: ./wrappers/build/** + key: wrappers-android-${{ matrix.arch }}-Release-${{hashFiles('./wrappers/**')}} + - name: Build Wrappers + if: steps.check-cache.outputs.cache-hit != 'true' + run: './wrappers/build-android.sh --ARCH=${{ matrix.arch }} --configuration=Release ' + - name: Store artifacts for wrappers-android-${{ matrix.arch }} + uses: actions/upload-artifact@v4 + with: + name: wrappers-android-${{ matrix.arch }} + path: ${{ github.workspace }}/wrappers/build/** + retention-days: ${{ github.event_name != 'pull_request' && 30 || 1 }} + if-no-files-found: error + strategy: + matrix: + arch: + - armeabi-v7a + - arm64-v8a + - x86 + - x86_64 + windows: + name: Windows + needs: + - check-cache + if: needs.check-cache.outputs.wrappers-windows-Win32 != 'true' || needs.check-cache.outputs.wrappers-windows-x64 != 'true' || needs.check-cache.outputs.wrappers-windows-ARM64 != 'true' + timeout-minutes: 90 + runs-on: windows-latest + steps: + - name: Checkout Code + uses: actions/checkout@v4 + with: + submodules: recursive + ref: ${{ github.event.pull_request.head.sha }} + - name: Check Cache for windows-${{ matrix.arch }} + id: check-cache + uses: actions/cache@v4 + with: + path: ./wrappers/build/** + key: wrappers-windows-${{ matrix.arch }}-Release-${{hashFiles('./wrappers/**')}} + - name: Setup MSVC + if: steps.check-cache.outputs.cache-hit != 'true' + run: Start-Process "C:\Program Files (x86)\Microsoft Visual Studio\Installer\vs_installer.exe" -ArgumentList 'modify --installPath "C:\Program Files\Microsoft Visual Studio\2022\Enterprise" --quiet --add Microsoft.VisualStudio.Component.VC.14.35.17.5.${{ startswith(matrix.arch, 'ARM') && matrix.arch || 'x86.x64' }}' -Wait -PassThru + shell: pwsh + - name: Build Wrappers + if: steps.check-cache.outputs.cache-hit != 'true' + run: pwsh ./wrappers/build.ps1 Windows -Platforms ${{ matrix.arch }} -ExtraCMakeArgs "-T v143,version=14.35" -Configuration Release -EnableLTO + - name: Store artifacts for wrappers-windows-${{ matrix.arch }} + uses: actions/upload-artifact@v4 + with: + name: wrappers-windows-${{ matrix.arch }} + path: ${{ github.workspace }}/wrappers/build/** + retention-days: ${{ github.event_name != 'pull_request' && 30 || 1 }} + if-no-files-found: error + strategy: + matrix: + arch: + - Win32 + - x64 + - ARM64 + uwp: + name: UWP + needs: + - check-cache + if: needs.check-cache.outputs.wrappers-windows-uwp-Win32 != 'true' || needs.check-cache.outputs.wrappers-windows-uwp-x64 != 'true' || needs.check-cache.outputs.wrappers-windows-uwp-ARM != 'true' || needs.check-cache.outputs.wrappers-windows-uwp-ARM64 != 'true' + timeout-minutes: 90 + runs-on: windows-latest + steps: + - name: Checkout Code + uses: actions/checkout@v4 + with: + submodules: recursive + ref: ${{ github.event.pull_request.head.sha }} + - name: Check Cache for windows-uwp-${{ matrix.arch }} + id: check-cache + uses: actions/cache@v4 + with: + path: ./wrappers/build/** + key: wrappers-windows-uwp-${{ matrix.arch }}-Release-${{hashFiles('./wrappers/**')}} + - name: Setup MSVC + if: steps.check-cache.outputs.cache-hit != 'true' + run: Start-Process "C:\Program Files (x86)\Microsoft Visual Studio\Installer\vs_installer.exe" -ArgumentList 'modify --installPath "C:\Program Files\Microsoft Visual Studio\2022\Enterprise" --quiet --add Microsoft.VisualStudio.Component.VC.14.35.17.5.${{ startswith(matrix.arch, 'ARM') && matrix.arch || 'x86.x64' }}' -Wait -PassThru + shell: pwsh + - name: Build Wrappers + if: steps.check-cache.outputs.cache-hit != 'true' + run: pwsh ./wrappers/build.ps1 WindowsStore -Platforms ${{ matrix.arch }} -ExtraCMakeArgs "-T v143,version=14.35" -Configuration Release -EnableLTO + - name: Store artifacts for wrappers-windows-uwp-${{ matrix.arch }} + uses: actions/upload-artifact@v4 + with: + name: wrappers-windows-uwp-${{ matrix.arch }} + path: ${{ github.workspace }}/wrappers/build/** + retention-days: ${{ github.event_name != 'pull_request' && 30 || 1 }} + if-no-files-found: error + strategy: + matrix: + arch: + - Win32 + - x64 + - ARM + - ARM64 diff --git a/.github/pkl-workflows/temp-outputs/wrappers.yml b/.github/pkl-workflows/temp-outputs/wrappers.yml deleted file mode 100644 index 31303025df..0000000000 --- a/.github/pkl-workflows/temp-outputs/wrappers.yml +++ /dev/null @@ -1,42 +0,0 @@ -# Do not modify! -# This file was generated from a template using https://github.com/apple/pkl - -name: wrappers -'on': - workflow_call: {} -env: - REALM_DISABLE_ANALYTICS: true - DOTNET_NOLOGO: true -jobs: - check-cache: - name: Check Cache - env: - CACHE_SKIP_SAVE: true - outputs: - wrappers-macos: ${{ steps.check-cache-macos.outputs.cache-hit }} - wrappers-catalyst: ${{ steps.check-cache-catalyst.outputs.cache-hit }} - wrappers-linux-x86_64: ${{ steps.check-cache-linux-x86_64.outputs.cache-hit }} - wrappers-linux-armhf: ${{ steps.check-cache-linux-armhf.outputs.cache-hit }} - wrappers-linux-aarch64: ${{ steps.check-cache-linux-aarch64.outputs.cache-hit }} - wrappers-android-armeabi-v7a: ${{ steps.check-cache-android-armeabi-v7a.outputs.cache-hit }} - wrappers-android-arm64-v8a: ${{ steps.check-cache-android-arm64-v8a.outputs.cache-hit }} - wrappers-android-x86: ${{ steps.check-cache-android-x86.outputs.cache-hit }} - wrappers-android-x86_64: ${{ steps.check-cache-android-x86_64.outputs.cache-hit }} - wrappers-windows-Win32: ${{ steps.check-cache-windows-Win32.outputs.cache-hit }} - wrappers-windows-x64: ${{ steps.check-cache-windows-x64.outputs.cache-hit }} - wrappers-windows-ARM64: ${{ steps.check-cache-windows-ARM64.outputs.cache-hit }} - wrappers-windows-upw-Win32: ${{ steps.check-cache-windows-upw-Win32.outputs.cache-hit }} - wrappers-windows-upw-x64: ${{ steps.check-cache-windows-upw-x64.outputs.cache-hit }} - wrappers-windows-upw-ARM: ${{ steps.check-cache-windows-upw-ARM.outputs.cache-hit }} - wrappers-windows-upw-ARM64: ${{ steps.check-cache-windows-upw-ARM64.outputs.cache-hit }} - wrappers-iOS-Device: ${{ steps.check-cache-iOS-Device.outputs.cache-hit }} - wrappers-tvOS-Device: ${{ steps.check-cache-tvOS-Device.outputs.cache-hit }} - wrappers-iOS-Simulator: ${{ steps.check-cache-iOS-Simulator.outputs.cache-hit }} - wrappers-tvOS-Simulator: ${{ steps.check-cache-tvOS-Simulator.outputs.cache-hit }} - strategy: - matrix: - os: - - ubuntu - - windows - runs-on: ${{ matrix.os }}-latest - steps: [] diff --git a/.github/templates/pr.yml b/.github/templates/pr.yml deleted file mode 100644 index 759ccc769b..0000000000 --- a/.github/templates/pr.yml +++ /dev/null @@ -1,95 +0,0 @@ -#@ load("@ytt:template", "template") -#@ load("common.lib.yml", "checkoutCode", "fetchPackageArtifacts", "nugetPackages") -#@ load("build.lib.yml", "deployBaas", "cleanupBaas", "runTests", "runNetCoreTests", "runWovenClassesTests", "runSourceGenerationTests", "buildUnity", "testUnity") ---- -name: PR Build -"on": - pull_request: - paths: - - '**.cs' - - '**.cpp' - - '**.hpp' - - '**.csproj' - - '**CMakeLists.txt' - - '**.ps1' - - '**.sh' - - '**.props' - - wrappers/realm-core - - .github/workflows/*.yml - - '!.github/workflows/main.yml' - - '!.github/workflows/publish-*.yml' - - .github/actions/** - - 'Tests/Tests.Android/Properties/AndroidManifest.xml' -env: - REALM_DISABLE_ANALYTICS: true - DOTNET_NOLOGO: true - -concurrency: - group: ${{ github.head_ref || github.run_id }} - cancel-in-progress: true - -jobs: - build-wrappers: - uses: ./.github/workflows/wrappers.yml - name: Wrappers - _: #@ template.replace(deployBaas(["Code Coverage"])) - build-packages: - uses: ./.github/workflows/build-packages.yml - name: Package - needs: - - build-wrappers - with: - build-docs: ${{ contains(github.head_ref, 'release') }} - _: #@ 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(runNetCoreTests('["net8.0"]')) - _: #@ template.replace(runTests("macOS", runSyncTests = False)) - _: #@ template.replace(runTests("iOS", runSyncTests = False)) - _: #@ template.replace(runTests("tvOS", runSyncTests = False)) - _: #@ template.replace(runTests("Android", runSyncTests = False, additionalSecrets=["AWS_DEVICEFARM_ACCESS_KEY_ID", "AWS_DEVICEFARM_SECRET_ACCESS_KEY", "DEVICEFARM_PROJECT_ARN", "DEVICEFARM_ANDROID_POOL_ARN"])) - _: #@ template.replace(runWovenClassesTests()) - _: #@ template.replace(runSourceGenerationTests()) - test-weaver: - uses: ./.github/workflows/test-weaver.yml - name: Test - _: #@ template.replace(runTests("Code Coverage")) - _: #@ template.replace(cleanupBaas(dependencies = ["Code Coverage"], targets = ["Code Coverage"])) - verify-namespaces: - runs-on: ubuntu-latest - name: Verify Namespaces - needs: - - build-packages - steps: - - #@ template.replace(checkoutCode("recursive", False)) - - #@ template.replace(fetchPackageArtifacts("needs.build-packages.outputs.package_version", packages = nugetPackages)) - - run: dotnet tool install ilspycmd -g --version 8.0.0.7345 - - name: Verify Namespaces - run: | - $isFailure = $false - Get-ChildItem ./Realm/packages -Filter *.nupkg | Foreach-Object { - $targetPath = Join-Path ./Realm/packages $_.BaseName - Expand-Archive $_.FullName -DestinationPath $targetPath - - Get-ChildItem $targetPath -Filter *.dll -Recurse | ForEach-Object { - if (-not ($_.FullName -match "runtimes")) { - $ilspyOutput = ilspycmd $_.FullName - - $parentDll = $_.FullName - - $ilspyOutput | ForEach-Object { - if ($_ -match "namespace.*Realm(\.|$)") { - Write-Output "::error file=$parentDll::Realm present in namespace - $($_)" - Set-Variable "isFailure" -Value $true - } - } - } - } - } - - if ($isFailure) { - exit 1 - } - shell: pwsh - diff --git a/.github/workflows/deploy-baas.yml b/.github/workflows/deploy-baas.yml deleted file mode 100755 index e1ff8b7431..0000000000 --- a/.github/workflows/deploy-baas.yml +++ /dev/null @@ -1,33 +0,0 @@ -name: deploy-baas -"on": - workflow_call: - inputs: - differentiators: - required: true - type: string - secrets: - BaaSaasApiKey: - required: true -env: - REALM_DISABLE_ANALYTICS: true - DOTNET_NOLOGO: true -jobs: - deploy-baas: - name: Deploy Baas - runs-on: ubuntu-latest - strategy: - matrix: - differentiator: ${{ fromJson(inputs.differentiators) }} - if: always() && !cancelled() && !contains(needs.*.result, 'failure') && !contains(needs.*.result, 'cancelled') - steps: - - name: Checkout code - uses: actions/checkout@v3 - with: - submodules: false - ref: ${{ github.event.pull_request.head.sha }} - - uses: actions/setup-dotnet@607fce577a46308457984d59e4954e075820f10a - with: - dotnet-version: 6.0.x - - name: Deploy Apps - run: dotnet run deploy-apps --baasaas-api-key=${{ secrets.BaaSaasApiKey }} --baas-differentiator=${{ matrix.differentiator }}-${{ github.run_id }}-${{ github.run_attempt }} - working-directory: Tools/DeployApps \ No newline at end of file diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index 086bb2ba54..f884b8225a 100755 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -30,11 +30,25 @@ jobs: name: Wrappers uses: ./.github/workflows/wrappers.yml deploy-baas: - uses: ./.github/workflows/deploy-baas.yml - with: - differentiators: '["code-coverage"]' - secrets: - BaaSaasApiKey: ${{ secrets.BAASAAS_API_KEY }} + name: Deploy BaaS + if: always() && !cancelled() && !contains(needs.*.result, 'failure') && !contains(needs.*.result, 'cancelled') + runs-on: ubuntu-latest + steps: + - name: Checkout Code + uses: actions/checkout@v4 + with: + submodules: recursive + ref: ${{ github.event.pull_request.head.sha }} + - uses: actions/setup-dotnet@607fce577a46308457984d59e4954e075820f10a + with: + dotnet-version: 6.0.x + - name: Deploy Apps + working-directory: Tools/DeployApps + run: dotnet run deploy-apps --baasaas-api-key=${{ secrets.BAASAAS_API_KEY }} --baas-differentiator=${{ matrix.differentiator }}-${{ github.run_id }}-${{ github.run_attempt }} + strategy: + matrix: + differentiator: + - code-coverage build-packages: name: Package needs: @@ -169,7 +183,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout Code - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: submodules: recursive ref: ${{ github.event.pull_request.head.sha }} From 92279ae2f8d11027aae89027049c73e5cfe078f3 Mon Sep 17 00:00:00 2001 From: Nikola Irinchev Date: Tue, 14 May 2024 14:41:26 +0200 Subject: [PATCH 06/39] Move cleanup-baas --- .github/pkl-workflows/PR.pkl | 21 +++++---------- .github/pkl-workflows/helpers/BaaS.pkl | 20 ++++++++++++++ .github/pkl-workflows/temp-outputs/PR.yml | 28 ++++++++++++------- .github/workflows/cleanup-baas.yml | 33 ----------------------- 4 files changed, 45 insertions(+), 57 deletions(-) delete mode 100755 .github/workflows/cleanup-baas.yml diff --git a/.github/pkl-workflows/PR.pkl b/.github/pkl-workflows/PR.pkl index 2ca95ce080..ad29548650 100644 --- a/.github/pkl-workflows/PR.pkl +++ b/.github/pkl-workflows/PR.pkl @@ -30,6 +30,10 @@ local JobNames = new JobNamesDefition{} local packages = List("Realm", "Realm.PlatformHelpers", "Realm.UnityUtils", "Realm.UnityWeaver") +local baasDifferentiators: Listing = new { + "code-coverage" +} + name = "PR Build" on { pull_request { @@ -64,7 +68,7 @@ jobs { uses = "./.github/workflows/wrappers.yml" name = "Wrappers" } - [JobNames.baas] = BaaS.deploy(new Listing { "code-coverage"}) // TODO: run baasaas tests for more targets + [JobNames.baas] = BaaS.deploy(baasDifferentiators) // TODO: run baasaas tests for more targets [JobNames.packages] = new ReusableWorkflowJob { uses = "./.github/workflows/build-packages.yml" name = "Package" @@ -141,20 +145,7 @@ jobs { ["BaaSaasApiKey"] = "${{ secrets.BAASAAS_API_KEY }}" } } - ["cleanup-baas"] = new ReusableWorkflowJob { - name = "Cleanup" - uses = "./.github/workflows/cleanup-baas.yml" - `if` = "always()" - needs { - JobNames.coverage - } - with { - ["differentiators"] = "[\"code-coverage\"]" - } - secrets { - ["BaaSaasApiKey"] = "${{ secrets.BAASAAS_API_KEY }}" - } - } + ["cleanup-baas"] = BaaS.cleanup(baasDifferentiators) ["verify-namespaces"] = new Job { `runs-on` = new UbuntuLatest{} name = "Verify Namespaces" diff --git a/.github/pkl-workflows/helpers/BaaS.pkl b/.github/pkl-workflows/helpers/BaaS.pkl index b36fcb762a..5de73ed2da 100644 --- a/.github/pkl-workflows/helpers/BaaS.pkl +++ b/.github/pkl-workflows/helpers/BaaS.pkl @@ -22,4 +22,24 @@ function deploy(differentiators: Listing): gha.MatrixJob = new { `working-directory` = "Tools/DeployApps" } } +} + +function cleanup(differentiators: Listing): gha.MatrixJob = new { + name = "Cleanup BaaS" + `runs-on` = new gha.UbuntuLatest{} + strategy { + matrix { + ["differentiator"] = differentiators + } + } + `if` = Common.ifNotCanceledCondition + steps { + Steps.checkout() + Steps.setupDotnet() + new gha.Step { + name = "Terminate Baas" + run = "dotnet run terminate-baas --baasaas-api-key=${{ secrets.BAASAAS_API_KEY }} --baas-differentiator=${{ matrix.differentiator }}-${{ github.run_id }}-${{ github.run_attempt }}" + `working-directory` = "Tools/DeployApps" + } + } } \ No newline at end of file diff --git a/.github/pkl-workflows/temp-outputs/PR.yml b/.github/pkl-workflows/temp-outputs/PR.yml index f884b8225a..8e0462d827 100644 --- a/.github/pkl-workflows/temp-outputs/PR.yml +++ b/.github/pkl-workflows/temp-outputs/PR.yml @@ -167,15 +167,25 @@ jobs: secrets: BaaSaasApiKey: ${{ secrets.BAASAAS_API_KEY }} cleanup-baas: - name: Cleanup - needs: - - test-code-coverage - if: always() - uses: ./.github/workflows/cleanup-baas.yml - with: - differentiators: '["code-coverage"]' - secrets: - BaaSaasApiKey: ${{ secrets.BAASAAS_API_KEY }} + name: Cleanup BaaS + if: always() && !cancelled() && !contains(needs.*.result, 'failure') && !contains(needs.*.result, 'cancelled') + runs-on: ubuntu-latest + steps: + - name: Checkout Code + uses: actions/checkout@v4 + with: + submodules: recursive + ref: ${{ github.event.pull_request.head.sha }} + - uses: actions/setup-dotnet@607fce577a46308457984d59e4954e075820f10a + with: + dotnet-version: 6.0.x + - name: Terminate Baas + working-directory: Tools/DeployApps + run: dotnet run terminate-baas --baasaas-api-key=${{ secrets.BAASAAS_API_KEY }} --baas-differentiator=${{ matrix.differentiator }}-${{ github.run_id }}-${{ github.run_attempt }} + strategy: + matrix: + differentiator: + - code-coverage verify-namespaces: name: Verify Namespaces needs: diff --git a/.github/workflows/cleanup-baas.yml b/.github/workflows/cleanup-baas.yml deleted file mode 100755 index 2237b54bd4..0000000000 --- a/.github/workflows/cleanup-baas.yml +++ /dev/null @@ -1,33 +0,0 @@ -name: cleanup-baas -"on": - workflow_call: - inputs: - differentiators: - required: true - type: string - secrets: - BaaSaasApiKey: - required: true -env: - REALM_DISABLE_ANALYTICS: true - DOTNET_NOLOGO: true -jobs: - cleanup-baas: - name: Cleanup Baas - runs-on: ubuntu-latest - strategy: - matrix: - differentiator: ${{ fromJson(inputs.differentiators) }} - timeout-minutes: 5 - steps: - - name: Checkout code - uses: actions/checkout@v3 - with: - submodules: false - ref: ${{ github.event.pull_request.head.sha }} - - uses: actions/setup-dotnet@607fce577a46308457984d59e4954e075820f10a - with: - dotnet-version: 6.0.x - - name: Terminate Baas - run: dotnet run terminate-baas --baasaas-api-key=${{ secrets.BaaSaasApiKey }} --baas-differentiator=${{ matrix.differentiator }}-${{ github.run_id }}-${{ github.run_attempt }} - working-directory: Tools/DeployApps \ No newline at end of file From 74d28eed91fb73d802045f16a143e1ba4b085d66 Mon Sep 17 00:00:00 2001 From: Nikola Irinchev Date: Tue, 14 May 2024 14:56:06 +0200 Subject: [PATCH 07/39] Actually commit the changes --- .github/workflows/pr.yml | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index f884b8225a..8e0462d827 100755 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -167,15 +167,25 @@ jobs: secrets: BaaSaasApiKey: ${{ secrets.BAASAAS_API_KEY }} cleanup-baas: - name: Cleanup - needs: - - test-code-coverage - if: always() - uses: ./.github/workflows/cleanup-baas.yml - with: - differentiators: '["code-coverage"]' - secrets: - BaaSaasApiKey: ${{ secrets.BAASAAS_API_KEY }} + name: Cleanup BaaS + if: always() && !cancelled() && !contains(needs.*.result, 'failure') && !contains(needs.*.result, 'cancelled') + runs-on: ubuntu-latest + steps: + - name: Checkout Code + uses: actions/checkout@v4 + with: + submodules: recursive + ref: ${{ github.event.pull_request.head.sha }} + - uses: actions/setup-dotnet@607fce577a46308457984d59e4954e075820f10a + with: + dotnet-version: 6.0.x + - name: Terminate Baas + working-directory: Tools/DeployApps + run: dotnet run terminate-baas --baasaas-api-key=${{ secrets.BAASAAS_API_KEY }} --baas-differentiator=${{ matrix.differentiator }}-${{ github.run_id }}-${{ github.run_attempt }} + strategy: + matrix: + differentiator: + - code-coverage verify-namespaces: name: Verify Namespaces needs: From 1fd7e17dbf579fee2301ae35e95497436440e354 Mon Sep 17 00:00:00 2001 From: Nikola Irinchev Date: Tue, 14 May 2024 16:01:32 +0200 Subject: [PATCH 08/39] Move test-net-framework --- .github/pkl-workflows/PR.pkl | 62 ++-------------- .github/pkl-workflows/helpers/BaaS.pkl | 12 ++-- .github/pkl-workflows/helpers/Common.pkl | 5 ++ .github/pkl-workflows/helpers/Lint.pkl | 67 ++++++++++++++++++ .github/pkl-workflows/helpers/Steps.pkl | 31 +++++++- .github/pkl-workflows/helpers/Test.pkl | 90 ++++++++++++++++++++++++ .github/workflows/lint.yml | 15 ---- .github/workflows/pr.yml | 55 +++++++++++++-- .github/workflows/test-net-framework.yml | 62 ---------------- 9 files changed, 255 insertions(+), 144 deletions(-) create mode 100644 .github/pkl-workflows/helpers/Lint.pkl create mode 100644 .github/pkl-workflows/helpers/Test.pkl delete mode 100644 .github/workflows/lint.yml delete mode 100755 .github/workflows/test-net-framework.yml diff --git a/.github/pkl-workflows/PR.pkl b/.github/pkl-workflows/PR.pkl index ad29548650..b59e015330 100644 --- a/.github/pkl-workflows/PR.pkl +++ b/.github/pkl-workflows/PR.pkl @@ -3,8 +3,9 @@ module pr amends "GithubAction/GithubAction.pkl" import "helpers/Common.pkl" -import "helpers/Steps.pkl" import "helpers/BaaS.pkl" +import "helpers/Lint.pkl" +import "helpers/Test.pkl" as TestJobs local class JobNamesDefition { const wrappers: String = "build-wrappers" @@ -28,8 +29,6 @@ local function createTestJob(workflow: String): ReusableWorkflowJob = new Reusab local JobNames = new JobNamesDefition{} -local packages = List("Realm", "Realm.PlatformHelpers", "Realm.UnityUtils", "Realm.UnityWeaver") - local baasDifferentiators: Listing = new { "code-coverage" } @@ -103,7 +102,7 @@ jobs { } `if` = Common.ifNotCanceledCondition } - ["test-net-framework"] = createTestJob("test-net-framework") + ["test-net-framework"] = TestJobs.netFramework(JobNames.packages, baasDifferentiators) ["test-uwp-managed"] = (createTestJob("test-uwp-managed")) { secrets { ["Pfx_Password"] = "${{ secrets.Pfx_Password }}" @@ -146,57 +145,6 @@ jobs { } } ["cleanup-baas"] = BaaS.cleanup(baasDifferentiators) - ["verify-namespaces"] = new Job { - `runs-on` = new UbuntuLatest{} - name = "Verify Namespaces" - needs { - JobNames.packages - } - steps { - Steps.checkout() - for (_package in packages) { - new { - name = "Fetch \(_package)" - uses = "actions/download-artifact@v3" - with { - ["name"] = "\(_package).${{ needs.\(JobNames.packages).outputs.package_version }}" - ["path"] = "${{ github.workspace }}/Realm/packages/" - } - } - } - new { - run = "dotnet tool install ilspycmd -g --version 8.0.0.7345" - } - new { - name = "Verify Namespaces" - run = """ - $isFailure = $false - Get-ChildItem ./Realm/packages -Filter *.nupkg | Foreach-Object { - $targetPath = Join-Path ./Realm/packages $_.BaseName - Expand-Archive $_.FullName -DestinationPath $targetPath - - Get-ChildItem $targetPath -Filter *.dll -Recurse | ForEach-Object { - if (-not ($_.FullName -match "runtimes")) { - $ilspyOutput = ilspycmd $_.FullName - - $parentDll = $_.FullName - - $ilspyOutput | ForEach-Object { - if ($_ -match "namespace.*Realm(\\.|$)") { - Write-Output "::error file=$parentDll::Realm present in namespace - $($_)" - Set-Variable "isFailure" -Value $true - } - } - } - } - } - - if ($isFailure) { - exit 1 - } - """ - shell = "pwsh" - } - } - } + ["verify-namespaces"] = Lint.verifyNamespaces(JobNames.packages) + ["lint"] = Lint.lint() } diff --git a/.github/pkl-workflows/helpers/BaaS.pkl b/.github/pkl-workflows/helpers/BaaS.pkl index 5de73ed2da..35d4ddfc76 100644 --- a/.github/pkl-workflows/helpers/BaaS.pkl +++ b/.github/pkl-workflows/helpers/BaaS.pkl @@ -16,14 +16,16 @@ function deploy(differentiators: Listing): gha.MatrixJob = new { steps { Steps.checkout() Steps.setupDotnet() - new gha.Step { - name = "Deploy Apps" - run = "dotnet run deploy-apps --baasaas-api-key=${{ secrets.BAASAAS_API_KEY }} --baas-differentiator=${{ matrix.differentiator }}-${{ github.run_id }}-${{ github.run_attempt }}" - `working-directory` = "Tools/DeployApps" - } + ...deployStep("${{ matrix.differentiator }}", true) } } +function deployStep(differentiator: String, shouldDeploy: Boolean): List = if (shouldDeploy) List(new gha.Step { + name = "Deploy Apps" + run = "dotnet run deploy-apps --baasaas-api-key=${{ secrets.BAASAAS_API_KEY }} --baas-differentiator=\(differentiator)-${{ github.run_id }}-${{ github.run_attempt }}" + `working-directory` = "Tools/DeployApps" +}) else List() + function cleanup(differentiators: Listing): gha.MatrixJob = new { name = "Cleanup BaaS" `runs-on` = new gha.UbuntuLatest{} diff --git a/.github/pkl-workflows/helpers/Common.pkl b/.github/pkl-workflows/helpers/Common.pkl index da848f2cf2..f5a54f68ce 100644 --- a/.github/pkl-workflows/helpers/Common.pkl +++ b/.github/pkl-workflows/helpers/Common.pkl @@ -26,3 +26,8 @@ const defaultEnv: Mapping = new { const function applePlatformTargets(_transform: (String, String) -> String): List = applePlatforms.map((platform) -> appleTargets.map((target) -> _transform.apply(platform, target))).flatten() const ifNotCanceledCondition = "always() && !cancelled() && !contains(needs.*.result, 'failure') && !contains(needs.*.result, 'cancelled')" + +const nugetPackages: List = List("Realm", "Realm.PlatformHelpers") +const packages: List = nugetPackages + List("Realm.UnityUtils", "Realm.UnityWeaver") + +const testTimeout = 60 diff --git a/.github/pkl-workflows/helpers/Lint.pkl b/.github/pkl-workflows/helpers/Lint.pkl new file mode 100644 index 0000000000..425fef5eb7 --- /dev/null +++ b/.github/pkl-workflows/helpers/Lint.pkl @@ -0,0 +1,67 @@ +module lint + +import "../GithubAction/GithubAction.pkl" as gha +import "Common.pkl" +import "Steps.pkl" + +function lint(): gha.Job = new { + name = "Verify TODOs" + `runs-on` = new gha.UbuntuLatest{} + steps { + Steps.checkout() + new gha.Step { + uses = "nirinchev/verify-todo@9be6f76daddad71433e5deb1b58c517490e5c66e" + with { + ["token"] = "${{ secrets.GITHUB_TOKEN }}" + ["include"] = "**/*.+(cs|cpp|hpp)" + ["exclude"] = "wrappers/realm-core/**" + ["pattern"] = "\\\\WR[A-Z]+-[0-9]+" + } + } + } +} + +function verifyNamespaces(packageJob: String): gha.Job = new { + `runs-on` = new gha.UbuntuLatest{} + name = "Verify Namespaces" + needs { + packageJob + } + steps { + Steps.checkout() + ...Steps.fetchPackages(packageJob, null) + new { + run = "dotnet tool install ilspycmd -g --version 8.0.0.7345" + } + new { + name = "Verify Namespaces" + run = """ + $isFailure = $false + Get-ChildItem ./Realm/packages -Filter *.nupkg | Foreach-Object { + $targetPath = Join-Path ./Realm/packages $_.BaseName + Expand-Archive $_.FullName -DestinationPath $targetPath + + Get-ChildItem $targetPath -Filter *.dll -Recurse | ForEach-Object { + if (-not ($_.FullName -match "runtimes")) { + $ilspyOutput = ilspycmd $_.FullName + + $parentDll = $_.FullName + + $ilspyOutput | ForEach-Object { + if ($_ -match "namespace.*Realm(\\.|$)") { + Write-Output "::error file=$parentDll::Realm present in namespace - $($_)" + Set-Variable "isFailure" -Value $true + } + } + } + } + } + + if ($isFailure) { + exit 1 + } + """ + shell = "pwsh" + } + } +} \ No newline at end of file diff --git a/.github/pkl-workflows/helpers/Steps.pkl b/.github/pkl-workflows/helpers/Steps.pkl index 43089292d0..e1a2cf61c4 100644 --- a/.github/pkl-workflows/helpers/Steps.pkl +++ b/.github/pkl-workflows/helpers/Steps.pkl @@ -1,4 +1,5 @@ import "../GithubAction/GithubAction.pkl" as gha +import "Common.pkl" const function checkout(): gha.Step = new { name = "Checkout Code" @@ -39,4 +40,32 @@ const function setupDotnet(): gha.Step = new { with { ["dotnet-version"] = "6.0.x" } -} \ No newline at end of file +} + +const function registerProblemMatchers(): gha.Step = new { + name = "Register csc problem matcher" + run = """ + echo "::add-matcher::.github/problem-matchers/csc.json" + echo "::add-matcher::.github/problem-matchers/msvc.json" + """ +} + +const function fetchPackages(packageJob: String, _packages: List?): List = (_packages ?? Common.packages).map((package) -> new gha.Step { + name = "Fetch \(package)" + uses = "actions/download-artifact@v3" + with { + ["name"] = "\(package).${{ needs.\(packageJob).outputs.package_version }}" + ["path"] = "${{ github.workspace }}/Realm/packages/" + } +}) + +const function addMSBuildToPath(): gha.Step = new { + name = "Add msbuild to PATH" + uses = "microsoft/setup-msbuild@0b44c6745b7e81956596964100aadb92d667c497" + `if` = "${{ runner.os == 'Windows' }}" +} + +const function msbuild(project: String, properties: Mapping): gha.Step = new { + name = "Build \(project)" + run = "msbuild \(project) -p:Configuration=\(Common.configuration) -restore \(properties.toMap().entries.map((kvp) -> "-p:\(kvp.key)=\(kvp.value)").join(" "))" +} diff --git a/.github/pkl-workflows/helpers/Test.pkl b/.github/pkl-workflows/helpers/Test.pkl new file mode 100644 index 0000000000..ef8f7cb850 --- /dev/null +++ b/.github/pkl-workflows/helpers/Test.pkl @@ -0,0 +1,90 @@ +module test + +import "../GithubAction/GithubAction.pkl" as gha +import "Common.pkl" +import "Steps.pkl" +import "BaaS.pkl" + +local const outputFile = "TestResults.xml" + +function netFramework(_packageJob: String, syncDifferentiators: Listing): gha.Job = new { + local testConfig = new TestConfig { + packageJob = _packageJob + runSyncTests = syncDifferentiators.toList().contains("net-framework") + syncDifferentiator = "net-framework" + title = ".NET Framework" + + } + name = "Test \(testConfig.title)" + needs { + _packageJob + } + `if` = Common.ifNotCanceledCondition + `runs-on` = new gha.WindowsLatest{} + `timeout-minutes` = Common.testTimeout + steps { + ...prepareTests(testConfig) + Steps.addMSBuildToPath() + buildTests(_packageJob, "Tests/Realm.Tests", new Mapping{}) + new gha.Step { + name = "Run the tests" + run = "./Tests/Realm/Tests/bin/\(Common.configuration)/net461/Realm.Tests.exe --result=\(outputFile) --labels=After \(baasTestArgs(testConfig))" + } + ...reportTestResults(testConfig) + } +} + +local function prepareTests(config: TestConfig): Listing = new Listing { + Steps.checkout() + ...cleanWorkspace(config.shouldCleanWorkspace) + ...fetchTestArtifacts(config.packageJob, config.useWrappers) + ...BaaS.deployStep(config.syncDifferentiator, config.runSyncTests) +} + +local function cleanWorkspace(shouldClean: Boolean): List = if (shouldClean) List(new gha.Step { + name = "Cleanup Workspace" + run = "git clean -fdx" +}) else List() + +local function fetchTestArtifacts(packageJob: String, useWrappers: Boolean): List = if (useWrappers) + Steps.fetchPackages(packageJob, Common.nugetPackages) + else Steps.fetchPackages(packageJob, Common.nugetPackages) + +local function buildTests(packageJob: String, projectPath: String, properties: Mapping): gha.Step = Steps.msbuild(projectPath, new Mapping{ + ["RestoreConfigFile"] = "Tests/Test.NuGet.Config" + ["UseRealmNupkgsWithVersion"] = "${{ needs.\(packageJob).outputs.package_version }}" + ...properties +}) + +local function baasTestArgs(config: TestConfig): String = if (config.runSyncTests) " --baasaas-api-key=${{ secrets.BAASAAS_API_KEY}} --baas-differentiator=\(config.syncDifferentiator)-${{ github.run_id }}-${{ github.run_attempt }}" else "" + +local function reportTestResults(config: TestConfig): Listing = new { + local _outputFile = if (config.transformResults) "\(outputFile)_transformed.xml" else outputFile + ...(if (config.transformResults) List(new gha.Step { + name = "Transform Results" + run = "xsltproc --output \(_outputFile) Tests/Realm.Tests/EmbeddedResources/nunit3-junit.xslt \(outputFile)" + }) else List()) + new gha.Step { + name = "Publish Unit Test Results" + uses = "LaPeste/test-reporter@510caf50a955b1003bec48a6494be4d6537f3a0b" + `if` = "always()" + with { + ["name"] = "Results \(config.title)" + ["path"] = _outputFile + ["reporter"] = "java-junit" + ["list-suites"] = "failed" + ["path-replace-backslashes"] = true + ["fail-on-error"] = true + } + } +} + +local class TestConfig { + packageJob: String + useWrappers: Boolean = false + shouldCleanWorkspace: Boolean = false + runSyncTests: Boolean = false + syncDifferentiator: String + transformResults: Boolean = false + title: String +} diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml deleted file mode 100644 index d4fdbeacb5..0000000000 --- a/.github/workflows/lint.yml +++ /dev/null @@ -1,15 +0,0 @@ -name: lint -"on": - pull_request: -jobs: - verify-todos: - runs-on: ubuntu-latest - name: Verify TODOs - steps: - - uses: actions/checkout@v3 - - uses: nirinchev/verify-todo@9be6f76daddad71433e5deb1b58c517490e5c66e - with: - token: ${{ secrets.GITHUB_TOKEN }} - include: "**/*.+(cs|cpp|hpp)" - exclude: "wrappers/realm-core/**" - pattern: "\\WR[A-Z]+-[0-9]+" \ No newline at end of file diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index 8e0462d827..3d886dcc86 100755 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -75,13 +75,45 @@ jobs: settings: '["Mono-Net4"]' platform: '[{ "os": "windows", "testPlatform": "Windows64" }, { "os": "linux", "testPlatform": "Linux64" }]' test-net-framework: - name: Test + name: Test .NET Framework needs: - build-packages if: always() && !cancelled() && !contains(needs.*.result, 'failure') && !contains(needs.*.result, 'cancelled') - uses: ./.github/workflows/test-net-framework.yml - with: - version: ${{ needs.build-packages.outputs.package_version }} + timeout-minutes: 60 + runs-on: windows-latest + steps: + - name: Checkout Code + uses: actions/checkout@v4 + with: + submodules: recursive + ref: ${{ github.event.pull_request.head.sha }} + - name: Fetch Realm + uses: actions/download-artifact@v3 + with: + name: Realm.${{ needs.build-packages.outputs.package_version }} + path: ${{ github.workspace }}/Realm/packages/ + - name: Fetch Realm.PlatformHelpers + uses: actions/download-artifact@v3 + with: + name: Realm.PlatformHelpers.${{ needs.build-packages.outputs.package_version }} + path: ${{ github.workspace }}/Realm/packages/ + - name: Add msbuild to PATH + if: ${{ runner.os == 'Windows' }} + uses: microsoft/setup-msbuild@0b44c6745b7e81956596964100aadb92d667c497 + - 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 }} + - name: Run the tests + run: './Tests/Realm/Tests/bin/Release/net461/Realm.Tests.exe --result=TestResults.xml --labels=After ' + - name: Publish Unit Test Results + if: always() + uses: LaPeste/test-reporter@510caf50a955b1003bec48a6494be4d6537f3a0b + with: + name: Results .NET Framework + path: TestResults.xml + reporter: java-junit + list-suites: failed + path-replace-backslashes: true + fail-on-error: true test-uwp-managed: name: Test needs: @@ -245,3 +277,18 @@ jobs: exit 1 } shell: pwsh + lint: + name: Verify TODOs + runs-on: ubuntu-latest + steps: + - name: Checkout Code + uses: actions/checkout@v4 + with: + submodules: recursive + ref: ${{ github.event.pull_request.head.sha }} + - uses: nirinchev/verify-todo@9be6f76daddad71433e5deb1b58c517490e5c66e + with: + token: ${{ secrets.GITHUB_TOKEN }} + include: '**/*.+(cs|cpp|hpp)' + exclude: wrappers/realm-core/** + pattern: \\WR[A-Z]+-[0-9]+ diff --git a/.github/workflows/test-net-framework.yml b/.github/workflows/test-net-framework.yml deleted file mode 100755 index 3402206a13..0000000000 --- a/.github/workflows/test-net-framework.yml +++ /dev/null @@ -1,62 +0,0 @@ -name: test-net-framework -"on": - workflow_call: - inputs: - version: - required: true - type: string - secrets: - BaaSaasApiKey: - required: false -env: - REALM_DISABLE_ANALYTICS: true - DOTNET_NOLOGO: true -jobs: - run-tests: - runs-on: windows-latest - name: .NET Framework - timeout-minutes: 60 - 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/ - - name: Deploy Baas (alternative) - env: - apiKey: ${{ secrets.BaaSaasApiKey }} - if: ${{ env.apiKey }} - run: dotnet run deploy-apps --baasaas-api-key=${{ secrets.BaaSaasApiKey }} --baas-differentiator=net-framework-${{ github.run_id }}-${{ github.run_attempt }} - working-directory: Tools/DeployApps - - name: Add msbuild to PATH - uses: microsoft/setup-msbuild@0b44c6745b7e81956596964100aadb92d667c497 - if: ${{ runner.os == 'Windows' }} - - 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 --baasaas-api-key=${{ secrets.BaaSaasApiKey}} --baas-differentiator=net-framework-${{ github.run_id }}-${{ github.run_attempt }} - - name: Publish Unit Test Results - uses: LaPeste/test-reporter@510caf50a955b1003bec48a6494be4d6537f3a0b - if: always() - with: - name: Results .NET Framework - path: TestResults.Windows.xml - reporter: java-junit - list-suites: failed - list-tests: failed - path-replace-backslashes: true - fail-on-error: true From e535de171b8372cafcd88e9872bef36b893b0afe Mon Sep 17 00:00:00 2001 From: Nikola Irinchev Date: Tue, 14 May 2024 22:20:50 +0200 Subject: [PATCH 09/39] Use download-artifact@v4 --- .github/pkl-workflows/helpers/Steps.pkl | 2 +- .github/pkl-workflows/{PR.pkl => pr.pkl} | 0 .github/pkl-workflows/temp-outputs/PR.yml | 247 ------- .../pkl-workflows/temp-outputs/Wrappers.yml | 640 ------------------ .../{Wrappers.pkl => wrappers.pkl} | 0 .github/templates/common.lib.yml | 2 +- .github/workflows/build-packages.yml | 40 +- .github/workflows/build-unity.yml | 8 +- .github/workflows/main.yml | 12 +- .github/workflows/pr.yml | 12 +- .github/workflows/test-android.yml | 8 +- .github/workflows/test-code-coverage.yml | 40 +- .github/workflows/test-ios.yml | 8 +- .github/workflows/test-macos.yml | 8 +- .github/workflows/test-net-core.yml | 4 +- .github/workflows/test-tvos.yml | 4 +- .github/workflows/test-unity.yml | 8 +- .github/workflows/test-uwp-managed.yml | 4 +- .github/workflows/test-woven-classes.yml | 4 +- Tools/DeployApps/BaasClient.cs | 2 +- 20 files changed, 83 insertions(+), 970 deletions(-) rename .github/pkl-workflows/{PR.pkl => pr.pkl} (100%) delete mode 100644 .github/pkl-workflows/temp-outputs/PR.yml delete mode 100644 .github/pkl-workflows/temp-outputs/Wrappers.yml rename .github/pkl-workflows/{Wrappers.pkl => wrappers.pkl} (100%) diff --git a/.github/pkl-workflows/helpers/Steps.pkl b/.github/pkl-workflows/helpers/Steps.pkl index e1a2cf61c4..2671607ed2 100644 --- a/.github/pkl-workflows/helpers/Steps.pkl +++ b/.github/pkl-workflows/helpers/Steps.pkl @@ -52,7 +52,7 @@ const function registerProblemMatchers(): gha.Step = new { const function fetchPackages(packageJob: String, _packages: List?): List = (_packages ?? Common.packages).map((package) -> new gha.Step { name = "Fetch \(package)" - uses = "actions/download-artifact@v3" + uses = "actions/download-artifact@v4" with { ["name"] = "\(package).${{ needs.\(packageJob).outputs.package_version }}" ["path"] = "${{ github.workspace }}/Realm/packages/" diff --git a/.github/pkl-workflows/PR.pkl b/.github/pkl-workflows/pr.pkl similarity index 100% rename from .github/pkl-workflows/PR.pkl rename to .github/pkl-workflows/pr.pkl diff --git a/.github/pkl-workflows/temp-outputs/PR.yml b/.github/pkl-workflows/temp-outputs/PR.yml deleted file mode 100644 index 8e0462d827..0000000000 --- a/.github/pkl-workflows/temp-outputs/PR.yml +++ /dev/null @@ -1,247 +0,0 @@ -# Do not modify! -# This file was generated from a template using https://github.com/apple/pkl - -name: PR Build -'on': - pull_request: - paths: - - '**.cs' - - '**.cpp' - - '**.hpp' - - '**.csproj' - - '**CMakeLists.txt' - - '**.ps1' - - '**.sh' - - '**.props' - - wrappers/realm-core - - .github/workflows/*.yml - - '!.github/workflows/main.yml' - - '!.github/workflows/publish-*.yml' - - .github/actions/** - - Tests/Tests.Android/Properties/AndroidManifest.xml -env: - REALM_DISABLE_ANALYTICS: true - DOTNET_NOLOGO: true -concurrency: - group: ${{ github.head_ref || github.run_id }} - cancel-in-progress: true -jobs: - build-wrappers: - name: Wrappers - uses: ./.github/workflows/wrappers.yml - deploy-baas: - name: Deploy BaaS - if: always() && !cancelled() && !contains(needs.*.result, 'failure') && !contains(needs.*.result, 'cancelled') - runs-on: ubuntu-latest - steps: - - name: Checkout Code - uses: actions/checkout@v4 - with: - submodules: recursive - ref: ${{ github.event.pull_request.head.sha }} - - uses: actions/setup-dotnet@607fce577a46308457984d59e4954e075820f10a - with: - dotnet-version: 6.0.x - - name: Deploy Apps - working-directory: Tools/DeployApps - run: dotnet run deploy-apps --baasaas-api-key=${{ secrets.BAASAAS_API_KEY }} --baas-differentiator=${{ matrix.differentiator }}-${{ github.run_id }}-${{ github.run_attempt }} - strategy: - matrix: - differentiator: - - code-coverage - build-packages: - name: Package - needs: - - build-wrappers - uses: ./.github/workflows/build-packages.yml - with: - build-docs: ${{ contains(github.head_ref, 'release') }} - build-unity: - name: Package - needs: - - build-packages - if: always() && !cancelled() && !contains(needs.*.result, 'failure') && !contains(needs.*.result, 'cancelled') - uses: ./.github/workflows/build-unity.yml - with: - version: ${{ needs.build-packages.outputs.package_version }} - test-unity: - name: Test - needs: - - build-unity - if: always() && !cancelled() && !contains(needs.*.result, 'failure') && !contains(needs.*.result, 'cancelled') - uses: ./.github/workflows/test-unity.yml - with: - version: ${{ needs.build-packages.outputs.package_version }} - settings: '["Mono-Net4"]' - platform: '[{ "os": "windows", "testPlatform": "Windows64" }, { "os": "linux", "testPlatform": "Linux64" }]' - test-net-framework: - name: Test - needs: - - build-packages - if: always() && !cancelled() && !contains(needs.*.result, 'failure') && !contains(needs.*.result, 'cancelled') - uses: ./.github/workflows/test-net-framework.yml - with: - version: ${{ needs.build-packages.outputs.package_version }} - test-uwp-managed: - name: Test - needs: - - build-packages - if: always() && !cancelled() && !contains(needs.*.result, 'failure') && !contains(needs.*.result, 'cancelled') - uses: ./.github/workflows/test-uwp-managed.yml - with: - version: ${{ needs.build-packages.outputs.package_version }} - secrets: - Pfx_Password: ${{ secrets.Pfx_Password }} - Base64_Encoded_Pfx: ${{ secrets.Base64_Encoded_Pfx }} - test-net-core: - name: Test - needs: - - build-packages - if: always() && !cancelled() && !contains(needs.*.result, 'failure') && !contains(needs.*.result, 'cancelled') - uses: ./.github/workflows/test-net-core.yml - with: - version: ${{ needs.build-packages.outputs.package_version }} - framework: '["net8.0"]' - test-macos: - name: Test - needs: - - build-packages - if: always() && !cancelled() && !contains(needs.*.result, 'failure') && !contains(needs.*.result, 'cancelled') - uses: ./.github/workflows/test-macos.yml - with: - version: ${{ needs.build-packages.outputs.package_version }} - test-ios: - name: Test - needs: - - build-packages - if: always() && !cancelled() && !contains(needs.*.result, 'failure') && !contains(needs.*.result, 'cancelled') - uses: ./.github/workflows/test-ios.yml - with: - version: ${{ needs.build-packages.outputs.package_version }} - test-tvos: - name: Test - needs: - - build-packages - if: always() && !cancelled() && !contains(needs.*.result, 'failure') && !contains(needs.*.result, 'cancelled') - uses: ./.github/workflows/test-tvos.yml - with: - version: ${{ needs.build-packages.outputs.package_version }} - test-android: - name: Test - needs: - - build-packages - if: always() && !cancelled() && !contains(needs.*.result, 'failure') && !contains(needs.*.result, 'cancelled') - uses: ./.github/workflows/test-android.yml - with: - version: ${{ needs.build-packages.outputs.package_version }} - secrets: - AWS_DEVICEFARM_ACCESS_KEY_ID: ${{ secrets.AWS_DEVICEFARM_ACCESS_KEY_ID }} - AWS_DEVICEFARM_SECRET_ACCESS_KEY: ${{ secrets.AWS_DEVICEFARM_SECRET_ACCESS_KEY }} - DEVICEFARM_PROJECT_ARN: ${{ secrets.DEVICEFARM_PROJECT_ARN }} - DEVICEFARM_ANDROID_POOL_ARN: ${{ secrets.DEVICEFARM_ANDROID_POOL_ARN }} - test-woven-classes: - name: Test - needs: - - build-packages - if: always() && !cancelled() && !contains(needs.*.result, 'failure') && !contains(needs.*.result, 'cancelled') - uses: ./.github/workflows/test-woven-classes.yml - with: - version: ${{ needs.build-packages.outputs.package_version }} - test-source-generation: - name: Test - if: always() && !cancelled() && !contains(needs.*.result, 'failure') && !contains(needs.*.result, 'cancelled') - uses: ./.github/workflows/test-source-generation.yml - test-weaver: - name: Test - if: always() && !cancelled() && !contains(needs.*.result, 'failure') && !contains(needs.*.result, 'cancelled') - uses: ./.github/workflows/test-weaver.yml - test-code-coverage: - name: Test - needs: - - build-packages - - deploy-baas - if: always() && !cancelled() && !contains(needs.*.result, 'failure') && !contains(needs.*.result, 'cancelled') - uses: ./.github/workflows/test-code-coverage.yml - with: - version: ${{ needs.build-packages.outputs.package_version }} - secrets: - BaaSaasApiKey: ${{ secrets.BAASAAS_API_KEY }} - cleanup-baas: - name: Cleanup BaaS - if: always() && !cancelled() && !contains(needs.*.result, 'failure') && !contains(needs.*.result, 'cancelled') - runs-on: ubuntu-latest - steps: - - name: Checkout Code - uses: actions/checkout@v4 - with: - submodules: recursive - ref: ${{ github.event.pull_request.head.sha }} - - uses: actions/setup-dotnet@607fce577a46308457984d59e4954e075820f10a - with: - dotnet-version: 6.0.x - - name: Terminate Baas - working-directory: Tools/DeployApps - run: dotnet run terminate-baas --baasaas-api-key=${{ secrets.BAASAAS_API_KEY }} --baas-differentiator=${{ matrix.differentiator }}-${{ github.run_id }}-${{ github.run_attempt }} - strategy: - matrix: - differentiator: - - code-coverage - verify-namespaces: - name: Verify Namespaces - needs: - - build-packages - runs-on: ubuntu-latest - steps: - - name: Checkout Code - uses: actions/checkout@v4 - with: - submodules: recursive - ref: ${{ github.event.pull_request.head.sha }} - - name: Fetch Realm - uses: actions/download-artifact@v3 - with: - name: Realm.${{ needs.build-packages.outputs.package_version }} - path: ${{ github.workspace }}/Realm/packages/ - - name: Fetch Realm.PlatformHelpers - uses: actions/download-artifact@v3 - with: - name: Realm.PlatformHelpers.${{ needs.build-packages.outputs.package_version }} - path: ${{ github.workspace }}/Realm/packages/ - - name: Fetch Realm.UnityUtils - uses: actions/download-artifact@v3 - with: - name: Realm.UnityUtils.${{ needs.build-packages.outputs.package_version }} - path: ${{ github.workspace }}/Realm/packages/ - - name: Fetch Realm.UnityWeaver - uses: actions/download-artifact@v3 - with: - name: Realm.UnityWeaver.${{ needs.build-packages.outputs.package_version }} - path: ${{ github.workspace }}/Realm/packages/ - - run: dotnet tool install ilspycmd -g --version 8.0.0.7345 - - name: Verify Namespaces - run: |- - $isFailure = $false - Get-ChildItem ./Realm/packages -Filter *.nupkg | Foreach-Object { - $targetPath = Join-Path ./Realm/packages $_.BaseName - Expand-Archive $_.FullName -DestinationPath $targetPath - - Get-ChildItem $targetPath -Filter *.dll -Recurse | ForEach-Object { - if (-not ($_.FullName -match "runtimes")) { - $ilspyOutput = ilspycmd $_.FullName - - $parentDll = $_.FullName - - $ilspyOutput | ForEach-Object { - if ($_ -match "namespace.*Realm(\.|$)") { - Write-Output "::error file=$parentDll::Realm present in namespace - $($_)" - Set-Variable "isFailure" -Value $true - } - } - } - } - } - - if ($isFailure) { - exit 1 - } - shell: pwsh diff --git a/.github/pkl-workflows/temp-outputs/Wrappers.yml b/.github/pkl-workflows/temp-outputs/Wrappers.yml deleted file mode 100644 index edd27f0cc8..0000000000 --- a/.github/pkl-workflows/temp-outputs/Wrappers.yml +++ /dev/null @@ -1,640 +0,0 @@ -# Do not modify! -# This file was generated from a template using https://github.com/apple/pkl - -name: wrappers -'on': - workflow_call: {} -env: - REALM_DISABLE_ANALYTICS: true - DOTNET_NOLOGO: true -jobs: - check-cache: - name: Check Cache - env: - CACHE_SKIP_SAVE: true - outputs: - wrappers-macos: ${{ steps.check-cache-macos.outputs.cache-hit }} - wrappers-catalyst: ${{ steps.check-cache-catalyst.outputs.cache-hit }} - wrappers-linux-x86_64: ${{ steps.check-cache-linux-x86_64.outputs.cache-hit }} - wrappers-linux-armhf: ${{ steps.check-cache-linux-armhf.outputs.cache-hit }} - wrappers-linux-aarch64: ${{ steps.check-cache-linux-aarch64.outputs.cache-hit }} - wrappers-android-armeabi-v7a: ${{ steps.check-cache-android-armeabi-v7a.outputs.cache-hit }} - wrappers-android-arm64-v8a: ${{ steps.check-cache-android-arm64-v8a.outputs.cache-hit }} - wrappers-android-x86: ${{ steps.check-cache-android-x86.outputs.cache-hit }} - wrappers-android-x86_64: ${{ steps.check-cache-android-x86_64.outputs.cache-hit }} - wrappers-windows-Win32: ${{ steps.check-cache-windows-Win32.outputs.cache-hit }} - wrappers-windows-x64: ${{ steps.check-cache-windows-x64.outputs.cache-hit }} - wrappers-windows-ARM64: ${{ steps.check-cache-windows-ARM64.outputs.cache-hit }} - wrappers-windows-uwp-Win32: ${{ steps.check-cache-windows-uwp-Win32.outputs.cache-hit }} - wrappers-windows-uwp-x64: ${{ steps.check-cache-windows-uwp-x64.outputs.cache-hit }} - wrappers-windows-uwp-ARM: ${{ steps.check-cache-windows-uwp-ARM.outputs.cache-hit }} - wrappers-windows-uwp-ARM64: ${{ steps.check-cache-windows-uwp-ARM64.outputs.cache-hit }} - wrappers-iOS-Device: ${{ steps.check-cache-iOS-Device.outputs.cache-hit }} - wrappers-iOS-Simulator: ${{ steps.check-cache-iOS-Simulator.outputs.cache-hit }} - wrappers-tvOS-Device: ${{ steps.check-cache-tvOS-Device.outputs.cache-hit }} - wrappers-tvOS-Simulator: ${{ steps.check-cache-tvOS-Simulator.outputs.cache-hit }} - runs-on: ${{ matrix.os }}-latest - steps: - - name: Checkout Code - uses: actions/checkout@v4 - with: - submodules: recursive - ref: ${{ github.event.pull_request.head.sha }} - - name: Check Cache for macos - id: check-cache-macos - if: matrix.os == 'ubuntu' - uses: actions/cache/restore@v4 - with: - path: ./wrappers/build/** - key: wrappers-macos-Release-${{hashFiles('./wrappers/**')}} - - name: Store artifacts for wrappers-macos - if: matrix.os == 'ubuntu' && steps.check-cache-macos.outputs.cache-hit == 'true' - uses: actions/upload-artifact@v4 - with: - name: wrappers-macos - path: ${{ github.workspace }}/wrappers/build/** - retention-days: ${{ github.event_name != 'pull_request' && 30 || 1 }} - if-no-files-found: error - - if: matrix.os == 'ubuntu' - run: git clean -fdx - - name: Check Cache for catalyst - id: check-cache-catalyst - if: matrix.os == 'ubuntu' - uses: actions/cache/restore@v4 - with: - path: ./wrappers/build/** - key: wrappers-catalyst-Release-${{hashFiles('./wrappers/**')}} - - name: Store artifacts for wrappers-catalyst - if: matrix.os == 'ubuntu' && steps.check-cache-catalyst.outputs.cache-hit == 'true' - uses: actions/upload-artifact@v4 - with: - name: wrappers-catalyst - path: ${{ github.workspace }}/wrappers/build/** - retention-days: ${{ github.event_name != 'pull_request' && 30 || 1 }} - if-no-files-found: error - - if: matrix.os == 'ubuntu' - run: git clean -fdx - - name: Check Cache for linux-x86_64 - id: check-cache-linux-x86_64 - if: matrix.os == 'ubuntu' - uses: actions/cache/restore@v4 - with: - path: ./wrappers/build/** - key: wrappers-linux-x86_64-Release-${{hashFiles('./wrappers/**')}} - - name: Store artifacts for wrappers-linux-x86_64 - if: matrix.os == 'ubuntu' && steps.check-cache-linux-x86_64.outputs.cache-hit == 'true' - uses: actions/upload-artifact@v4 - with: - name: wrappers-linux-x86_64 - path: ${{ github.workspace }}/wrappers/build/** - retention-days: ${{ github.event_name != 'pull_request' && 30 || 1 }} - if-no-files-found: error - - if: matrix.os == 'ubuntu' - run: git clean -fdx - - name: Check Cache for linux-armhf - id: check-cache-linux-armhf - if: matrix.os == 'ubuntu' - uses: actions/cache/restore@v4 - with: - path: ./wrappers/build/** - key: wrappers-linux-armhf-Release-${{hashFiles('./wrappers/**')}} - - name: Store artifacts for wrappers-linux-armhf - if: matrix.os == 'ubuntu' && steps.check-cache-linux-armhf.outputs.cache-hit == 'true' - uses: actions/upload-artifact@v4 - with: - name: wrappers-linux-armhf - path: ${{ github.workspace }}/wrappers/build/** - retention-days: ${{ github.event_name != 'pull_request' && 30 || 1 }} - if-no-files-found: error - - if: matrix.os == 'ubuntu' - run: git clean -fdx - - name: Check Cache for linux-aarch64 - id: check-cache-linux-aarch64 - if: matrix.os == 'ubuntu' - uses: actions/cache/restore@v4 - with: - path: ./wrappers/build/** - key: wrappers-linux-aarch64-Release-${{hashFiles('./wrappers/**')}} - - name: Store artifacts for wrappers-linux-aarch64 - if: matrix.os == 'ubuntu' && steps.check-cache-linux-aarch64.outputs.cache-hit == 'true' - uses: actions/upload-artifact@v4 - with: - name: wrappers-linux-aarch64 - path: ${{ github.workspace }}/wrappers/build/** - retention-days: ${{ github.event_name != 'pull_request' && 30 || 1 }} - if-no-files-found: error - - if: matrix.os == 'ubuntu' - run: git clean -fdx - - name: Check Cache for android-armeabi-v7a - id: check-cache-android-armeabi-v7a - if: matrix.os == 'ubuntu' - uses: actions/cache/restore@v4 - with: - path: ./wrappers/build/** - key: wrappers-android-armeabi-v7a-Release-${{hashFiles('./wrappers/**')}} - - name: Store artifacts for wrappers-android-armeabi-v7a - if: matrix.os == 'ubuntu' && steps.check-cache-android-armeabi-v7a.outputs.cache-hit == 'true' - uses: actions/upload-artifact@v4 - with: - name: wrappers-android-armeabi-v7a - path: ${{ github.workspace }}/wrappers/build/** - retention-days: ${{ github.event_name != 'pull_request' && 30 || 1 }} - if-no-files-found: error - - if: matrix.os == 'ubuntu' - run: git clean -fdx - - name: Check Cache for android-arm64-v8a - id: check-cache-android-arm64-v8a - if: matrix.os == 'ubuntu' - uses: actions/cache/restore@v4 - with: - path: ./wrappers/build/** - key: wrappers-android-arm64-v8a-Release-${{hashFiles('./wrappers/**')}} - - name: Store artifacts for wrappers-android-arm64-v8a - if: matrix.os == 'ubuntu' && steps.check-cache-android-arm64-v8a.outputs.cache-hit == 'true' - uses: actions/upload-artifact@v4 - with: - name: wrappers-android-arm64-v8a - path: ${{ github.workspace }}/wrappers/build/** - retention-days: ${{ github.event_name != 'pull_request' && 30 || 1 }} - if-no-files-found: error - - if: matrix.os == 'ubuntu' - run: git clean -fdx - - name: Check Cache for android-x86 - id: check-cache-android-x86 - if: matrix.os == 'ubuntu' - uses: actions/cache/restore@v4 - with: - path: ./wrappers/build/** - key: wrappers-android-x86-Release-${{hashFiles('./wrappers/**')}} - - name: Store artifacts for wrappers-android-x86 - if: matrix.os == 'ubuntu' && steps.check-cache-android-x86.outputs.cache-hit == 'true' - uses: actions/upload-artifact@v4 - with: - name: wrappers-android-x86 - path: ${{ github.workspace }}/wrappers/build/** - retention-days: ${{ github.event_name != 'pull_request' && 30 || 1 }} - if-no-files-found: error - - if: matrix.os == 'ubuntu' - run: git clean -fdx - - name: Check Cache for android-x86_64 - id: check-cache-android-x86_64 - if: matrix.os == 'ubuntu' - uses: actions/cache/restore@v4 - with: - path: ./wrappers/build/** - key: wrappers-android-x86_64-Release-${{hashFiles('./wrappers/**')}} - - name: Store artifacts for wrappers-android-x86_64 - if: matrix.os == 'ubuntu' && steps.check-cache-android-x86_64.outputs.cache-hit == 'true' - uses: actions/upload-artifact@v4 - with: - name: wrappers-android-x86_64 - path: ${{ github.workspace }}/wrappers/build/** - retention-days: ${{ github.event_name != 'pull_request' && 30 || 1 }} - if-no-files-found: error - - if: matrix.os == 'ubuntu' - run: git clean -fdx - - name: Check Cache for windows-Win32 - id: check-cache-windows-Win32 - if: matrix.os == 'windows' - uses: actions/cache/restore@v4 - with: - path: ./wrappers/build/** - key: wrappers-windows-Win32-Release-${{hashFiles('./wrappers/**')}} - - name: Store artifacts for wrappers-windows-Win32 - if: matrix.os == 'windows' && steps.check-cache-windows-Win32.outputs.cache-hit == 'true' - uses: actions/upload-artifact@v4 - with: - name: wrappers-windows-Win32 - path: ${{ github.workspace }}/wrappers/build/** - retention-days: ${{ github.event_name != 'pull_request' && 30 || 1 }} - if-no-files-found: error - - if: matrix.os == 'windows' - run: git clean -fdx - - name: Check Cache for windows-x64 - id: check-cache-windows-x64 - if: matrix.os == 'windows' - uses: actions/cache/restore@v4 - with: - path: ./wrappers/build/** - key: wrappers-windows-x64-Release-${{hashFiles('./wrappers/**')}} - - name: Store artifacts for wrappers-windows-x64 - if: matrix.os == 'windows' && steps.check-cache-windows-x64.outputs.cache-hit == 'true' - uses: actions/upload-artifact@v4 - with: - name: wrappers-windows-x64 - path: ${{ github.workspace }}/wrappers/build/** - retention-days: ${{ github.event_name != 'pull_request' && 30 || 1 }} - if-no-files-found: error - - if: matrix.os == 'windows' - run: git clean -fdx - - name: Check Cache for windows-ARM64 - id: check-cache-windows-ARM64 - if: matrix.os == 'windows' - uses: actions/cache/restore@v4 - with: - path: ./wrappers/build/** - key: wrappers-windows-ARM64-Release-${{hashFiles('./wrappers/**')}} - - name: Store artifacts for wrappers-windows-ARM64 - if: matrix.os == 'windows' && steps.check-cache-windows-ARM64.outputs.cache-hit == 'true' - uses: actions/upload-artifact@v4 - with: - name: wrappers-windows-ARM64 - path: ${{ github.workspace }}/wrappers/build/** - retention-days: ${{ github.event_name != 'pull_request' && 30 || 1 }} - if-no-files-found: error - - if: matrix.os == 'windows' - run: git clean -fdx - - name: Check Cache for windows-uwp-Win32 - id: check-cache-windows-uwp-Win32 - if: matrix.os == 'windows' - uses: actions/cache/restore@v4 - with: - path: ./wrappers/build/** - key: wrappers-windows-uwp-Win32-Release-${{hashFiles('./wrappers/**')}} - - name: Store artifacts for wrappers-windows-uwp-Win32 - if: matrix.os == 'windows' && steps.check-cache-windows-uwp-Win32.outputs.cache-hit == 'true' - uses: actions/upload-artifact@v4 - with: - name: wrappers-windows-uwp-Win32 - path: ${{ github.workspace }}/wrappers/build/** - retention-days: ${{ github.event_name != 'pull_request' && 30 || 1 }} - if-no-files-found: error - - if: matrix.os == 'windows' - run: git clean -fdx - - name: Check Cache for windows-uwp-x64 - id: check-cache-windows-uwp-x64 - if: matrix.os == 'windows' - uses: actions/cache/restore@v4 - with: - path: ./wrappers/build/** - key: wrappers-windows-uwp-x64-Release-${{hashFiles('./wrappers/**')}} - - name: Store artifacts for wrappers-windows-uwp-x64 - if: matrix.os == 'windows' && steps.check-cache-windows-uwp-x64.outputs.cache-hit == 'true' - uses: actions/upload-artifact@v4 - with: - name: wrappers-windows-uwp-x64 - path: ${{ github.workspace }}/wrappers/build/** - retention-days: ${{ github.event_name != 'pull_request' && 30 || 1 }} - if-no-files-found: error - - if: matrix.os == 'windows' - run: git clean -fdx - - name: Check Cache for windows-uwp-ARM - id: check-cache-windows-uwp-ARM - if: matrix.os == 'windows' - uses: actions/cache/restore@v4 - with: - path: ./wrappers/build/** - key: wrappers-windows-uwp-ARM-Release-${{hashFiles('./wrappers/**')}} - - name: Store artifacts for wrappers-windows-uwp-ARM - if: matrix.os == 'windows' && steps.check-cache-windows-uwp-ARM.outputs.cache-hit == 'true' - uses: actions/upload-artifact@v4 - with: - name: wrappers-windows-uwp-ARM - path: ${{ github.workspace }}/wrappers/build/** - retention-days: ${{ github.event_name != 'pull_request' && 30 || 1 }} - if-no-files-found: error - - if: matrix.os == 'windows' - run: git clean -fdx - - name: Check Cache for windows-uwp-ARM64 - id: check-cache-windows-uwp-ARM64 - if: matrix.os == 'windows' - uses: actions/cache/restore@v4 - with: - path: ./wrappers/build/** - key: wrappers-windows-uwp-ARM64-Release-${{hashFiles('./wrappers/**')}} - - name: Store artifacts for wrappers-windows-uwp-ARM64 - if: matrix.os == 'windows' && steps.check-cache-windows-uwp-ARM64.outputs.cache-hit == 'true' - uses: actions/upload-artifact@v4 - with: - name: wrappers-windows-uwp-ARM64 - path: ${{ github.workspace }}/wrappers/build/** - retention-days: ${{ github.event_name != 'pull_request' && 30 || 1 }} - if-no-files-found: error - - if: matrix.os == 'windows' - run: git clean -fdx - - name: Check Cache for iOS-Device - id: check-cache-iOS-Device - if: matrix.os == 'ubuntu' - uses: actions/cache/restore@v4 - with: - path: ./wrappers/build/** - key: wrappers-iOS-Device-Release-${{hashFiles('./wrappers/**')}} - - name: Store artifacts for wrappers-iOS-Device - if: matrix.os == 'ubuntu' && steps.check-cache-iOS-Device.outputs.cache-hit == 'true' - uses: actions/upload-artifact@v4 - with: - name: wrappers-iOS-Device - path: ${{ github.workspace }}/wrappers/build/** - retention-days: ${{ github.event_name != 'pull_request' && 30 || 1 }} - if-no-files-found: error - - if: matrix.os == 'ubuntu' - run: git clean -fdx - - name: Check Cache for iOS-Simulator - id: check-cache-iOS-Simulator - if: matrix.os == 'ubuntu' - uses: actions/cache/restore@v4 - with: - path: ./wrappers/build/** - key: wrappers-iOS-Simulator-Release-${{hashFiles('./wrappers/**')}} - - name: Store artifacts for wrappers-iOS-Simulator - if: matrix.os == 'ubuntu' && steps.check-cache-iOS-Simulator.outputs.cache-hit == 'true' - uses: actions/upload-artifact@v4 - with: - name: wrappers-iOS-Simulator - path: ${{ github.workspace }}/wrappers/build/** - retention-days: ${{ github.event_name != 'pull_request' && 30 || 1 }} - if-no-files-found: error - - if: matrix.os == 'ubuntu' - run: git clean -fdx - - name: Check Cache for tvOS-Device - id: check-cache-tvOS-Device - if: matrix.os == 'ubuntu' - uses: actions/cache/restore@v4 - with: - path: ./wrappers/build/** - key: wrappers-tvOS-Device-Release-${{hashFiles('./wrappers/**')}} - - name: Store artifacts for wrappers-tvOS-Device - if: matrix.os == 'ubuntu' && steps.check-cache-tvOS-Device.outputs.cache-hit == 'true' - uses: actions/upload-artifact@v4 - with: - name: wrappers-tvOS-Device - path: ${{ github.workspace }}/wrappers/build/** - retention-days: ${{ github.event_name != 'pull_request' && 30 || 1 }} - if-no-files-found: error - - if: matrix.os == 'ubuntu' - run: git clean -fdx - - name: Check Cache for tvOS-Simulator - id: check-cache-tvOS-Simulator - if: matrix.os == 'ubuntu' - uses: actions/cache/restore@v4 - with: - path: ./wrappers/build/** - key: wrappers-tvOS-Simulator-Release-${{hashFiles('./wrappers/**')}} - - name: Store artifacts for wrappers-tvOS-Simulator - if: matrix.os == 'ubuntu' && steps.check-cache-tvOS-Simulator.outputs.cache-hit == 'true' - uses: actions/upload-artifact@v4 - with: - name: wrappers-tvOS-Simulator - path: ${{ github.workspace }}/wrappers/build/** - retention-days: ${{ github.event_name != 'pull_request' && 30 || 1 }} - if-no-files-found: error - - if: matrix.os == 'ubuntu' - run: git clean -fdx - strategy: - matrix: - os: - - ubuntu - - windows - macos: - name: MacOS - needs: - - check-cache - if: needs.check-cache.outputs.wrappers-macos != 'true' - timeout-minutes: 90 - runs-on: macos-12 - steps: - - name: Checkout Code - uses: actions/checkout@v4 - with: - submodules: recursive - ref: ${{ github.event.pull_request.head.sha }} - - name: Check Cache for macos - id: check-cache - uses: actions/cache@v4 - with: - path: ./wrappers/build/** - key: wrappers-macos-Release-${{hashFiles('./wrappers/**')}} - - name: Build Wrappers - if: steps.check-cache.outputs.cache-hit != 'true' - run: ./wrappers/build-macos.sh --configuration=Release -DCMAKE_INTERPROCEDURAL_OPTIMIZATION='ON' - - name: Store artifacts for wrappers-macos - uses: actions/upload-artifact@v4 - with: - name: wrappers-macos - path: ${{ github.workspace }}/wrappers/build/** - retention-days: ${{ github.event_name != 'pull_request' && 30 || 1 }} - if-no-files-found: error - catalyst: - name: Catalyst - needs: - - check-cache - if: needs.check-cache.outputs.wrappers-catalyst != 'true' - timeout-minutes: 90 - runs-on: macos-12 - steps: - - name: Checkout Code - uses: actions/checkout@v4 - with: - submodules: recursive - ref: ${{ github.event.pull_request.head.sha }} - - name: Check Cache for catalyst - id: check-cache - uses: actions/cache@v4 - with: - path: ./wrappers/build/** - key: wrappers-catalyst-Release-${{hashFiles('./wrappers/**')}} - - name: Build Wrappers - if: steps.check-cache.outputs.cache-hit != 'true' - run: pwsh ./wrappers/build-apple-platform.ps1 Catalyst -Configuration Release -EnableLTO - - name: Store artifacts for wrappers-catalyst - uses: actions/upload-artifact@v4 - with: - name: wrappers-catalyst - path: ${{ github.workspace }}/wrappers/build/** - retention-days: ${{ github.event_name != 'pull_request' && 30 || 1 }} - if-no-files-found: error - apple-platform: - name: Apple Platform - needs: - - check-cache - if: needs.check-cache.outputs.wrappers-iOS-Device != 'true' || needs.check-cache.outputs.wrappers-iOS-Simulator != 'true' || needs.check-cache.outputs.wrappers-tvOS-Device != 'true' || needs.check-cache.outputs.wrappers-tvOS-Simulator != 'true' - timeout-minutes: 90 - runs-on: macos-12 - steps: - - name: Checkout Code - uses: actions/checkout@v4 - with: - submodules: recursive - ref: ${{ github.event.pull_request.head.sha }} - - name: Check Cache for ${{ matrix.platform }}-${{ matrix.target }} - id: check-cache - uses: actions/cache@v4 - with: - path: ./wrappers/build/** - key: wrappers-${{ matrix.platform }}-${{ matrix.target }}-Release-${{hashFiles('./wrappers/**')}} - - name: Setup Xcode - if: steps.check-cache.outputs.cache-hit != 'true' - uses: maxim-lobanov/setup-xcode@60606e260d2fc5762a71e64e74b2174e8ea3c8bd - with: - xcode-version: '14' - - name: Build Wrappers - if: steps.check-cache.outputs.cache-hit != 'true' - run: 'pwsh ./wrappers/build-apple-platform.ps1 ${{ matrix.platform }} -Targets ${{ matrix.target }} -Configuration Release ' - - name: Store artifacts for wrappers-${{ matrix.platform }}-${{ matrix.target }} - uses: actions/upload-artifact@v4 - with: - name: wrappers-${{ matrix.platform }}-${{ matrix.target }} - path: ${{ github.workspace }}/wrappers/build/** - retention-days: ${{ github.event_name != 'pull_request' && 30 || 1 }} - if-no-files-found: error - strategy: - matrix: - platform: - - iOS - - tvOS - target: - - Device - - Simulator - linux: - name: Linux - needs: - - check-cache - if: needs.check-cache.outputs.wrappers-linux-x86_64 != 'true' || needs.check-cache.outputs.wrappers-linux-armhf != 'true' || needs.check-cache.outputs.wrappers-linux-aarch64 != 'true' - timeout-minutes: 90 - runs-on: ubuntu-latest - steps: - - name: Checkout Code - uses: actions/checkout@v4 - with: - submodules: recursive - ref: ${{ github.event.pull_request.head.sha }} - - name: Check Cache for linux-${{ matrix.arch }} - id: check-cache - uses: actions/cache@v4 - with: - path: ./wrappers/build/** - key: wrappers-linux-${{ matrix.arch }}-Release-${{hashFiles('./wrappers/**')}} - - name: Install Ninja - if: steps.check-cache.outputs.cache-hit != 'true' - run: sudo apt install ninja-build - - name: Build Wrappers - if: steps.check-cache.outputs.cache-hit != 'true' - run: ./wrappers/build-linux.sh -a=${{ matrix.arch }} --configuration=Release -DCMAKE_INTERPROCEDURAL_OPTIMIZATION='ON' - - name: Store artifacts for wrappers-linux-${{ matrix.arch }} - uses: actions/upload-artifact@v4 - with: - name: wrappers-linux-${{ matrix.arch }} - path: ${{ github.workspace }}/wrappers/build/** - retention-days: ${{ github.event_name != 'pull_request' && 30 || 1 }} - if-no-files-found: error - strategy: - matrix: - arch: - - x86_64 - - armhf - - aarch64 - android: - name: Android - needs: - - check-cache - if: needs.check-cache.outputs.wrappers-android-armeabi-v7a != 'true' || needs.check-cache.outputs.wrappers-android-arm64-v8a != 'true' || needs.check-cache.outputs.wrappers-android-x86 != 'true' || needs.check-cache.outputs.wrappers-android-x86_64 != 'true' - timeout-minutes: 90 - runs-on: ubuntu-20.04 - steps: - - name: Checkout Code - uses: actions/checkout@v4 - with: - submodules: recursive - ref: ${{ github.event.pull_request.head.sha }} - - name: Check Cache for android-${{ matrix.arch }} - id: check-cache - uses: actions/cache@v4 - with: - path: ./wrappers/build/** - key: wrappers-android-${{ matrix.arch }}-Release-${{hashFiles('./wrappers/**')}} - - name: Build Wrappers - if: steps.check-cache.outputs.cache-hit != 'true' - run: './wrappers/build-android.sh --ARCH=${{ matrix.arch }} --configuration=Release ' - - name: Store artifacts for wrappers-android-${{ matrix.arch }} - uses: actions/upload-artifact@v4 - with: - name: wrappers-android-${{ matrix.arch }} - path: ${{ github.workspace }}/wrappers/build/** - retention-days: ${{ github.event_name != 'pull_request' && 30 || 1 }} - if-no-files-found: error - strategy: - matrix: - arch: - - armeabi-v7a - - arm64-v8a - - x86 - - x86_64 - windows: - name: Windows - needs: - - check-cache - if: needs.check-cache.outputs.wrappers-windows-Win32 != 'true' || needs.check-cache.outputs.wrappers-windows-x64 != 'true' || needs.check-cache.outputs.wrappers-windows-ARM64 != 'true' - timeout-minutes: 90 - runs-on: windows-latest - steps: - - name: Checkout Code - uses: actions/checkout@v4 - with: - submodules: recursive - ref: ${{ github.event.pull_request.head.sha }} - - name: Check Cache for windows-${{ matrix.arch }} - id: check-cache - uses: actions/cache@v4 - with: - path: ./wrappers/build/** - key: wrappers-windows-${{ matrix.arch }}-Release-${{hashFiles('./wrappers/**')}} - - name: Setup MSVC - if: steps.check-cache.outputs.cache-hit != 'true' - run: Start-Process "C:\Program Files (x86)\Microsoft Visual Studio\Installer\vs_installer.exe" -ArgumentList 'modify --installPath "C:\Program Files\Microsoft Visual Studio\2022\Enterprise" --quiet --add Microsoft.VisualStudio.Component.VC.14.35.17.5.${{ startswith(matrix.arch, 'ARM') && matrix.arch || 'x86.x64' }}' -Wait -PassThru - shell: pwsh - - name: Build Wrappers - if: steps.check-cache.outputs.cache-hit != 'true' - run: pwsh ./wrappers/build.ps1 Windows -Platforms ${{ matrix.arch }} -ExtraCMakeArgs "-T v143,version=14.35" -Configuration Release -EnableLTO - - name: Store artifacts for wrappers-windows-${{ matrix.arch }} - uses: actions/upload-artifact@v4 - with: - name: wrappers-windows-${{ matrix.arch }} - path: ${{ github.workspace }}/wrappers/build/** - retention-days: ${{ github.event_name != 'pull_request' && 30 || 1 }} - if-no-files-found: error - strategy: - matrix: - arch: - - Win32 - - x64 - - ARM64 - uwp: - name: UWP - needs: - - check-cache - if: needs.check-cache.outputs.wrappers-windows-uwp-Win32 != 'true' || needs.check-cache.outputs.wrappers-windows-uwp-x64 != 'true' || needs.check-cache.outputs.wrappers-windows-uwp-ARM != 'true' || needs.check-cache.outputs.wrappers-windows-uwp-ARM64 != 'true' - timeout-minutes: 90 - runs-on: windows-latest - steps: - - name: Checkout Code - uses: actions/checkout@v4 - with: - submodules: recursive - ref: ${{ github.event.pull_request.head.sha }} - - name: Check Cache for windows-uwp-${{ matrix.arch }} - id: check-cache - uses: actions/cache@v4 - with: - path: ./wrappers/build/** - key: wrappers-windows-uwp-${{ matrix.arch }}-Release-${{hashFiles('./wrappers/**')}} - - name: Setup MSVC - if: steps.check-cache.outputs.cache-hit != 'true' - run: Start-Process "C:\Program Files (x86)\Microsoft Visual Studio\Installer\vs_installer.exe" -ArgumentList 'modify --installPath "C:\Program Files\Microsoft Visual Studio\2022\Enterprise" --quiet --add Microsoft.VisualStudio.Component.VC.14.35.17.5.${{ startswith(matrix.arch, 'ARM') && matrix.arch || 'x86.x64' }}' -Wait -PassThru - shell: pwsh - - name: Build Wrappers - if: steps.check-cache.outputs.cache-hit != 'true' - run: pwsh ./wrappers/build.ps1 WindowsStore -Platforms ${{ matrix.arch }} -ExtraCMakeArgs "-T v143,version=14.35" -Configuration Release -EnableLTO - - name: Store artifacts for wrappers-windows-uwp-${{ matrix.arch }} - uses: actions/upload-artifact@v4 - with: - name: wrappers-windows-uwp-${{ matrix.arch }} - path: ${{ github.workspace }}/wrappers/build/** - retention-days: ${{ github.event_name != 'pull_request' && 30 || 1 }} - if-no-files-found: error - strategy: - matrix: - arch: - - Win32 - - x64 - - ARM - - ARM64 diff --git a/.github/pkl-workflows/Wrappers.pkl b/.github/pkl-workflows/wrappers.pkl similarity index 100% rename from .github/pkl-workflows/Wrappers.pkl rename to .github/pkl-workflows/wrappers.pkl diff --git a/.github/templates/common.lib.yml b/.github/templates/common.lib.yml index cd4e6cb582..64d65de68e 100644 --- a/.github/templates/common.lib.yml +++ b/.github/templates/common.lib.yml @@ -6,7 +6,7 @@ #@ actionCheckout = "actions/checkout@v3" #@ actionCache = "nirinchev/cache@29e8e4dd9148ea81f9e188480132072cb6cc92d8" #@ actionUploadArtifact = "actions/upload-artifact@v3" -#@ actionDownloadArtifact = "actions/download-artifact@v3" +#@ actionDownloadArtifact = "actions/download-artifact@v4" #@ actionSetupMSBuild = "microsoft/setup-msbuild@0b44c6745b7e81956596964100aadb92d667c497" #@ actionSetupDotnet = "actions/setup-dotnet@3e6b9fe3930cac7c59c651af5de1514b47a805b9" #! 4.0.0 #@ actionCodeQLInit = "github/codeql-action/init@40542d38bc4936c2ca7da883aeb050a6081b4b31" diff --git a/.github/workflows/build-packages.yml b/.github/workflows/build-packages.yml index 051719deb3..22615f02e8 100755 --- a/.github/workflows/build-packages.yml +++ b/.github/workflows/build-packages.yml @@ -61,102 +61,102 @@ jobs: } echo "build_suffix=$suffix" >> $Env:GITHUB_OUTPUT - name: Fetch artifacts for macos - uses: actions/download-artifact@v3 + uses: actions/download-artifact@v4 with: name: wrappers-macos path: wrappers/build - name: Fetch artifacts for catalyst - uses: actions/download-artifact@v3 + uses: actions/download-artifact@v4 with: name: wrappers-catalyst path: wrappers/build - name: Fetch artifacts for linux-x86_64 - uses: actions/download-artifact@v3 + uses: actions/download-artifact@v4 with: name: wrappers-linux-x86_64 path: wrappers/build - name: Fetch artifacts for linux-armhf - uses: actions/download-artifact@v3 + uses: actions/download-artifact@v4 with: name: wrappers-linux-armhf path: wrappers/build - name: Fetch artifacts for linux-aarch64 - uses: actions/download-artifact@v3 + uses: actions/download-artifact@v4 with: name: wrappers-linux-aarch64 path: wrappers/build - name: Fetch artifacts for iOS-Device - uses: actions/download-artifact@v3 + uses: actions/download-artifact@v4 with: name: wrappers-iOS-Device path: wrappers/build - name: Fetch artifacts for iOS-Simulator - uses: actions/download-artifact@v3 + uses: actions/download-artifact@v4 with: name: wrappers-iOS-Simulator path: wrappers/build - name: Fetch artifacts for tvOS-Device - uses: actions/download-artifact@v3 + uses: actions/download-artifact@v4 with: name: wrappers-tvOS-Device path: wrappers/build - name: Fetch artifacts for tvOS-Simulator - uses: actions/download-artifact@v3 + uses: actions/download-artifact@v4 with: name: wrappers-tvOS-Simulator path: wrappers/build - name: Fetch artifacts for android-armeabi-v7a - uses: actions/download-artifact@v3 + uses: actions/download-artifact@v4 with: name: wrappers-android-armeabi-v7a path: wrappers/build - name: Fetch artifacts for android-arm64-v8a - uses: actions/download-artifact@v3 + uses: actions/download-artifact@v4 with: name: wrappers-android-arm64-v8a path: wrappers/build - name: Fetch artifacts for android-x86 - uses: actions/download-artifact@v3 + uses: actions/download-artifact@v4 with: name: wrappers-android-x86 path: wrappers/build - name: Fetch artifacts for android-x86_64 - uses: actions/download-artifact@v3 + uses: actions/download-artifact@v4 with: name: wrappers-android-x86_64 path: wrappers/build - name: Fetch artifacts for windows-Win32 - uses: actions/download-artifact@v3 + uses: actions/download-artifact@v4 with: name: wrappers-windows-Win32 path: wrappers/build - name: Fetch artifacts for windows-x64 - uses: actions/download-artifact@v3 + uses: actions/download-artifact@v4 with: name: wrappers-windows-x64 path: wrappers/build - name: Fetch artifacts for windows-ARM64 - uses: actions/download-artifact@v3 + uses: actions/download-artifact@v4 with: name: wrappers-windows-ARM64 path: wrappers/build - name: Fetch artifacts for windows-uwp-Win32 - uses: actions/download-artifact@v3 + uses: actions/download-artifact@v4 with: name: wrappers-windows-uwp-Win32 path: wrappers/build - name: Fetch artifacts for windows-uwp-x64 - uses: actions/download-artifact@v3 + uses: actions/download-artifact@v4 with: name: wrappers-windows-uwp-x64 path: wrappers/build - name: Fetch artifacts for windows-uwp-ARM - uses: actions/download-artifact@v3 + uses: actions/download-artifact@v4 with: name: wrappers-windows-uwp-ARM path: wrappers/build - name: Fetch artifacts for windows-uwp-ARM64 - uses: actions/download-artifact@v3 + uses: actions/download-artifact@v4 with: name: wrappers-windows-uwp-ARM64 path: wrappers/build diff --git a/.github/workflows/build-unity.yml b/.github/workflows/build-unity.yml index 178da4b8a0..d7189a4d52 100755 --- a/.github/workflows/build-unity.yml +++ b/.github/workflows/build-unity.yml @@ -24,22 +24,22 @@ jobs: - name: Register msvc problem matcher run: echo "::add-matcher::.github/problem-matchers/msvc.json" - name: Fetch Realm.PlatformHelpers - uses: actions/download-artifact@v3 + uses: actions/download-artifact@v4 with: name: Realm.PlatformHelpers.${{ inputs.version }} path: ${{ github.workspace }}/Realm/packages/ - name: Fetch Realm - uses: actions/download-artifact@v3 + uses: actions/download-artifact@v4 with: name: Realm.${{ inputs.version }} path: ${{ github.workspace }}/Realm/packages/ - name: Fetch Realm.UnityUtils - uses: actions/download-artifact@v3 + uses: actions/download-artifact@v4 with: name: Realm.UnityUtils.${{ inputs.version }} path: ${{ github.workspace }}/Realm/packages/ - name: Fetch Realm.UnityWeaver - uses: actions/download-artifact@v3 + uses: actions/download-artifact@v4 with: name: Realm.UnityWeaver.${{ inputs.version }} path: ${{ github.workspace }}/Realm/packages/ diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 573602e82a..404324e16d 100755 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -44,12 +44,12 @@ jobs: submodules: false ref: ${{ github.event.pull_request.head.sha }} - name: Fetch Realm.PlatformHelpers - uses: actions/download-artifact@v3 + uses: actions/download-artifact@v4 with: name: Realm.PlatformHelpers.${{ needs.build-packages.outputs.package_version }} path: ${{ github.workspace }}/Realm/packages/ - name: Fetch Realm - uses: actions/download-artifact@v3 + uses: actions/download-artifact@v4 with: name: Realm.${{ needs.build-packages.outputs.package_version }} path: ${{ github.workspace }}/Realm/packages/ @@ -174,12 +174,12 @@ jobs: - name: Register msvc problem matcher run: echo "::add-matcher::.github/problem-matchers/msvc.json" - name: Fetch Realm.PlatformHelpers - uses: actions/download-artifact@v3 + uses: actions/download-artifact@v4 with: name: Realm.PlatformHelpers.${{ needs.build-packages.outputs.package_version }} path: ${{ github.workspace }}/Realm/packages/ - name: Fetch Realm - uses: actions/download-artifact@v3 + uses: actions/download-artifact@v4 with: name: Realm.${{ needs.build-packages.outputs.package_version }} path: ${{ github.workspace }}/Realm/packages/ @@ -224,12 +224,12 @@ jobs: - name: Register msvc problem matcher run: echo "::add-matcher::.github/problem-matchers/msvc.json" - name: Fetch Realm.PlatformHelpers - uses: actions/download-artifact@v3 + uses: actions/download-artifact@v4 with: name: Realm.PlatformHelpers.${{ needs.build-packages.outputs.package_version }} path: ${{ github.workspace }}/Realm/packages/ - name: Fetch Realm - uses: actions/download-artifact@v3 + uses: actions/download-artifact@v4 with: name: Realm.${{ needs.build-packages.outputs.package_version }} path: ${{ github.workspace }}/Realm/packages/ diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index 3d886dcc86..73a6d80bba 100755 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -88,12 +88,12 @@ jobs: submodules: recursive ref: ${{ github.event.pull_request.head.sha }} - name: Fetch Realm - uses: actions/download-artifact@v3 + uses: actions/download-artifact@v4 with: name: Realm.${{ needs.build-packages.outputs.package_version }} path: ${{ github.workspace }}/Realm/packages/ - name: Fetch Realm.PlatformHelpers - uses: actions/download-artifact@v3 + uses: actions/download-artifact@v4 with: name: Realm.PlatformHelpers.${{ needs.build-packages.outputs.package_version }} path: ${{ github.workspace }}/Realm/packages/ @@ -230,22 +230,22 @@ jobs: submodules: recursive ref: ${{ github.event.pull_request.head.sha }} - name: Fetch Realm - uses: actions/download-artifact@v3 + uses: actions/download-artifact@v4 with: name: Realm.${{ needs.build-packages.outputs.package_version }} path: ${{ github.workspace }}/Realm/packages/ - name: Fetch Realm.PlatformHelpers - uses: actions/download-artifact@v3 + uses: actions/download-artifact@v4 with: name: Realm.PlatformHelpers.${{ needs.build-packages.outputs.package_version }} path: ${{ github.workspace }}/Realm/packages/ - name: Fetch Realm.UnityUtils - uses: actions/download-artifact@v3 + uses: actions/download-artifact@v4 with: name: Realm.UnityUtils.${{ needs.build-packages.outputs.package_version }} path: ${{ github.workspace }}/Realm/packages/ - name: Fetch Realm.UnityWeaver - uses: actions/download-artifact@v3 + uses: actions/download-artifact@v4 with: name: Realm.UnityWeaver.${{ needs.build-packages.outputs.package_version }} path: ${{ github.workspace }}/Realm/packages/ diff --git a/.github/workflows/test-android.yml b/.github/workflows/test-android.yml index 879350e3a1..48c2666213 100755 --- a/.github/workflows/test-android.yml +++ b/.github/workflows/test-android.yml @@ -40,12 +40,12 @@ jobs: - name: Register msvc problem matcher run: echo "::add-matcher::.github/problem-matchers/msvc.json" - name: Fetch Realm.PlatformHelpers - uses: actions/download-artifact@v3 + uses: actions/download-artifact@v4 with: name: Realm.PlatformHelpers.${{ inputs.version }} path: ${{ github.workspace }}/Realm/packages/ - name: Fetch Realm - uses: actions/download-artifact@v3 + uses: actions/download-artifact@v4 with: name: Realm.${{ inputs.version }} path: ${{ github.workspace }}/Realm/packages/ @@ -101,12 +101,12 @@ jobs: - name: Register msvc problem matcher run: echo "::add-matcher::.github/problem-matchers/msvc.json" - name: Fetch Realm.PlatformHelpers - uses: actions/download-artifact@v3 + uses: actions/download-artifact@v4 with: name: Realm.PlatformHelpers.${{ inputs.version }} path: ${{ github.workspace }}/Realm/packages/ - name: Fetch Realm - uses: actions/download-artifact@v3 + uses: actions/download-artifact@v4 with: name: Realm.${{ inputs.version }} path: ${{ github.workspace }}/Realm/packages/ diff --git a/.github/workflows/test-code-coverage.yml b/.github/workflows/test-code-coverage.yml index de8242ef77..6cee9116bb 100755 --- a/.github/workflows/test-code-coverage.yml +++ b/.github/workflows/test-code-coverage.yml @@ -27,102 +27,102 @@ jobs: - name: Register msvc problem matcher run: echo "::add-matcher::.github/problem-matchers/msvc.json" - name: Fetch artifacts for macos - uses: actions/download-artifact@v3 + uses: actions/download-artifact@v4 with: name: wrappers-macos path: wrappers/build - name: Fetch artifacts for catalyst - uses: actions/download-artifact@v3 + uses: actions/download-artifact@v4 with: name: wrappers-catalyst path: wrappers/build - name: Fetch artifacts for linux-x86_64 - uses: actions/download-artifact@v3 + uses: actions/download-artifact@v4 with: name: wrappers-linux-x86_64 path: wrappers/build - name: Fetch artifacts for linux-armhf - uses: actions/download-artifact@v3 + uses: actions/download-artifact@v4 with: name: wrappers-linux-armhf path: wrappers/build - name: Fetch artifacts for linux-aarch64 - uses: actions/download-artifact@v3 + uses: actions/download-artifact@v4 with: name: wrappers-linux-aarch64 path: wrappers/build - name: Fetch artifacts for iOS-Device - uses: actions/download-artifact@v3 + uses: actions/download-artifact@v4 with: name: wrappers-iOS-Device path: wrappers/build - name: Fetch artifacts for iOS-Simulator - uses: actions/download-artifact@v3 + uses: actions/download-artifact@v4 with: name: wrappers-iOS-Simulator path: wrappers/build - name: Fetch artifacts for tvOS-Device - uses: actions/download-artifact@v3 + uses: actions/download-artifact@v4 with: name: wrappers-tvOS-Device path: wrappers/build - name: Fetch artifacts for tvOS-Simulator - uses: actions/download-artifact@v3 + uses: actions/download-artifact@v4 with: name: wrappers-tvOS-Simulator path: wrappers/build - name: Fetch artifacts for android-armeabi-v7a - uses: actions/download-artifact@v3 + uses: actions/download-artifact@v4 with: name: wrappers-android-armeabi-v7a path: wrappers/build - name: Fetch artifacts for android-arm64-v8a - uses: actions/download-artifact@v3 + uses: actions/download-artifact@v4 with: name: wrappers-android-arm64-v8a path: wrappers/build - name: Fetch artifacts for android-x86 - uses: actions/download-artifact@v3 + uses: actions/download-artifact@v4 with: name: wrappers-android-x86 path: wrappers/build - name: Fetch artifacts for android-x86_64 - uses: actions/download-artifact@v3 + uses: actions/download-artifact@v4 with: name: wrappers-android-x86_64 path: wrappers/build - name: Fetch artifacts for windows-Win32 - uses: actions/download-artifact@v3 + uses: actions/download-artifact@v4 with: name: wrappers-windows-Win32 path: wrappers/build - name: Fetch artifacts for windows-x64 - uses: actions/download-artifact@v3 + uses: actions/download-artifact@v4 with: name: wrappers-windows-x64 path: wrappers/build - name: Fetch artifacts for windows-ARM64 - uses: actions/download-artifact@v3 + uses: actions/download-artifact@v4 with: name: wrappers-windows-ARM64 path: wrappers/build - name: Fetch artifacts for windows-uwp-Win32 - uses: actions/download-artifact@v3 + uses: actions/download-artifact@v4 with: name: wrappers-windows-uwp-Win32 path: wrappers/build - name: Fetch artifacts for windows-uwp-x64 - uses: actions/download-artifact@v3 + uses: actions/download-artifact@v4 with: name: wrappers-windows-uwp-x64 path: wrappers/build - name: Fetch artifacts for windows-uwp-ARM - uses: actions/download-artifact@v3 + uses: actions/download-artifact@v4 with: name: wrappers-windows-uwp-ARM path: wrappers/build - name: Fetch artifacts for windows-uwp-ARM64 - uses: actions/download-artifact@v3 + uses: actions/download-artifact@v4 with: name: wrappers-windows-uwp-ARM64 path: wrappers/build diff --git a/.github/workflows/test-ios.yml b/.github/workflows/test-ios.yml index 1154de38ad..8c559a2986 100755 --- a/.github/workflows/test-ios.yml +++ b/.github/workflows/test-ios.yml @@ -27,12 +27,12 @@ jobs: - name: Register msvc problem matcher run: echo "::add-matcher::.github/problem-matchers/msvc.json" - name: Fetch Realm.PlatformHelpers - uses: actions/download-artifact@v3 + uses: actions/download-artifact@v4 with: name: Realm.PlatformHelpers.${{ inputs.version }} path: ${{ github.workspace }}/Realm/packages/ - name: Fetch Realm - uses: actions/download-artifact@v3 + uses: actions/download-artifact@v4 with: name: Realm.${{ inputs.version }} path: ${{ github.workspace }}/Realm/packages/ @@ -80,12 +80,12 @@ jobs: - name: Register msvc problem matcher run: echo "::add-matcher::.github/problem-matchers/msvc.json" - name: Fetch Realm.PlatformHelpers - uses: actions/download-artifact@v3 + uses: actions/download-artifact@v4 with: name: Realm.PlatformHelpers.${{ inputs.version }} path: ${{ github.workspace }}/Realm/packages/ - name: Fetch Realm - uses: actions/download-artifact@v3 + uses: actions/download-artifact@v4 with: name: Realm.${{ inputs.version }} path: ${{ github.workspace }}/Realm/packages/ diff --git a/.github/workflows/test-macos.yml b/.github/workflows/test-macos.yml index 80f39ada4d..dccf02ece6 100755 --- a/.github/workflows/test-macos.yml +++ b/.github/workflows/test-macos.yml @@ -27,12 +27,12 @@ jobs: - name: Register msvc problem matcher run: echo "::add-matcher::.github/problem-matchers/msvc.json" - name: Fetch Realm.PlatformHelpers - uses: actions/download-artifact@v3 + uses: actions/download-artifact@v4 with: name: Realm.PlatformHelpers.${{ inputs.version }} path: ${{ github.workspace }}/Realm/packages/ - name: Fetch Realm - uses: actions/download-artifact@v3 + uses: actions/download-artifact@v4 with: name: Realm.${{ inputs.version }} path: ${{ github.workspace }}/Realm/packages/ @@ -75,12 +75,12 @@ jobs: - name: Register msvc problem matcher run: echo "::add-matcher::.github/problem-matchers/msvc.json" - name: Fetch Realm.PlatformHelpers - uses: actions/download-artifact@v3 + uses: actions/download-artifact@v4 with: name: Realm.PlatformHelpers.${{ inputs.version }} path: ${{ github.workspace }}/Realm/packages/ - name: Fetch Realm - uses: actions/download-artifact@v3 + uses: actions/download-artifact@v4 with: name: Realm.${{ inputs.version }} path: ${{ github.workspace }}/Realm/packages/ diff --git a/.github/workflows/test-net-core.yml b/.github/workflows/test-net-core.yml index b7b81910f3..e17de623dd 100755 --- a/.github/workflows/test-net-core.yml +++ b/.github/workflows/test-net-core.yml @@ -48,12 +48,12 @@ jobs: - name: Cleanup Workspace run: git clean -fdx - name: Fetch Realm.PlatformHelpers - uses: actions/download-artifact@v3 + uses: actions/download-artifact@v4 with: name: Realm.PlatformHelpers.${{ inputs.version }} path: ${{ github.workspace }}/Realm/packages/ - name: Fetch Realm - uses: actions/download-artifact@v3 + uses: actions/download-artifact@v4 with: name: Realm.${{ inputs.version }} path: ${{ github.workspace }}/Realm/packages/ diff --git a/.github/workflows/test-tvos.yml b/.github/workflows/test-tvos.yml index 396f232543..6f64bd1e03 100755 --- a/.github/workflows/test-tvos.yml +++ b/.github/workflows/test-tvos.yml @@ -27,12 +27,12 @@ jobs: - name: Register msvc problem matcher run: echo "::add-matcher::.github/problem-matchers/msvc.json" - name: Fetch Realm.PlatformHelpers - uses: actions/download-artifact@v3 + uses: actions/download-artifact@v4 with: name: Realm.PlatformHelpers.${{ inputs.version }} path: ${{ github.workspace }}/Realm/packages/ - name: Fetch Realm - uses: actions/download-artifact@v3 + uses: actions/download-artifact@v4 with: name: Realm.${{ inputs.version }} path: ${{ github.workspace }}/Realm/packages/ diff --git a/.github/workflows/test-unity.yml b/.github/workflows/test-unity.yml index 8a41017505..1cbe3a5bc0 100755 --- a/.github/workflows/test-unity.yml +++ b/.github/workflows/test-unity.yml @@ -39,12 +39,12 @@ jobs: - name: Cleanup Workspace run: git clean -fdx - name: Fetch Unity Package - uses: actions/download-artifact@v3 + uses: actions/download-artifact@v4 with: name: io.realm.unity-${{ inputs.version }}.tgz path: Realm/Realm.Unity - name: Fetch Unity Tests - uses: actions/download-artifact@v3 + uses: actions/download-artifact@v4 with: name: UnityTests path: Tests/Tests.Unity @@ -76,7 +76,7 @@ jobs: - name: Register msvc problem matcher run: echo "::add-matcher::.github/problem-matchers/msvc.json" - name: Download Test Runner - uses: actions/download-artifact@v3 + uses: actions/download-artifact@v4 with: name: UnityTestsRunner.linux path: TestRunner @@ -115,7 +115,7 @@ jobs: - name: Register msvc problem matcher run: echo "::add-matcher::.github/problem-matchers/msvc.json" - name: Download Test Runner - uses: actions/download-artifact@v3 + uses: actions/download-artifact@v4 with: name: UnityTestsRunner.windows path: TestRunner diff --git a/.github/workflows/test-uwp-managed.yml b/.github/workflows/test-uwp-managed.yml index 18cd63991a..fe8e3639f3 100755 --- a/.github/workflows/test-uwp-managed.yml +++ b/.github/workflows/test-uwp-managed.yml @@ -31,12 +31,12 @@ jobs: - name: Register msvc problem matcher run: echo "::add-matcher::.github/problem-matchers/msvc.json" - name: Fetch Realm.PlatformHelpers - uses: actions/download-artifact@v3 + uses: actions/download-artifact@v4 with: name: Realm.PlatformHelpers.${{ inputs.version }} path: ${{ github.workspace }}/Realm/packages/ - name: Fetch Realm - uses: actions/download-artifact@v3 + uses: actions/download-artifact@v4 with: name: Realm.${{ inputs.version }} path: ${{ github.workspace }}/Realm/packages/ diff --git a/.github/workflows/test-woven-classes.yml b/.github/workflows/test-woven-classes.yml index a81b28827d..646a345ce7 100644 --- a/.github/workflows/test-woven-classes.yml +++ b/.github/workflows/test-woven-classes.yml @@ -27,12 +27,12 @@ jobs: - name: Register msvc problem matcher run: echo "::add-matcher::.github/problem-matchers/msvc.json" - name: Fetch Realm.PlatformHelpers - uses: actions/download-artifact@v3 + uses: actions/download-artifact@v4 with: name: Realm.PlatformHelpers.${{ inputs.version }} path: ${{ github.workspace }}/Realm/packages/ - name: Fetch Realm - uses: actions/download-artifact@v3 + uses: actions/download-artifact@v4 with: name: Realm.${{ inputs.version }} path: ${{ github.workspace }}/Realm/packages/ diff --git a/Tools/DeployApps/BaasClient.cs b/Tools/DeployApps/BaasClient.cs index 714a45bee8..a70205b8f6 100644 --- a/Tools/DeployApps/BaasClient.cs +++ b/Tools/DeployApps/BaasClient.cs @@ -1125,7 +1125,7 @@ private async Task WaitForContainer(string containerId, int maxRe await Task.Delay(2000); } - throw new Exception($"Container with id={containerId} was not found or ready after {maxRetries} retrues"); + throw new Exception($"Container with id={containerId} was not found or ready after 100 retries"); } private async Task CallEndpointAsync(HttpMethod method, string relativePath, object? payload = null) From 9ed2139e75b78fc46aec3679fdb8dd6f601f6761 Mon Sep 17 00:00:00 2001 From: Nikola Irinchev Date: Wed, 15 May 2024 00:10:49 +0200 Subject: [PATCH 10/39] Use upload artifact v4 --- .github/templates/common.lib.yml | 2 +- .github/templates/test-code-coverage.yml | 2 +- .github/templates/test-net-core.yml | 2 +- .github/workflows/build-packages.yml | 12 ++++++------ .github/workflows/build-unity.yml | 6 +++--- .github/workflows/main.yml | 2 +- .github/workflows/test-code-coverage.yml | 2 +- .github/workflows/test-net-core.yml | 2 +- .github/workflows/test-unity.yml | 2 +- 9 files changed, 16 insertions(+), 16 deletions(-) diff --git a/.github/templates/common.lib.yml b/.github/templates/common.lib.yml index 64d65de68e..fd6b8aae5f 100644 --- a/.github/templates/common.lib.yml +++ b/.github/templates/common.lib.yml @@ -5,7 +5,7 @@ #@ nugetPackages = publishedPackages + [ 'Realm.UnityUtils', 'Realm.UnityWeaver' ] #@ actionCheckout = "actions/checkout@v3" #@ actionCache = "nirinchev/cache@29e8e4dd9148ea81f9e188480132072cb6cc92d8" -#@ actionUploadArtifact = "actions/upload-artifact@v3" +#@ actionUploadArtifact = "actions/upload-artifact@v4" #@ actionDownloadArtifact = "actions/download-artifact@v4" #@ actionSetupMSBuild = "microsoft/setup-msbuild@0b44c6745b7e81956596964100aadb92d667c497" #@ actionSetupDotnet = "actions/setup-dotnet@3e6b9fe3930cac7c59c651af5de1514b47a805b9" #! 4.0.0 diff --git a/.github/templates/test-code-coverage.yml b/.github/templates/test-code-coverage.yml index 5e01ad8d95..4245827d89 100644 --- a/.github/templates/test-code-coverage.yml +++ b/.github/templates/test-code-coverage.yml @@ -24,7 +24,7 @@ jobs: 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" + baasTestArgs("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 + uses: actions/upload-artifact@v4 if: failure() with: name: crash-report-net-core-code-coverage diff --git a/.github/templates/test-net-core.yml b/.github/templates/test-net-core.yml index c2dc524126..68f3735a6a 100644 --- a/.github/templates/test-net-core.yml +++ b/.github/templates/test-net-core.yml @@ -45,7 +45,7 @@ jobs: DOTNET_EnableCrashReport: 1 run: #@ "${{ steps.dotnet-publish.outputs.executable-path }}/Realm.Tests --result=TestResults.xml --labels=After" - name: Archive core dump - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 if: failure() with: name: crash-report-net-core-${{ matrix.runner }}-${{ matrix.runtime }} diff --git a/.github/workflows/build-packages.yml b/.github/workflows/build-packages.yml index 22615f02e8..6f78bf3620 100755 --- a/.github/workflows/build-packages.yml +++ b/.github/workflows/build-packages.yml @@ -179,35 +179,35 @@ jobs: echo "version=$pkgVersion" >> $GITHUB_OUTPUT shell: bash - name: Store artifacts for Realm.PlatformHelpers.${{ steps.get-version.outputs.version }} - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: Realm.PlatformHelpers.${{ steps.get-version.outputs.version }} path: ${{ github.workspace }}/Realm/packages/Realm.PlatformHelpers.${{ steps.get-version.outputs.version }}.*nupkg retention-days: ${{ github.event_name != 'pull_request' && 30 || 1 }} if-no-files-found: error - name: Store artifacts for Realm.${{ steps.get-version.outputs.version }} - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: Realm.${{ steps.get-version.outputs.version }} path: ${{ github.workspace }}/Realm/packages/Realm.${{ steps.get-version.outputs.version }}.*nupkg retention-days: ${{ github.event_name != 'pull_request' && 30 || 1 }} if-no-files-found: error - name: Store artifacts for Realm.UnityUtils.${{ steps.get-version.outputs.version }} - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: Realm.UnityUtils.${{ steps.get-version.outputs.version }} path: ${{ github.workspace }}/Realm/packages/Realm.UnityUtils.${{ steps.get-version.outputs.version }}.*nupkg retention-days: ${{ github.event_name != 'pull_request' && 30 || 1 }} if-no-files-found: error - name: Store artifacts for Realm.UnityWeaver.${{ steps.get-version.outputs.version }} - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: Realm.UnityWeaver.${{ steps.get-version.outputs.version }} path: ${{ github.workspace }}/Realm/packages/Realm.UnityWeaver.${{ steps.get-version.outputs.version }}.*nupkg retention-days: ${{ github.event_name != 'pull_request' && 30 || 1 }} if-no-files-found: error - name: Store artifacts for ExtractedChangelog - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: ExtractedChangelog path: ${{ github.workspace }}/Realm/Realm/ExtractedChangelog.md @@ -251,7 +251,7 @@ jobs: run: | Compress-Archive -Path Docs/_site -DestinationPath "Realm/packages/Docs.zip" - name: Store artifacts for Docs.zip - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: Docs.zip path: ${{ github.workspace }}/Realm/packages/Docs.zip diff --git a/.github/workflows/build-unity.yml b/.github/workflows/build-unity.yml index d7189a4d52..354ba7f97f 100755 --- a/.github/workflows/build-unity.yml +++ b/.github/workflows/build-unity.yml @@ -46,14 +46,14 @@ jobs: - name: Build Unity run: dotnet run --project Tools/SetupUnityPackage/ -- realm --packages-path Realm/packages --pack - name: Store artifacts for io.realm.unity-${{ inputs.version }}.tgz - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: io.realm.unity-${{ inputs.version }}.tgz path: ${{ github.workspace }}/Realm/Realm.Unity/io.realm.unity-${{ inputs.version }}.tgz retention-days: ${{ github.event_name != 'pull_request' && 30 || 1 }} if-no-files-found: error - name: Store artifacts for AssetStorePublisher-${{ inputs.version }} - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: AssetStorePublisher-${{ inputs.version }} path: ${{ github.workspace }}/Tools/AssetStorePublisher @@ -62,7 +62,7 @@ jobs: - name: Build Tests run: dotnet run --project Tools/SetupUnityPackage/ -- tests --realm-package Realm/Realm.Unity/io.realm.unity-${{ inputs.version }}.tgz - name: Store artifacts for UnityTests - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: UnityTests path: ${{ github.workspace }}/Tests/Tests.Unity diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 404324e16d..bcd338f625 100755 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -258,7 +258,7 @@ jobs: dashboard-path: dashboard.charts nuget-package: ${{ github.workspace }}/Realm/packages/Realm.${{ needs.build-packages.outputs.package_version }}.nupkg - name: Store artifacts for dashboard.charts - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: dashboard.charts path: ${{ github.workspace }}/dashboard.charts diff --git a/.github/workflows/test-code-coverage.yml b/.github/workflows/test-code-coverage.yml index 6cee9116bb..c99772632f 100755 --- a/.github/workflows/test-code-coverage.yml +++ b/.github/workflows/test-code-coverage.yml @@ -149,7 +149,7 @@ jobs: 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 --baasaas-api-key=${{ secrets.BaaSaasApiKey}} --baas-differentiator=code-coverage-${{ github.run_id }}-${{ github.run_attempt }}' -f lcov -o ./report.lcov --exclude '[Realm.Tests]*' --exclude '[Realm.Fody]*' --exclude '[Realm.PlatformHelpers]*' - name: Archive core dump - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 if: failure() with: name: crash-report-net-core-code-coverage diff --git a/.github/workflows/test-net-core.yml b/.github/workflows/test-net-core.yml index e17de623dd..8c4ac9a8bb 100755 --- a/.github/workflows/test-net-core.yml +++ b/.github/workflows/test-net-core.yml @@ -76,7 +76,7 @@ jobs: DOTNET_EnableCrashReport: 1 run: ${{ steps.dotnet-publish.outputs.executable-path }}/Realm.Tests --result=TestResults.xml --labels=After - name: Archive core dump - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 if: failure() with: name: crash-report-net-core-${{ matrix.runner }}-${{ matrix.runtime }} diff --git a/.github/workflows/test-unity.yml b/.github/workflows/test-unity.yml index 1cbe3a5bc0..dd89d4ef00 100755 --- a/.github/workflows/test-unity.yml +++ b/.github/workflows/test-unity.yml @@ -52,7 +52,7 @@ jobs: run: | unity-editor -runTests -batchmode -projectPath ${{ github.workspace }}/Tests/Tests.Unity -testPlatform Standalone${{ matrix.platform.testPlatform }} -testSettingsFile ${{ github.workspace }}/Tests/Tests.Unity/.TestConfigs/${{ matrix.settings }}.json -logFile ${{ matrix.platform.os == 'windows' && 'build.log' || '-'}} - name: Store artifacts for UnityTestsRunner.${{ matrix.platform.os }} - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: UnityTestsRunner.${{ matrix.platform.os }} path: ${{ github.workspace }}/Tests/Tests.Unity/Player_Standalone${{ matrix.platform.testPlatform }}_${{ matrix.settings }}/ From 18d1b7d75da4ff2956200c9ba87be89405bd8a90 Mon Sep 17 00:00:00 2001 From: Nikola Irinchev Date: Wed, 15 May 2024 15:37:53 +0200 Subject: [PATCH 11/39] Move net core tests --- .../GithubAction/GithubAction.pkl | 3 +- .github/pkl-workflows/helpers/BaaS.pkl | 6 +- .github/pkl-workflows/helpers/Common.pkl | 3 + .github/pkl-workflows/helpers/Lint.pkl | 1 - .github/pkl-workflows/helpers/Steps.pkl | 32 ++++-- .github/pkl-workflows/helpers/Test.pkl | 97 +++++++++++++++++-- .github/pkl-workflows/pr.pkl | 7 +- .github/workflows/pr.yml | 88 +++++++++++++++-- .github/workflows/wrappers.yml | 6 ++ 9 files changed, 212 insertions(+), 31 deletions(-) diff --git a/.github/pkl-workflows/GithubAction/GithubAction.pkl b/.github/pkl-workflows/GithubAction/GithubAction.pkl index 0ef56b492e..206fec7c85 100644 --- a/.github/pkl-workflows/GithubAction/GithubAction.pkl +++ b/.github/pkl-workflows/GithubAction/GithubAction.pkl @@ -525,7 +525,7 @@ class On { } // Environment Variables -typealias EnvironmentVariables = Mapping +typealias EnvironmentVariables = Mapping // Permissions class Permissions { @@ -556,6 +556,7 @@ abstract class Strategy class MatrixStrategy extends Strategy { matrix: Mapping + `fail-fast`: Boolean = false } // Jobs diff --git a/.github/pkl-workflows/helpers/BaaS.pkl b/.github/pkl-workflows/helpers/BaaS.pkl index 35d4ddfc76..2b4f8704a9 100644 --- a/.github/pkl-workflows/helpers/BaaS.pkl +++ b/.github/pkl-workflows/helpers/BaaS.pkl @@ -15,12 +15,12 @@ function deploy(differentiators: Listing): gha.MatrixJob = new { `if` = Common.ifNotCanceledCondition steps { Steps.checkout() - Steps.setupDotnet() + Steps.setupDotnet("6.0.x") ...deployStep("${{ matrix.differentiator }}", true) } } -function deployStep(differentiator: String, shouldDeploy: Boolean): List = if (shouldDeploy) List(new gha.Step { +function deployStep(differentiator: String?, shouldDeploy: Boolean): List = if (shouldDeploy && differentiator != null) List(new gha.Step { name = "Deploy Apps" run = "dotnet run deploy-apps --baasaas-api-key=${{ secrets.BAASAAS_API_KEY }} --baas-differentiator=\(differentiator)-${{ github.run_id }}-${{ github.run_attempt }}" `working-directory` = "Tools/DeployApps" @@ -37,7 +37,7 @@ function cleanup(differentiators: Listing): gha.MatrixJob = new { `if` = Common.ifNotCanceledCondition steps { Steps.checkout() - Steps.setupDotnet() + Steps.setupDotnet("6.0.x") new gha.Step { name = "Terminate Baas" run = "dotnet run terminate-baas --baasaas-api-key=${{ secrets.BAASAAS_API_KEY }} --baas-differentiator=${{ matrix.differentiator }}-${{ github.run_id }}-${{ github.run_attempt }}" diff --git a/.github/pkl-workflows/helpers/Common.pkl b/.github/pkl-workflows/helpers/Common.pkl index f5a54f68ce..2401ef4995 100644 --- a/.github/pkl-workflows/helpers/Common.pkl +++ b/.github/pkl-workflows/helpers/Common.pkl @@ -10,6 +10,9 @@ const uwpArchs: List = List("Win32", "x64", "ARM", "ARM64") const appleTargets: List = List("Device", "Simulator") +typealias NetFramework = "net6.0" | "net8.0" | String +typealias NetRuntime = "win-x64" | "linux-x64" | "osx-x64" | "osx-arm64" | String + const wrapperBinaryNames: List = List("macos", "catalyst") + linuxArchs.map((arch) -> "linux-\(arch)") diff --git a/.github/pkl-workflows/helpers/Lint.pkl b/.github/pkl-workflows/helpers/Lint.pkl index 425fef5eb7..61dbe813d0 100644 --- a/.github/pkl-workflows/helpers/Lint.pkl +++ b/.github/pkl-workflows/helpers/Lint.pkl @@ -1,7 +1,6 @@ module lint import "../GithubAction/GithubAction.pkl" as gha -import "Common.pkl" import "Steps.pkl" function lint(): gha.Job = new { diff --git a/.github/pkl-workflows/helpers/Steps.pkl b/.github/pkl-workflows/helpers/Steps.pkl index 2671607ed2..f17003fa28 100644 --- a/.github/pkl-workflows/helpers/Steps.pkl +++ b/.github/pkl-workflows/helpers/Steps.pkl @@ -35,10 +35,10 @@ const function setupMSVC(edition: String): gha.Step = new { shell = "pwsh" } -const function setupDotnet(): gha.Step = new { +const function setupDotnet(version: String?): gha.Step = new { uses = "actions/setup-dotnet@607fce577a46308457984d59e4954e075820f10a" with { - ["dotnet-version"] = "6.0.x" + ["dotnet-version"] = version ?? "8.0.x" } } @@ -59,13 +59,31 @@ const function fetchPackages(packageJob: String, _packages: List?): List } }) -const function addMSBuildToPath(): gha.Step = new { +const function msbuild(project: String, properties: Mapping): List = List( + addMSBuildToPath(), + new gha.Step { + name = "Build \(project)" + run = "msbuild \(project) -p:Configuration=\(Common.configuration) -restore \(propertiesToString(properties))" + } +) + +const function dotnetPublish(project: String, framework: Common.NetFramework, runtime: Common.NetRuntime, properties: Mapping): Listing = new Listing { + new gha.Step { + name = "Publish \(project)" + run = "dotnet publish \(project) -c \(Common.configuration) -restore \(propertiesToString(properties))" + } + new gha.Step { + name = "Output executable path" + id = "dotnet-publish" + run = "echo 'executable-path=./\(project)/bin/\(Common.configuration)/\(framework)/\(runtime)' >> $GITHUB_OUTPUT" + shell = "bash" + } +} + +local const function addMSBuildToPath(): gha.Step = new { name = "Add msbuild to PATH" uses = "microsoft/setup-msbuild@0b44c6745b7e81956596964100aadb92d667c497" `if` = "${{ runner.os == 'Windows' }}" } -const function msbuild(project: String, properties: Mapping): gha.Step = new { - name = "Build \(project)" - run = "msbuild \(project) -p:Configuration=\(Common.configuration) -restore \(properties.toMap().entries.map((kvp) -> "-p:\(kvp.key)=\(kvp.value)").join(" "))" -} +local const function propertiesToString(properties: Mapping): String = properties.toMap().entries.map((kvp) -> "-p:\(kvp.key)=\(kvp.value)").join(" ") \ No newline at end of file diff --git a/.github/pkl-workflows/helpers/Test.pkl b/.github/pkl-workflows/helpers/Test.pkl index ef8f7cb850..df077a5b3c 100644 --- a/.github/pkl-workflows/helpers/Test.pkl +++ b/.github/pkl-workflows/helpers/Test.pkl @@ -7,13 +7,13 @@ import "BaaS.pkl" local const outputFile = "TestResults.xml" +// Public test targets function netFramework(_packageJob: String, syncDifferentiators: Listing): gha.Job = new { local testConfig = new TestConfig { packageJob = _packageJob runSyncTests = syncDifferentiators.toList().contains("net-framework") syncDifferentiator = "net-framework" title = ".NET Framework" - } name = "Test \(testConfig.title)" needs { @@ -24,8 +24,9 @@ function netFramework(_packageJob: String, syncDifferentiators: Listing) `timeout-minutes` = Common.testTimeout steps { ...prepareTests(testConfig) - Steps.addMSBuildToPath() - buildTests(_packageJob, "Tests/Realm.Tests", new Mapping{}) + ...buildTests(_packageJob, "Tests/Realm.Tests", new Mapping { + ["TargetFramework"] = "net461" + }) new gha.Step { name = "Run the tests" run = "./Tests/Realm/Tests/bin/\(Common.configuration)/net461/Realm.Tests.exe --result=\(outputFile) --labels=After \(baasTestArgs(testConfig))" @@ -34,6 +35,76 @@ function netFramework(_packageJob: String, syncDifferentiators: Listing) } } +function netCore(_packageJob: String, frameworks: Listing): gha.MatrixJob = new { + local testConfig = new TestConfig { + packageJob = _packageJob + title = "${{ matrix.framework }}, ${{ (matrix.os.runner == 'win81' && 'win81') || matrix.os.runtime }}" + shouldCleanWorkspace = true + } + + name = "Test \(testConfig.title)" + needs { + _packageJob + } + `runs-on` = "${{ matrix.os.runner }}" + `timeout-minutes` = Common.testTimeout + strategy { + matrix { + ["framework"] = frameworks + ["os"] = new Listing { + new { runner = "windows-latest" runtime = "win-x64" } + new { runner = "ubuntu-latest" runtime = "linux-x64" } + new { runner = "macos-13" runtime = "osx-x64" } + } + ["include"] = new Listing { + new Mapping { + ["framework"] = "net8.0" + ["os"] = new NetCoreOS { runner = "macos-14" runtime = "osx-arm64" } + } + } + } + } + steps { + ...prepareTests(testConfig) + // To avoid NU5037 error + new gha.Step { + name = "Clear nuget cache" + run = "dotnet nuget locals all --clear" + `if` = "${{ matrix.os.runner == 'win81' }}" + } + new gha.Step { + id = "get-net-version" + name = "Extract .NET version" + run = """ + NET_VERSION=$(echo '${{ matrix.framework }}.x' | sed 's/net//g') + echo "version=$NET_VERSION" >> $GITHUB_OUTPUT + """ + shell = "bash" + } + Steps.setupDotnet("${{ steps.get-net-version.outputs.version }}") + ...dotnetPublishNetCoreTests(_packageJob, "Tests/Realm.Tests", "${{ matrix.framework }}", "${{ matrix.os.runtime }}") + new gha.Step { + name = "Run the tests" + env { + ["DOTNET_DbgEnableMiniDump"] = 1 + ["DOTNET_EnableCrashReport"] = 1 + } + run = "${{ steps.dotnet-publish.outputs.executable-path }}/Realm.Tests --result=\(outputFile) --labels=After" + } + new gha.Step { + name = "Archive core dump" + uses = "actions/upload-artifact@v4" + `if` = "failure()" + with { + ["name"] = "crash-report-net-core-${{ matrix.os.runner }}-${{ matrix.os.runtime }}" + ["path"] = "/tmp/coredump*" + } + } + ...reportTestResults(testConfig) + } +} + +// Private helpers local function prepareTests(config: TestConfig): Listing = new Listing { Steps.checkout() ...cleanWorkspace(config.shouldCleanWorkspace) @@ -50,9 +121,8 @@ local function fetchTestArtifacts(packageJob: String, useWrappers: Boolean): Lis Steps.fetchPackages(packageJob, Common.nugetPackages) else Steps.fetchPackages(packageJob, Common.nugetPackages) -local function buildTests(packageJob: String, projectPath: String, properties: Mapping): gha.Step = Steps.msbuild(projectPath, new Mapping{ - ["RestoreConfigFile"] = "Tests/Test.NuGet.Config" - ["UseRealmNupkgsWithVersion"] = "${{ needs.\(packageJob).outputs.package_version }}" +local function buildTests(packageJob: String, projectPath: String, properties: Mapping): List = Steps.msbuild(projectPath, new Mapping{ + ...getTestProps(packageJob) ...properties }) @@ -79,12 +149,25 @@ local function reportTestResults(config: TestConfig): Listing = new { } } +local function dotnetPublishNetCoreTests(packageJob: String, project: String, framework: Common.NetFramework, runtime: Common.NetRuntime): Listing = Steps.dotnetPublish(project, framework, runtime, getTestProps(packageJob)) + +local function getTestProps(packageJob: String): Mapping = new Mapping { + ["RestoreConfigFile"] = "Tests/Test.NuGet.Config" + ["UseRealmNupkgsWithVersion"] = "${{ needs.\(packageJob).outputs.package_version }}" + ["RealmTestsStandaloneExe"] = "true" +} + +local class NetCoreOS { + runner: "windows-latest" | "ubuntu-latest" | "macos-13" | "macos-14" + runtime: Common.NetRuntime +} + local class TestConfig { packageJob: String useWrappers: Boolean = false shouldCleanWorkspace: Boolean = false runSyncTests: Boolean = false - syncDifferentiator: String + syncDifferentiator: String? transformResults: Boolean = false title: String } diff --git a/.github/pkl-workflows/pr.pkl b/.github/pkl-workflows/pr.pkl index b59e015330..1d5048655c 100644 --- a/.github/pkl-workflows/pr.pkl +++ b/.github/pkl-workflows/pr.pkl @@ -99,6 +99,7 @@ jobs { } needs { JobNames.unity + JobNames.packages } `if` = Common.ifNotCanceledCondition } @@ -109,11 +110,7 @@ jobs { ["Base64_Encoded_Pfx"] = "${{ secrets.Base64_Encoded_Pfx }}" } } - ["test-net-core"] = (createTestJob("test-net-core")) { - with { - ["framework"] = "[\"net8.0\"]" - } - } + ["test-net-core"] = TestJobs.netCore(JobNames.packages, new Listing { "net8.0" }) ["test-macos"] = createTestJob("test-macos") ["test-ios"] = createTestJob("test-ios") ["test-tvos"] = createTestJob("test-tvos") diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index 73a6d80bba..3934592f3c 100755 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -49,6 +49,7 @@ jobs: matrix: differentiator: - code-coverage + fail-fast: false build-packages: name: Package needs: @@ -68,6 +69,7 @@ jobs: name: Test needs: - build-unity + - build-packages if: always() && !cancelled() && !contains(needs.*.result, 'failure') && !contains(needs.*.result, 'cancelled') uses: ./.github/workflows/test-unity.yml with: @@ -101,7 +103,7 @@ jobs: if: ${{ runner.os == 'Windows' }} uses: microsoft/setup-msbuild@0b44c6745b7e81956596964100aadb92d667c497 - 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 }} + run: msbuild Tests/Realm.Tests -p:Configuration=Release -restore -p:RestoreConfigFile=Tests/Test.NuGet.Config -p:UseRealmNupkgsWithVersion=${{ needs.build-packages.outputs.package_version }} -p:RealmTestsStandaloneExe=true -p:TargetFramework=net461 - name: Run the tests run: './Tests/Realm/Tests/bin/Release/net461/Realm.Tests.exe --result=TestResults.xml --labels=After ' - name: Publish Unit Test Results @@ -126,14 +128,85 @@ jobs: Pfx_Password: ${{ secrets.Pfx_Password }} Base64_Encoded_Pfx: ${{ secrets.Base64_Encoded_Pfx }} test-net-core: - name: Test + name: Test ${{ matrix.framework }}, ${{ (matrix.os.runner == 'win81' && 'win81') || matrix.os.runtime }} needs: - build-packages - if: always() && !cancelled() && !contains(needs.*.result, 'failure') && !contains(needs.*.result, 'cancelled') - uses: ./.github/workflows/test-net-core.yml - with: - version: ${{ needs.build-packages.outputs.package_version }} - framework: '["net8.0"]' + timeout-minutes: 60 + runs-on: ${{ matrix.os.runner }} + steps: + - name: Checkout Code + uses: actions/checkout@v4 + with: + submodules: recursive + ref: ${{ github.event.pull_request.head.sha }} + - name: Cleanup Workspace + run: git clean -fdx + - name: Fetch Realm + uses: actions/download-artifact@v4 + with: + name: Realm.${{ needs.build-packages.outputs.package_version }} + path: ${{ github.workspace }}/Realm/packages/ + - name: Fetch Realm.PlatformHelpers + uses: actions/download-artifact@v4 + with: + name: Realm.PlatformHelpers.${{ needs.build-packages.outputs.package_version }} + path: ${{ github.workspace }}/Realm/packages/ + - name: Clear nuget cache + if: ${{ matrix.os.runner == 'win81' }} + run: dotnet nuget locals all --clear + - name: Extract .NET version + id: get-net-version + run: |2- + NET_VERSION=$(echo '${{ matrix.framework }}.x' | sed 's/net//g') + echo "version=$NET_VERSION" >> $GITHUB_OUTPUT + shell: bash + - uses: actions/setup-dotnet@607fce577a46308457984d59e4954e075820f10a + with: + dotnet-version: ${{ steps.get-net-version.outputs.version }} + - name: Publish Tests/Realm.Tests + run: dotnet publish Tests/Realm.Tests -c Release -restore -p:RestoreConfigFile=Tests/Test.NuGet.Config -p:UseRealmNupkgsWithVersion=${{ needs.build-packages.outputs.package_version }} -p:RealmTestsStandaloneExe=true + - name: Output executable path + id: dotnet-publish + run: echo 'executable-path=./Tests/Realm.Tests/bin/Release/${{ matrix.framework }}/${{ matrix.os.runtime }}' >> $GITHUB_OUTPUT + shell: bash + - name: Run the tests + env: + DOTNET_DbgEnableMiniDump: 1 + DOTNET_EnableCrashReport: 1 + run: ${{ steps.dotnet-publish.outputs.executable-path }}/Realm.Tests --result=TestResults.xml --labels=After + - name: Archive core dump + if: failure() + uses: actions/upload-artifact@v4 + with: + name: crash-report-net-core-${{ matrix.os.runner }}-${{ matrix.os.runtime }} + path: /tmp/coredump* + - name: Publish Unit Test Results + if: always() + uses: LaPeste/test-reporter@510caf50a955b1003bec48a6494be4d6537f3a0b + with: + name: Results ${{ matrix.framework }}, ${{ (matrix.os.runner == 'win81' && 'win81') || matrix.os.runtime }} + path: TestResults.xml + reporter: java-junit + list-suites: failed + path-replace-backslashes: true + fail-on-error: true + strategy: + matrix: + framework: + - net8.0 + os: + - runner: windows-latest + runtime: win-x64 + - runner: ubuntu-latest + runtime: linux-x64 + - runner: macos-13 + runtime: osx-x64 + include: + - framework: net8.0 + os: + runner: macos-14 + runtime: osx-arm64 + fail-fast: false test-macos: name: Test needs: @@ -218,6 +291,7 @@ jobs: matrix: differentiator: - code-coverage + fail-fast: false verify-namespaces: name: Verify Namespaces needs: diff --git a/.github/workflows/wrappers.yml b/.github/workflows/wrappers.yml index edd27f0cc8..5b9e919602 100755 --- a/.github/workflows/wrappers.yml +++ b/.github/workflows/wrappers.yml @@ -385,6 +385,7 @@ jobs: os: - ubuntu - windows + fail-fast: false macos: name: MacOS needs: @@ -485,6 +486,7 @@ jobs: target: - Device - Simulator + fail-fast: false linux: name: Linux needs: @@ -523,6 +525,7 @@ jobs: - x86_64 - armhf - aarch64 + fail-fast: false android: name: Android needs: @@ -559,6 +562,7 @@ jobs: - arm64-v8a - x86 - x86_64 + fail-fast: false windows: name: Windows needs: @@ -598,6 +602,7 @@ jobs: - Win32 - x64 - ARM64 + fail-fast: false uwp: name: UWP needs: @@ -638,3 +643,4 @@ jobs: - x64 - ARM - ARM64 + fail-fast: false From de7ab935fdda302cfcbf4d22cc42ccd7da8139e6 Mon Sep 17 00:00:00 2001 From: Nikola Irinchev Date: Wed, 15 May 2024 15:55:28 +0200 Subject: [PATCH 12/39] Move test-weaver --- .github/pkl-workflows/helpers/Steps.pkl | 10 ++- .github/pkl-workflows/helpers/Test.pkl | 37 +++++++++- .github/pkl-workflows/pr.pkl | 12 ++-- .github/templates/test-net-core.yml | 53 -------------- .github/templates/test-weaver.yml | 33 --------- .github/workflows/pr.yml | 50 +++++++++++-- .github/workflows/test-net-core.yml | 94 ------------------------- .github/workflows/test-weaver.yml | 59 ---------------- 8 files changed, 95 insertions(+), 253 deletions(-) delete mode 100644 .github/templates/test-net-core.yml delete mode 100644 .github/templates/test-weaver.yml delete mode 100755 .github/workflows/test-net-core.yml delete mode 100755 .github/workflows/test-weaver.yml diff --git a/.github/pkl-workflows/helpers/Steps.pkl b/.github/pkl-workflows/helpers/Steps.pkl index f17003fa28..b3dba6fef4 100644 --- a/.github/pkl-workflows/helpers/Steps.pkl +++ b/.github/pkl-workflows/helpers/Steps.pkl @@ -59,6 +59,14 @@ const function fetchPackages(packageJob: String, _packages: List?): List } }) +const function setupWorkloads(workloads: String, dotnetVersion: String): Listing = new Listing { + setupDotnet(dotnetVersion) + new { + name = "Setup workloads" + run = "dotnet workload install \(workloads)" + } +} + const function msbuild(project: String, properties: Mapping): List = List( addMSBuildToPath(), new gha.Step { @@ -70,7 +78,7 @@ const function msbuild(project: String, properties: Mapping): Li const function dotnetPublish(project: String, framework: Common.NetFramework, runtime: Common.NetRuntime, properties: Mapping): Listing = new Listing { new gha.Step { name = "Publish \(project)" - run = "dotnet publish \(project) -c \(Common.configuration) -restore \(propertiesToString(properties))" + run = "dotnet publish \(project) -c \(Common.configuration) -f \(framework) -r \(runtime) -restore \(propertiesToString(properties))" } new gha.Step { name = "Output executable path" diff --git a/.github/pkl-workflows/helpers/Test.pkl b/.github/pkl-workflows/helpers/Test.pkl index df077a5b3c..ae0c5e4436 100644 --- a/.github/pkl-workflows/helpers/Test.pkl +++ b/.github/pkl-workflows/helpers/Test.pkl @@ -48,10 +48,11 @@ function netCore(_packageJob: String, frameworks: Listing): } `runs-on` = "${{ matrix.os.runner }}" `timeout-minutes` = Common.testTimeout + `if` = Common.ifNotCanceledCondition strategy { matrix { ["framework"] = frameworks - ["os"] = new Listing { + ["os"] = new Listing { new { runner = "windows-latest" runtime = "win-x64" } new { runner = "ubuntu-latest" runtime = "linux-x64" } new { runner = "macos-13" runtime = "osx-x64" } @@ -59,7 +60,7 @@ function netCore(_packageJob: String, frameworks: Listing): ["include"] = new Listing { new Mapping { ["framework"] = "net8.0" - ["os"] = new NetCoreOS { runner = "macos-14" runtime = "osx-arm64" } + ["os"] = new MatrixOS { runner = "macos-14" runtime = "osx-arm64" } } } } @@ -104,6 +105,36 @@ function netCore(_packageJob: String, frameworks: Listing): } } +function weaver(): gha.MatrixJob = new { + local testConfig = new TestConfig { + title = "Weaver" + shouldCleanWorkspace = true + } + + name = "Test \(testConfig.title)" + strategy { + matrix { + ["os"] = new Listing { + new { runner = "windows-latest" runtime = "win-x64" } + new { runner = "ubuntu-latest" runtime = "linux-x64" } + new { runner = "macos-14" runtime = "osx-arm64" } + } + } + } + `runs-on` = "${{ matrix.os.runner }}" + `timeout-minutes` = Common.testTimeout + steps { + Steps.checkout() + ...Steps.setupWorkloads("android ${{ (matrix.os.runner != 'ubuntu-latest' && 'tvos ios maccatalyst') || '' }}", "6.0.x").toList() + ...Steps.dotnetPublish("Tests/Weaver/Realm.Fody.Tests", "net6.0", "${{ matrix.os.runtime }}", new Mapping{}).toList() + new gha.Step { + name = "Run the tests" + run = "${{ steps.dotnet-publish.outputs.executable-path }}/Realm.Fody.Tests --result=\(outputFile) --labels=After" + } + ...reportTestResults(testConfig) + } +} + // Private helpers local function prepareTests(config: TestConfig): Listing = new Listing { Steps.checkout() @@ -157,7 +188,7 @@ local function getTestProps(packageJob: String): Mapping = new M ["RealmTestsStandaloneExe"] = "true" } -local class NetCoreOS { +local class MatrixOS { runner: "windows-latest" | "ubuntu-latest" | "macos-13" | "macos-14" runtime: Common.NetRuntime } diff --git a/.github/pkl-workflows/pr.pkl b/.github/pkl-workflows/pr.pkl index 1d5048655c..1620f9638f 100644 --- a/.github/pkl-workflows/pr.pkl +++ b/.github/pkl-workflows/pr.pkl @@ -128,11 +128,7 @@ jobs { name = "Test" uses = "./.github/workflows/test-source-generation.yml" } - ["test-weaver"] = new ReusableWorkflowJob { - `if` = Common.ifNotCanceledCondition - name = "Test" - uses = "./.github/workflows/test-weaver.yml" - } + ["test-weaver"] = TestJobs.weaver() ["test-code-coverage"] = (createTestJob("test-code-coverage")) { needs { JobNames.baas @@ -141,7 +137,11 @@ jobs { ["BaaSaasApiKey"] = "${{ secrets.BAASAAS_API_KEY }}" } } - ["cleanup-baas"] = BaaS.cleanup(baasDifferentiators) + ["cleanup-baas"] = (BaaS.cleanup(baasDifferentiators)) { + needs { + JobNames.coverage + } + } ["verify-namespaces"] = Lint.verifyNamespaces(JobNames.packages) ["lint"] = Lint.lint() } diff --git a/.github/templates/test-net-core.yml b/.github/templates/test-net-core.yml deleted file mode 100644 index 68f3735a6a..0000000000 --- a/.github/templates/test-net-core.yml +++ /dev/null @@ -1,53 +0,0 @@ -#@ load("@ytt:template", "template") -#@ load("common.lib.yml", "checkoutCode", "uploadArtifacts", "setupDotnet") -#@ load("test.lib.yml", "baasTestArgs", "publishTestsResults", "testDefinition", "buildTests", "dotnetBuildTests", "prepareTest") - ---- -name: test-net-core -_: #@ template.replace(testDefinition(additionalInputs = [ "framework"])) -jobs: - run-tests: - runs-on: ${{ matrix.os.runner }} - name: ${{ matrix.framework }}, ${{ (matrix.os.runner == 'win81' && 'win81') || matrix.os.runtime }} - timeout-minutes: 45 - strategy: - fail-fast: false - matrix: - os: - - runner: windows-latest - runtime: win-x64 - - runner: ubuntu-latest - runtime: linux-x64 - - runner: macos-13 - runtime: osx-x64 - framework: ${{ fromJson(inputs.framework) }} - include: - - framework: net8.0 - os: - runner: macos-14 - runtime: osx-arm64 - #! - framework: net6.0 // Need to install net8 sdk to the win81 runner - #! os: - #! runner: win81 - #! runtime: win-x64 - - steps: - - #@ template.replace(prepareTest(cleanupWorkspace = True)) - #! To avoid NU5037 error - - name: Clear nuget cache - run: dotnet nuget locals all --clear - if: ${{ matrix.os.runner == 'win81' }} - - _: #@ template.replace(setupDotnet()) - - #@ template.replace(dotnetBuildTests("Tests/Realm.Tests", "${{ matrix.framework }}", "${{ matrix.os.runtime }}")) - - name: Run the tests - env: - DOTNET_DbgEnableMiniDump: 1 - DOTNET_EnableCrashReport: 1 - run: #@ "${{ steps.dotnet-publish.outputs.executable-path }}/Realm.Tests --result=TestResults.xml --labels=After" - - name: Archive core dump - uses: actions/upload-artifact@v4 - if: failure() - with: - name: crash-report-net-core-${{ matrix.runner }}-${{ matrix.runtime }} - path: /tmp/coredump* - - #@ template.replace(publishTestsResults("TestResults.xml", ".NET (${{ matrix.os.runner }}, ${{ matrix.framework }})")) diff --git a/.github/templates/test-weaver.yml b/.github/templates/test-weaver.yml deleted file mode 100644 index 9194d124ca..0000000000 --- a/.github/templates/test-weaver.yml +++ /dev/null @@ -1,33 +0,0 @@ -#@ load("@ytt:template", "template") -#@ load("common.lib.yml", "checkoutCode", "dotnetPublish", "setupWorkloads", "setupDotnet") -#@ load("test.lib.yml", "publishTestsResults") - ---- -name: test-weaver -"on": - workflow_call: -env: - REALM_DISABLE_ANALYTICS: true - DOTNET_NOLOGO: true -jobs: - run-tests-weaver: - strategy: - matrix: - os: - - runner: windows-latest - runtime: win-x64 - - runner: ubuntu-latest - runtime: linux-x64 - - runner: macos-14 - runtime: osx-arm64 - runs-on: ${{ matrix.os.runner }} - name: Weaver - timeout-minutes: 30 - steps: - - #@ template.replace(checkoutCode()) - - #@ template.replace(setupWorkloads("android ${{ (matrix.os.runner != 'ubuntu-latest' && 'tvos ios maccatalyst') || '' }}")) - - _: #@ template.replace(setupDotnet("6.0.x")) - - #@ template.replace(dotnetPublish("Tests/Weaver/Realm.Fody.Tests", "net6.0", "${{ matrix.os.runtime }}")) - - name: Run Tests - run: ${{ steps.dotnet-publish.outputs.executable-path }}/Realm.Fody.Tests --result=TestResults.Weaver.xml --labels=After - - #@ template.replace(publishTestsResults("TestResults.Weaver.xml", "Weaver ${{ matrix.os.runtime }}")) diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index 3934592f3c..aa1fe44398 100755 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -131,6 +131,7 @@ jobs: name: Test ${{ matrix.framework }}, ${{ (matrix.os.runner == 'win81' && 'win81') || matrix.os.runtime }} needs: - build-packages + if: always() && !cancelled() && !contains(needs.*.result, 'failure') && !contains(needs.*.result, 'cancelled') timeout-minutes: 60 runs-on: ${{ matrix.os.runner }} steps: @@ -164,7 +165,7 @@ jobs: with: dotnet-version: ${{ steps.get-net-version.outputs.version }} - name: Publish Tests/Realm.Tests - run: dotnet publish Tests/Realm.Tests -c Release -restore -p:RestoreConfigFile=Tests/Test.NuGet.Config -p:UseRealmNupkgsWithVersion=${{ needs.build-packages.outputs.package_version }} -p:RealmTestsStandaloneExe=true + run: dotnet publish Tests/Realm.Tests -c Release -f ${{ matrix.framework }} -r ${{ matrix.os.runtime }} -restore -p:RestoreConfigFile=Tests/Test.NuGet.Config -p:UseRealmNupkgsWithVersion=${{ needs.build-packages.outputs.package_version }} -p:RealmTestsStandaloneExe=true - name: Output executable path id: dotnet-publish run: echo 'executable-path=./Tests/Realm.Tests/bin/Release/${{ matrix.framework }}/${{ matrix.os.runtime }}' >> $GITHUB_OUTPUT @@ -257,9 +258,48 @@ jobs: if: always() && !cancelled() && !contains(needs.*.result, 'failure') && !contains(needs.*.result, 'cancelled') uses: ./.github/workflows/test-source-generation.yml test-weaver: - name: Test - if: always() && !cancelled() && !contains(needs.*.result, 'failure') && !contains(needs.*.result, 'cancelled') - uses: ./.github/workflows/test-weaver.yml + name: Test Weaver + timeout-minutes: 60 + runs-on: ${{ matrix.os.runner }} + steps: + - name: Checkout Code + uses: actions/checkout@v4 + with: + submodules: recursive + ref: ${{ github.event.pull_request.head.sha }} + - uses: actions/setup-dotnet@607fce577a46308457984d59e4954e075820f10a + with: + dotnet-version: 6.0.x + - name: Setup workloads + run: dotnet workload install android ${{ (matrix.os.runner != 'ubuntu-latest' && 'tvos ios maccatalyst') || '' }} + - name: Publish Tests/Weaver/Realm.Fody.Tests + run: 'dotnet publish Tests/Weaver/Realm.Fody.Tests -c Release -f net6.0 -r ${{ matrix.os.runtime }} -restore ' + - name: Output executable path + id: dotnet-publish + run: echo 'executable-path=./Tests/Weaver/Realm.Fody.Tests/bin/Release/net6.0/${{ matrix.os.runtime }}' >> $GITHUB_OUTPUT + shell: bash + - name: Run the tests + run: ${{ steps.dotnet-publish.outputs.executable-path }}/Realm.Fody.Tests --result=TestResults.xml --labels=After + - name: Publish Unit Test Results + if: always() + uses: LaPeste/test-reporter@510caf50a955b1003bec48a6494be4d6537f3a0b + with: + name: Results Weaver + path: TestResults.xml + reporter: java-junit + list-suites: failed + path-replace-backslashes: true + fail-on-error: true + strategy: + matrix: + os: + - runner: windows-latest + runtime: win-x64 + - runner: ubuntu-latest + runtime: linux-x64 + - runner: macos-14 + runtime: osx-arm64 + fail-fast: false test-code-coverage: name: Test needs: @@ -273,6 +313,8 @@ jobs: BaaSaasApiKey: ${{ secrets.BAASAAS_API_KEY }} cleanup-baas: name: Cleanup BaaS + needs: + - test-code-coverage if: always() && !cancelled() && !contains(needs.*.result, 'failure') && !contains(needs.*.result, 'cancelled') runs-on: ubuntu-latest steps: diff --git a/.github/workflows/test-net-core.yml b/.github/workflows/test-net-core.yml deleted file mode 100755 index 8c4ac9a8bb..0000000000 --- a/.github/workflows/test-net-core.yml +++ /dev/null @@ -1,94 +0,0 @@ -name: test-net-core -"on": - workflow_call: - inputs: - version: - required: true - type: string - framework: - required: true - type: string - secrets: - BaaSaasApiKey: - required: false -env: - REALM_DISABLE_ANALYTICS: true - DOTNET_NOLOGO: true -jobs: - run-tests: - runs-on: ${{ matrix.os.runner }} - name: ${{ matrix.framework }}, ${{ (matrix.os.runner == 'win81' && 'win81') || matrix.os.runtime }} - timeout-minutes: 45 - strategy: - fail-fast: false - matrix: - os: - - runner: windows-latest - runtime: win-x64 - - runner: ubuntu-latest - runtime: linux-x64 - - runner: macos-13 - runtime: osx-x64 - framework: ${{ fromJson(inputs.framework) }} - include: - - framework: net8.0 - os: - runner: macos-14 - runtime: osx-arm64 - 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: Cleanup Workspace - run: git clean -fdx - - name: Fetch Realm.PlatformHelpers - uses: actions/download-artifact@v4 - with: - name: Realm.PlatformHelpers.${{ inputs.version }} - path: ${{ github.workspace }}/Realm/packages/ - - name: Fetch Realm - uses: actions/download-artifact@v4 - with: - name: Realm.${{ inputs.version }} - path: ${{ github.workspace }}/Realm/packages/ - - name: Clear nuget cache - run: dotnet nuget locals all --clear - if: ${{ matrix.os.runner == 'win81' }} - - name: Configure .NET - uses: actions/setup-dotnet@3e6b9fe3930cac7c59c651af5de1514b47a805b9 - with: - dotnet-version: 8.0.x - - 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 - id: dotnet-publish - run: echo 'executable-path=./Tests/Realm.Tests/bin/Release/${{ matrix.framework }}/${{ matrix.os.runtime }}' >> $GITHUB_OUTPUT - shell: bash - - name: Run the tests - env: - DOTNET_DbgEnableMiniDump: 1 - DOTNET_EnableCrashReport: 1 - run: ${{ steps.dotnet-publish.outputs.executable-path }}/Realm.Tests --result=TestResults.xml --labels=After - - name: Archive core dump - uses: actions/upload-artifact@v4 - if: failure() - with: - name: crash-report-net-core-${{ matrix.runner }}-${{ matrix.runtime }} - path: /tmp/coredump* - - name: Publish Unit Test Results - uses: LaPeste/test-reporter@510caf50a955b1003bec48a6494be4d6537f3a0b - if: always() - with: - name: Results .NET (${{ matrix.os.runner }}, ${{ matrix.framework }}) - path: TestResults.xml - reporter: java-junit - list-suites: failed - list-tests: failed - path-replace-backslashes: true - fail-on-error: true diff --git a/.github/workflows/test-weaver.yml b/.github/workflows/test-weaver.yml deleted file mode 100755 index e14e5aeca5..0000000000 --- a/.github/workflows/test-weaver.yml +++ /dev/null @@ -1,59 +0,0 @@ -name: test-weaver -"on": - workflow_call: null -env: - REALM_DISABLE_ANALYTICS: true - DOTNET_NOLOGO: true -jobs: - run-tests-weaver: - strategy: - matrix: - os: - - runner: windows-latest - runtime: win-x64 - - runner: ubuntu-latest - runtime: linux-x64 - - runner: macos-14 - runtime: osx-arm64 - runs-on: ${{ matrix.os.runner }} - name: Weaver - timeout-minutes: 30 - 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: Configure .NET - uses: actions/setup-dotnet@3e6b9fe3930cac7c59c651af5de1514b47a805b9 - with: - dotnet-version: 8.0.x - - name: Setup workloads - run: dotnet workload install android ${{ (matrix.os.runner != 'ubuntu-latest' && 'tvos ios maccatalyst') || '' }} - - name: Configure .NET - uses: actions/setup-dotnet@3e6b9fe3930cac7c59c651af5de1514b47a805b9 - with: - dotnet-version: 6.0.x - - name: Publish Tests/Weaver/Realm.Fody.Tests - run: dotnet publish Tests/Weaver/Realm.Fody.Tests -c Release -f net6.0 -r ${{ matrix.os.runtime }} --no-self-contained - - name: Output executable path - id: dotnet-publish - run: echo 'executable-path=./Tests/Weaver/Realm.Fody.Tests/bin/Release/net6.0/${{ matrix.os.runtime }}' >> $GITHUB_OUTPUT - shell: bash - - name: Run Tests - run: ${{ steps.dotnet-publish.outputs.executable-path }}/Realm.Fody.Tests --result=TestResults.Weaver.xml --labels=After - - name: Publish Unit Test Results - uses: LaPeste/test-reporter@510caf50a955b1003bec48a6494be4d6537f3a0b - if: always() - with: - name: Results Weaver ${{ matrix.os.runtime }} - path: TestResults.Weaver.xml - reporter: java-junit - list-suites: failed - list-tests: failed - path-replace-backslashes: true - fail-on-error: true From 893b8a3dd9a2856cba9c08cf56adb9edbac9b7b1 Mon Sep 17 00:00:00 2001 From: Nikola Irinchev Date: Wed, 15 May 2024 16:11:42 +0200 Subject: [PATCH 13/39] add --no-self-contained --- .github/pkl-workflows/helpers/Steps.pkl | 2 +- .github/workflows/pr.yml | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/pkl-workflows/helpers/Steps.pkl b/.github/pkl-workflows/helpers/Steps.pkl index b3dba6fef4..fbdfebb954 100644 --- a/.github/pkl-workflows/helpers/Steps.pkl +++ b/.github/pkl-workflows/helpers/Steps.pkl @@ -78,7 +78,7 @@ const function msbuild(project: String, properties: Mapping): Li const function dotnetPublish(project: String, framework: Common.NetFramework, runtime: Common.NetRuntime, properties: Mapping): Listing = new Listing { new gha.Step { name = "Publish \(project)" - run = "dotnet publish \(project) -c \(Common.configuration) -f \(framework) -r \(runtime) -restore \(propertiesToString(properties))" + run = "dotnet publish \(project) -c \(Common.configuration) -f \(framework) -r \(runtime) -restore \(propertiesToString(properties)) --no-self-contained" } new gha.Step { name = "Output executable path" diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index aa1fe44398..b70852d2e7 100755 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -165,7 +165,7 @@ jobs: with: dotnet-version: ${{ steps.get-net-version.outputs.version }} - name: Publish Tests/Realm.Tests - run: dotnet publish Tests/Realm.Tests -c Release -f ${{ matrix.framework }} -r ${{ matrix.os.runtime }} -restore -p:RestoreConfigFile=Tests/Test.NuGet.Config -p:UseRealmNupkgsWithVersion=${{ needs.build-packages.outputs.package_version }} -p:RealmTestsStandaloneExe=true + run: dotnet publish Tests/Realm.Tests -c Release -f ${{ matrix.framework }} -r ${{ matrix.os.runtime }} -restore -p:RestoreConfigFile=Tests/Test.NuGet.Config -p:UseRealmNupkgsWithVersion=${{ needs.build-packages.outputs.package_version }} -p:RealmTestsStandaloneExe=true --no-self-contained - name: Output executable path id: dotnet-publish run: echo 'executable-path=./Tests/Realm.Tests/bin/Release/${{ matrix.framework }}/${{ matrix.os.runtime }}' >> $GITHUB_OUTPUT @@ -273,7 +273,7 @@ jobs: - name: Setup workloads run: dotnet workload install android ${{ (matrix.os.runner != 'ubuntu-latest' && 'tvos ios maccatalyst') || '' }} - name: Publish Tests/Weaver/Realm.Fody.Tests - run: 'dotnet publish Tests/Weaver/Realm.Fody.Tests -c Release -f net6.0 -r ${{ matrix.os.runtime }} -restore ' + run: dotnet publish Tests/Weaver/Realm.Fody.Tests -c Release -f net6.0 -r ${{ matrix.os.runtime }} -restore --no-self-contained - name: Output executable path id: dotnet-publish run: echo 'executable-path=./Tests/Weaver/Realm.Fody.Tests/bin/Release/net6.0/${{ matrix.os.runtime }}' >> $GITHUB_OUTPUT From 92ead96cfa49be1e715c513d8062fae4ee84dcbc Mon Sep 17 00:00:00 2001 From: Nikola Irinchev Date: Wed, 15 May 2024 19:23:01 +0200 Subject: [PATCH 14/39] fix paths --- .github/pkl-workflows/helpers/Steps.pkl | 2 +- .github/pkl-workflows/helpers/Test.pkl | 2 +- .github/workflows/pr.yml | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/pkl-workflows/helpers/Steps.pkl b/.github/pkl-workflows/helpers/Steps.pkl index fbdfebb954..dc35633427 100644 --- a/.github/pkl-workflows/helpers/Steps.pkl +++ b/.github/pkl-workflows/helpers/Steps.pkl @@ -78,7 +78,7 @@ const function msbuild(project: String, properties: Mapping): Li const function dotnetPublish(project: String, framework: Common.NetFramework, runtime: Common.NetRuntime, properties: Mapping): Listing = new Listing { new gha.Step { name = "Publish \(project)" - run = "dotnet publish \(project) -c \(Common.configuration) -f \(framework) -r \(runtime) -restore \(propertiesToString(properties)) --no-self-contained" + run = "dotnet publish \(project) -c \(Common.configuration) -f \(framework) -r \(runtime) \(propertiesToString(properties)) --no-self-contained" } new gha.Step { name = "Output executable path" diff --git a/.github/pkl-workflows/helpers/Test.pkl b/.github/pkl-workflows/helpers/Test.pkl index ae0c5e4436..f48f176d0d 100644 --- a/.github/pkl-workflows/helpers/Test.pkl +++ b/.github/pkl-workflows/helpers/Test.pkl @@ -29,7 +29,7 @@ function netFramework(_packageJob: String, syncDifferentiators: Listing) }) new gha.Step { name = "Run the tests" - run = "./Tests/Realm/Tests/bin/\(Common.configuration)/net461/Realm.Tests.exe --result=\(outputFile) --labels=After \(baasTestArgs(testConfig))" + run = "./Tests/Realm.Tests/bin/\(Common.configuration)/net461/Realm.Tests.exe --result=\(outputFile) --labels=After \(baasTestArgs(testConfig))" } ...reportTestResults(testConfig) } diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index b70852d2e7..86ac264872 100755 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -105,7 +105,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:RealmTestsStandaloneExe=true -p:TargetFramework=net461 - name: Run the tests - run: './Tests/Realm/Tests/bin/Release/net461/Realm.Tests.exe --result=TestResults.xml --labels=After ' + run: './Tests/Realm.Tests/bin/Release/net461/Realm.Tests.exe --result=TestResults.xml --labels=After ' - name: Publish Unit Test Results if: always() uses: LaPeste/test-reporter@510caf50a955b1003bec48a6494be4d6537f3a0b @@ -165,7 +165,7 @@ jobs: with: dotnet-version: ${{ steps.get-net-version.outputs.version }} - name: Publish Tests/Realm.Tests - run: dotnet publish Tests/Realm.Tests -c Release -f ${{ matrix.framework }} -r ${{ matrix.os.runtime }} -restore -p:RestoreConfigFile=Tests/Test.NuGet.Config -p:UseRealmNupkgsWithVersion=${{ needs.build-packages.outputs.package_version }} -p:RealmTestsStandaloneExe=true --no-self-contained + run: dotnet publish Tests/Realm.Tests -c Release -f ${{ matrix.framework }} -r ${{ matrix.os.runtime }} -p:RestoreConfigFile=Tests/Test.NuGet.Config -p:UseRealmNupkgsWithVersion=${{ needs.build-packages.outputs.package_version }} -p:RealmTestsStandaloneExe=true --no-self-contained - name: Output executable path id: dotnet-publish run: echo 'executable-path=./Tests/Realm.Tests/bin/Release/${{ matrix.framework }}/${{ matrix.os.runtime }}' >> $GITHUB_OUTPUT @@ -273,7 +273,7 @@ jobs: - name: Setup workloads run: dotnet workload install android ${{ (matrix.os.runner != 'ubuntu-latest' && 'tvos ios maccatalyst') || '' }} - name: Publish Tests/Weaver/Realm.Fody.Tests - run: dotnet publish Tests/Weaver/Realm.Fody.Tests -c Release -f net6.0 -r ${{ matrix.os.runtime }} -restore --no-self-contained + run: dotnet publish Tests/Weaver/Realm.Fody.Tests -c Release -f net6.0 -r ${{ matrix.os.runtime }} --no-self-contained - name: Output executable path id: dotnet-publish run: echo 'executable-path=./Tests/Weaver/Realm.Fody.Tests/bin/Release/net6.0/${{ matrix.os.runtime }}' >> $GITHUB_OUTPUT From 271c4f7284440b08549f3b0eb3ad64f42f13d1be Mon Sep 17 00:00:00 2001 From: Nikola Irinchev Date: Wed, 15 May 2024 22:03:41 +0200 Subject: [PATCH 15/39] Move SG tests --- .github/pkl-workflows/helpers/BaaS.pkl | 4 +- .github/pkl-workflows/helpers/Lint.pkl | 4 +- .github/pkl-workflows/helpers/Steps.pkl | 9 +- .github/pkl-workflows/helpers/Test.pkl | 196 +++++++++++-------- .github/pkl-workflows/pr.pkl | 6 +- .github/pkl-workflows/wrappers.pkl | 4 +- .github/templates/test-net-framework.yml | 18 -- .github/templates/test-source-generation.yml | 20 -- .github/workflows/pr.yml | 71 ++++++- .github/workflows/test-source-generation.yml | 43 ---- 10 files changed, 187 insertions(+), 188 deletions(-) delete mode 100644 .github/templates/test-net-framework.yml delete mode 100644 .github/templates/test-source-generation.yml delete mode 100644 .github/workflows/test-source-generation.yml diff --git a/.github/pkl-workflows/helpers/BaaS.pkl b/.github/pkl-workflows/helpers/BaaS.pkl index 2b4f8704a9..982f92b4fc 100644 --- a/.github/pkl-workflows/helpers/BaaS.pkl +++ b/.github/pkl-workflows/helpers/BaaS.pkl @@ -14,7 +14,7 @@ function deploy(differentiators: Listing): gha.MatrixJob = new { } `if` = Common.ifNotCanceledCondition steps { - Steps.checkout() + ...Steps.checkout() Steps.setupDotnet("6.0.x") ...deployStep("${{ matrix.differentiator }}", true) } @@ -36,7 +36,7 @@ function cleanup(differentiators: Listing): gha.MatrixJob = new { } `if` = Common.ifNotCanceledCondition steps { - Steps.checkout() + ...Steps.checkout() Steps.setupDotnet("6.0.x") new gha.Step { name = "Terminate Baas" diff --git a/.github/pkl-workflows/helpers/Lint.pkl b/.github/pkl-workflows/helpers/Lint.pkl index 61dbe813d0..f6c33ca28e 100644 --- a/.github/pkl-workflows/helpers/Lint.pkl +++ b/.github/pkl-workflows/helpers/Lint.pkl @@ -7,7 +7,7 @@ function lint(): gha.Job = new { name = "Verify TODOs" `runs-on` = new gha.UbuntuLatest{} steps { - Steps.checkout() + Steps.checkoutWithoutMatchers() new gha.Step { uses = "nirinchev/verify-todo@9be6f76daddad71433e5deb1b58c517490e5c66e" with { @@ -27,7 +27,7 @@ function verifyNamespaces(packageJob: String): gha.Job = new { packageJob } steps { - Steps.checkout() + Steps.checkoutWithoutMatchers() ...Steps.fetchPackages(packageJob, null) new { run = "dotnet tool install ilspycmd -g --version 8.0.0.7345" diff --git a/.github/pkl-workflows/helpers/Steps.pkl b/.github/pkl-workflows/helpers/Steps.pkl index dc35633427..322c6af90c 100644 --- a/.github/pkl-workflows/helpers/Steps.pkl +++ b/.github/pkl-workflows/helpers/Steps.pkl @@ -1,7 +1,12 @@ import "../GithubAction/GithubAction.pkl" as gha import "Common.pkl" -const function checkout(): gha.Step = new { +const function checkout(): Listing = new Listing { + checkoutWithoutMatchers() + registerProblemMatchers() +} + +const function checkoutWithoutMatchers(): gha.Step = new { name = "Checkout Code" uses = "actions/checkout@v4" with { @@ -83,7 +88,7 @@ const function dotnetPublish(project: String, framework: Common.NetFramework, ru new gha.Step { name = "Output executable path" id = "dotnet-publish" - run = "echo 'executable-path=./\(project)/bin/\(Common.configuration)/\(framework)/\(runtime)' >> $GITHUB_OUTPUT" + run = "echo 'executable-path=./\(project)/bin/\(Common.configuration)/\(framework)/\(runtime)/\(project.split("/").last)' >> $GITHUB_OUTPUT" shell = "bash" } } diff --git a/.github/pkl-workflows/helpers/Test.pkl b/.github/pkl-workflows/helpers/Test.pkl index f48f176d0d..732dbd87fb 100644 --- a/.github/pkl-workflows/helpers/Test.pkl +++ b/.github/pkl-workflows/helpers/Test.pkl @@ -8,48 +8,34 @@ import "BaaS.pkl" local const outputFile = "TestResults.xml" // Public test targets -function netFramework(_packageJob: String, syncDifferentiators: Listing): gha.Job = new { - local testConfig = new TestConfig { +function netFramework(_packageJob: String, syncDifferentiators: Listing): gha.StepJobBase = testJob(new TestConfig { packageJob = _packageJob runSyncTests = syncDifferentiators.toList().contains("net-framework") syncDifferentiator = "net-framework" title = ".NET Framework" - } - name = "Test \(testConfig.title)" - needs { - _packageJob - } - `if` = Common.ifNotCanceledCondition - `runs-on` = new gha.WindowsLatest{} - `timeout-minutes` = Common.testTimeout - steps { - ...prepareTests(testConfig) + }, + new gha.WindowsLatest{}, + null, + (config) -> new Listing { + ...prepareTests(config) ...buildTests(_packageJob, "Tests/Realm.Tests", new Mapping { ["TargetFramework"] = "net461" }) new gha.Step { name = "Run the tests" - run = "./Tests/Realm.Tests/bin/\(Common.configuration)/net461/Realm.Tests.exe --result=\(outputFile) --labels=After \(baasTestArgs(testConfig))" + run = "./Tests/Realm.Tests/bin/\(Common.configuration)/net461/Realm.Tests.exe --result=\(outputFile) --labels=After \(baasTestArgs(config))" } - ...reportTestResults(testConfig) - } -} + ...reportTestResults(config) + }) -function netCore(_packageJob: String, frameworks: Listing): gha.MatrixJob = new { - local testConfig = new TestConfig { +function netCore(_packageJob: String, frameworks: Listing): gha.StepJobBase = testJob( + new TestConfig { packageJob = _packageJob title = "${{ matrix.framework }}, ${{ (matrix.os.runner == 'win81' && 'win81') || matrix.os.runtime }}" shouldCleanWorkspace = true - } - - name = "Test \(testConfig.title)" - needs { - _packageJob - } - `runs-on` = "${{ matrix.os.runner }}" - `timeout-minutes` = Common.testTimeout - `if` = Common.ifNotCanceledCondition - strategy { + }, + "${{ matrix.os.runner }}", + new gha.MatrixStrategy { matrix { ["framework"] = frameworks ["os"] = new Listing { @@ -64,9 +50,9 @@ function netCore(_packageJob: String, frameworks: Listing): } } } - } - steps { - ...prepareTests(testConfig) + }, + (config) -> new Listing { + ...prepareTests(config) // To avoid NU5037 error new gha.Step { name = "Clear nuget cache" @@ -77,42 +63,24 @@ function netCore(_packageJob: String, frameworks: Listing): id = "get-net-version" name = "Extract .NET version" run = """ - NET_VERSION=$(echo '${{ matrix.framework }}.x' | sed 's/net//g') - echo "version=$NET_VERSION" >> $GITHUB_OUTPUT - """ + NET_VERSION=$(echo '${{ matrix.framework }}.x' | sed 's/net//g') + echo "version=$NET_VERSION" >> $GITHUB_OUTPUT + """ shell = "bash" } Steps.setupDotnet("${{ steps.get-net-version.outputs.version }}") - ...dotnetPublishNetCoreTests(_packageJob, "Tests/Realm.Tests", "${{ matrix.framework }}", "${{ matrix.os.runtime }}") - new gha.Step { - name = "Run the tests" - env { - ["DOTNET_DbgEnableMiniDump"] = 1 - ["DOTNET_EnableCrashReport"] = 1 - } - run = "${{ steps.dotnet-publish.outputs.executable-path }}/Realm.Tests --result=\(outputFile) --labels=After" - } - new gha.Step { - name = "Archive core dump" - uses = "actions/upload-artifact@v4" - `if` = "failure()" - with { - ["name"] = "crash-report-net-core-${{ matrix.os.runner }}-${{ matrix.os.runtime }}" - ["path"] = "/tmp/coredump*" - } - } - ...reportTestResults(testConfig) - } -} + ...Steps.dotnetPublish("Tests/Realm.Tests", "${{ matrix.framework }}", "${{ matrix.os.runtime }}", getTestProps(_packageJob)) + ...dotnetRunTests(true) + ...reportTestResults(config) + }) -function weaver(): gha.MatrixJob = new { - local testConfig = new TestConfig { +function weaver(): gha.StepJobBase = testJob( + new TestConfig { title = "Weaver" shouldCleanWorkspace = true - } - - name = "Test \(testConfig.title)" - strategy { + }, + "${{ matrix.os.runner }}", + new gha.MatrixStrategy { matrix { ["os"] = new Listing { new { runner = "windows-latest" runtime = "win-x64" } @@ -120,33 +88,61 @@ function weaver(): gha.MatrixJob = new { new { runner = "macos-14" runtime = "osx-arm64" } } } - } - `runs-on` = "${{ matrix.os.runner }}" - `timeout-minutes` = Common.testTimeout - steps { - Steps.checkout() + }, + (config) -> new Listing { + ...Steps.checkout() ...Steps.setupWorkloads("android ${{ (matrix.os.runner != 'ubuntu-latest' && 'tvos ios maccatalyst') || '' }}", "6.0.x").toList() ...Steps.dotnetPublish("Tests/Weaver/Realm.Fody.Tests", "net6.0", "${{ matrix.os.runtime }}", new Mapping{}).toList() - new gha.Step { - name = "Run the tests" - run = "${{ steps.dotnet-publish.outputs.executable-path }}/Realm.Fody.Tests --result=\(outputFile) --labels=After" + ...dotnetRunTests(false) + ...reportTestResults(config) + } +) + +function sourceGeneration(): gha.StepJobBase = testJob( + new TestConfig { + title = "Source Generation" + }, + new gha.WindowsLatest{}, + null, + (config) -> new Listing { + ...Steps.checkout() + ...Steps.setupWorkloads("tvos ios maccatalyst android", "6.0.x").toList() + ...Steps.dotnetPublish("Tests/SourceGenerators/Realm.SourceGenerator.Tests", "net6.0", "win-x64", new Mapping{}).toList() + ...dotnetRunTests(false) + ...reportTestResults(config) + }) + +// Private helpers +local function testJob(config: TestConfig, runsOn: gha.Machine | String, _strategy: gha.MatrixStrategy?, _steps: Function1>): gha.StepJobBase = (if (_strategy != null) new gha.MatrixJob{ + strategy = _strategy +} else new gha.Job{}) { + name = "Test \(config.title)" + `runs-on` = runsOn + when (config.packageJob != null) { + needs { + config.packageJob!! } - ...reportTestResults(testConfig) } + `if` = Common.ifNotCanceledCondition + `timeout-minutes` = Common.testTimeout + steps = _steps.apply(config) } -// Private helpers local function prepareTests(config: TestConfig): Listing = new Listing { - Steps.checkout() + ...Steps.checkout() ...cleanWorkspace(config.shouldCleanWorkspace) - ...fetchTestArtifacts(config.packageJob, config.useWrappers) + ...fetchTestArtifacts(config.packageJob!!, config.useWrappers) ...BaaS.deployStep(config.syncDifferentiator, config.runSyncTests) } -local function cleanWorkspace(shouldClean: Boolean): List = if (shouldClean) List(new gha.Step { - name = "Cleanup Workspace" - run = "git clean -fdx" -}) else List() +local function cleanWorkspace(shouldClean: Boolean): Listing = new Listing { + when (shouldClean) { + new gha.Step { + name = "Cleanup Workspace" + run = "git clean -fdx" + } + } +} local function fetchTestArtifacts(packageJob: String, useWrappers: Boolean): List = if (useWrappers) Steps.fetchPackages(packageJob, Common.nugetPackages) @@ -161,10 +157,12 @@ local function baasTestArgs(config: TestConfig): String = if (config.runSyncTest local function reportTestResults(config: TestConfig): Listing = new { local _outputFile = if (config.transformResults) "\(outputFile)_transformed.xml" else outputFile - ...(if (config.transformResults) List(new gha.Step { - name = "Transform Results" - run = "xsltproc --output \(_outputFile) Tests/Realm.Tests/EmbeddedResources/nunit3-junit.xslt \(outputFile)" - }) else List()) + when (config.transformResults) { + new gha.Step { + name = "Transform Results" + run = "xsltproc --output \(_outputFile) Tests/Realm.Tests/EmbeddedResources/nunit3-junit.xslt \(outputFile)" + } + } new gha.Step { name = "Publish Unit Test Results" uses = "LaPeste/test-reporter@510caf50a955b1003bec48a6494be4d6537f3a0b" @@ -180,25 +178,51 @@ local function reportTestResults(config: TestConfig): Listing = new { } } -local function dotnetPublishNetCoreTests(packageJob: String, project: String, framework: Common.NetFramework, runtime: Common.NetRuntime): Listing = Steps.dotnetPublish(project, framework, runtime, getTestProps(packageJob)) - local function getTestProps(packageJob: String): Mapping = new Mapping { ["RestoreConfigFile"] = "Tests/Test.NuGet.Config" ["UseRealmNupkgsWithVersion"] = "${{ needs.\(packageJob).outputs.package_version }}" ["RealmTestsStandaloneExe"] = "true" } +local function dotnetRunTests(enableCoreDumps: Boolean): Listing = new Listing { + new gha.Step { + name = "Run the tests" + run = "${{ steps.dotnet-publish.outputs.executable-path }} --result=\(outputFile) --labels=After" + when (enableCoreDumps) { + env { + ["DOTNET_DbgEnableMiniDump"] = 1 + ["DOTNET_EnableCrashReport"] = 1 + } + } + } + when (enableCoreDumps) { + new gha.Step { + name = "Archive core dump" + uses = "actions/upload-artifact@v4" + `if` = "${{ failure() && runner.os != 'Windows' }}" + with { + ["name"] = "crash-report-net-core-${{ runner.os }}-${{ runner.arch }}" + ["path"] = "/tmp/coredump*" + } + } + } +} + +local function applyTestProps(config: TestConfig): Mixin = new Mixin { + +} + local class MatrixOS { runner: "windows-latest" | "ubuntu-latest" | "macos-13" | "macos-14" runtime: Common.NetRuntime } local class TestConfig { - packageJob: String + title: String + packageJob: String? = null useWrappers: Boolean = false shouldCleanWorkspace: Boolean = false runSyncTests: Boolean = false - syncDifferentiator: String? + syncDifferentiator: String? = null transformResults: Boolean = false - title: String } diff --git a/.github/pkl-workflows/pr.pkl b/.github/pkl-workflows/pr.pkl index 1620f9638f..5e3b95ed47 100644 --- a/.github/pkl-workflows/pr.pkl +++ b/.github/pkl-workflows/pr.pkl @@ -123,11 +123,7 @@ jobs { } } ["test-woven-classes"] = createTestJob("test-woven-classes") - ["test-source-generation"] = new ReusableWorkflowJob { - `if` = Common.ifNotCanceledCondition - name = "Test" - uses = "./.github/workflows/test-source-generation.yml" - } + ["test-source-generation"] = TestJobs.sourceGeneration() ["test-weaver"] = TestJobs.weaver() ["test-code-coverage"] = (createTestJob("test-code-coverage")) { needs { diff --git a/.github/pkl-workflows/wrappers.pkl b/.github/pkl-workflows/wrappers.pkl index de2f628ca0..f08169ed52 100644 --- a/.github/pkl-workflows/wrappers.pkl +++ b/.github/pkl-workflows/wrappers.pkl @@ -38,7 +38,7 @@ jobs { .toMap((platform) -> "wrappers-\(platform)",(platform) -> "${{ steps.check-cache-\(platform).outputs.cache-hit }}") .toMapping() steps { - Steps.checkout() + Steps.checkoutWithoutMatchers() for (platform in Common.wrapperBinaryNames) { restoreCache(platform) |> withCondition(platform, null) Steps.uploadArtifacts("wrappers-\(platform)", "wrappers/build/**") |> withCondition(platform, "steps.check-cache-\(platform).outputs.cache-hit == 'true'") @@ -176,7 +176,7 @@ local function wrappersJob(config: JobConfig) = new Mixin { } `if` = config.ifCondition steps { - Steps.checkout() + Steps.checkoutWithoutMatchers() checkCache(config.platform) ...config.intermediateSteps.toList().map((step) -> (step) { `if` = WrappersCacheCondition diff --git a/.github/templates/test-net-framework.yml b/.github/templates/test-net-framework.yml deleted file mode 100644 index 3afe46653e..0000000000 --- a/.github/templates/test-net-framework.yml +++ /dev/null @@ -1,18 +0,0 @@ -#@ load("@ytt:template", "template") -#@ load("common.lib.yml", "checkoutCode", "configuration") -#@ load("test.lib.yml", "baasTestArgs", "publishTestsResults", "testDefinition", "buildTests", "prepareTest") - ---- -name: test-net-framework -_: #@ template.replace(testDefinition()) -jobs: - run-tests: - runs-on: windows-latest - name: .NET Framework - timeout-minutes: 60 - steps: - - #@ 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") - - #@ template.replace(publishTestsResults("TestResults.Windows.xml", ".NET Framework")) diff --git a/.github/templates/test-source-generation.yml b/.github/templates/test-source-generation.yml deleted file mode 100644 index 56b06b3525..0000000000 --- a/.github/templates/test-source-generation.yml +++ /dev/null @@ -1,20 +0,0 @@ -#@ load("@ytt:template", "template") -#@ load("common.lib.yml", "checkoutCode", "dotnetPublish", "setupWorkloads") -#@ load("test.lib.yml", "publishTestsResults") - ---- -name: test-source-generation -"on": - workflow_call: -jobs: - run-tests: - runs-on: windows-latest - name: Source Generation - timeout-minutes: 45 - steps: - - #@ template.replace(checkoutCode()) - - #@ template.replace(setupWorkloads('tvos ios maccatalyst android')) - - #@ template.replace(dotnetPublish("Tests/SourceGenerators/Realm.SourceGenerator.Tests", "net6.0", "win-x64")) - - name: Run the tests - run: #@ "${{ steps.dotnet-publish.outputs.executable-path }}/Realm.SourceGenerator.Tests --result=TestResults.SourceGeneration.xml" - - #@ template.replace(publishTestsResults("TestResults.SourceGeneration.xml", "Source Generation")) diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index 86ac264872..f8c928c1c9 100755 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -39,6 +39,10 @@ jobs: with: submodules: recursive ref: ${{ github.event.pull_request.head.sha }} + - name: Register csc problem matcher + run: |- + echo "::add-matcher::.github/problem-matchers/csc.json" + echo "::add-matcher::.github/problem-matchers/msvc.json" - uses: actions/setup-dotnet@607fce577a46308457984d59e4954e075820f10a with: dotnet-version: 6.0.x @@ -89,6 +93,10 @@ jobs: with: submodules: recursive ref: ${{ github.event.pull_request.head.sha }} + - name: Register csc problem matcher + run: |- + echo "::add-matcher::.github/problem-matchers/csc.json" + echo "::add-matcher::.github/problem-matchers/msvc.json" - name: Fetch Realm uses: actions/download-artifact@v4 with: @@ -140,6 +148,10 @@ jobs: with: submodules: recursive ref: ${{ github.event.pull_request.head.sha }} + - name: Register csc problem matcher + run: |- + echo "::add-matcher::.github/problem-matchers/csc.json" + echo "::add-matcher::.github/problem-matchers/msvc.json" - name: Cleanup Workspace run: git clean -fdx - name: Fetch Realm @@ -168,18 +180,18 @@ jobs: run: dotnet publish Tests/Realm.Tests -c Release -f ${{ matrix.framework }} -r ${{ matrix.os.runtime }} -p:RestoreConfigFile=Tests/Test.NuGet.Config -p:UseRealmNupkgsWithVersion=${{ needs.build-packages.outputs.package_version }} -p:RealmTestsStandaloneExe=true --no-self-contained - name: Output executable path id: dotnet-publish - run: echo 'executable-path=./Tests/Realm.Tests/bin/Release/${{ matrix.framework }}/${{ matrix.os.runtime }}' >> $GITHUB_OUTPUT + run: echo 'executable-path=./Tests/Realm.Tests/bin/Release/${{ matrix.framework }}/${{ matrix.os.runtime }}/Realm.Tests' >> $GITHUB_OUTPUT shell: bash - name: Run the tests env: DOTNET_DbgEnableMiniDump: 1 DOTNET_EnableCrashReport: 1 - run: ${{ steps.dotnet-publish.outputs.executable-path }}/Realm.Tests --result=TestResults.xml --labels=After + run: ${{ steps.dotnet-publish.outputs.executable-path }} --result=TestResults.xml --labels=After - name: Archive core dump - if: failure() + if: ${{ failure() && runner.os != 'Windows' }} uses: actions/upload-artifact@v4 with: - name: crash-report-net-core-${{ matrix.os.runner }}-${{ matrix.os.runtime }} + name: crash-report-net-core-${{ runner.os }}-${{ runner.arch }} path: /tmp/coredump* - name: Publish Unit Test Results if: always() @@ -254,11 +266,46 @@ jobs: with: version: ${{ needs.build-packages.outputs.package_version }} test-source-generation: - name: Test + name: Test Source Generation if: always() && !cancelled() && !contains(needs.*.result, 'failure') && !contains(needs.*.result, 'cancelled') - uses: ./.github/workflows/test-source-generation.yml + timeout-minutes: 60 + runs-on: windows-latest + steps: + - name: Checkout Code + uses: actions/checkout@v4 + with: + submodules: recursive + ref: ${{ github.event.pull_request.head.sha }} + - name: Register csc problem matcher + run: |- + echo "::add-matcher::.github/problem-matchers/csc.json" + echo "::add-matcher::.github/problem-matchers/msvc.json" + - uses: actions/setup-dotnet@607fce577a46308457984d59e4954e075820f10a + with: + dotnet-version: 6.0.x + - name: Setup workloads + run: dotnet workload install tvos ios maccatalyst android + - name: Publish Tests/SourceGenerators/Realm.SourceGenerator.Tests + run: dotnet publish Tests/SourceGenerators/Realm.SourceGenerator.Tests -c Release -f net6.0 -r win-x64 --no-self-contained + - name: Output executable path + id: dotnet-publish + run: echo 'executable-path=./Tests/SourceGenerators/Realm.SourceGenerator.Tests/bin/Release/net6.0/win-x64/Realm.SourceGenerator.Tests' >> $GITHUB_OUTPUT + shell: bash + - name: Run the tests + run: ${{ steps.dotnet-publish.outputs.executable-path }} --result=TestResults.xml --labels=After + - name: Publish Unit Test Results + if: always() + uses: LaPeste/test-reporter@510caf50a955b1003bec48a6494be4d6537f3a0b + with: + name: Results Source Generation + path: TestResults.xml + reporter: java-junit + list-suites: failed + path-replace-backslashes: true + fail-on-error: true test-weaver: name: Test Weaver + if: always() && !cancelled() && !contains(needs.*.result, 'failure') && !contains(needs.*.result, 'cancelled') timeout-minutes: 60 runs-on: ${{ matrix.os.runner }} steps: @@ -267,6 +314,10 @@ jobs: with: submodules: recursive ref: ${{ github.event.pull_request.head.sha }} + - name: Register csc problem matcher + run: |- + echo "::add-matcher::.github/problem-matchers/csc.json" + echo "::add-matcher::.github/problem-matchers/msvc.json" - uses: actions/setup-dotnet@607fce577a46308457984d59e4954e075820f10a with: dotnet-version: 6.0.x @@ -276,10 +327,10 @@ jobs: run: dotnet publish Tests/Weaver/Realm.Fody.Tests -c Release -f net6.0 -r ${{ matrix.os.runtime }} --no-self-contained - name: Output executable path id: dotnet-publish - run: echo 'executable-path=./Tests/Weaver/Realm.Fody.Tests/bin/Release/net6.0/${{ matrix.os.runtime }}' >> $GITHUB_OUTPUT + run: echo 'executable-path=./Tests/Weaver/Realm.Fody.Tests/bin/Release/net6.0/${{ matrix.os.runtime }}/Realm.Fody.Tests' >> $GITHUB_OUTPUT shell: bash - name: Run the tests - run: ${{ steps.dotnet-publish.outputs.executable-path }}/Realm.Fody.Tests --result=TestResults.xml --labels=After + run: ${{ steps.dotnet-publish.outputs.executable-path }} --result=TestResults.xml --labels=After - name: Publish Unit Test Results if: always() uses: LaPeste/test-reporter@510caf50a955b1003bec48a6494be4d6537f3a0b @@ -323,6 +374,10 @@ jobs: with: submodules: recursive ref: ${{ github.event.pull_request.head.sha }} + - name: Register csc problem matcher + run: |- + echo "::add-matcher::.github/problem-matchers/csc.json" + echo "::add-matcher::.github/problem-matchers/msvc.json" - uses: actions/setup-dotnet@607fce577a46308457984d59e4954e075820f10a with: dotnet-version: 6.0.x diff --git a/.github/workflows/test-source-generation.yml b/.github/workflows/test-source-generation.yml deleted file mode 100644 index ac280110a1..0000000000 --- a/.github/workflows/test-source-generation.yml +++ /dev/null @@ -1,43 +0,0 @@ -name: test-source-generation -"on": - workflow_call: null -jobs: - run-tests: - runs-on: windows-latest - name: Source Generation - 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: Configure .NET - uses: actions/setup-dotnet@3e6b9fe3930cac7c59c651af5de1514b47a805b9 - with: - dotnet-version: 8.0.x - - name: Setup workloads - run: dotnet workload install tvos ios maccatalyst android - - name: Publish Tests/SourceGenerators/Realm.SourceGenerator.Tests - run: dotnet publish Tests/SourceGenerators/Realm.SourceGenerator.Tests -c Release -f net6.0 -r win-x64 --no-self-contained - - name: Output executable path - id: dotnet-publish - run: echo 'executable-path=./Tests/SourceGenerators/Realm.SourceGenerator.Tests/bin/Release/net6.0/win-x64' >> $GITHUB_OUTPUT - shell: bash - - name: Run the tests - run: ${{ steps.dotnet-publish.outputs.executable-path }}/Realm.SourceGenerator.Tests --result=TestResults.SourceGeneration.xml - - name: Publish Unit Test Results - uses: LaPeste/test-reporter@510caf50a955b1003bec48a6494be4d6537f3a0b - if: always() - with: - name: Results Source Generation - path: TestResults.SourceGeneration.xml - reporter: java-junit - list-suites: failed - list-tests: failed - path-replace-backslashes: true - fail-on-error: true From e955112c337fc99a35636ac72b8300b6464c6d1e Mon Sep 17 00:00:00 2001 From: Nikola Irinchev Date: Wed, 15 May 2024 22:25:40 +0200 Subject: [PATCH 16/39] Move tvOS --- .github/pkl-workflows/helpers/Steps.pkl | 16 ++++ .github/pkl-workflows/helpers/Test.pkl | 56 ++++++++++++-- .github/pkl-workflows/pr.pkl | 4 +- .github/templates/test-tvos.yml | 24 ------ .github/templates/test-woven-classes.yml | 19 ----- .github/workflows/pr.yml | 95 ++++++++++++++++++++++-- .github/workflows/test-tvos.yml | 62 ---------------- .github/workflows/test-woven-classes.yml | 57 -------------- 8 files changed, 153 insertions(+), 180 deletions(-) delete mode 100644 .github/templates/test-tvos.yml delete mode 100644 .github/templates/test-woven-classes.yml delete mode 100755 .github/workflows/test-tvos.yml delete mode 100644 .github/workflows/test-woven-classes.yml diff --git a/.github/pkl-workflows/helpers/Steps.pkl b/.github/pkl-workflows/helpers/Steps.pkl index 322c6af90c..dab7030ece 100644 --- a/.github/pkl-workflows/helpers/Steps.pkl +++ b/.github/pkl-workflows/helpers/Steps.pkl @@ -1,6 +1,8 @@ import "../GithubAction/GithubAction.pkl" as gha import "Common.pkl" +const actionRunSimulator = "realm/ci-actions/run-ios-simulator@6418e15ed9bbdb19b7d456a347e5623779f95cdf" + const function checkout(): Listing = new Listing { checkoutWithoutMatchers() registerProblemMatchers() @@ -93,6 +95,20 @@ const function dotnetPublish(project: String, framework: Common.NetFramework, ru } } +const function runSimulator(config: SimulatorConfig): gha.Step = new { + name = "Run on Simulator" + uses = actionRunSimulator + with = config.toMap().toMapping() +} + +class SimulatorConfig { + appPath: String + bundleId: String + iphoneToSimulate: "Apple-TV-1080p" + arguments: String + os: "tvOS" +} + local const function addMSBuildToPath(): gha.Step = new { name = "Add msbuild to PATH" uses = "microsoft/setup-msbuild@0b44c6745b7e81956596964100aadb92d667c497" diff --git a/.github/pkl-workflows/helpers/Test.pkl b/.github/pkl-workflows/helpers/Test.pkl index 732dbd87fb..e03af27250 100644 --- a/.github/pkl-workflows/helpers/Test.pkl +++ b/.github/pkl-workflows/helpers/Test.pkl @@ -8,11 +8,12 @@ import "BaaS.pkl" local const outputFile = "TestResults.xml" // Public test targets -function netFramework(_packageJob: String, syncDifferentiators: Listing): gha.StepJobBase = testJob(new TestConfig { +function netFramework(_packageJob: String, _syncDifferentiators: Listing): gha.StepJobBase = testJob( + new TestConfig { + title = ".NET Framework" packageJob = _packageJob - runSyncTests = syncDifferentiators.toList().contains("net-framework") syncDifferentiator = "net-framework" - title = ".NET Framework" + syncDifferentiators = _syncDifferentiators }, new gha.WindowsLatest{}, null, @@ -112,6 +113,48 @@ function sourceGeneration(): gha.StepJobBase = testJob( ...reportTestResults(config) }) +function wovenClasses(_packageJob: String): gha.StepJobBase = testJob( + new TestConfig { + packageJob = _packageJob + title = "Woven Classes" + }, + new gha.WindowsLatest{}, + null, + (config) -> new Listing { + ...prepareTests(config) + ...Steps.dotnetPublish("Tests/Realm.Tests", "net8.0", "win-x64", (getTestProps(_packageJob)) { + ["TestWeavedClasses"] = "true" + }) + ...dotnetRunTests(false) + ...reportTestResults(config) + } +) + +function tvOS(_packageJob: String, _syncDifferentiators: Listing): gha.StepJobBase = testJob( + new TestConfig { + packageJob = _packageJob + title = "Xamarin.tvOS" + syncDifferentiator = "tvos" + syncDifferentiators = _syncDifferentiators + }, + "macos-12", + null, + (config) -> new Listing { + ...prepareTests(config) + ...buildTests(_packageJob, "Tests/Tests.XamarinTVOS", new Mapping { + ["Platform"] = "iPhoneSimulator" + }) + Steps.runSimulator(new Steps.SimulatorConfig{ + appPath = "Tests/Tests.XamarinTVOS/bin/iPhoneSimulator/\(Common.configuration)/Tests.XamarinTVOS.app" + arguments = "--headless --result=${{ github.workspace }}/\(outputFile) --labels=All \(baasTestArgs(config))" + bundleId = "io.realm.Tests-XamarinTVOS" + iphoneToSimulate = "Apple-TV-1080p" + os = "tvOS" + }) + ...reportTestResults(config) + } +) + // Private helpers local function testJob(config: TestConfig, runsOn: gha.Machine | String, _strategy: gha.MatrixStrategy?, _steps: Function1>): gha.StepJobBase = (if (_strategy != null) new gha.MatrixJob{ strategy = _strategy @@ -208,10 +251,6 @@ local function dotnetRunTests(enableCoreDumps: Boolean): Listing = new } } -local function applyTestProps(config: TestConfig): Mixin = new Mixin { - -} - local class MatrixOS { runner: "windows-latest" | "ubuntu-latest" | "macos-13" | "macos-14" runtime: Common.NetRuntime @@ -222,7 +261,8 @@ local class TestConfig { packageJob: String? = null useWrappers: Boolean = false shouldCleanWorkspace: Boolean = false - runSyncTests: Boolean = false syncDifferentiator: String? = null transformResults: Boolean = false + syncDifferentiators: Listing? + runSyncTests: Boolean = syncDifferentiators?.toList()?.contains(syncDifferentiator) ?? false } diff --git a/.github/pkl-workflows/pr.pkl b/.github/pkl-workflows/pr.pkl index 5e3b95ed47..d64cbc4d19 100644 --- a/.github/pkl-workflows/pr.pkl +++ b/.github/pkl-workflows/pr.pkl @@ -113,7 +113,7 @@ jobs { ["test-net-core"] = TestJobs.netCore(JobNames.packages, new Listing { "net8.0" }) ["test-macos"] = createTestJob("test-macos") ["test-ios"] = createTestJob("test-ios") - ["test-tvos"] = createTestJob("test-tvos") + ["test-tvos"] = TestJobs.tvOS(JobNames.packages, baasDifferentiators) ["test-android"] = (createTestJob("test-android")) { secrets { ["AWS_DEVICEFARM_ACCESS_KEY_ID"] = "${{ secrets.AWS_DEVICEFARM_ACCESS_KEY_ID }}" @@ -122,7 +122,7 @@ jobs { ["DEVICEFARM_ANDROID_POOL_ARN"] = "${{ secrets.DEVICEFARM_ANDROID_POOL_ARN }}" } } - ["test-woven-classes"] = createTestJob("test-woven-classes") + ["test-woven-classes"] = TestJobs.wovenClasses(JobNames.packages) ["test-source-generation"] = TestJobs.sourceGeneration() ["test-weaver"] = TestJobs.weaver() ["test-code-coverage"] = (createTestJob("test-code-coverage")) { diff --git a/.github/templates/test-tvos.yml b/.github/templates/test-tvos.yml deleted file mode 100644 index 1000a24a78..0000000000 --- a/.github/templates/test-tvos.yml +++ /dev/null @@ -1,24 +0,0 @@ -#@ load("@ytt:template", "template") -#@ load("common.lib.yml", "checkoutCode", "configuration", "actionRuniOSSimulator") -#@ load("test.lib.yml", "baasTestArgs", "publishTestsResults", "testDefinition", "buildTests", "prepareTest") - ---- -name: test-tvos -_: #@ template.replace(testDefinition()) -jobs: - test-xamarin: - runs-on: macos-12 - name: Xamarin.tvOS - timeout-minutes: 45 - steps: - - #@ template.replace(prepareTest()) - - #@ template.replace(buildTests("Tests/Tests.XamarinTVOS", Platform="iPhoneSimulator")) - - name: Run the tests - uses: #@ actionRuniOSSimulator - with: - appPath: #@ "Tests/Tests.XamarinTVOS/bin/iPhoneSimulator/" + configuration + "/Tests.XamarinTVOS.app" - bundleId: 'io.realm.Tests-XamarinTVOS' - iphoneToSimulate: 'Apple-TV-1080p' - arguments: #@ "--headless --result=${{ github.workspace }}/TestResults.tvOS.xml --labels=All" + baasTestArgs("tvos") - os: 'tvOS' - - #@ template.replace(publishTestsResults("TestResults.tvOS.xml", "Xamarin.tvOS")) \ No newline at end of file diff --git a/.github/templates/test-woven-classes.yml b/.github/templates/test-woven-classes.yml deleted file mode 100644 index 741014778d..0000000000 --- a/.github/templates/test-woven-classes.yml +++ /dev/null @@ -1,19 +0,0 @@ -#@ load("@ytt:template", "template") -#@ load("common.lib.yml", "checkoutCode", "fetchPackageArtifacts") -#@ load("test.lib.yml", "baasTestArgs", "publishTestsResults", "testDefinition", "buildTests", "wovenClassesBuildTests") - ---- -name: test-woven-classes -_: #@ template.replace(testDefinition()) -jobs: - run-tests: - runs-on: windows-latest - name: Woven classes - timeout-minutes: 45 - steps: - - #@ template.replace(checkoutCode()) - - #@ template.replace(fetchPackageArtifacts()) - - #@ template.replace(wovenClassesBuildTests("Tests/Realm.Tests", "net8.0", "win-x64")) - - name: Run the tests - run: #@ "${{ steps.dotnet-publish.outputs.executable-path }}/Realm.Tests --result=TestResults.WovenClasses.xml --labels=After" - - #@ template.replace(publishTestsResults("TestResults.WovenClasses.xml", "Woven classes")) diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index f8c928c1c9..cbfbedcd7b 100755 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -237,13 +237,55 @@ jobs: with: version: ${{ needs.build-packages.outputs.package_version }} test-tvos: - name: Test + name: Test Xamarin.tvOS needs: - build-packages if: always() && !cancelled() && !contains(needs.*.result, 'failure') && !contains(needs.*.result, 'cancelled') - uses: ./.github/workflows/test-tvos.yml - with: - version: ${{ needs.build-packages.outputs.package_version }} + timeout-minutes: 60 + runs-on: macos-12 + steps: + - name: Checkout Code + uses: actions/checkout@v4 + with: + submodules: recursive + ref: ${{ github.event.pull_request.head.sha }} + - name: Register csc problem matcher + run: |- + echo "::add-matcher::.github/problem-matchers/csc.json" + echo "::add-matcher::.github/problem-matchers/msvc.json" + - name: Fetch Realm + uses: actions/download-artifact@v4 + with: + name: Realm.${{ needs.build-packages.outputs.package_version }} + path: ${{ github.workspace }}/Realm/packages/ + - name: Fetch Realm.PlatformHelpers + uses: actions/download-artifact@v4 + with: + name: Realm.PlatformHelpers.${{ needs.build-packages.outputs.package_version }} + path: ${{ github.workspace }}/Realm/packages/ + - name: Add msbuild to PATH + if: ${{ runner.os == 'Windows' }} + uses: microsoft/setup-msbuild@0b44c6745b7e81956596964100aadb92d667c497 + - name: Build Tests/Tests.XamarinTVOS + run: msbuild Tests/Tests.XamarinTVOS -p:Configuration=Release -restore -p:RestoreConfigFile=Tests/Test.NuGet.Config -p:UseRealmNupkgsWithVersion=${{ needs.build-packages.outputs.package_version }} -p:RealmTestsStandaloneExe=true -p:Platform=iPhoneSimulator + - name: Run on Simulator + uses: realm/ci-actions/run-ios-simulator@6418e15ed9bbdb19b7d456a347e5623779f95cdf + with: + 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.xml --labels=All ' + os: tvOS + - name: Publish Unit Test Results + if: always() + uses: LaPeste/test-reporter@510caf50a955b1003bec48a6494be4d6537f3a0b + with: + name: Results Xamarin.tvOS + path: TestResults.xml + reporter: java-junit + list-suites: failed + path-replace-backslashes: true + fail-on-error: true test-android: name: Test needs: @@ -258,13 +300,50 @@ jobs: DEVICEFARM_PROJECT_ARN: ${{ secrets.DEVICEFARM_PROJECT_ARN }} DEVICEFARM_ANDROID_POOL_ARN: ${{ secrets.DEVICEFARM_ANDROID_POOL_ARN }} test-woven-classes: - name: Test + name: Test Woven Classes needs: - build-packages if: always() && !cancelled() && !contains(needs.*.result, 'failure') && !contains(needs.*.result, 'cancelled') - uses: ./.github/workflows/test-woven-classes.yml - with: - version: ${{ needs.build-packages.outputs.package_version }} + timeout-minutes: 60 + runs-on: windows-latest + steps: + - name: Checkout Code + uses: actions/checkout@v4 + with: + submodules: recursive + ref: ${{ github.event.pull_request.head.sha }} + - name: Register csc problem matcher + run: |- + echo "::add-matcher::.github/problem-matchers/csc.json" + echo "::add-matcher::.github/problem-matchers/msvc.json" + - name: Fetch Realm + uses: actions/download-artifact@v4 + with: + name: Realm.${{ needs.build-packages.outputs.package_version }} + path: ${{ github.workspace }}/Realm/packages/ + - name: Fetch Realm.PlatformHelpers + uses: actions/download-artifact@v4 + with: + name: Realm.PlatformHelpers.${{ needs.build-packages.outputs.package_version }} + path: ${{ github.workspace }}/Realm/packages/ + - name: Publish Tests/Realm.Tests + run: dotnet publish Tests/Realm.Tests -c Release -f net8.0 -r win-x64 -p:RestoreConfigFile=Tests/Test.NuGet.Config -p:UseRealmNupkgsWithVersion=${{ needs.build-packages.outputs.package_version }} -p:RealmTestsStandaloneExe=true -p:TestWeavedClasses=true --no-self-contained + - name: Output executable path + id: dotnet-publish + run: echo 'executable-path=./Tests/Realm.Tests/bin/Release/net8.0/win-x64/Realm.Tests' >> $GITHUB_OUTPUT + shell: bash + - name: Run the tests + run: ${{ steps.dotnet-publish.outputs.executable-path }} --result=TestResults.xml --labels=After + - name: Publish Unit Test Results + if: always() + uses: LaPeste/test-reporter@510caf50a955b1003bec48a6494be4d6537f3a0b + with: + name: Results Woven Classes + path: TestResults.xml + reporter: java-junit + list-suites: failed + path-replace-backslashes: true + fail-on-error: true test-source-generation: name: Test Source Generation if: always() && !cancelled() && !contains(needs.*.result, 'failure') && !contains(needs.*.result, 'cancelled') diff --git a/.github/workflows/test-tvos.yml b/.github/workflows/test-tvos.yml deleted file mode 100755 index 6f64bd1e03..0000000000 --- a/.github/workflows/test-tvos.yml +++ /dev/null @@ -1,62 +0,0 @@ -name: test-tvos -"on": - workflow_call: - inputs: - version: - required: true - type: string - secrets: - BaaSaasApiKey: - required: false -env: - REALM_DISABLE_ANALYTICS: true - DOTNET_NOLOGO: true -jobs: - test-xamarin: - runs-on: macos-12 - name: Xamarin.tvOS - 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@v4 - with: - name: Realm.PlatformHelpers.${{ inputs.version }} - path: ${{ github.workspace }}/Realm/packages/ - - name: Fetch Realm - uses: actions/download-artifact@v4 - with: - name: Realm.${{ inputs.version }} - path: ${{ github.workspace }}/Realm/packages/ - - name: Add msbuild to PATH - uses: microsoft/setup-msbuild@0b44c6745b7e81956596964100aadb92d667c497 - if: ${{ runner.os == 'Windows' }} - - name: Build Tests/Tests.XamarinTVOS - run: msbuild Tests/Tests.XamarinTVOS -p:Configuration=Release -restore -p:RestoreConfigFile=Tests/Test.NuGet.Config -p:UseRealmNupkgsWithVersion=${{ inputs.version }} -p:Platform=iPhoneSimulator - - name: Run the tests - uses: realm/ci-actions/run-ios-simulator@6418e15ed9bbdb19b7d456a347e5623779f95cdf - with: - 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 --baasaas-api-key=${{ secrets.BaaSaasApiKey}} --baas-differentiator=tvos-${{ github.run_id }}-${{ github.run_attempt }} - os: tvOS - - name: Publish Unit Test Results - uses: LaPeste/test-reporter@510caf50a955b1003bec48a6494be4d6537f3a0b - if: always() - with: - name: Results Xamarin.tvOS - path: TestResults.tvOS.xml - reporter: java-junit - list-suites: failed - list-tests: failed - path-replace-backslashes: true - fail-on-error: true diff --git a/.github/workflows/test-woven-classes.yml b/.github/workflows/test-woven-classes.yml deleted file mode 100644 index 646a345ce7..0000000000 --- a/.github/workflows/test-woven-classes.yml +++ /dev/null @@ -1,57 +0,0 @@ -name: test-woven-classes -"on": - workflow_call: - inputs: - version: - required: true - type: string - secrets: - BaaSaasApiKey: - required: false -env: - REALM_DISABLE_ANALYTICS: true - DOTNET_NOLOGO: true -jobs: - run-tests: - runs-on: windows-latest - name: Woven classes - 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@v4 - with: - name: Realm.PlatformHelpers.${{ inputs.version }} - path: ${{ github.workspace }}/Realm/packages/ - - name: Fetch Realm - uses: actions/download-artifact@v4 - with: - name: Realm.${{ inputs.version }} - path: ${{ github.workspace }}/Realm/packages/ - - name: Publish Tests/Realm.Tests - run: dotnet publish Tests/Realm.Tests -c Release -f net8.0 -r win-x64 -p:RestoreConfigFile=Tests/Test.NuGet.Config -p:UseRealmNupkgsWithVersion=${{ inputs.version }} -p:TestWeavedClasses=true -p:RealmTestsStandaloneExe=true --no-self-contained - - name: Output executable path - id: dotnet-publish - run: echo 'executable-path=./Tests/Realm.Tests/bin/Release/net8.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 - - name: Publish Unit Test Results - uses: LaPeste/test-reporter@510caf50a955b1003bec48a6494be4d6537f3a0b - if: always() - with: - name: Results Woven classes - path: TestResults.WovenClasses.xml - reporter: java-junit - list-suites: failed - list-tests: failed - path-replace-backslashes: true - fail-on-error: true From 4c39ece20f4fb9d727cdd2c9449af628dda3231a Mon Sep 17 00:00:00 2001 From: Nikola Irinchev Date: Wed, 15 May 2024 23:01:39 +0200 Subject: [PATCH 17/39] migrate iOS and macOS test jobs --- .github/pkl-workflows/helpers/BaaS.pkl | 6 +- .github/pkl-workflows/helpers/Common.pkl | 1 + .github/pkl-workflows/helpers/Steps.pkl | 13 +- .github/pkl-workflows/helpers/Test.pkl | 113 +++++++++++-- .github/pkl-workflows/pr.pkl | 8 +- .github/templates/test-ios.yml | 43 ----- .github/templates/test-macos.yml | 32 ---- .github/workflows/pr.yml | 200 +++++++++++++++++++++-- .github/workflows/test-ios.yml | 124 -------------- .github/workflows/test-macos.yml | 114 ------------- 10 files changed, 303 insertions(+), 351 deletions(-) delete mode 100644 .github/templates/test-ios.yml delete mode 100644 .github/templates/test-macos.yml delete mode 100755 .github/workflows/test-ios.yml delete mode 100755 .github/workflows/test-macos.yml diff --git a/.github/pkl-workflows/helpers/BaaS.pkl b/.github/pkl-workflows/helpers/BaaS.pkl index 982f92b4fc..dfe2cb492c 100644 --- a/.github/pkl-workflows/helpers/BaaS.pkl +++ b/.github/pkl-workflows/helpers/BaaS.pkl @@ -4,7 +4,7 @@ import "../GithubAction/GithubAction.pkl" as gha import "Common.pkl" import "Steps.pkl" -function deploy(differentiators: Listing): gha.MatrixJob = new { +function deploy(differentiators: Listing): gha.MatrixJob = new { name = "Deploy BaaS" `runs-on` = new gha.UbuntuLatest{} strategy { @@ -20,13 +20,13 @@ function deploy(differentiators: Listing): gha.MatrixJob = new { } } -function deployStep(differentiator: String?, shouldDeploy: Boolean): List = if (shouldDeploy && differentiator != null) List(new gha.Step { +function deployStep(differentiator: Common.SyncDifferentiator?, shouldDeploy: Boolean): List = if (shouldDeploy && differentiator != null) List(new gha.Step { name = "Deploy Apps" run = "dotnet run deploy-apps --baasaas-api-key=${{ secrets.BAASAAS_API_KEY }} --baas-differentiator=\(differentiator)-${{ github.run_id }}-${{ github.run_attempt }}" `working-directory` = "Tools/DeployApps" }) else List() -function cleanup(differentiators: Listing): gha.MatrixJob = new { +function cleanup(differentiators: Listing): gha.MatrixJob = new { name = "Cleanup BaaS" `runs-on` = new gha.UbuntuLatest{} strategy { diff --git a/.github/pkl-workflows/helpers/Common.pkl b/.github/pkl-workflows/helpers/Common.pkl index 2401ef4995..30c51d5ceb 100644 --- a/.github/pkl-workflows/helpers/Common.pkl +++ b/.github/pkl-workflows/helpers/Common.pkl @@ -12,6 +12,7 @@ const appleTargets: List = List("Device", "Simulator") typealias NetFramework = "net6.0" | "net8.0" | String typealias NetRuntime = "win-x64" | "linux-x64" | "osx-x64" | "osx-arm64" | String +typealias SyncDifferentiator = "ios" | "tvos" | "catalyst" | "code-coverage" | String const wrapperBinaryNames: List = List("macos", "catalyst") diff --git a/.github/pkl-workflows/helpers/Steps.pkl b/.github/pkl-workflows/helpers/Steps.pkl index dab7030ece..a0d50b1feb 100644 --- a/.github/pkl-workflows/helpers/Steps.pkl +++ b/.github/pkl-workflows/helpers/Steps.pkl @@ -66,11 +66,11 @@ const function fetchPackages(packageJob: String, _packages: List?): List } }) -const function setupWorkloads(workloads: String, dotnetVersion: String): Listing = new Listing { +const function setupWorkloads(workloads: String?, dotnetVersion: String?): Listing = new Listing { setupDotnet(dotnetVersion) new { name = "Setup workloads" - run = "dotnet workload install \(workloads)" + run = "dotnet workload install \(workloads ?? "android ${{ (runner.os != 'Linux' && 'tvos ios maccatalyst') || '' }}")" } } @@ -95,6 +95,11 @@ const function dotnetPublish(project: String, framework: Common.NetFramework, ru } } +const function dotnetBuild(project: String, framework: Common.NetFramework, properties: Mapping): gha.Step = new gha.Step { + name = "Build \(project)" + run = "dotnet build \(project) -c \(Common.configuration) -f \(framework) \(propertiesToString(properties))" +} + const function runSimulator(config: SimulatorConfig): gha.Step = new { name = "Run on Simulator" uses = actionRunSimulator @@ -104,9 +109,9 @@ const function runSimulator(config: SimulatorConfig): gha.Step = new { class SimulatorConfig { appPath: String bundleId: String - iphoneToSimulate: "Apple-TV-1080p" + iphoneToSimulate: "Apple-TV-1080p" | "iPhone-8" | "iPhone-15" arguments: String - os: "tvOS" + os: "tvOS" | "iOS" } local const function addMSBuildToPath(): gha.Step = new { diff --git a/.github/pkl-workflows/helpers/Test.pkl b/.github/pkl-workflows/helpers/Test.pkl index e03af27250..9379350530 100644 --- a/.github/pkl-workflows/helpers/Test.pkl +++ b/.github/pkl-workflows/helpers/Test.pkl @@ -19,7 +19,7 @@ function netFramework(_packageJob: String, _syncDifferentiators: Listing null, (config) -> new Listing { ...prepareTests(config) - ...buildTests(_packageJob, "Tests/Realm.Tests", new Mapping { + ...buildTests(config, "Tests/Realm.Tests", new Mapping { ["TargetFramework"] = "net461" }) new gha.Step { @@ -70,7 +70,7 @@ function netCore(_packageJob: String, frameworks: Listing): shell = "bash" } Steps.setupDotnet("${{ steps.get-net-version.outputs.version }}") - ...Steps.dotnetPublish("Tests/Realm.Tests", "${{ matrix.framework }}", "${{ matrix.os.runtime }}", getTestProps(_packageJob)) + ...Steps.dotnetPublish("Tests/Realm.Tests", "${{ matrix.framework }}", "${{ matrix.os.runtime }}", getTestProps(config)) ...dotnetRunTests(true) ...reportTestResults(config) }) @@ -92,7 +92,7 @@ function weaver(): gha.StepJobBase = testJob( }, (config) -> new Listing { ...Steps.checkout() - ...Steps.setupWorkloads("android ${{ (matrix.os.runner != 'ubuntu-latest' && 'tvos ios maccatalyst') || '' }}", "6.0.x").toList() + ...Steps.setupWorkloads(null, "6.0.x") ...Steps.dotnetPublish("Tests/Weaver/Realm.Fody.Tests", "net6.0", "${{ matrix.os.runtime }}", new Mapping{}).toList() ...dotnetRunTests(false) ...reportTestResults(config) @@ -107,7 +107,7 @@ function sourceGeneration(): gha.StepJobBase = testJob( null, (config) -> new Listing { ...Steps.checkout() - ...Steps.setupWorkloads("tvos ios maccatalyst android", "6.0.x").toList() + ...Steps.setupWorkloads(null, "6.0.x") ...Steps.dotnetPublish("Tests/SourceGenerators/Realm.SourceGenerator.Tests", "net6.0", "win-x64", new Mapping{}).toList() ...dotnetRunTests(false) ...reportTestResults(config) @@ -122,7 +122,7 @@ function wovenClasses(_packageJob: String): gha.StepJobBase = testJob( null, (config) -> new Listing { ...prepareTests(config) - ...Steps.dotnetPublish("Tests/Realm.Tests", "net8.0", "win-x64", (getTestProps(_packageJob)) { + ...Steps.dotnetPublish("Tests/Realm.Tests", "net8.0", "win-x64", (getTestProps(config)) { ["TestWeavedClasses"] = "true" }) ...dotnetRunTests(false) @@ -130,7 +130,7 @@ function wovenClasses(_packageJob: String): gha.StepJobBase = testJob( } ) -function tvOS(_packageJob: String, _syncDifferentiators: Listing): gha.StepJobBase = testJob( +function tvOS(_packageJob: String, _syncDifferentiators: Listing): gha.StepJobBase = testJob( new TestConfig { packageJob = _packageJob title = "Xamarin.tvOS" @@ -141,7 +141,7 @@ function tvOS(_packageJob: String, _syncDifferentiators: Listing): gha.S null, (config) -> new Listing { ...prepareTests(config) - ...buildTests(_packageJob, "Tests/Tests.XamarinTVOS", new Mapping { + ...buildTests(config, "Tests/Tests.XamarinTVOS", new Mapping { ["Platform"] = "iPhoneSimulator" }) Steps.runSimulator(new Steps.SimulatorConfig{ @@ -152,8 +152,89 @@ function tvOS(_packageJob: String, _syncDifferentiators: Listing): gha.S os = "tvOS" }) ...reportTestResults(config) - } -) + }) + +function iOS_Xamarin(_packageJob: String): gha.StepJobBase = testJob( + new TestConfig { + packageJob = _packageJob + title = "Xamarin.iOS" + }, + "macos-12", + null, + (config) -> new Listing { + ...prepareTests(config) + ...buildTests(config, "Tests/Tests.iOS", new Mapping { + ["Platform"] = "iPhoneSimulator" + }) + Steps.runSimulator(new Steps.SimulatorConfig{ + appPath = "Tests/Tests.iOS/bin/iPhoneSimulator/\(Common.configuration)/Tests.iOS.app" + arguments = "--headless --result=${{ github.workspace }}/\(outputFile) --labels=All \(baasTestArgs(config))" + bundleId = "io.realm.dotnettests" + iphoneToSimulate = "iPhone-8" + os = "iOS" + }) + ...reportTestResults(config) + }) + +function iOS_Maui(_packageJob: String, _syncDifferentiators: Listing): gha.StepJobBase = testJob( + new TestConfig { + packageJob = _packageJob + title = "Maui.iOS" + syncDifferentiator = "ios" + syncDifferentiators = _syncDifferentiators + }, + "macos-14", + null, + (config) -> new Listing { + ...prepareTests(config) + ...Steps.setupWorkloads("maui", null) + Steps.dotnetBuild("Tests/Tests.Maui", "net8.0-ios", getTestProps(config)) + Steps.runSimulator(new Steps.SimulatorConfig{ + appPath = "Tests/Tests.Maui/bin/\(Common.configuration)/net8.0-ios/iossimulator-arm64/Tests.Maui.app" + arguments = "--headless --result=${{ github.workspace }}/\(outputFile) --labels=All \(baasTestArgs(config))" + bundleId = "io.realm.mauitests" + iphoneToSimulate = "iPhone-15" + os = "iOS" + }) + ...reportTestResults(config) + }) + +function macOS_Xamarin(_packageJob: String): gha.StepJobBase = testJob( + new TestConfig { + packageJob = _packageJob + title = "Xamarin.macOS" + }, + "macos-12", + null, + (config) -> new Listing { + ...prepareTests(config) + ...buildTests(config, "Tests/Tests.XamarinMac", new Mapping {}) + new { + name = "Run the tests" + run = "Tests/Tests.XamarinMac/bin/\(Common.configuration)/Tests.XamarinMac.app/Contents/MacOS/Tests.XamarinMac --headless --result=${{ github.workspace }}/\(outputFile) --labels=All" + } + ...reportTestResults(config) + }) + +function macOS_Maui(_packageJob: String, _syncDifferentiators: Listing): gha.StepJobBase = testJob( + new TestConfig { + packageJob = _packageJob + title = "Maui.MacCatalyst" + syncDifferentiator = "catalyst" + syncDifferentiators = _syncDifferentiators + }, + "macos-14", + null, + (config) -> new Listing { + ...prepareTests(config) + ...Steps.setupWorkloads("maui", null) + Steps.dotnetBuild("Tests/Tests.Maui", "net8.0-maccatalyst", getTestProps(config)) + new { + name = "Run the tests" + run = "Tests/Tests.Maui/bin/\(Common.configuration)/net8.0-maccatalyst/maccatalyst-arm64/Tests.Maui.app/Contents/MacOS/Tests.Maui --headless --result=${{ github.workspace }}/\(outputFile) --labels=All \(baasTestArgs(config))" + } + ...reportTestResults(config) + }) // Private helpers local function testJob(config: TestConfig, runsOn: gha.Machine | String, _strategy: gha.MatrixStrategy?, _steps: Function1>): gha.StepJobBase = (if (_strategy != null) new gha.MatrixJob{ @@ -191,8 +272,8 @@ local function fetchTestArtifacts(packageJob: String, useWrappers: Boolean): Lis Steps.fetchPackages(packageJob, Common.nugetPackages) else Steps.fetchPackages(packageJob, Common.nugetPackages) -local function buildTests(packageJob: String, projectPath: String, properties: Mapping): List = Steps.msbuild(projectPath, new Mapping{ - ...getTestProps(packageJob) +local function buildTests(config: TestConfig, projectPath: String, properties: Mapping): List = Steps.msbuild(projectPath, new Mapping{ + ...getTestProps(config) ...properties }) @@ -221,9 +302,9 @@ local function reportTestResults(config: TestConfig): Listing = new { } } -local function getTestProps(packageJob: String): Mapping = new Mapping { +local function getTestProps(config: TestConfig): Mapping = new Mapping { ["RestoreConfigFile"] = "Tests/Test.NuGet.Config" - ["UseRealmNupkgsWithVersion"] = "${{ needs.\(packageJob).outputs.package_version }}" + ["UseRealmNupkgsWithVersion"] = "${{ needs.\(config.packageJob!!).outputs.package_version }}" ["RealmTestsStandaloneExe"] = "true" } @@ -261,8 +342,8 @@ local class TestConfig { packageJob: String? = null useWrappers: Boolean = false shouldCleanWorkspace: Boolean = false - syncDifferentiator: String? = null + syncDifferentiator: Common.SyncDifferentiator? = null transformResults: Boolean = false - syncDifferentiators: Listing? - runSyncTests: Boolean = syncDifferentiators?.toList()?.contains(syncDifferentiator) ?? false + syncDifferentiators: Listing? + runSyncTests: Boolean = syncDifferentiator != null && (syncDifferentiators?.toList()?.contains(syncDifferentiator) ?? false) } diff --git a/.github/pkl-workflows/pr.pkl b/.github/pkl-workflows/pr.pkl index d64cbc4d19..2c02c6b5d7 100644 --- a/.github/pkl-workflows/pr.pkl +++ b/.github/pkl-workflows/pr.pkl @@ -29,7 +29,7 @@ local function createTestJob(workflow: String): ReusableWorkflowJob = new Reusab local JobNames = new JobNamesDefition{} -local baasDifferentiators: Listing = new { +local baasDifferentiators: Listing = new { "code-coverage" } @@ -111,8 +111,10 @@ jobs { } } ["test-net-core"] = TestJobs.netCore(JobNames.packages, new Listing { "net8.0" }) - ["test-macos"] = createTestJob("test-macos") - ["test-ios"] = createTestJob("test-ios") + ["test-macos-xamarin"] = TestJobs.macOS_Xamarin(JobNames.packages) + ["test-macos-maui"] = TestJobs.macOS_Maui(JobNames.packages, baasDifferentiators) + ["test-ios-xamarin"] = TestJobs.iOS_Xamarin(JobNames.packages) + ["test-ios-maui"] = TestJobs.iOS_Maui(JobNames.packages, baasDifferentiators) ["test-tvos"] = TestJobs.tvOS(JobNames.packages, baasDifferentiators) ["test-android"] = (createTestJob("test-android")) { secrets { diff --git a/.github/templates/test-ios.yml b/.github/templates/test-ios.yml deleted file mode 100644 index 930e591cfa..0000000000 --- a/.github/templates/test-ios.yml +++ /dev/null @@ -1,43 +0,0 @@ -#@ load("@ytt:template", "template") -#@ load("common.lib.yml", "checkoutCode", "configuration", "actionRuniOSSimulator", "fetchPackageArtifacts", "setupWorkloads", "setupXcode") -#@ load("test.lib.yml", "baasTestArgs", "publishTestsResults", "testDefinition", "buildTests", "prepareTest") - ---- -name: test-ios -_: #@ template.replace(testDefinition()) -jobs: - test-xamarin: - runs-on: macos-12 - name: Xamarin.iOS - timeout-minutes: 90 - steps: - - #@ template.replace(prepareTest("ios")) - - #@ template.replace(buildTests("Tests/Tests.iOS", Platform="iPhoneSimulator")) - - name: Run the tests - uses: #@ actionRuniOSSimulator - with: - appPath: #@ "Tests/Tests.iOS/bin/iPhoneSimulator/" + configuration + "/Tests.iOS.app" - bundleId: 'io.realm.dotnettests' - iphoneToSimulate: 'iPhone-8' - arguments: #@ "--headless --result=${{ github.workspace }}/TestResults.iOS.xml" + baasTestArgs("ios") - - #@ template.replace(publishTestsResults("TestResults.iOS.xml", "Xamarin.iOS")) - - test-maui: - runs-on: macos-13 - name: Maui.iOS - timeout-minutes: 45 - steps: - - #@ template.replace(checkoutCode()) - - #@ template.replace(fetchPackageArtifacts()) - - #@ setupXcode("latest-stable") - - #@ template.replace(setupWorkloads()) - - name: Build the tests - run: #@ "dotnet build Tests/Tests.Maui -c " + configuration + " -f net8.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 + "/net8.0-ios/iossimulator-x64/Tests.Maui.app" - bundleId: 'io.realm.mauitests' - iphoneToSimulate: 'iPhone-15' - arguments: #@ "--headless --result=${{ github.workspace }}/TestResults.iOS.xml --labels=After" - - #@ template.replace(publishTestsResults("TestResults.iOS.xml", "Maui.iOS", run_transform=True)) \ No newline at end of file diff --git a/.github/templates/test-macos.yml b/.github/templates/test-macos.yml deleted file mode 100644 index 4d4cb0ca72..0000000000 --- a/.github/templates/test-macos.yml +++ /dev/null @@ -1,32 +0,0 @@ -#@ load("@ytt:template", "template") -#@ load("common.lib.yml", "checkoutCode", "configuration", "fetchPackageArtifacts", "setupWorkloads", "setupXcode") -#@ load("test.lib.yml", "baasTestArgs", "publishTestsResults", "testDefinition", "buildTests", "prepareTest") - ---- -name: test-macos -_: #@ template.replace(testDefinition()) -jobs: - test-xamarin: - runs-on: macos-12 - name: Xamarin.macOS - timeout-minutes: 60 - steps: - - #@ 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") - - #@ template.replace(publishTestsResults("TestResults.XamarinMac.xml", "Xamarin.macOS")) - test-maui: - runs-on: macos-13 - name: Maui.MacCatalyst - timeout-minutes: 60 - steps: - - #@ template.replace(checkoutCode()) - - #@ template.replace(fetchPackageArtifacts()) - - #@ setupXcode("latest-stable") - - #@ template.replace(setupWorkloads()) - - name: Build the tests - run: #@ "dotnet build Tests/Tests.Maui -c " + configuration + " -f net8.0-maccatalyst -p:RestoreConfigFile=Tests/Test.NuGet.Config -p:UseRealmNupkgsWithVersion=${{ inputs.version }}" - - name: Run the tests - run: #@ "Tests/Tests.Maui/bin/" + configuration + "/net8.0-maccatalyst/maccatalyst-x64/Tests.Maui.app/Contents/MacOS/Tests.Maui --headless --result=${{ github.workspace }}/TestResults.MacCatalyst.xml --labels=All" + baasTestArgs("maccatalyst") - - #@ template.replace(publishTestsResults("TestResults.MacCatalyst.xml", "Maui.MacCatalyst", run_transform=True)) \ No newline at end of file diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index cbfbedcd7b..d05c7cc233 100755 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -220,22 +220,198 @@ jobs: runner: macos-14 runtime: osx-arm64 fail-fast: false - test-macos: - name: Test + test-macos-xamarin: + name: Test Xamarin.macOS needs: - build-packages if: always() && !cancelled() && !contains(needs.*.result, 'failure') && !contains(needs.*.result, 'cancelled') - uses: ./.github/workflows/test-macos.yml - with: - version: ${{ needs.build-packages.outputs.package_version }} - test-ios: - name: Test + timeout-minutes: 60 + runs-on: macos-12 + steps: + - name: Checkout Code + uses: actions/checkout@v4 + with: + submodules: recursive + ref: ${{ github.event.pull_request.head.sha }} + - name: Register csc problem matcher + run: |- + echo "::add-matcher::.github/problem-matchers/csc.json" + echo "::add-matcher::.github/problem-matchers/msvc.json" + - name: Fetch Realm + uses: actions/download-artifact@v4 + with: + name: Realm.${{ needs.build-packages.outputs.package_version }} + path: ${{ github.workspace }}/Realm/packages/ + - name: Fetch Realm.PlatformHelpers + uses: actions/download-artifact@v4 + with: + name: Realm.PlatformHelpers.${{ needs.build-packages.outputs.package_version }} + path: ${{ github.workspace }}/Realm/packages/ + - name: Add msbuild to PATH + if: ${{ runner.os == 'Windows' }} + uses: microsoft/setup-msbuild@0b44c6745b7e81956596964100aadb92d667c497 + - name: Build Tests/Tests.XamarinMac + run: msbuild Tests/Tests.XamarinMac -p:Configuration=Release -restore -p:RestoreConfigFile=Tests/Test.NuGet.Config -p:UseRealmNupkgsWithVersion=${{ needs.build-packages.outputs.package_version }} -p:RealmTestsStandaloneExe=true + - name: Run the tests + run: Tests/Tests.XamarinMac/bin/Release/Tests.XamarinMac.app/Contents/MacOS/Tests.XamarinMac --headless --result=${{ github.workspace }}/TestResults.xml --labels=All + - name: Publish Unit Test Results + if: always() + uses: LaPeste/test-reporter@510caf50a955b1003bec48a6494be4d6537f3a0b + with: + name: Results Xamarin.macOS + path: TestResults.xml + reporter: java-junit + list-suites: failed + path-replace-backslashes: true + fail-on-error: true + test-macos-maui: + name: Test Maui.MacCatalyst needs: - build-packages if: always() && !cancelled() && !contains(needs.*.result, 'failure') && !contains(needs.*.result, 'cancelled') - uses: ./.github/workflows/test-ios.yml - with: - version: ${{ needs.build-packages.outputs.package_version }} + timeout-minutes: 60 + runs-on: macos-14 + steps: + - name: Checkout Code + uses: actions/checkout@v4 + with: + submodules: recursive + ref: ${{ github.event.pull_request.head.sha }} + - name: Register csc problem matcher + run: |- + echo "::add-matcher::.github/problem-matchers/csc.json" + echo "::add-matcher::.github/problem-matchers/msvc.json" + - name: Fetch Realm + uses: actions/download-artifact@v4 + with: + name: Realm.${{ needs.build-packages.outputs.package_version }} + path: ${{ github.workspace }}/Realm/packages/ + - name: Fetch Realm.PlatformHelpers + uses: actions/download-artifact@v4 + with: + name: Realm.PlatformHelpers.${{ needs.build-packages.outputs.package_version }} + path: ${{ github.workspace }}/Realm/packages/ + - uses: actions/setup-dotnet@607fce577a46308457984d59e4954e075820f10a + with: + dotnet-version: 8.0.x + - name: Setup workloads + run: dotnet workload install maui + - name: Build Tests/Tests.Maui + run: dotnet build Tests/Tests.Maui -c Release -f net8.0-maccatalyst -p:RestoreConfigFile=Tests/Test.NuGet.Config -p:UseRealmNupkgsWithVersion=${{ needs.build-packages.outputs.package_version }} -p:RealmTestsStandaloneExe=true + - name: Run the tests + run: 'Tests/Tests.Maui/bin/Release/net8.0-maccatalyst/maccatalyst-arm64/Tests.Maui.app/Contents/MacOS/Tests.Maui --headless --result=${{ github.workspace }}/TestResults.xml --labels=All ' + - name: Publish Unit Test Results + if: always() + uses: LaPeste/test-reporter@510caf50a955b1003bec48a6494be4d6537f3a0b + with: + name: Results Maui.MacCatalyst + path: TestResults.xml + reporter: java-junit + list-suites: failed + path-replace-backslashes: true + fail-on-error: true + test-ios-xamarin: + name: Test Xamarin.iOS + needs: + - build-packages + if: always() && !cancelled() && !contains(needs.*.result, 'failure') && !contains(needs.*.result, 'cancelled') + timeout-minutes: 60 + runs-on: macos-12 + steps: + - name: Checkout Code + uses: actions/checkout@v4 + with: + submodules: recursive + ref: ${{ github.event.pull_request.head.sha }} + - name: Register csc problem matcher + run: |- + echo "::add-matcher::.github/problem-matchers/csc.json" + echo "::add-matcher::.github/problem-matchers/msvc.json" + - name: Fetch Realm + uses: actions/download-artifact@v4 + with: + name: Realm.${{ needs.build-packages.outputs.package_version }} + path: ${{ github.workspace }}/Realm/packages/ + - name: Fetch Realm.PlatformHelpers + uses: actions/download-artifact@v4 + with: + name: Realm.PlatformHelpers.${{ needs.build-packages.outputs.package_version }} + path: ${{ github.workspace }}/Realm/packages/ + - name: Add msbuild to PATH + if: ${{ runner.os == 'Windows' }} + uses: microsoft/setup-msbuild@0b44c6745b7e81956596964100aadb92d667c497 + - name: Build Tests/Tests.iOS + run: msbuild Tests/Tests.iOS -p:Configuration=Release -restore -p:RestoreConfigFile=Tests/Test.NuGet.Config -p:UseRealmNupkgsWithVersion=${{ needs.build-packages.outputs.package_version }} -p:RealmTestsStandaloneExe=true -p:Platform=iPhoneSimulator + - name: Run on Simulator + uses: realm/ci-actions/run-ios-simulator@6418e15ed9bbdb19b7d456a347e5623779f95cdf + with: + appPath: Tests/Tests.iOS/bin/iPhoneSimulator/Release/Tests.iOS.app + bundleId: io.realm.dotnettests + iphoneToSimulate: iPhone-8 + arguments: '--headless --result=${{ github.workspace }}/TestResults.xml --labels=All ' + os: iOS + - name: Publish Unit Test Results + if: always() + uses: LaPeste/test-reporter@510caf50a955b1003bec48a6494be4d6537f3a0b + with: + name: Results Xamarin.iOS + path: TestResults.xml + reporter: java-junit + list-suites: failed + path-replace-backslashes: true + fail-on-error: true + test-ios-maui: + name: Test Maui.iOS + needs: + - build-packages + if: always() && !cancelled() && !contains(needs.*.result, 'failure') && !contains(needs.*.result, 'cancelled') + timeout-minutes: 60 + runs-on: macos-14 + steps: + - name: Checkout Code + uses: actions/checkout@v4 + with: + submodules: recursive + ref: ${{ github.event.pull_request.head.sha }} + - name: Register csc problem matcher + run: |- + echo "::add-matcher::.github/problem-matchers/csc.json" + echo "::add-matcher::.github/problem-matchers/msvc.json" + - name: Fetch Realm + uses: actions/download-artifact@v4 + with: + name: Realm.${{ needs.build-packages.outputs.package_version }} + path: ${{ github.workspace }}/Realm/packages/ + - name: Fetch Realm.PlatformHelpers + uses: actions/download-artifact@v4 + with: + name: Realm.PlatformHelpers.${{ needs.build-packages.outputs.package_version }} + path: ${{ github.workspace }}/Realm/packages/ + - uses: actions/setup-dotnet@607fce577a46308457984d59e4954e075820f10a + with: + dotnet-version: 8.0.x + - name: Setup workloads + run: dotnet workload install maui + - name: Build Tests/Tests.Maui + run: dotnet build Tests/Tests.Maui -c Release -f net8.0-ios -p:RestoreConfigFile=Tests/Test.NuGet.Config -p:UseRealmNupkgsWithVersion=${{ needs.build-packages.outputs.package_version }} -p:RealmTestsStandaloneExe=true + - name: Run on Simulator + uses: realm/ci-actions/run-ios-simulator@6418e15ed9bbdb19b7d456a347e5623779f95cdf + with: + appPath: Tests/Tests.Maui/bin/Release/net8.0-ios/iossimulator-arm64/Tests.Maui.app + bundleId: io.realm.mauitests + iphoneToSimulate: iPhone-15 + arguments: '--headless --result=${{ github.workspace }}/TestResults.xml --labels=All ' + os: iOS + - name: Publish Unit Test Results + if: always() + uses: LaPeste/test-reporter@510caf50a955b1003bec48a6494be4d6537f3a0b + with: + name: Results Maui.iOS + path: TestResults.xml + reporter: java-junit + list-suites: failed + path-replace-backslashes: true + fail-on-error: true test-tvos: name: Test Xamarin.tvOS needs: @@ -363,7 +539,7 @@ jobs: with: dotnet-version: 6.0.x - name: Setup workloads - run: dotnet workload install tvos ios maccatalyst android + run: dotnet workload install android ${{ (runner.os != 'Linux' && 'tvos ios maccatalyst') || '' }} - name: Publish Tests/SourceGenerators/Realm.SourceGenerator.Tests run: dotnet publish Tests/SourceGenerators/Realm.SourceGenerator.Tests -c Release -f net6.0 -r win-x64 --no-self-contained - name: Output executable path @@ -401,7 +577,7 @@ jobs: with: dotnet-version: 6.0.x - name: Setup workloads - run: dotnet workload install android ${{ (matrix.os.runner != 'ubuntu-latest' && 'tvos ios maccatalyst') || '' }} + run: dotnet workload install android ${{ (runner.os != 'Linux' && 'tvos ios maccatalyst') || '' }} - name: Publish Tests/Weaver/Realm.Fody.Tests run: dotnet publish Tests/Weaver/Realm.Fody.Tests -c Release -f net6.0 -r ${{ matrix.os.runtime }} --no-self-contained - name: Output executable path diff --git a/.github/workflows/test-ios.yml b/.github/workflows/test-ios.yml deleted file mode 100755 index 8c559a2986..0000000000 --- a/.github/workflows/test-ios.yml +++ /dev/null @@ -1,124 +0,0 @@ -name: test-ios -"on": - workflow_call: - inputs: - version: - required: true - type: string - secrets: - BaaSaasApiKey: - required: false -env: - REALM_DISABLE_ANALYTICS: true - DOTNET_NOLOGO: true -jobs: - test-xamarin: - runs-on: macos-12 - name: Xamarin.iOS - timeout-minutes: 90 - 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@v4 - with: - name: Realm.PlatformHelpers.${{ inputs.version }} - path: ${{ github.workspace }}/Realm/packages/ - - name: Fetch Realm - uses: actions/download-artifact@v4 - with: - name: Realm.${{ inputs.version }} - path: ${{ github.workspace }}/Realm/packages/ - - name: Deploy Baas (alternative) - env: - apiKey: ${{ secrets.BaaSaasApiKey }} - if: ${{ env.apiKey }} - run: dotnet run deploy-apps --baasaas-api-key=${{ secrets.BaaSaasApiKey }} --baas-differentiator=ios-${{ github.run_id }}-${{ github.run_attempt }} - working-directory: Tools/DeployApps - - name: Add msbuild to PATH - uses: microsoft/setup-msbuild@0b44c6745b7e81956596964100aadb92d667c497 - if: ${{ runner.os == 'Windows' }} - - name: Build Tests/Tests.iOS - run: msbuild Tests/Tests.iOS -p:Configuration=Release -restore -p:RestoreConfigFile=Tests/Test.NuGet.Config -p:UseRealmNupkgsWithVersion=${{ inputs.version }} -p:Platform=iPhoneSimulator - - name: Run the tests - uses: realm/ci-actions/run-ios-simulator@6418e15ed9bbdb19b7d456a347e5623779f95cdf - with: - 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 --baasaas-api-key=${{ secrets.BaaSaasApiKey}} --baas-differentiator=ios-${{ github.run_id }}-${{ github.run_attempt }} - - name: Publish Unit Test Results - uses: LaPeste/test-reporter@510caf50a955b1003bec48a6494be4d6537f3a0b - if: always() - with: - name: Results Xamarin.iOS - path: TestResults.iOS.xml - reporter: java-junit - list-suites: failed - list-tests: failed - path-replace-backslashes: true - fail-on-error: true - test-maui: - runs-on: macos-13 - name: Maui.iOS - 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@v4 - with: - name: Realm.PlatformHelpers.${{ inputs.version }} - path: ${{ github.workspace }}/Realm/packages/ - - name: Fetch Realm - uses: actions/download-artifact@v4 - with: - name: Realm.${{ inputs.version }} - path: ${{ github.workspace }}/Realm/packages/ - - name: Setup Xcode - uses: maxim-lobanov/setup-xcode@60606e260d2fc5762a71e64e74b2174e8ea3c8bd - with: - xcode-version: latest-stable - - name: Configure .NET - uses: actions/setup-dotnet@3e6b9fe3930cac7c59c651af5de1514b47a805b9 - with: - dotnet-version: 8.0.x - - name: Setup workloads - run: dotnet workload install maui - - name: Build the tests - run: dotnet build Tests/Tests.Maui -c Release -f net8.0-ios -p:RestoreConfigFile=Tests/Test.NuGet.Config -p:UseRealmNupkgsWithVersion=${{ inputs.version }} - - name: Run the tests - uses: realm/ci-actions/run-ios-simulator@6418e15ed9bbdb19b7d456a347e5623779f95cdf - with: - appPath: Tests/Tests.Maui/bin/Release/net8.0-ios/iossimulator-x64/Tests.Maui.app - bundleId: io.realm.mauitests - iphoneToSimulate: iPhone-15 - arguments: --headless --result=${{ github.workspace }}/TestResults.iOS.xml --labels=After - - name: Transform Results - run: xsltproc --output TestResults.iOS.xml_transformed.xml Tests/Realm.Tests/EmbeddedResources/nunit3-junit.xslt TestResults.iOS.xml - shell: bash - - name: Publish Unit Test Results - uses: LaPeste/test-reporter@510caf50a955b1003bec48a6494be4d6537f3a0b - if: always() - with: - name: Results Maui.iOS - path: TestResults.iOS.xml_transformed.xml - reporter: java-junit - list-suites: failed - list-tests: failed - path-replace-backslashes: true - fail-on-error: true diff --git a/.github/workflows/test-macos.yml b/.github/workflows/test-macos.yml deleted file mode 100755 index dccf02ece6..0000000000 --- a/.github/workflows/test-macos.yml +++ /dev/null @@ -1,114 +0,0 @@ -name: test-macos -"on": - workflow_call: - inputs: - version: - required: true - type: string - secrets: - BaaSaasApiKey: - required: false -env: - REALM_DISABLE_ANALYTICS: true - DOTNET_NOLOGO: true -jobs: - test-xamarin: - runs-on: macos-12 - name: Xamarin.macOS - timeout-minutes: 60 - 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@v4 - with: - name: Realm.PlatformHelpers.${{ inputs.version }} - path: ${{ github.workspace }}/Realm/packages/ - - name: Fetch Realm - uses: actions/download-artifact@v4 - with: - name: Realm.${{ inputs.version }} - path: ${{ github.workspace }}/Realm/packages/ - - name: Deploy Baas (alternative) - env: - apiKey: ${{ secrets.BaaSaasApiKey }} - if: ${{ env.apiKey }} - run: dotnet run deploy-apps --baasaas-api-key=${{ secrets.BaaSaasApiKey }} --baas-differentiator=xamarinmacos-${{ github.run_id }}-${{ github.run_attempt }} - working-directory: Tools/DeployApps - - name: Add msbuild to PATH - uses: microsoft/setup-msbuild@0b44c6745b7e81956596964100aadb92d667c497 - if: ${{ runner.os == 'Windows' }} - - 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 --baasaas-api-key=${{ secrets.BaaSaasApiKey}} --baas-differentiator=xamarinmacos-${{ github.run_id }}-${{ github.run_attempt }} - - name: Publish Unit Test Results - uses: LaPeste/test-reporter@510caf50a955b1003bec48a6494be4d6537f3a0b - if: always() - with: - name: Results Xamarin.macOS - path: TestResults.XamarinMac.xml - reporter: java-junit - list-suites: failed - list-tests: failed - path-replace-backslashes: true - fail-on-error: true - test-maui: - runs-on: macos-13 - name: Maui.MacCatalyst - timeout-minutes: 60 - 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@v4 - with: - name: Realm.PlatformHelpers.${{ inputs.version }} - path: ${{ github.workspace }}/Realm/packages/ - - name: Fetch Realm - uses: actions/download-artifact@v4 - with: - name: Realm.${{ inputs.version }} - path: ${{ github.workspace }}/Realm/packages/ - - name: Setup Xcode - uses: maxim-lobanov/setup-xcode@60606e260d2fc5762a71e64e74b2174e8ea3c8bd - with: - xcode-version: latest-stable - - name: Configure .NET - uses: actions/setup-dotnet@3e6b9fe3930cac7c59c651af5de1514b47a805b9 - with: - dotnet-version: 8.0.x - - name: Setup workloads - run: dotnet workload install maui - - name: Build the tests - run: dotnet build Tests/Tests.Maui -c Release -f net8.0-maccatalyst -p:RestoreConfigFile=Tests/Test.NuGet.Config -p:UseRealmNupkgsWithVersion=${{ inputs.version }} - - name: Run the tests - run: Tests/Tests.Maui/bin/Release/net8.0-maccatalyst/maccatalyst-x64/Tests.Maui.app/Contents/MacOS/Tests.Maui --headless --result=${{ github.workspace }}/TestResults.MacCatalyst.xml --labels=All --baasaas-api-key=${{ secrets.BaaSaasApiKey}} --baas-differentiator=maccatalyst-${{ github.run_id }}-${{ github.run_attempt }} - - name: Transform Results - run: xsltproc --output TestResults.MacCatalyst.xml_transformed.xml Tests/Realm.Tests/EmbeddedResources/nunit3-junit.xslt TestResults.MacCatalyst.xml - shell: bash - - name: Publish Unit Test Results - uses: LaPeste/test-reporter@510caf50a955b1003bec48a6494be4d6537f3a0b - if: always() - with: - name: Results Maui.MacCatalyst - path: TestResults.MacCatalyst.xml_transformed.xml - reporter: java-junit - list-suites: failed - list-tests: failed - path-replace-backslashes: true - fail-on-error: true From 89c280a93070fa7b3244c08a0291baaf454a4b10 Mon Sep 17 00:00:00 2001 From: Nikola Irinchev Date: Wed, 15 May 2024 23:46:04 +0200 Subject: [PATCH 18/39] Move android, fix catalyst --- .../GithubAction/GithubAction.pkl | 2 +- .github/pkl-workflows/helpers/Common.pkl | 6 +- .github/pkl-workflows/helpers/Steps.pkl | 49 +++++- .github/pkl-workflows/helpers/Test.pkl | 92 ++++++++++- .github/pkl-workflows/pr.pkl | 7 +- .github/pkl-workflows/wrappers.pkl | 2 +- .github/templates/test-android.yml | 49 ------ .github/templates/test-uwp-managed.yml | 26 --- .github/workflows/pr.yml | 69 ++++++-- .github/workflows/test-android.yml | 153 ------------------ .github/workflows/test-uwp-managed.yml | 74 --------- Tests/Realm.Tests/Sync/AppTests.cs | 2 +- Tests/Tests.Maui/Tests.Maui.csproj | 2 +- 13 files changed, 200 insertions(+), 333 deletions(-) delete mode 100644 .github/templates/test-android.yml delete mode 100644 .github/templates/test-uwp-managed.yml delete mode 100755 .github/workflows/test-android.yml delete mode 100755 .github/workflows/test-uwp-managed.yml diff --git a/.github/pkl-workflows/GithubAction/GithubAction.pkl b/.github/pkl-workflows/GithubAction/GithubAction.pkl index 206fec7c85..2dd6637194 100644 --- a/.github/pkl-workflows/GithubAction/GithubAction.pkl +++ b/.github/pkl-workflows/GithubAction/GithubAction.pkl @@ -601,7 +601,7 @@ class WindowsLatest extends Machine { name = "windows-latest" } -typealias Shell = "pwsh" | "bash" | "sh" | "cmd" | "PowerShell" | "python" +typealias Shell = "pwsh" | "bash" | "sh" | "cmd" | "powershell" | "python" // Step, part of Jobs class Step { diff --git a/.github/pkl-workflows/helpers/Common.pkl b/.github/pkl-workflows/helpers/Common.pkl index 30c51d5ceb..e0a33fe2a1 100644 --- a/.github/pkl-workflows/helpers/Common.pkl +++ b/.github/pkl-workflows/helpers/Common.pkl @@ -10,9 +10,9 @@ const uwpArchs: List = List("Win32", "x64", "ARM", "ARM64") const appleTargets: List = List("Device", "Simulator") -typealias NetFramework = "net6.0" | "net8.0" | String -typealias NetRuntime = "win-x64" | "linux-x64" | "osx-x64" | "osx-arm64" | String -typealias SyncDifferentiator = "ios" | "tvos" | "catalyst" | "code-coverage" | String +typealias NetFramework = "net6.0" | String(startsWith("${{ matrix")) | String(startsWith("net8")) +typealias NetRuntime = "win-x64" | "linux-x64" | "osx-x64" | "osx-arm64" | String(startsWith("${{ matrix")) +typealias SyncDifferentiator = "ios" | "android" | "tvos" | "catalyst" | "code-coverage" | "uwp" | "net-framework" | String(startsWith("${{ matrix")) const wrapperBinaryNames: List = List("macos", "catalyst") diff --git a/.github/pkl-workflows/helpers/Steps.pkl b/.github/pkl-workflows/helpers/Steps.pkl index a0d50b1feb..86dbde92c5 100644 --- a/.github/pkl-workflows/helpers/Steps.pkl +++ b/.github/pkl-workflows/helpers/Steps.pkl @@ -2,6 +2,8 @@ import "../GithubAction/GithubAction.pkl" as gha import "Common.pkl" const actionRunSimulator = "realm/ci-actions/run-ios-simulator@6418e15ed9bbdb19b7d456a347e5623779f95cdf" +const actionSetupJDK = "actions/setup-java@0ab4596768b603586c0de567f2430c30f5b0d2b0" +const actionAWSConfigureCredentials = "" const function checkout(): Listing = new Listing { checkoutWithoutMatchers() @@ -28,11 +30,11 @@ const function uploadArtifacts(artifactName: String, relPath: String): gha.Step } } -const function setupXcode(): gha.Step = new { +const function setupXcode(version: String): gha.Step = new gha.Step { name = "Setup Xcode" uses = "maxim-lobanov/setup-xcode@60606e260d2fc5762a71e64e74b2174e8ea3c8bd" with { - ["xcode-version"] = "14" + ["xcode-version"] = version } } @@ -74,6 +76,25 @@ const function setupWorkloads(workloads: String?, dotnetVersion: String?): Listi } } +const function setupJDK(): gha.Step = new { + name = "Setup JDK" + uses = actionSetupJDK + with { + ["distribution"] = "microsoft" + ["java-version"] = 11 + } +} + +const function configureAWSCredentials(accessKey: String, secretKey: String, region: String): gha.Step = new { + name = "Configure AWS Credentials" + uses = actionAWSConfigureCredentials + with { + ["aws-access-key-id"] = "${{ secrets.\(accessKey) }}" + ["aws-secret-access-key"] = "${{ secrets.\(secretKey) }}" + ["aws-region"] = region + } +} + const function msbuild(project: String, properties: Mapping): List = List( addMSBuildToPath(), new gha.Step { @@ -82,10 +103,10 @@ const function msbuild(project: String, properties: Mapping): Li } ) -const function dotnetPublish(project: String, framework: Common.NetFramework, runtime: Common.NetRuntime, properties: Mapping): Listing = new Listing { +const function dotnetPublish(project: String, framework: Common.NetFramework, runtime: Common.NetRuntime?, properties: Mapping): Listing = new Listing { new gha.Step { name = "Publish \(project)" - run = "dotnet publish \(project) -c \(Common.configuration) -f \(framework) -r \(runtime) \(propertiesToString(properties)) --no-self-contained" + run = "dotnet publish \(project) -c \(Common.configuration) -f \(framework) \(if (runtime != null) "-r \(runtime)" else "") \(propertiesToString(properties)) --no-self-contained" } new gha.Step { name = "Output executable path" @@ -106,6 +127,21 @@ const function runSimulator(config: SimulatorConfig): gha.Step = new { with = config.toMap().toMapping() } +const function runDeviceFarm(config: DeviceFarmConfig): Listing = new Listing { + configureAWSCredentials("AWS_DEVICEFARM_ACCESS_KEY_ID", "AWS_DEVICEFARM_SECRET_ACCESS_KEY", "us-west-2") + new gha.Step { + name = "Run the tests" + uses = "./.github/actions/run-android-device-farm-test" + id = "run_tests" + with { + ["apk-path"] = config.apkPath + ["app-id"] = config.appId + ["project-arn"] = "${{ secrets.DEVICEFARM_PROJECT_ARN }}" + ["device-pool-arn"] = "${{ secrets.DEVICEFARM_ANDROID_POOL_ARN }}" + } + } +} + class SimulatorConfig { appPath: String bundleId: String @@ -114,6 +150,11 @@ class SimulatorConfig { os: "tvOS" | "iOS" } +class DeviceFarmConfig { + apkPath: String + appId: String +} + local const function addMSBuildToPath(): gha.Step = new { name = "Add msbuild to PATH" uses = "microsoft/setup-msbuild@0b44c6745b7e81956596964100aadb92d667c497" diff --git a/.github/pkl-workflows/helpers/Test.pkl b/.github/pkl-workflows/helpers/Test.pkl index 9379350530..2e7a39d108 100644 --- a/.github/pkl-workflows/helpers/Test.pkl +++ b/.github/pkl-workflows/helpers/Test.pkl @@ -182,12 +182,14 @@ function iOS_Maui(_packageJob: String, _syncDifferentiators: Listing new Listing { ...prepareTests(config) ...Steps.setupWorkloads("maui", null) + Steps.setupXcode("latest-stable") Steps.dotnetBuild("Tests/Tests.Maui", "net8.0-ios", getTestProps(config)) Steps.runSimulator(new Steps.SimulatorConfig{ appPath = "Tests/Tests.Maui/bin/\(Common.configuration)/net8.0-ios/iossimulator-arm64/Tests.Maui.app" @@ -222,6 +224,7 @@ function macOS_Maui(_packageJob: String, _syncDifferentiators: Listing): gha.StepJobBase = testJob( + new TestConfig { + packageJob = _packageJob + title = "UWP" + syncDifferentiators = _syncDifferentiators + syncDifferentiator = "uwp" + }, + new gha.WindowsLatest{}, + null, + (config) -> new Listing { + ...prepareTests(config) + new { + 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" + } + ...buildTests(config, "Tests/Tests.UWP", new Mapping { + ["AppxBundle"] = "Always" + ["PackageCertificateKeyFile"] = "${{ github.workspace }}\\Tests\\Tests.UWP\\Tests.UWP_TemporaryKey.pfx" + ["PackageCertificatePassword"] = "${{ secrets.Pfx_Password }}" + ["UseDotNetNativeToolchain"] = "false" + ["AppxBundlePlatforms"] = "x64" + }) + new { + name = "Run the tests" + run = "./Tests/Tests.UWP/RunTests.ps1 -ExtraAppArgs '\(baasTestArgs(config))" + shell = "powershell" + } + ...reportTestResultsWithCustomFile("${{ env.TEST_RESULTS }}", config) + }) + +function android_Xamarin(_packageJob: String): gha.StepJobBase = testJob( + new TestConfig { + packageJob = _packageJob + title = "Xamarin.Android" + }, + new gha.WindowsLatest{}, + null, + (config) -> new Listing { + Steps.setupJDK() + ...prepareTests(config) + ...buildTests(config, "Tests/Tests.Android", new Mapping { + ["AndroidUseSharedRuntime"] = "False" + ["EmbedAssembliesIntoApk"] = "True" + }) + ...Steps.runDeviceFarm(new Steps.DeviceFarmConfig { + apkPath = "${{ github.workspace }}/Tests/Tests.Android/bin/Release/io.realm.xamarintests-Signed.apk" + appId = "io.realm.xamarintests" + }) + ...reportTestResultsWithCustomFile("${{ steps.run_tests.outputs.test-results-path }}", config) + }) + +function android_Maui(_packageJob: String, _syncDifferentiators: Listing): gha.StepJobBase = testJob( + new TestConfig { + packageJob = _packageJob + title = "Maui.Android" + syncDifferentiator = "android" + syncDifferentiators = _syncDifferentiators + transformResults = true + }, + new gha.WindowsLatest{}, + null, + (config) -> new Listing { + Steps.setupJDK() + ...prepareTests(config) + ...Steps.setupWorkloads("maui", null) + ...Steps.dotnetPublish("Tests/Tests.Maui", "net8.0-android", /* runtime */ null, getTestProps(config)) + ...Steps.runDeviceFarm(new Steps.DeviceFarmConfig { + apkPath = "${{ github.workspace }}/Tests/Tests.Maui/bin/Release/net8.0-android/publish/io.realm.mauitests-Signed.apk" + appId = "io.realm.mauitests" + }) + ...reportTestResultsWithCustomFile("${{ steps.run_tests.outputs.test-results-path }}", config) + }) + // Private helpers local function testJob(config: TestConfig, runsOn: gha.Machine | String, _strategy: gha.MatrixStrategy?, _steps: Function1>): gha.StepJobBase = (if (_strategy != null) new gha.MatrixJob{ strategy = _strategy @@ -279,12 +361,14 @@ local function buildTests(config: TestConfig, projectPath: String, properties: M local function baasTestArgs(config: TestConfig): String = if (config.runSyncTests) " --baasaas-api-key=${{ secrets.BAASAAS_API_KEY}} --baas-differentiator=\(config.syncDifferentiator)-${{ github.run_id }}-${{ github.run_attempt }}" else "" -local function reportTestResults(config: TestConfig): Listing = new { - local _outputFile = if (config.transformResults) "\(outputFile)_transformed.xml" else outputFile +local function reportTestResults(config: TestConfig): Listing = reportTestResultsWithCustomFile(outputFile, config) + +local function reportTestResultsWithCustomFile(_outputFile: String, config: TestConfig): Listing = new { + local __outputFile = if (config.transformResults) "\(_outputFile)_transformed.xml" else _outputFile when (config.transformResults) { new gha.Step { name = "Transform Results" - run = "xsltproc --output \(_outputFile) Tests/Realm.Tests/EmbeddedResources/nunit3-junit.xslt \(outputFile)" + run = "xsltproc --output \(__outputFile) Tests/Realm.Tests/EmbeddedResources/nunit3-junit.xslt \(_outputFile)" } } new gha.Step { @@ -293,7 +377,7 @@ local function reportTestResults(config: TestConfig): Listing = new { `if` = "always()" with { ["name"] = "Results \(config.title)" - ["path"] = _outputFile + ["path"] = __outputFile ["reporter"] = "java-junit" ["list-suites"] = "failed" ["path-replace-backslashes"] = true diff --git a/.github/pkl-workflows/pr.pkl b/.github/pkl-workflows/pr.pkl index 2c02c6b5d7..f7648ab64b 100644 --- a/.github/pkl-workflows/pr.pkl +++ b/.github/pkl-workflows/pr.pkl @@ -104,12 +104,7 @@ jobs { `if` = Common.ifNotCanceledCondition } ["test-net-framework"] = TestJobs.netFramework(JobNames.packages, baasDifferentiators) - ["test-uwp-managed"] = (createTestJob("test-uwp-managed")) { - secrets { - ["Pfx_Password"] = "${{ secrets.Pfx_Password }}" - ["Base64_Encoded_Pfx"] = "${{ secrets.Base64_Encoded_Pfx }}" - } - } + ["test-uwp"] = TestJobs.uwp(JobNames.packages, baasDifferentiators) ["test-net-core"] = TestJobs.netCore(JobNames.packages, new Listing { "net8.0" }) ["test-macos-xamarin"] = TestJobs.macOS_Xamarin(JobNames.packages) ["test-macos-maui"] = TestJobs.macOS_Maui(JobNames.packages, baasDifferentiators) diff --git a/.github/pkl-workflows/wrappers.pkl b/.github/pkl-workflows/wrappers.pkl index f08169ed52..d1380df8b4 100644 --- a/.github/pkl-workflows/wrappers.pkl +++ b/.github/pkl-workflows/wrappers.pkl @@ -76,7 +76,7 @@ jobs { enableLTO = false platform = "${{ matrix.platform }}-${{ matrix.target }}" intermediateSteps { - Steps.setupXcode() + Steps.setupXcode("14") } ifCondition = "\(Common.applePlatformTargets((platform, target) -> "needs.\(JobNames.checkCache).outputs.wrappers-\(platform)-\(target) != 'true'").join(" || "))" }) diff --git a/.github/templates/test-android.yml b/.github/templates/test-android.yml deleted file mode 100644 index b9188d306c..0000000000 --- a/.github/templates/test-android.yml +++ /dev/null @@ -1,49 +0,0 @@ -#@ load("@ytt:template", "template") -#@ load("common.lib.yml", "checkoutCode", "configureAWSCredentials", "fetchPackageArtifacts", "setupWorkloads", "setupJDK") -#@ load("test.lib.yml", "baasTestArgs", "publishTestsResults", "testDefinition", "buildTests", "prepareTest") - ---- -name: test-android -_: #@ template.replace(testDefinition(additionalSecrets=["AWS_DEVICEFARM_ACCESS_KEY_ID", "AWS_DEVICEFARM_SECRET_ACCESS_KEY", "DEVICEFARM_PROJECT_ARN", "DEVICEFARM_ANDROID_POOL_ARN"])) -jobs: - test-xamarin: - runs-on: windows-latest - name: Xamarin.Android - timeout-minutes: 60 - steps: - - #@ setupJDK() - - #@ 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 - uses: ./.github/actions/run-android-device-farm-test - id: run_tests - #@yaml/text-templated-strings - with: - apk-path: ${{ github.workspace }}/Tests/Tests.Android/bin/Release/io.realm.xamarintests-Signed.apk - app-id: io.realm.xamarintests - project-arn: ${{ secrets.DEVICEFARM_PROJECT_ARN }} - device-pool-arn: ${{ secrets.DEVICEFARM_ANDROID_POOL_ARN }} - arguments: (@= baasTestArgs('android') @) - - #@ template.replace(publishTestsResults("${{ steps.run_tests.outputs.test-results-path }}", "Xamarin.Android")) - test-maui: - runs-on: windows-latest - name: Maui.Android - timeout-minutes: 60 - steps: - - #@ template.replace(checkoutCode()) - - #@ template.replace(fetchPackageArtifacts()) - - #@ template.replace(setupWorkloads()) - - #@ setupJDK() - - name: Build the tests - run: #@ "dotnet publish Tests/Tests.Maui -c Release -f net8.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/net8.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 }} - - #@ template.replace(publishTestsResults("${{ steps.run_tests.outputs.test-results-path }}", "Maui.Android", run_transform=True)) \ 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 402023fc66..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-latest - name: UWP - timeout-minutes: 60 - steps: - - #@ template.replace(prepareTest("uwp-managed")) - - 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 - - #@ template.replace(publishTestsResults("${{ env.TEST_RESULTS }}", "UWP Managed")) diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index d05c7cc233..49bf1dc914 100755 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -124,17 +124,58 @@ jobs: list-suites: failed path-replace-backslashes: true fail-on-error: true - test-uwp-managed: - name: Test + test-uwp: + name: Test UWP needs: - build-packages if: always() && !cancelled() && !contains(needs.*.result, 'failure') && !contains(needs.*.result, 'cancelled') - uses: ./.github/workflows/test-uwp-managed.yml - with: - version: ${{ needs.build-packages.outputs.package_version }} - secrets: - Pfx_Password: ${{ secrets.Pfx_Password }} - Base64_Encoded_Pfx: ${{ secrets.Base64_Encoded_Pfx }} + timeout-minutes: 60 + runs-on: windows-latest + steps: + - name: Checkout Code + uses: actions/checkout@v4 + with: + submodules: recursive + ref: ${{ github.event.pull_request.head.sha }} + - name: Register csc problem matcher + run: |- + echo "::add-matcher::.github/problem-matchers/csc.json" + echo "::add-matcher::.github/problem-matchers/msvc.json" + - name: Fetch Realm + uses: actions/download-artifact@v4 + with: + name: Realm.${{ needs.build-packages.outputs.package_version }} + path: ${{ github.workspace }}/Realm/packages/ + - name: Fetch Realm.PlatformHelpers + uses: actions/download-artifact@v4 + with: + name: Realm.PlatformHelpers.${{ needs.build-packages.outputs.package_version }} + path: ${{ github.workspace }}/Realm/packages/ + - 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 + if: ${{ runner.os == 'Windows' }} + uses: microsoft/setup-msbuild@0b44c6745b7e81956596964100aadb92d667c497 + - name: Build Tests/Tests.UWP + run: msbuild Tests/Tests.UWP -p:Configuration=Release -restore -p:RestoreConfigFile=Tests/Test.NuGet.Config -p:UseRealmNupkgsWithVersion=${{ needs.build-packages.outputs.package_version }} -p:RealmTestsStandaloneExe=true -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 ' + shell: powershell + - name: Publish Unit Test Results + if: always() + uses: LaPeste/test-reporter@510caf50a955b1003bec48a6494be4d6537f3a0b + with: + name: Results UWP + path: ${{ env.TEST_RESULTS }} + reporter: java-junit + list-suites: failed + path-replace-backslashes: true + fail-on-error: true test-net-core: name: Test ${{ matrix.framework }}, ${{ (matrix.os.runner == 'win81' && 'win81') || matrix.os.runtime }} needs: @@ -300,12 +341,14 @@ jobs: run: dotnet build Tests/Tests.Maui -c Release -f net8.0-maccatalyst -p:RestoreConfigFile=Tests/Test.NuGet.Config -p:UseRealmNupkgsWithVersion=${{ needs.build-packages.outputs.package_version }} -p:RealmTestsStandaloneExe=true - name: Run the tests run: 'Tests/Tests.Maui/bin/Release/net8.0-maccatalyst/maccatalyst-arm64/Tests.Maui.app/Contents/MacOS/Tests.Maui --headless --result=${{ github.workspace }}/TestResults.xml --labels=All ' + - name: Transform Results + run: xsltproc --output TestResults.xml_transformed.xml Tests/Realm.Tests/EmbeddedResources/nunit3-junit.xslt TestResults.xml - name: Publish Unit Test Results if: always() uses: LaPeste/test-reporter@510caf50a955b1003bec48a6494be4d6537f3a0b with: name: Results Maui.MacCatalyst - path: TestResults.xml + path: TestResults.xml_transformed.xml reporter: java-junit list-suites: failed path-replace-backslashes: true @@ -392,6 +435,10 @@ jobs: dotnet-version: 8.0.x - name: Setup workloads run: dotnet workload install maui + - name: Setup Xcode + uses: maxim-lobanov/setup-xcode@60606e260d2fc5762a71e64e74b2174e8ea3c8bd + with: + xcode-version: latest-stable - name: Build Tests/Tests.Maui run: dotnet build Tests/Tests.Maui -c Release -f net8.0-ios -p:RestoreConfigFile=Tests/Test.NuGet.Config -p:UseRealmNupkgsWithVersion=${{ needs.build-packages.outputs.package_version }} -p:RealmTestsStandaloneExe=true - name: Run on Simulator @@ -402,12 +449,14 @@ jobs: iphoneToSimulate: iPhone-15 arguments: '--headless --result=${{ github.workspace }}/TestResults.xml --labels=All ' os: iOS + - name: Transform Results + run: xsltproc --output TestResults.xml_transformed.xml Tests/Realm.Tests/EmbeddedResources/nunit3-junit.xslt TestResults.xml - name: Publish Unit Test Results if: always() uses: LaPeste/test-reporter@510caf50a955b1003bec48a6494be4d6537f3a0b with: name: Results Maui.iOS - path: TestResults.xml + path: TestResults.xml_transformed.xml reporter: java-junit list-suites: failed path-replace-backslashes: true diff --git a/.github/workflows/test-android.yml b/.github/workflows/test-android.yml deleted file mode 100755 index 48c2666213..0000000000 --- a/.github/workflows/test-android.yml +++ /dev/null @@ -1,153 +0,0 @@ -name: test-android -"on": - workflow_call: - inputs: - version: - required: true - type: string - secrets: - BaaSaasApiKey: - required: false - AWS_DEVICEFARM_ACCESS_KEY_ID: - required: true - AWS_DEVICEFARM_SECRET_ACCESS_KEY: - required: true - DEVICEFARM_PROJECT_ARN: - required: true - DEVICEFARM_ANDROID_POOL_ARN: - required: true -env: - REALM_DISABLE_ANALYTICS: true - DOTNET_NOLOGO: true -jobs: - test-xamarin: - runs-on: windows-latest - name: Xamarin.Android - timeout-minutes: 60 - steps: - - name: Setup JDK - uses: actions/setup-java@0ab4596768b603586c0de567f2430c30f5b0d2b0 - with: - distribution: microsoft - java-version: 11 - - 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@v4 - with: - name: Realm.PlatformHelpers.${{ inputs.version }} - path: ${{ github.workspace }}/Realm/packages/ - - name: Fetch Realm - uses: actions/download-artifact@v4 - with: - name: Realm.${{ inputs.version }} - path: ${{ github.workspace }}/Realm/packages/ - - name: Deploy Baas (alternative) - env: - apiKey: ${{ secrets.BaaSaasApiKey }} - if: ${{ env.apiKey }} - run: dotnet run deploy-apps --baasaas-api-key=${{ secrets.BaaSaasApiKey }} --baas-differentiator=android-${{ github.run_id }}-${{ github.run_attempt }} - working-directory: Tools/DeployApps - - name: Add msbuild to PATH - uses: microsoft/setup-msbuild@0b44c6745b7e81956596964100aadb92d667c497 - if: ${{ runner.os == 'Windows' }} - - name: Build Tests/Tests.Android - run: msbuild Tests/Tests.Android -t:SignAndroidPackage -p:Configuration=Release -restore -p:RestoreConfigFile=Tests/Test.NuGet.Config -p:UseRealmNupkgsWithVersion=${{ inputs.version }} -p:AndroidUseSharedRuntime=False -p:EmbedAssembliesIntoApk=True - - name: Configure AWS Credentials - uses: aws-actions/configure-aws-credentials@v1-node16 - with: - aws-access-key-id: ${{ secrets.AWS_DEVICEFARM_ACCESS_KEY_ID }} - aws-secret-access-key: ${{ secrets.AWS_DEVICEFARM_SECRET_ACCESS_KEY }} - aws-region: 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.Android/bin/Release/io.realm.xamarintests-Signed.apk - app-id: io.realm.xamarintests - project-arn: ${{ secrets.DEVICEFARM_PROJECT_ARN }} - device-pool-arn: ${{ secrets.DEVICEFARM_ANDROID_POOL_ARN }} - arguments: ' --baasaas-api-key=${{ secrets.BaaSaasApiKey}} --baas-differentiator=android-${{ github.run_id }}-${{ github.run_attempt }}' - - name: Publish Unit Test Results - uses: LaPeste/test-reporter@510caf50a955b1003bec48a6494be4d6537f3a0b - if: always() - with: - name: Results Xamarin.Android - path: ${{ steps.run_tests.outputs.test-results-path }} - reporter: java-junit - list-suites: failed - list-tests: failed - path-replace-backslashes: true - fail-on-error: true - test-maui: - runs-on: windows-latest - name: Maui.Android - timeout-minutes: 60 - 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@v4 - with: - name: Realm.PlatformHelpers.${{ inputs.version }} - path: ${{ github.workspace }}/Realm/packages/ - - name: Fetch Realm - uses: actions/download-artifact@v4 - with: - name: Realm.${{ inputs.version }} - path: ${{ github.workspace }}/Realm/packages/ - - name: Configure .NET - uses: actions/setup-dotnet@3e6b9fe3930cac7c59c651af5de1514b47a805b9 - with: - dotnet-version: 8.0.x - - name: Setup workloads - run: dotnet workload install maui - - name: Setup JDK - uses: actions/setup-java@0ab4596768b603586c0de567f2430c30f5b0d2b0 - with: - distribution: microsoft - java-version: 11 - - name: Build the tests - run: dotnet publish Tests/Tests.Maui -c Release -f net8.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: - aws-access-key-id: ${{ secrets.AWS_DEVICEFARM_ACCESS_KEY_ID }} - aws-secret-access-key: ${{ secrets.AWS_DEVICEFARM_SECRET_ACCESS_KEY }} - aws-region: 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/net8.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 }} - - name: Transform Results - run: xsltproc --output ${{ steps.run_tests.outputs.test-results-path }}_transformed.xml Tests/Realm.Tests/EmbeddedResources/nunit3-junit.xslt ${{ steps.run_tests.outputs.test-results-path }} - shell: bash - - name: Publish Unit Test Results - uses: LaPeste/test-reporter@510caf50a955b1003bec48a6494be4d6537f3a0b - if: always() - with: - name: Results Maui.Android - path: ${{ steps.run_tests.outputs.test-results-path }}_transformed.xml - reporter: java-junit - list-suites: failed - list-tests: failed - path-replace-backslashes: true - fail-on-error: true diff --git a/.github/workflows/test-uwp-managed.yml b/.github/workflows/test-uwp-managed.yml deleted file mode 100755 index fe8e3639f3..0000000000 --- a/.github/workflows/test-uwp-managed.yml +++ /dev/null @@ -1,74 +0,0 @@ -name: test-uwp-managed -"on": - workflow_call: - inputs: - version: - required: true - type: string - secrets: - BaaSaasApiKey: - 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-latest - name: UWP - timeout-minutes: 60 - 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@v4 - with: - name: Realm.PlatformHelpers.${{ inputs.version }} - path: ${{ github.workspace }}/Realm/packages/ - - name: Fetch Realm - uses: actions/download-artifact@v4 - with: - name: Realm.${{ inputs.version }} - path: ${{ github.workspace }}/Realm/packages/ - - name: Deploy Baas (alternative) - env: - apiKey: ${{ secrets.BaaSaasApiKey }} - if: ${{ env.apiKey }} - run: dotnet run deploy-apps --baasaas-api-key=${{ secrets.BaaSaasApiKey }} --baas-differentiator=uwp-managed-${{ github.run_id }}-${{ github.run_attempt }} - working-directory: Tools/DeployApps - - 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 ' --baasaas-api-key=${{ secrets.BaaSaasApiKey}} --baas-differentiator=uwp-managed-${{ github.run_id }}-${{ github.run_attempt }}' - 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: true diff --git a/Tests/Realm.Tests/Sync/AppTests.cs b/Tests/Realm.Tests/Sync/AppTests.cs index 7f109511fc..271bb10c31 100644 --- a/Tests/Realm.Tests/Sync/AppTests.cs +++ b/Tests/Realm.Tests/Sync/AppTests.cs @@ -118,7 +118,7 @@ static void AssertBundleId(params string?[] expectedValues) break; case "Mac Catalyst": Assert.That(Platform.DeviceInfo.Name, Is.EqualTo("iPad"), "Name"); - Assert.That(Platform.DeviceInfo.Version, Does.Contain("iPad").Or.EqualTo("x86_64"), "Version"); + Assert.That(Platform.DeviceInfo.Version, Does.Contain("iPad").Or.EqualTo("x86_64").Or.EqualTo("arm64"), "Version"); AssertBundleId("Tests.Maui"); break; default: diff --git a/Tests/Tests.Maui/Tests.Maui.csproj b/Tests/Tests.Maui/Tests.Maui.csproj index 1286850e4f..425fb6e55a 100644 --- a/Tests/Tests.Maui/Tests.Maui.csproj +++ b/Tests/Tests.Maui/Tests.Maui.csproj @@ -23,7 +23,7 @@ 1 - True + True 11.0 13.2 From 33893964813e5a4c3d0f1980360474e105fd3fee Mon Sep 17 00:00:00 2001 From: Nikola Irinchev Date: Wed, 15 May 2024 23:57:26 +0200 Subject: [PATCH 19/39] Actually use the android steps --- .github/pkl-workflows/helpers/Steps.pkl | 2 +- .github/pkl-workflows/pr.pkl | 10 +- .github/workflows/pr.yml | 137 ++++++++++++++++++++++-- 3 files changed, 130 insertions(+), 19 deletions(-) diff --git a/.github/pkl-workflows/helpers/Steps.pkl b/.github/pkl-workflows/helpers/Steps.pkl index 86dbde92c5..7be18c54cf 100644 --- a/.github/pkl-workflows/helpers/Steps.pkl +++ b/.github/pkl-workflows/helpers/Steps.pkl @@ -3,7 +3,7 @@ import "Common.pkl" const actionRunSimulator = "realm/ci-actions/run-ios-simulator@6418e15ed9bbdb19b7d456a347e5623779f95cdf" const actionSetupJDK = "actions/setup-java@0ab4596768b603586c0de567f2430c30f5b0d2b0" -const actionAWSConfigureCredentials = "" +const actionAWSConfigureCredentials = "aws-actions/configure-aws-credentials@v4.0.2" const function checkout(): Listing = new Listing { checkoutWithoutMatchers() diff --git a/.github/pkl-workflows/pr.pkl b/.github/pkl-workflows/pr.pkl index f7648ab64b..761ce94c46 100644 --- a/.github/pkl-workflows/pr.pkl +++ b/.github/pkl-workflows/pr.pkl @@ -111,14 +111,8 @@ jobs { ["test-ios-xamarin"] = TestJobs.iOS_Xamarin(JobNames.packages) ["test-ios-maui"] = TestJobs.iOS_Maui(JobNames.packages, baasDifferentiators) ["test-tvos"] = TestJobs.tvOS(JobNames.packages, baasDifferentiators) - ["test-android"] = (createTestJob("test-android")) { - secrets { - ["AWS_DEVICEFARM_ACCESS_KEY_ID"] = "${{ secrets.AWS_DEVICEFARM_ACCESS_KEY_ID }}" - ["AWS_DEVICEFARM_SECRET_ACCESS_KEY"] = "${{ secrets.AWS_DEVICEFARM_SECRET_ACCESS_KEY }}" - ["DEVICEFARM_PROJECT_ARN"] = "${{ secrets.DEVICEFARM_PROJECT_ARN }}" - ["DEVICEFARM_ANDROID_POOL_ARN"] = "${{ secrets.DEVICEFARM_ANDROID_POOL_ARN }}" - } - } + ["test-android-xamarin"] = TestJobs.android_Xamarin(JobNames.packages) + ["test-android-maui"] = TestJobs.android_Maui(JobNames.packages, baasDifferentiators) ["test-woven-classes"] = TestJobs.wovenClasses(JobNames.packages) ["test-source-generation"] = TestJobs.sourceGeneration() ["test-weaver"] = TestJobs.weaver() diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index 49bf1dc914..94afe320bc 100755 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -511,19 +511,136 @@ jobs: list-suites: failed path-replace-backslashes: true fail-on-error: true - test-android: - name: Test + test-android-xamarin: + name: Test Xamarin.Android needs: - build-packages if: always() && !cancelled() && !contains(needs.*.result, 'failure') && !contains(needs.*.result, 'cancelled') - uses: ./.github/workflows/test-android.yml - with: - version: ${{ needs.build-packages.outputs.package_version }} - secrets: - AWS_DEVICEFARM_ACCESS_KEY_ID: ${{ secrets.AWS_DEVICEFARM_ACCESS_KEY_ID }} - AWS_DEVICEFARM_SECRET_ACCESS_KEY: ${{ secrets.AWS_DEVICEFARM_SECRET_ACCESS_KEY }} - DEVICEFARM_PROJECT_ARN: ${{ secrets.DEVICEFARM_PROJECT_ARN }} - DEVICEFARM_ANDROID_POOL_ARN: ${{ secrets.DEVICEFARM_ANDROID_POOL_ARN }} + timeout-minutes: 60 + runs-on: windows-latest + steps: + - name: Setup JDK + uses: actions/setup-java@0ab4596768b603586c0de567f2430c30f5b0d2b0 + with: + distribution: microsoft + java-version: 11 + - name: Checkout Code + uses: actions/checkout@v4 + with: + submodules: recursive + ref: ${{ github.event.pull_request.head.sha }} + - name: Register csc problem matcher + run: |- + echo "::add-matcher::.github/problem-matchers/csc.json" + echo "::add-matcher::.github/problem-matchers/msvc.json" + - name: Fetch Realm + uses: actions/download-artifact@v4 + with: + name: Realm.${{ needs.build-packages.outputs.package_version }} + path: ${{ github.workspace }}/Realm/packages/ + - name: Fetch Realm.PlatformHelpers + uses: actions/download-artifact@v4 + with: + name: Realm.PlatformHelpers.${{ needs.build-packages.outputs.package_version }} + path: ${{ github.workspace }}/Realm/packages/ + - name: Add msbuild to PATH + if: ${{ runner.os == 'Windows' }} + uses: microsoft/setup-msbuild@0b44c6745b7e81956596964100aadb92d667c497 + - name: Build Tests/Tests.Android + run: msbuild Tests/Tests.Android -p:Configuration=Release -restore -p:RestoreConfigFile=Tests/Test.NuGet.Config -p:UseRealmNupkgsWithVersion=${{ needs.build-packages.outputs.package_version }} -p:RealmTestsStandaloneExe=true -p:AndroidUseSharedRuntime=False -p:EmbedAssembliesIntoApk=True + - name: Configure AWS Credentials + uses: aws-actions/configure-aws-credentials@v4.0.2 + with: + aws-access-key-id: ${{ secrets.AWS_DEVICEFARM_ACCESS_KEY_ID }} + aws-secret-access-key: ${{ secrets.AWS_DEVICEFARM_SECRET_ACCESS_KEY }} + aws-region: us-west-2 + - name: Run the tests + id: run_tests + uses: ./.github/actions/run-android-device-farm-test + with: + apk-path: ${{ github.workspace }}/Tests/Tests.Android/bin/Release/io.realm.xamarintests-Signed.apk + app-id: io.realm.xamarintests + project-arn: ${{ secrets.DEVICEFARM_PROJECT_ARN }} + device-pool-arn: ${{ secrets.DEVICEFARM_ANDROID_POOL_ARN }} + - name: Publish Unit Test Results + if: always() + uses: LaPeste/test-reporter@510caf50a955b1003bec48a6494be4d6537f3a0b + with: + name: Results Xamarin.Android + path: ${{ steps.run_tests.outputs.test-results-path }} + reporter: java-junit + list-suites: failed + path-replace-backslashes: true + fail-on-error: true + test-android-maui: + name: Test Maui.Android + needs: + - build-packages + if: always() && !cancelled() && !contains(needs.*.result, 'failure') && !contains(needs.*.result, 'cancelled') + timeout-minutes: 60 + runs-on: windows-latest + steps: + - name: Setup JDK + uses: actions/setup-java@0ab4596768b603586c0de567f2430c30f5b0d2b0 + with: + distribution: microsoft + java-version: 11 + - name: Checkout Code + uses: actions/checkout@v4 + with: + submodules: recursive + ref: ${{ github.event.pull_request.head.sha }} + - name: Register csc problem matcher + run: |- + echo "::add-matcher::.github/problem-matchers/csc.json" + echo "::add-matcher::.github/problem-matchers/msvc.json" + - name: Fetch Realm + uses: actions/download-artifact@v4 + with: + name: Realm.${{ needs.build-packages.outputs.package_version }} + path: ${{ github.workspace }}/Realm/packages/ + - name: Fetch Realm.PlatformHelpers + uses: actions/download-artifact@v4 + with: + name: Realm.PlatformHelpers.${{ needs.build-packages.outputs.package_version }} + path: ${{ github.workspace }}/Realm/packages/ + - uses: actions/setup-dotnet@607fce577a46308457984d59e4954e075820f10a + with: + dotnet-version: 8.0.x + - name: Setup workloads + run: dotnet workload install maui + - name: Publish Tests/Tests.Maui + run: dotnet publish Tests/Tests.Maui -c Release -f net8.0-android -p:RestoreConfigFile=Tests/Test.NuGet.Config -p:UseRealmNupkgsWithVersion=${{ needs.build-packages.outputs.package_version }} -p:RealmTestsStandaloneExe=true --no-self-contained + - name: Output executable path + id: dotnet-publish + run: echo 'executable-path=./Tests/Tests.Maui/bin/Release/net8.0-android/null/Tests.Maui' >> $GITHUB_OUTPUT + shell: bash + - name: Configure AWS Credentials + uses: aws-actions/configure-aws-credentials@v4.0.2 + with: + aws-access-key-id: ${{ secrets.AWS_DEVICEFARM_ACCESS_KEY_ID }} + aws-secret-access-key: ${{ secrets.AWS_DEVICEFARM_SECRET_ACCESS_KEY }} + aws-region: us-west-2 + - name: Run the tests + id: run_tests + uses: ./.github/actions/run-android-device-farm-test + with: + apk-path: ${{ github.workspace }}/Tests/Tests.Maui/bin/Release/net8.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 }} + - name: Transform Results + run: xsltproc --output ${{ steps.run_tests.outputs.test-results-path }}_transformed.xml Tests/Realm.Tests/EmbeddedResources/nunit3-junit.xslt ${{ steps.run_tests.outputs.test-results-path }} + - name: Publish Unit Test Results + if: always() + uses: LaPeste/test-reporter@510caf50a955b1003bec48a6494be4d6537f3a0b + with: + name: Results Maui.Android + path: ${{ steps.run_tests.outputs.test-results-path }}_transformed.xml + reporter: java-junit + list-suites: failed + path-replace-backslashes: true + fail-on-error: true test-woven-classes: name: Test Woven Classes needs: From 37be022d260d182d5f36ca3b65355636b0dca844 Mon Sep 17 00:00:00 2001 From: Nikola Irinchev Date: Thu, 16 May 2024 00:44:58 +0200 Subject: [PATCH 20/39] Migrate code coverage --- .github/pkl-workflows/helpers/Common.pkl | 7 +- .github/pkl-workflows/helpers/Lint.pkl | 7 +- .github/pkl-workflows/helpers/Steps.pkl | 40 ++++- .github/pkl-workflows/helpers/Test.pkl | 202 +++++++++++++++-------- .github/pkl-workflows/pr.pkl | 59 ++----- .github/templates/test-code-coverage.yml | 42 ----- .github/workflows/pr.yml | 94 +++++++++-- .github/workflows/test-code-coverage.yml | 177 -------------------- 8 files changed, 271 insertions(+), 357 deletions(-) delete mode 100644 .github/templates/test-code-coverage.yml delete mode 100755 .github/workflows/test-code-coverage.yml diff --git a/.github/pkl-workflows/helpers/Common.pkl b/.github/pkl-workflows/helpers/Common.pkl index e0a33fe2a1..a586345d3f 100644 --- a/.github/pkl-workflows/helpers/Common.pkl +++ b/.github/pkl-workflows/helpers/Common.pkl @@ -10,9 +10,12 @@ const uwpArchs: List = List("Win32", "x64", "ARM", "ARM64") const appleTargets: List = List("Device", "Simulator") -typealias NetFramework = "net6.0" | String(startsWith("${{ matrix")) | String(startsWith("net8")) +const job_Packages: String = "build-packages" +const job_Baas: String = "deploy-baas" + +typealias NetFramework = "net6.0" | "net8.0" | String(startsWith("${{ matrix")) | String(startsWith("net8")) typealias NetRuntime = "win-x64" | "linux-x64" | "osx-x64" | "osx-arm64" | String(startsWith("${{ matrix")) -typealias SyncDifferentiator = "ios" | "android" | "tvos" | "catalyst" | "code-coverage" | "uwp" | "net-framework" | String(startsWith("${{ matrix")) +typealias SyncDifferentiator = "ios-maui" | "android-maui" | "tvos" | "macos-maui" | "code-coverage" | "uwp" | "net-framework" | String(startsWith("${{ matrix")) const wrapperBinaryNames: List = List("macos", "catalyst") diff --git a/.github/pkl-workflows/helpers/Lint.pkl b/.github/pkl-workflows/helpers/Lint.pkl index f6c33ca28e..0af1c4cd93 100644 --- a/.github/pkl-workflows/helpers/Lint.pkl +++ b/.github/pkl-workflows/helpers/Lint.pkl @@ -2,6 +2,7 @@ module lint import "../GithubAction/GithubAction.pkl" as gha import "Steps.pkl" +import "Common.pkl" function lint(): gha.Job = new { name = "Verify TODOs" @@ -20,15 +21,15 @@ function lint(): gha.Job = new { } } -function verifyNamespaces(packageJob: String): gha.Job = new { +function verifyNamespaces(): gha.Job = new { `runs-on` = new gha.UbuntuLatest{} name = "Verify Namespaces" needs { - packageJob + Common.job_Packages } steps { Steps.checkoutWithoutMatchers() - ...Steps.fetchPackages(packageJob, null) + ...Steps.fetchPackages(Common.job_Packages, null) new { run = "dotnet tool install ilspycmd -g --version 8.0.0.7345" } diff --git a/.github/pkl-workflows/helpers/Steps.pkl b/.github/pkl-workflows/helpers/Steps.pkl index 7be18c54cf..758721e963 100644 --- a/.github/pkl-workflows/helpers/Steps.pkl +++ b/.github/pkl-workflows/helpers/Steps.pkl @@ -4,6 +4,7 @@ import "Common.pkl" const actionRunSimulator = "realm/ci-actions/run-ios-simulator@6418e15ed9bbdb19b7d456a347e5623779f95cdf" const actionSetupJDK = "actions/setup-java@0ab4596768b603586c0de567f2430c30f5b0d2b0" const actionAWSConfigureCredentials = "aws-actions/configure-aws-credentials@v4.0.2" +const actionCoveralls = "coverallsapp/github-action@v2.3.0" const function checkout(): Listing = new Listing { checkoutWithoutMatchers() @@ -95,18 +96,27 @@ const function configureAWSCredentials(accessKey: String, secretKey: String, reg } } -const function msbuild(project: String, properties: Mapping): List = List( +class MSBuildConfig { + project: String + target: String? + properties: Mapping = new Mapping{} + + function getTargetForInvocation(): String = if (target != null) " -t \(target)" else "" + function getPropertiesForInvocation(): String = "-p:Configuration=\(Common.configuration)\(propertiesToString(properties))" +} + +const function msbuild(config: MSBuildConfig): List = List( addMSBuildToPath(), new gha.Step { - name = "Build \(project)" - run = "msbuild \(project) -p:Configuration=\(Common.configuration) -restore \(propertiesToString(properties))" + name = "Build \(config.project)" + run = "msbuild \(config.project)\(config.getTargetForInvocation()) -restore \(config.getPropertiesForInvocation())" } ) const function dotnetPublish(project: String, framework: Common.NetFramework, runtime: Common.NetRuntime?, properties: Mapping): Listing = new Listing { new gha.Step { name = "Publish \(project)" - run = "dotnet publish \(project) -c \(Common.configuration) -f \(framework) \(if (runtime != null) "-r \(runtime)" else "") \(propertiesToString(properties)) --no-self-contained" + run = "dotnet publish \(project) -c \(Common.configuration) -f \(framework)\(if (runtime != null) " -r \(runtime)" else "")\(propertiesToString(properties)) --no-self-contained" } new gha.Step { name = "Output executable path" @@ -118,7 +128,7 @@ const function dotnetPublish(project: String, framework: Common.NetFramework, ru const function dotnetBuild(project: String, framework: Common.NetFramework, properties: Mapping): gha.Step = new gha.Step { name = "Build \(project)" - run = "dotnet build \(project) -c \(Common.configuration) -f \(framework) \(propertiesToString(properties))" + run = "dotnet build \(project) -c \(Common.configuration) -f \(framework)\(propertiesToString(properties))" } const function runSimulator(config: SimulatorConfig): gha.Step = new { @@ -142,6 +152,24 @@ const function runDeviceFarm(config: DeviceFarmConfig): Listing = new } } +const function publishCoverage(file: String): Listing = new Listing { + new gha.Step { + name = "Publish Coverage" + id = "publish-coveralls" + uses = actionCoveralls + with { + ["github-token"] = "${{ secrets.GITHUB_TOKEN }}" + ["file"] = file + ["git-commit"] = "${{ github.event.pull_request.head.sha }}" + ["compare-sha"] = "${{ github.event.pull_request.base.sha }}" + } + } + new gha.Step { + name = "Output Coveralls response" + run = "echo ${{ steps.publish-coveralls.outputs.coveralls-api-result }}" + } +} + class SimulatorConfig { appPath: String bundleId: String @@ -161,4 +189,4 @@ local const function addMSBuildToPath(): gha.Step = new { `if` = "${{ runner.os == 'Windows' }}" } -local const function propertiesToString(properties: Mapping): String = properties.toMap().entries.map((kvp) -> "-p:\(kvp.key)=\(kvp.value)").join(" ") \ No newline at end of file +local const function propertiesToString(properties: Mapping): String = " " + properties.toMap().entries.map((kvp) -> "-p:\(kvp.key)=\(kvp.value)").join(" ") \ No newline at end of file diff --git a/.github/pkl-workflows/helpers/Test.pkl b/.github/pkl-workflows/helpers/Test.pkl index 2e7a39d108..abc38903aa 100644 --- a/.github/pkl-workflows/helpers/Test.pkl +++ b/.github/pkl-workflows/helpers/Test.pkl @@ -8,10 +8,10 @@ import "BaaS.pkl" local const outputFile = "TestResults.xml" // Public test targets -function netFramework(_packageJob: String, _syncDifferentiators: Listing): gha.StepJobBase = testJob( +function netFramework(_syncDifferentiators: Listing): gha.StepJobBase = testJob( new TestConfig { title = ".NET Framework" - packageJob = _packageJob + needsPackages = true syncDifferentiator = "net-framework" syncDifferentiators = _syncDifferentiators }, @@ -19,8 +19,11 @@ function netFramework(_packageJob: String, _syncDifferentiators: Listing null, (config) -> new Listing { ...prepareTests(config) - ...buildTests(config, "Tests/Realm.Tests", new Mapping { - ["TargetFramework"] = "net461" + ...buildTests(new Steps.MSBuildConfig { + project = "Tests/Realm.Tests" + properties { + ["TargetFramework"] = "net461" + } }) new gha.Step { name = "Run the tests" @@ -29,9 +32,9 @@ function netFramework(_packageJob: String, _syncDifferentiators: Listing ...reportTestResults(config) }) -function netCore(_packageJob: String, frameworks: Listing): gha.StepJobBase = testJob( +function netCore(frameworks: Listing): gha.StepJobBase = testJob( new TestConfig { - packageJob = _packageJob + needsPackages = true title = "${{ matrix.framework }}, ${{ (matrix.os.runner == 'win81' && 'win81') || matrix.os.runtime }}" shouldCleanWorkspace = true }, @@ -70,7 +73,7 @@ function netCore(_packageJob: String, frameworks: Listing): shell = "bash" } Steps.setupDotnet("${{ steps.get-net-version.outputs.version }}") - ...Steps.dotnetPublish("Tests/Realm.Tests", "${{ matrix.framework }}", "${{ matrix.os.runtime }}", getTestProps(config)) + ...Steps.dotnetPublish("Tests/Realm.Tests", "${{ matrix.framework }}", "${{ matrix.os.runtime }}", getTestProps()) ...dotnetRunTests(true) ...reportTestResults(config) }) @@ -113,16 +116,16 @@ function sourceGeneration(): gha.StepJobBase = testJob( ...reportTestResults(config) }) -function wovenClasses(_packageJob: String): gha.StepJobBase = testJob( +function wovenClasses(): gha.StepJobBase = testJob( new TestConfig { - packageJob = _packageJob + needsPackages = true title = "Woven Classes" }, new gha.WindowsLatest{}, null, (config) -> new Listing { ...prepareTests(config) - ...Steps.dotnetPublish("Tests/Realm.Tests", "net8.0", "win-x64", (getTestProps(config)) { + ...Steps.dotnetPublish("Tests/Realm.Tests", "net8.0", "win-x64", (getTestProps()) { ["TestWeavedClasses"] = "true" }) ...dotnetRunTests(false) @@ -130,9 +133,9 @@ function wovenClasses(_packageJob: String): gha.StepJobBase = testJob( } ) -function tvOS(_packageJob: String, _syncDifferentiators: Listing): gha.StepJobBase = testJob( +function tvOS(_syncDifferentiators: Listing): gha.StepJobBase = testJob( new TestConfig { - packageJob = _packageJob + needsPackages = true title = "Xamarin.tvOS" syncDifferentiator = "tvos" syncDifferentiators = _syncDifferentiators @@ -141,8 +144,11 @@ function tvOS(_packageJob: String, _syncDifferentiators: Listing new Listing { ...prepareTests(config) - ...buildTests(config, "Tests/Tests.XamarinTVOS", new Mapping { - ["Platform"] = "iPhoneSimulator" + ...buildTests(new Steps.MSBuildConfig { + project = "Tests/Tests.XamarinTVOS" + properties { + ["Platform"] = "iPhoneSimulator" + } }) Steps.runSimulator(new Steps.SimulatorConfig{ appPath = "Tests/Tests.XamarinTVOS/bin/iPhoneSimulator/\(Common.configuration)/Tests.XamarinTVOS.app" @@ -154,17 +160,20 @@ function tvOS(_packageJob: String, _syncDifferentiators: Listing new Listing { ...prepareTests(config) - ...buildTests(config, "Tests/Tests.iOS", new Mapping { - ["Platform"] = "iPhoneSimulator" + ...buildTests(new Steps.MSBuildConfig { + project = "Tests/Tests.iOS" + properties { + ["Platform"] = "iPhoneSimulator" + } }) Steps.runSimulator(new Steps.SimulatorConfig{ appPath = "Tests/Tests.iOS/bin/iPhoneSimulator/\(Common.configuration)/Tests.iOS.app" @@ -176,11 +185,11 @@ function iOS_Xamarin(_packageJob: String): gha.StepJobBase = testJob( ...reportTestResults(config) }) -function iOS_Maui(_packageJob: String, _syncDifferentiators: Listing): gha.StepJobBase = testJob( +function iOS_Maui(_syncDifferentiators: Listing): gha.StepJobBase = testJob( new TestConfig { - packageJob = _packageJob + needsPackages = true title = "Maui.iOS" - syncDifferentiator = "ios" + syncDifferentiator = "ios-maui" syncDifferentiators = _syncDifferentiators transformResults = true }, @@ -190,7 +199,7 @@ function iOS_Maui(_packageJob: String, _syncDifferentiators: Listing new Listing { ...prepareTests(config) - ...buildTests(config, "Tests/Tests.XamarinMac", new Mapping {}) + ...buildTests(new Steps.MSBuildConfig { + project = "Tests/Tests.XamarinMac" + }) new { name = "Run the tests" run = "Tests/Tests.XamarinMac/bin/\(Common.configuration)/Tests.XamarinMac.app/Contents/MacOS/Tests.XamarinMac --headless --result=${{ github.workspace }}/\(outputFile) --labels=All" @@ -218,11 +229,11 @@ function macOS_Xamarin(_packageJob: String): gha.StepJobBase = testJob( ...reportTestResults(config) }) -function macOS_Maui(_packageJob: String, _syncDifferentiators: Listing): gha.StepJobBase = testJob( +function macOS_Maui(_syncDifferentiators: Listing): gha.StepJobBase = testJob( new TestConfig { - packageJob = _packageJob + needsPackages = true title = "Maui.MacCatalyst" - syncDifferentiator = "catalyst" + syncDifferentiator = "macos-maui" syncDifferentiators = _syncDifferentiators transformResults = true }, @@ -231,7 +242,8 @@ function macOS_Maui(_packageJob: String, _syncDifferentiators: Listing new Listing { ...prepareTests(config) ...Steps.setupWorkloads("maui", null) - Steps.dotnetBuild("Tests/Tests.Maui", "net8.0-maccatalyst", getTestProps(config)) + Steps.setupXcode("latest-stable") + Steps.dotnetBuild("Tests/Tests.Maui", "net8.0-maccatalyst", getTestProps()) new { name = "Run the tests" run = "Tests/Tests.Maui/bin/\(Common.configuration)/net8.0-maccatalyst/maccatalyst-arm64/Tests.Maui.app/Contents/MacOS/Tests.Maui --headless --result=${{ github.workspace }}/\(outputFile) --labels=All \(baasTestArgs(config))" @@ -239,9 +251,9 @@ function macOS_Maui(_packageJob: String, _syncDifferentiators: Listing): gha.StepJobBase = testJob( +function uwp(_syncDifferentiators: Listing): gha.StepJobBase = testJob( new TestConfig { - packageJob = _packageJob + needsPackages = true title = "UWP" syncDifferentiators = _syncDifferentiators syncDifferentiator = "uwp" @@ -260,24 +272,27 @@ function uwp(_packageJob: String, _syncDifferentiators: Listing new Listing { Steps.setupJDK() ...prepareTests(config) - ...buildTests(config, "Tests/Tests.Android", new Mapping { - ["AndroidUseSharedRuntime"] = "False" - ["EmbedAssembliesIntoApk"] = "True" + ...buildTests(new Steps.MSBuildConfig { + project = "Tests/Tests.Android" + target = "SignAndroidPackage" + properties { + ["AndroidUseSharedRuntime"] = "False" + ["EmbedAssembliesIntoApk"] = "True" + } }) ...Steps.runDeviceFarm(new Steps.DeviceFarmConfig { apkPath = "${{ github.workspace }}/Tests/Tests.Android/bin/Release/io.realm.xamarintests-Signed.apk" @@ -296,11 +315,11 @@ function android_Xamarin(_packageJob: String): gha.StepJobBase = testJob( ...reportTestResultsWithCustomFile("${{ steps.run_tests.outputs.test-results-path }}", config) }) -function android_Maui(_packageJob: String, _syncDifferentiators: Listing): gha.StepJobBase = testJob( +function android_Maui(_syncDifferentiators: Listing): gha.StepJobBase = testJob( new TestConfig { - packageJob = _packageJob + needsPackages = true title = "Maui.Android" - syncDifferentiator = "android" + syncDifferentiator = "android-maui" syncDifferentiators = _syncDifferentiators transformResults = true }, @@ -310,7 +329,7 @@ function android_Maui(_packageJob: String, _syncDifferentiators: Listing): gha.StepJobBase = testJob( + new TestConfig { + needsPackages = true + title = "Code Coverage" + syncDifferentiator = "code-coverage" + syncDifferentiators = _syncDifferentiators + useWrappers = true + }, + new gha.UbuntuLatest{}, + null, + (config) -> new Listing { + ...prepareTests(config) + new gha.Step { + name = "Setup Coverlet & Report Generator" + run = """ + dotnet tool install coverlet.console --tool-path tools + dotnet tool install dotnet-reportgenerator-globaltool --tool-path tools + echo "${{ github.workspace }}/tools" >> $GITHUB_PATH + """ + } + ...Steps.dotnetPublish("Tests/Realm.Tests", "net8.0", "linux-x64", new Mapping { ["RealmTestsStandaloneExe"] = "true" }) + new gha.Step { + name = "Run the tests" + run = "./tools/coverlet ./Tests/Realm.Tests/bin/\(Common.configuration)/net8.0/linux-x64 -t ${{ steps.dotnet-publish.outputs.executable-path }}/Realm.Tests -a '--result=\(outputFile) --labels=After\(baasTestArgs(config))' -f lcov -o ./report.lcov --exclude '[Realm.Tests]*' --exclude '[Realm.Fody]*' --exclude '[Realm.PlatformHelpers]*'" + } |> enableCoreDumps(true) + archiveCoreDump() + ...Steps.publishCoverage("./report.lcov") + ...reportTestResults(config) + }) + // Private helpers local function testJob(config: TestConfig, runsOn: gha.Machine | String, _strategy: gha.MatrixStrategy?, _steps: Function1>): gha.StepJobBase = (if (_strategy != null) new gha.MatrixJob{ strategy = _strategy } else new gha.Job{}) { name = "Test \(config.title)" `runs-on` = runsOn - when (config.packageJob != null) { + when (config.needsPackages) { needs { - config.packageJob!! + Common.job_Packages + when (config.runSyncTests) { + Common.job_Baas + } } } `if` = Common.ifNotCanceledCondition @@ -334,10 +386,10 @@ local function testJob(config: TestConfig, runsOn: gha.Machine | String, _strate steps = _steps.apply(config) } -local function prepareTests(config: TestConfig): Listing = new Listing { +local function prepareTests(config: TestConfig(needsPackages == true)): Listing = new Listing { ...Steps.checkout() ...cleanWorkspace(config.shouldCleanWorkspace) - ...fetchTestArtifacts(config.packageJob!!, config.useWrappers) + ...fetchTestArtifacts(Common.job_Packages, config.useWrappers) ...BaaS.deployStep(config.syncDifferentiator, config.runSyncTests) } @@ -354,9 +406,10 @@ local function fetchTestArtifacts(packageJob: String, useWrappers: Boolean): Lis Steps.fetchPackages(packageJob, Common.nugetPackages) else Steps.fetchPackages(packageJob, Common.nugetPackages) -local function buildTests(config: TestConfig, projectPath: String, properties: Mapping): List = Steps.msbuild(projectPath, new Mapping{ - ...getTestProps(config) - ...properties +local function buildTests(config: Steps.MSBuildConfig): List = Steps.msbuild((config) { + properties { + ...getTestProps() + } }) local function baasTestArgs(config: TestConfig): String = if (config.runSyncTests) " --baasaas-api-key=${{ secrets.BAASAAS_API_KEY}} --baas-differentiator=\(config.syncDifferentiator)-${{ github.run_id }}-${{ github.run_attempt }}" else "" @@ -386,9 +439,9 @@ local function reportTestResultsWithCustomFile(_outputFile: String, config: Test } } -local function getTestProps(config: TestConfig): Mapping = new Mapping { +local function getTestProps(): Mapping = new Mapping { ["RestoreConfigFile"] = "Tests/Test.NuGet.Config" - ["UseRealmNupkgsWithVersion"] = "${{ needs.\(config.packageJob!!).outputs.package_version }}" + ["UseRealmNupkgsWithVersion"] = "${{ needs.\(Common.job_Packages).outputs.package_version }}" ["RealmTestsStandaloneExe"] = "true" } @@ -396,26 +449,31 @@ local function dotnetRunTests(enableCoreDumps: Boolean): Listing = new new gha.Step { name = "Run the tests" run = "${{ steps.dotnet-publish.outputs.executable-path }} --result=\(outputFile) --labels=After" - when (enableCoreDumps) { - env { - ["DOTNET_DbgEnableMiniDump"] = 1 - ["DOTNET_EnableCrashReport"] = 1 - } - } - } + } |> enableCoreDumps(enableCoreDumps) when (enableCoreDumps) { - new gha.Step { - name = "Archive core dump" - uses = "actions/upload-artifact@v4" - `if` = "${{ failure() && runner.os != 'Windows' }}" - with { - ["name"] = "crash-report-net-core-${{ runner.os }}-${{ runner.arch }}" - ["path"] = "/tmp/coredump*" - } + archiveCoreDump() + } +} + +local function enableCoreDumps(enable: Boolean): Mixin = new Mixin { + when (enable) { + env { + ["DOTNET_DbgEnableMiniDump"] = 1 + ["DOTNET_EnableCrashReport"] = 1 } } } +local function archiveCoreDump(): gha.Step = new { + name = "Archive core dump" + uses = "actions/upload-artifact@v4" + `if` = "${{ failure() && runner.os != 'Windows' }}" + with { + ["name"] = "crash-report-net-core-${{ runner.os }}-${{ runner.arch }}" + ["path"] = "/tmp/coredump*" + } +} + local class MatrixOS { runner: "windows-latest" | "ubuntu-latest" | "macos-13" | "macos-14" runtime: Common.NetRuntime @@ -423,7 +481,7 @@ local class MatrixOS { local class TestConfig { title: String - packageJob: String? = null + needsPackages: Boolean = false useWrappers: Boolean = false shouldCleanWorkspace: Boolean = false syncDifferentiator: Common.SyncDifferentiator? = null diff --git a/.github/pkl-workflows/pr.pkl b/.github/pkl-workflows/pr.pkl index 761ce94c46..16e80fec8c 100644 --- a/.github/pkl-workflows/pr.pkl +++ b/.github/pkl-workflows/pr.pkl @@ -9,24 +9,10 @@ import "helpers/Test.pkl" as TestJobs local class JobNamesDefition { const wrappers: String = "build-wrappers" - const packages: String = "build-packages" const unity: String = "build-unity" - const baas: String = "deploy-baas" const coverage: String = "test-code-coverage" } -local function createTestJob(workflow: String): ReusableWorkflowJob = new ReusableWorkflowJob { - uses = "./.github/workflows/\(workflow).yml" - name = "Test" - `if` = Common.ifNotCanceledCondition - needs { - JobNames.packages - } - with { - ["version"] = "${{ needs.\(JobNames.packages).outputs.package_version }}" - } -} - local JobNames = new JobNamesDefition{} local baasDifferentiators: Listing = new { @@ -67,8 +53,8 @@ jobs { uses = "./.github/workflows/wrappers.yml" name = "Wrappers" } - [JobNames.baas] = BaaS.deploy(baasDifferentiators) // TODO: run baasaas tests for more targets - [JobNames.packages] = new ReusableWorkflowJob { + [Common.job_Baas] = BaaS.deploy(baasDifferentiators) // TODO: run baasaas tests for more targets + [Common.job_Packages] = new ReusableWorkflowJob { uses = "./.github/workflows/build-packages.yml" name = "Package" needs { @@ -85,7 +71,7 @@ jobs { ["version"] = "${{ needs.build-packages.outputs.package_version }}" } needs { - JobNames.packages + Common.job_Packages } `if` = Common.ifNotCanceledCondition } @@ -99,36 +85,27 @@ jobs { } needs { JobNames.unity - JobNames.packages + Common.job_Packages } `if` = Common.ifNotCanceledCondition } - ["test-net-framework"] = TestJobs.netFramework(JobNames.packages, baasDifferentiators) - ["test-uwp"] = TestJobs.uwp(JobNames.packages, baasDifferentiators) - ["test-net-core"] = TestJobs.netCore(JobNames.packages, new Listing { "net8.0" }) - ["test-macos-xamarin"] = TestJobs.macOS_Xamarin(JobNames.packages) - ["test-macos-maui"] = TestJobs.macOS_Maui(JobNames.packages, baasDifferentiators) - ["test-ios-xamarin"] = TestJobs.iOS_Xamarin(JobNames.packages) - ["test-ios-maui"] = TestJobs.iOS_Maui(JobNames.packages, baasDifferentiators) - ["test-tvos"] = TestJobs.tvOS(JobNames.packages, baasDifferentiators) - ["test-android-xamarin"] = TestJobs.android_Xamarin(JobNames.packages) - ["test-android-maui"] = TestJobs.android_Maui(JobNames.packages, baasDifferentiators) - ["test-woven-classes"] = TestJobs.wovenClasses(JobNames.packages) + ["test-net-framework"] = TestJobs.netFramework(baasDifferentiators) + ["test-uwp"] = TestJobs.uwp(baasDifferentiators) + ["test-net-core"] = TestJobs.netCore(new Listing { "net8.0" }) + ["test-macos-xamarin"] = TestJobs.macOS_Xamarin() + ["test-macos-maui"] = TestJobs.macOS_Maui(baasDifferentiators) + ["test-ios-xamarin"] = TestJobs.iOS_Xamarin() + ["test-ios-maui"] = TestJobs.iOS_Maui(baasDifferentiators) + ["test-tvos"] = TestJobs.tvOS(baasDifferentiators) + ["test-android-xamarin"] = TestJobs.android_Xamarin() + ["test-android-maui"] = TestJobs.android_Maui(baasDifferentiators) + ["test-woven-classes"] = TestJobs.wovenClasses() ["test-source-generation"] = TestJobs.sourceGeneration() ["test-weaver"] = TestJobs.weaver() - ["test-code-coverage"] = (createTestJob("test-code-coverage")) { - needs { - JobNames.baas - } - secrets { - ["BaaSaasApiKey"] = "${{ secrets.BAASAAS_API_KEY }}" - } - } + ["test-code-coverage"] = TestJobs.codeCoverage(baasDifferentiators) ["cleanup-baas"] = (BaaS.cleanup(baasDifferentiators)) { - needs { - JobNames.coverage - } + needs = baasDifferentiators.toList().map((d) -> "test-\(d)").toListing() } - ["verify-namespaces"] = Lint.verifyNamespaces(JobNames.packages) + ["verify-namespaces"] = Lint.verifyNamespaces() ["lint"] = Lint.lint() } diff --git a/.github/templates/test-code-coverage.yml b/.github/templates/test-code-coverage.yml deleted file mode 100644 index 4245827d89..0000000000 --- a/.github/templates/test-code-coverage.yml +++ /dev/null @@ -1,42 +0,0 @@ -#@ load("@ytt:template", "template") -#@ load("common.lib.yml", "checkoutCode", "fetchWrapperBinaries", "dotnetPublish", "actionCoveralls") -#@ load("test.lib.yml", "baasTestArgs", "publishTestsResults", "testDefinition", "prepareTest") - ---- -name: test-code-coverage -_: #@ template.replace(testDefinition()) -jobs: - run-tests: - runs-on: ubuntu-latest - name: Code Coverage - timeout-minutes: 90 - steps: - - #@ template.replace(prepareTest("code-coverage", fetchWrappers=True)) - - name: Setup Coverlet & Report Generator - run: | - dotnet tool install coverlet.console --tool-path tools - dotnet tool install dotnet-reportgenerator-globaltool --tool-path tools - echo "${{ github.workspace }}/tools" >> $GITHUB_PATH - - #@ template.replace(dotnetPublish("Tests/Realm.Tests", "net8.0", "linux-x64", { "RealmTestsStandaloneExe": "true" })) - - name: Run the tests - 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" + baasTestArgs("code-coverage") + "' -f lcov -o ./report.lcov --exclude '[Realm.Tests]*' --exclude '[Realm.Fody]*' --exclude '[Realm.PlatformHelpers]*'" - - name: Archive core dump - uses: actions/upload-artifact@v4 - if: failure() - with: - name: crash-report-net-core-code-coverage - path: /tmp/coredump* - - name: Publish Coverage - id: publish-coveralls - uses: #@ actionCoveralls - with: - github-token: ${{ secrets.GITHUB_TOKEN }} - file: ./report.lcov - git-commit: ${{ github.event.pull_request.head.sha }} - compare-sha: ${{ github.event.pull_request.base.sha }} - - name: Output Coveralls response - run: echo ${{ steps.publish-coveralls.outputs.coveralls-api-result }} - - #@ template.replace(publishTestsResults("TestResults.Linux.xml", "Code Coverage")) diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index 94afe320bc..7bd7e909e7 100755 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -111,7 +111,7 @@ jobs: if: ${{ runner.os == 'Windows' }} uses: microsoft/setup-msbuild@0b44c6745b7e81956596964100aadb92d667c497 - 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:RealmTestsStandaloneExe=true -p:TargetFramework=net461 + run: msbuild Tests/Realm.Tests -restore -p:Configuration=Release -p:TargetFramework=net461 -p:RestoreConfigFile=Tests/Test.NuGet.Config -p:UseRealmNupkgsWithVersion=${{ needs.build-packages.outputs.package_version }} -p:RealmTestsStandaloneExe=true - name: Run the tests run: './Tests/Realm.Tests/bin/Release/net461/Realm.Tests.exe --result=TestResults.xml --labels=After ' - name: Publish Unit Test Results @@ -162,9 +162,9 @@ jobs: if: ${{ runner.os == 'Windows' }} uses: microsoft/setup-msbuild@0b44c6745b7e81956596964100aadb92d667c497 - name: Build Tests/Tests.UWP - run: msbuild Tests/Tests.UWP -p:Configuration=Release -restore -p:RestoreConfigFile=Tests/Test.NuGet.Config -p:UseRealmNupkgsWithVersion=${{ needs.build-packages.outputs.package_version }} -p:RealmTestsStandaloneExe=true -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 + run: msbuild Tests/Tests.UWP -restore -p:Configuration=Release -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 -p:RestoreConfigFile=Tests/Test.NuGet.Config -p:UseRealmNupkgsWithVersion=${{ needs.build-packages.outputs.package_version }} -p:RealmTestsStandaloneExe=true - name: Run the tests - run: ./Tests/Tests.UWP/RunTests.ps1 -ExtraAppArgs ' + run: ./Tests/Tests.UWP/RunTests.ps1 -ExtraAppArgs '' shell: powershell - name: Publish Unit Test Results if: always() @@ -292,7 +292,7 @@ jobs: if: ${{ runner.os == 'Windows' }} uses: microsoft/setup-msbuild@0b44c6745b7e81956596964100aadb92d667c497 - name: Build Tests/Tests.XamarinMac - run: msbuild Tests/Tests.XamarinMac -p:Configuration=Release -restore -p:RestoreConfigFile=Tests/Test.NuGet.Config -p:UseRealmNupkgsWithVersion=${{ needs.build-packages.outputs.package_version }} -p:RealmTestsStandaloneExe=true + run: msbuild Tests/Tests.XamarinMac -restore -p:Configuration=Release -p:RestoreConfigFile=Tests/Test.NuGet.Config -p:UseRealmNupkgsWithVersion=${{ needs.build-packages.outputs.package_version }} -p:RealmTestsStandaloneExe=true - name: Run the tests run: Tests/Tests.XamarinMac/bin/Release/Tests.XamarinMac.app/Contents/MacOS/Tests.XamarinMac --headless --result=${{ github.workspace }}/TestResults.xml --labels=All - name: Publish Unit Test Results @@ -337,6 +337,10 @@ jobs: dotnet-version: 8.0.x - name: Setup workloads run: dotnet workload install maui + - name: Setup Xcode + uses: maxim-lobanov/setup-xcode@60606e260d2fc5762a71e64e74b2174e8ea3c8bd + with: + xcode-version: latest-stable - name: Build Tests/Tests.Maui run: dotnet build Tests/Tests.Maui -c Release -f net8.0-maccatalyst -p:RestoreConfigFile=Tests/Test.NuGet.Config -p:UseRealmNupkgsWithVersion=${{ needs.build-packages.outputs.package_version }} -p:RealmTestsStandaloneExe=true - name: Run the tests @@ -384,7 +388,7 @@ jobs: if: ${{ runner.os == 'Windows' }} uses: microsoft/setup-msbuild@0b44c6745b7e81956596964100aadb92d667c497 - name: Build Tests/Tests.iOS - run: msbuild Tests/Tests.iOS -p:Configuration=Release -restore -p:RestoreConfigFile=Tests/Test.NuGet.Config -p:UseRealmNupkgsWithVersion=${{ needs.build-packages.outputs.package_version }} -p:RealmTestsStandaloneExe=true -p:Platform=iPhoneSimulator + run: msbuild Tests/Tests.iOS -restore -p:Configuration=Release -p:Platform=iPhoneSimulator -p:RestoreConfigFile=Tests/Test.NuGet.Config -p:UseRealmNupkgsWithVersion=${{ needs.build-packages.outputs.package_version }} -p:RealmTestsStandaloneExe=true - name: Run on Simulator uses: realm/ci-actions/run-ios-simulator@6418e15ed9bbdb19b7d456a347e5623779f95cdf with: @@ -492,7 +496,7 @@ jobs: if: ${{ runner.os == 'Windows' }} uses: microsoft/setup-msbuild@0b44c6745b7e81956596964100aadb92d667c497 - name: Build Tests/Tests.XamarinTVOS - run: msbuild Tests/Tests.XamarinTVOS -p:Configuration=Release -restore -p:RestoreConfigFile=Tests/Test.NuGet.Config -p:UseRealmNupkgsWithVersion=${{ needs.build-packages.outputs.package_version }} -p:RealmTestsStandaloneExe=true -p:Platform=iPhoneSimulator + run: msbuild Tests/Tests.XamarinTVOS -restore -p:Configuration=Release -p:Platform=iPhoneSimulator -p:RestoreConfigFile=Tests/Test.NuGet.Config -p:UseRealmNupkgsWithVersion=${{ needs.build-packages.outputs.package_version }} -p:RealmTestsStandaloneExe=true - name: Run on Simulator uses: realm/ci-actions/run-ios-simulator@6418e15ed9bbdb19b7d456a347e5623779f95cdf with: @@ -547,7 +551,7 @@ jobs: if: ${{ runner.os == 'Windows' }} uses: microsoft/setup-msbuild@0b44c6745b7e81956596964100aadb92d667c497 - name: Build Tests/Tests.Android - run: msbuild Tests/Tests.Android -p:Configuration=Release -restore -p:RestoreConfigFile=Tests/Test.NuGet.Config -p:UseRealmNupkgsWithVersion=${{ needs.build-packages.outputs.package_version }} -p:RealmTestsStandaloneExe=true -p:AndroidUseSharedRuntime=False -p:EmbedAssembliesIntoApk=True + run: msbuild Tests/Tests.Android -t SignAndroidPackage -restore -p:Configuration=Release -p:AndroidUseSharedRuntime=False -p:EmbedAssembliesIntoApk=True -p:RestoreConfigFile=Tests/Test.NuGet.Config -p:UseRealmNupkgsWithVersion=${{ needs.build-packages.outputs.package_version }} -p:RealmTestsStandaloneExe=true - name: Configure AWS Credentials uses: aws-actions/configure-aws-credentials@v4.0.2 with: @@ -610,7 +614,7 @@ jobs: - name: Setup workloads run: dotnet workload install maui - name: Publish Tests/Tests.Maui - run: dotnet publish Tests/Tests.Maui -c Release -f net8.0-android -p:RestoreConfigFile=Tests/Test.NuGet.Config -p:UseRealmNupkgsWithVersion=${{ needs.build-packages.outputs.package_version }} -p:RealmTestsStandaloneExe=true --no-self-contained + run: dotnet publish Tests/Tests.Maui -c Release -f net8.0-android -p:RestoreConfigFile=Tests/Test.NuGet.Config -p:UseRealmNupkgsWithVersion=${{ needs.build-packages.outputs.package_version }} -p:RealmTestsStandaloneExe=true --no-self-contained - name: Output executable path id: dotnet-publish run: echo 'executable-path=./Tests/Tests.Maui/bin/Release/net8.0-android/null/Tests.Maui' >> $GITHUB_OUTPUT @@ -773,16 +777,78 @@ jobs: runtime: osx-arm64 fail-fast: false test-code-coverage: - name: Test + name: Test Code Coverage needs: - build-packages - deploy-baas if: always() && !cancelled() && !contains(needs.*.result, 'failure') && !contains(needs.*.result, 'cancelled') - uses: ./.github/workflows/test-code-coverage.yml - with: - version: ${{ needs.build-packages.outputs.package_version }} - secrets: - BaaSaasApiKey: ${{ secrets.BAASAAS_API_KEY }} + timeout-minutes: 60 + runs-on: ubuntu-latest + steps: + - name: Checkout Code + uses: actions/checkout@v4 + with: + submodules: recursive + ref: ${{ github.event.pull_request.head.sha }} + - name: Register csc problem matcher + run: |- + echo "::add-matcher::.github/problem-matchers/csc.json" + echo "::add-matcher::.github/problem-matchers/msvc.json" + - name: Fetch Realm + uses: actions/download-artifact@v4 + with: + name: Realm.${{ needs.build-packages.outputs.package_version }} + path: ${{ github.workspace }}/Realm/packages/ + - name: Fetch Realm.PlatformHelpers + uses: actions/download-artifact@v4 + with: + name: Realm.PlatformHelpers.${{ needs.build-packages.outputs.package_version }} + path: ${{ github.workspace }}/Realm/packages/ + - name: Deploy Apps + working-directory: Tools/DeployApps + run: dotnet run deploy-apps --baasaas-api-key=${{ secrets.BAASAAS_API_KEY }} --baas-differentiator=code-coverage-${{ github.run_id }}-${{ github.run_attempt }} + - name: Setup Coverlet & Report Generator + run: |- + dotnet tool install coverlet.console --tool-path tools + dotnet tool install dotnet-reportgenerator-globaltool --tool-path tools + echo "${{ github.workspace }}/tools" >> $GITHUB_PATH + - name: Publish Tests/Realm.Tests + run: dotnet publish Tests/Realm.Tests -c Release -f net8.0 -r linux-x64 -p:RealmTestsStandaloneExe=true --no-self-contained + - name: Output executable path + id: dotnet-publish + run: echo 'executable-path=./Tests/Realm.Tests/bin/Release/net8.0/linux-x64/Realm.Tests' >> $GITHUB_OUTPUT + shell: bash + - name: Run the tests + env: + DOTNET_DbgEnableMiniDump: 1 + DOTNET_EnableCrashReport: 1 + run: ./tools/coverlet ./Tests/Realm.Tests/bin/Release/net8.0/linux-x64 -t ${{ steps.dotnet-publish.outputs.executable-path }}/Realm.Tests -a '--result=TestResults.xml --labels=After --baasaas-api-key=${{ secrets.BAASAAS_API_KEY}} --baas-differentiator=code-coverage-${{ github.run_id }}-${{ github.run_attempt }}' -f lcov -o ./report.lcov --exclude '[Realm.Tests]*' --exclude '[Realm.Fody]*' --exclude '[Realm.PlatformHelpers]*' + - name: Archive core dump + if: ${{ failure() && runner.os != 'Windows' }} + uses: actions/upload-artifact@v4 + with: + name: crash-report-net-core-${{ runner.os }}-${{ runner.arch }} + path: /tmp/coredump* + - name: Publish Coverage + id: publish-coveralls + uses: coverallsapp/github-action@v2.3.0 + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + file: ./report.lcov + git-commit: ${{ github.event.pull_request.head.sha }} + compare-sha: ${{ github.event.pull_request.base.sha }} + - name: Output Coveralls response + run: echo ${{ steps.publish-coveralls.outputs.coveralls-api-result }} + - name: Publish Unit Test Results + if: always() + uses: LaPeste/test-reporter@510caf50a955b1003bec48a6494be4d6537f3a0b + with: + name: Results Code Coverage + path: TestResults.xml + reporter: java-junit + list-suites: failed + path-replace-backslashes: true + fail-on-error: true cleanup-baas: name: Cleanup BaaS needs: diff --git a/.github/workflows/test-code-coverage.yml b/.github/workflows/test-code-coverage.yml deleted file mode 100755 index c99772632f..0000000000 --- a/.github/workflows/test-code-coverage.yml +++ /dev/null @@ -1,177 +0,0 @@ -name: test-code-coverage -"on": - workflow_call: - inputs: - version: - required: true - type: string - secrets: - BaaSaasApiKey: - required: false -env: - REALM_DISABLE_ANALYTICS: true - DOTNET_NOLOGO: true -jobs: - run-tests: - runs-on: ubuntu-latest - name: Code Coverage - timeout-minutes: 90 - 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 artifacts for macos - uses: actions/download-artifact@v4 - with: - name: wrappers-macos - path: wrappers/build - - name: Fetch artifacts for catalyst - uses: actions/download-artifact@v4 - with: - name: wrappers-catalyst - path: wrappers/build - - name: Fetch artifacts for linux-x86_64 - uses: actions/download-artifact@v4 - with: - name: wrappers-linux-x86_64 - path: wrappers/build - - name: Fetch artifacts for linux-armhf - uses: actions/download-artifact@v4 - with: - name: wrappers-linux-armhf - path: wrappers/build - - name: Fetch artifacts for linux-aarch64 - uses: actions/download-artifact@v4 - with: - name: wrappers-linux-aarch64 - path: wrappers/build - - name: Fetch artifacts for iOS-Device - uses: actions/download-artifact@v4 - with: - name: wrappers-iOS-Device - path: wrappers/build - - name: Fetch artifacts for iOS-Simulator - uses: actions/download-artifact@v4 - with: - name: wrappers-iOS-Simulator - path: wrappers/build - - name: Fetch artifacts for tvOS-Device - uses: actions/download-artifact@v4 - with: - name: wrappers-tvOS-Device - path: wrappers/build - - name: Fetch artifacts for tvOS-Simulator - uses: actions/download-artifact@v4 - with: - name: wrappers-tvOS-Simulator - path: wrappers/build - - name: Fetch artifacts for android-armeabi-v7a - uses: actions/download-artifact@v4 - with: - name: wrappers-android-armeabi-v7a - path: wrappers/build - - name: Fetch artifacts for android-arm64-v8a - uses: actions/download-artifact@v4 - with: - name: wrappers-android-arm64-v8a - path: wrappers/build - - name: Fetch artifacts for android-x86 - uses: actions/download-artifact@v4 - with: - name: wrappers-android-x86 - path: wrappers/build - - name: Fetch artifacts for android-x86_64 - uses: actions/download-artifact@v4 - with: - name: wrappers-android-x86_64 - path: wrappers/build - - name: Fetch artifacts for windows-Win32 - uses: actions/download-artifact@v4 - with: - name: wrappers-windows-Win32 - path: wrappers/build - - name: Fetch artifacts for windows-x64 - uses: actions/download-artifact@v4 - with: - name: wrappers-windows-x64 - path: wrappers/build - - name: Fetch artifacts for windows-ARM64 - uses: actions/download-artifact@v4 - with: - name: wrappers-windows-ARM64 - path: wrappers/build - - name: Fetch artifacts for windows-uwp-Win32 - uses: actions/download-artifact@v4 - with: - name: wrappers-windows-uwp-Win32 - path: wrappers/build - - name: Fetch artifacts for windows-uwp-x64 - uses: actions/download-artifact@v4 - with: - name: wrappers-windows-uwp-x64 - path: wrappers/build - - name: Fetch artifacts for windows-uwp-ARM - uses: actions/download-artifact@v4 - with: - name: wrappers-windows-uwp-ARM - path: wrappers/build - - name: Fetch artifacts for windows-uwp-ARM64 - uses: actions/download-artifact@v4 - with: - name: wrappers-windows-uwp-ARM64 - path: wrappers/build - - name: Deploy Baas (alternative) - env: - apiKey: ${{ secrets.BaaSaasApiKey }} - if: ${{ env.apiKey }} - run: dotnet run deploy-apps --baasaas-api-key=${{ secrets.BaaSaasApiKey }} --baas-differentiator=code-coverage-${{ github.run_id }}-${{ github.run_attempt }} - working-directory: Tools/DeployApps - - name: Setup Coverlet & Report Generator - run: | - dotnet tool install coverlet.console --tool-path tools - dotnet tool install dotnet-reportgenerator-globaltool --tool-path tools - echo "${{ github.workspace }}/tools" >> $GITHUB_PATH - - name: Publish Tests/Realm.Tests - run: dotnet publish Tests/Realm.Tests -c Release -f net8.0 -r linux-x64 -p:RealmTestsStandaloneExe=true --no-self-contained - - name: Output executable path - id: dotnet-publish - run: echo 'executable-path=./Tests/Realm.Tests/bin/Release/net8.0/linux-x64' >> $GITHUB_OUTPUT - shell: bash - - name: Run the tests - 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 --baasaas-api-key=${{ secrets.BaaSaasApiKey}} --baas-differentiator=code-coverage-${{ github.run_id }}-${{ github.run_attempt }}' -f lcov -o ./report.lcov --exclude '[Realm.Tests]*' --exclude '[Realm.Fody]*' --exclude '[Realm.PlatformHelpers]*' - - name: Archive core dump - uses: actions/upload-artifact@v4 - if: failure() - with: - name: crash-report-net-core-code-coverage - path: /tmp/coredump* - - name: Publish Coverage - id: publish-coveralls - uses: coverallsapp/github-action@95b1a2355bd0e526ad2fd62da9fd386ad4c98474 - with: - github-token: ${{ secrets.GITHUB_TOKEN }} - file: ./report.lcov - git-commit: ${{ github.event.pull_request.head.sha }} - compare-sha: ${{ github.event.pull_request.base.sha }} - - name: Output Coveralls response - run: echo ${{ steps.publish-coveralls.outputs.coveralls-api-result }} - - name: Publish Unit Test Results - uses: LaPeste/test-reporter@510caf50a955b1003bec48a6494be4d6537f3a0b - if: always() - with: - name: Results Code Coverage - path: TestResults.Linux.xml - reporter: java-junit - list-suites: failed - list-tests: failed - path-replace-backslashes: true - fail-on-error: true From aa2cdd5177e3df86815c54756cec6cb1e808d6cc Mon Sep 17 00:00:00 2001 From: Nikola Irinchev Date: Thu, 16 May 2024 01:18:32 +0200 Subject: [PATCH 21/39] try to fix some build failures --- .github/pkl-workflows/helpers/Steps.pkl | 15 ++- .github/pkl-workflows/helpers/Test.pkl | 17 +-- .github/pkl-workflows/pr.pkl | 2 +- .github/templates/wrappers.yml | 161 ------------------------ .github/workflows/pr.yml | 109 ++++++++++++++-- 5 files changed, 122 insertions(+), 182 deletions(-) delete mode 100644 .github/templates/wrappers.yml diff --git a/.github/pkl-workflows/helpers/Steps.pkl b/.github/pkl-workflows/helpers/Steps.pkl index 758721e963..f30426900f 100644 --- a/.github/pkl-workflows/helpers/Steps.pkl +++ b/.github/pkl-workflows/helpers/Steps.pkl @@ -69,6 +69,15 @@ const function fetchPackages(packageJob: String, _packages: List?): List } }) +const function fetchWrappers(): List = Common.wrapperBinaryNames.map((wrapper) -> new gha.Step { + name = "Fetch wrappers for \(wrapper)" + uses = "actions/download-artifact@v4" + with { + ["name"] = "wrappers-\(wrapper)" + ["path"] = "wrappers/build" + } +}) + const function setupWorkloads(workloads: String?, dotnetVersion: String?): Listing = new Listing { setupDotnet(dotnetVersion) new { @@ -101,7 +110,7 @@ class MSBuildConfig { target: String? properties: Mapping = new Mapping{} - function getTargetForInvocation(): String = if (target != null) " -t \(target)" else "" + function getTargetForInvocation(): String = if (target != null) " -t:\(target)" else "" function getPropertiesForInvocation(): String = "-p:Configuration=\(Common.configuration)\(propertiesToString(properties))" } @@ -126,9 +135,9 @@ const function dotnetPublish(project: String, framework: Common.NetFramework, ru } } -const function dotnetBuild(project: String, framework: Common.NetFramework, properties: Mapping): gha.Step = new gha.Step { +const function dotnetBuild(project: String, framework: Common.NetFramework, runtime: Common.NetRuntime?, properties: Mapping): gha.Step = new gha.Step { name = "Build \(project)" - run = "dotnet build \(project) -c \(Common.configuration) -f \(framework)\(propertiesToString(properties))" + run = "dotnet build \(project) -c \(Common.configuration) -f \(framework)\(if (runtime != null) " -r \(runtime)" else "")\(propertiesToString(properties))" } const function runSimulator(config: SimulatorConfig): gha.Step = new { diff --git a/.github/pkl-workflows/helpers/Test.pkl b/.github/pkl-workflows/helpers/Test.pkl index abc38903aa..09d4401a2b 100644 --- a/.github/pkl-workflows/helpers/Test.pkl +++ b/.github/pkl-workflows/helpers/Test.pkl @@ -199,7 +199,7 @@ function iOS_Maui(_syncDifferentiators: Listing): gha ...prepareTests(config) ...Steps.setupWorkloads("maui", null) Steps.setupXcode("latest-stable") - Steps.dotnetBuild("Tests/Tests.Maui", "net8.0-ios", getTestProps()) + Steps.dotnetBuild("Tests/Tests.Maui", "net8.0-ios", null, getTestProps()) Steps.runSimulator(new Steps.SimulatorConfig{ appPath = "Tests/Tests.Maui/bin/\(Common.configuration)/net8.0-ios/iossimulator-arm64/Tests.Maui.app" arguments = "--headless --result=${{ github.workspace }}/\(outputFile) --labels=All \(baasTestArgs(config))" @@ -243,7 +243,7 @@ function macOS_Maui(_syncDifferentiators: Listing): g ...prepareTests(config) ...Steps.setupWorkloads("maui", null) Steps.setupXcode("latest-stable") - Steps.dotnetBuild("Tests/Tests.Maui", "net8.0-maccatalyst", getTestProps()) + Steps.dotnetBuild("Tests/Tests.Maui", "net8.0-maccatalyst", "osx-arm64", getTestProps()) new { name = "Run the tests" run = "Tests/Tests.Maui/bin/\(Common.configuration)/net8.0-maccatalyst/maccatalyst-arm64/Tests.Maui.app/Contents/MacOS/Tests.Maui --headless --result=${{ github.workspace }}/\(outputFile) --labels=All \(baasTestArgs(config))" @@ -337,9 +337,8 @@ function android_Maui(_syncDifferentiators: Listing): ...reportTestResultsWithCustomFile("${{ steps.run_tests.outputs.test-results-path }}", config) }) -function codeCoverage(_syncDifferentiators: Listing): gha.StepJobBase = testJob( +function codeCoverage(wrappersJob: String, _syncDifferentiators: Listing): gha.StepJobBase = (testJob( new TestConfig { - needsPackages = true title = "Code Coverage" syncDifferentiator = "code-coverage" syncDifferentiators = _syncDifferentiators @@ -365,7 +364,11 @@ function codeCoverage(_syncDifferentiators: Listing): archiveCoreDump() ...Steps.publishCoverage("./report.lcov") ...reportTestResults(config) - }) + })) { + needs { + wrappersJob + } + } // Private helpers local function testJob(config: TestConfig, runsOn: gha.Machine | String, _strategy: gha.MatrixStrategy?, _steps: Function1>): gha.StepJobBase = (if (_strategy != null) new gha.MatrixJob{ @@ -386,7 +389,7 @@ local function testJob(config: TestConfig, runsOn: gha.Machine | String, _strate steps = _steps.apply(config) } -local function prepareTests(config: TestConfig(needsPackages == true)): Listing = new Listing { +local function prepareTests(config: TestConfig(needsPackages == true || useWrappers == true)): Listing = new Listing { ...Steps.checkout() ...cleanWorkspace(config.shouldCleanWorkspace) ...fetchTestArtifacts(Common.job_Packages, config.useWrappers) @@ -403,7 +406,7 @@ local function cleanWorkspace(shouldClean: Boolean): Listing = new Lis } local function fetchTestArtifacts(packageJob: String, useWrappers: Boolean): List = if (useWrappers) - Steps.fetchPackages(packageJob, Common.nugetPackages) + Steps.fetchWrappers() else Steps.fetchPackages(packageJob, Common.nugetPackages) local function buildTests(config: Steps.MSBuildConfig): List = Steps.msbuild((config) { diff --git a/.github/pkl-workflows/pr.pkl b/.github/pkl-workflows/pr.pkl index 16e80fec8c..b31846f70c 100644 --- a/.github/pkl-workflows/pr.pkl +++ b/.github/pkl-workflows/pr.pkl @@ -102,7 +102,7 @@ jobs { ["test-woven-classes"] = TestJobs.wovenClasses() ["test-source-generation"] = TestJobs.sourceGeneration() ["test-weaver"] = TestJobs.weaver() - ["test-code-coverage"] = TestJobs.codeCoverage(baasDifferentiators) + ["test-code-coverage"] = TestJobs.codeCoverage(JobNames.wrappers, baasDifferentiators) ["cleanup-baas"] = (BaaS.cleanup(baasDifferentiators)) { needs = baasDifferentiators.toList().map((d) -> "test-\(d)").toListing() } diff --git a/.github/templates/wrappers.yml b/.github/templates/wrappers.yml deleted file mode 100644 index 60d57ae2dc..0000000000 --- a/.github/templates/wrappers.yml +++ /dev/null @@ -1,161 +0,0 @@ -#@ load("@ytt:template", "template") -#@ load("common.lib.yml", "configuration", "checkoutCode", "actionCache", "actionDownloadArtifact", "getWrapperBinaryNames", "androidABIs", "windowsArchs", "windowsUWPArchs", "applePlatforms", "actionDockerLayerCaching", "actionDockerBuild", "actionDockerRun", "uploadArtifacts", "setupXcode", "linuxArchs") - -#@ wrappersTimeout = 90 -#@ wrappersCacheCondition = "steps.check-cache.outputs.cache-hit != 'true'" - -#@ def getWrapperBuildCommand(cmd, enableLto = True): -#@ defaultParams = " --configuration=" + configuration -#@ if enableLto: -#@ defaultParams = defaultParams + " -DCMAKE_INTERPROCEDURAL_OPTIMIZATION='ON'" -#@ end -#@ if cmd.startswith("pwsh"): -#@ defaultParams = " -Configuration " + configuration -#@ if enableLto: -#@ defaultParams = defaultParams + " -EnableLTO" -#@ end -#@ end -#@ return cmd + defaultParams -#@ end - -#@ def checkCache(outputVar, path = "wrappers/build/**", id = "check-cache", name = "Check cache"): -#@ key = outputVar + "-" + configuration + "-${{hashFiles('./wrappers/**')}}" -name: #@ name -id: #@ id -uses: #@ actionCache -with: - path: #@ "./" + path - key: #@ key -#@ end ---- -#@ def setupMSVC(): - - name: Setup MSVC - run: | - Start-Process "C:\Program Files (x86)\Microsoft Visual Studio\Installer\vs_installer.exe" -ArgumentList 'modify --installPath "C:\Program Files\Microsoft Visual Studio\2022\Enterprise" --quiet --add Microsoft.VisualStudio.Component.VC.14.35.17.5.${{ startswith(matrix.arch, 'ARM') && matrix.arch || 'x86.x64' }}' -Wait -PassThru - shell: pwsh - if: #@ wrappersCacheCondition -#@ end ---- -#@ def setupXcodeStep(): - - #@ setupXcode() -#@ end ---- -#@ def buildWrappers(cmd, outputVar, intermediateSteps = [], enableLto = True, artifactsPath = "wrappers/build/**", cacheVariable = ""): -#@ if cacheVariable == "": -#@ cacheVariable = outputVar -#@ end -timeout-minutes: #@ wrappersTimeout -needs: - - check-cache -if: #@ "needs.check-cache.outputs." + cacheVariable + " != 'true'" -steps: - - #@ template.replace(checkoutCode("recursive", False)) - - #@ checkCache(outputVar, artifactsPath) - #@ for step in intermediateSteps: - - #@ template.replace(step) - #@ end - - name: Build wrappers - run: #@ getWrapperBuildCommand(cmd, enableLto) - if: #@ wrappersCacheCondition - - #@ uploadArtifacts(outputVar, artifactsPath, 1) -#@ end - ---- -name: wrappers -"on": - workflow_call: -env: - REALM_DISABLE_ANALYTICS: true - DOTNET_NOLOGO: true -jobs: - check-cache: - strategy: - matrix: - os: - - ubuntu - - windows - runs-on: ${{ matrix.os }}-latest - name: Check cache - env: - CACHE_SKIP_SAVE: true - outputs: - #@ for platform in getWrapperBinaryNames(): - #@yaml/text-templated-strings - (@= "wrappers-" + platform @): #@ "${{ steps.check-cache-" + platform + ".outputs.cache-hit }}" - #@ end - steps: - - #@ template.replace(checkoutCode("recursive", False)) - #@ for platform in getWrapperBinaryNames(): - #@ condition = "matrix.os == " + ("'windows'" if platform.find("windows") > -1 else "'ubuntu'") - - _: #@ template.replace(checkCache("wrappers-" + platform, id = "check-cache-" + platform, name = "Check cache for " + platform)) - if: #@ condition - - _: #@ template.replace(uploadArtifacts("wrappers-" + platform, "wrappers/build/**", 1)) - if: #@ condition + " && steps.check-cache-" + platform + ".outputs.cache-hit == 'true'" - - run: git clean -fdx - if: #@ condition - #@ end - macos: - runs-on: macos-12 - name: macOS - _: #@ template.replace(buildWrappers("./wrappers/build-macos.sh", "wrappers-macos")) - catalyst: - runs-on: macos-12 - name: Catalyst - _: #@ template.replace(buildWrappers("pwsh ./wrappers/build-apple-platform.ps1 Catalyst", "wrappers-catalyst")) - apple-platforms: - runs-on: macos-12 - name: Apple Platform - strategy: - matrix: - platform: #@ applePlatforms - target: [ 'Device', 'Simulator' ] - _: #@ template.replace(buildWrappers("pwsh ./wrappers/build-apple-platform.ps1 ${{ matrix.platform }} -Targets ${{ matrix.target }}", "wrappers-${{ matrix.platform }}-${{ matrix.target }}", enableLto = False, intermediateSteps = [setupXcodeStep()])) - #@yaml/map-key-override - if: #@ " || ".join([ "needs.check-cache.outputs.wrappers-" + x + "-Device != 'true'" for x in applePlatforms ] + [ "needs.check-cache.outputs.wrappers-" + x + "-Simulator != 'true'" for x in applePlatforms ]) - linux: - runs-on: ubuntu-latest - name: Linux - strategy: - matrix: - arch: #@ linuxArchs - timeout-minutes: #@ wrappersTimeout - needs: - - check-cache - if: #@ " || ".join([ "needs.check-cache.outputs.wrappers-linux-" + x + " != 'true'" for x in linuxArchs ]) - steps: - - #@ template.replace(checkoutCode("recursive")) - - #@ checkCache("wrappers-linux-${{ matrix.arch }}") - - name: Install Ninja - run: sudo apt install ninja-build - if: #@ wrappersCacheCondition - - name: Build wrappers - run: #@ getWrapperBuildCommand("./wrappers/build-linux.sh -a=${{ matrix.arch }}") - if: #@ wrappersCacheCondition - - #@ uploadArtifacts("wrappers-linux-${{ matrix.arch }}", "wrappers/build/**", 1) - android: - runs-on: ubuntu-20.04 - name: Android - strategy: - matrix: - arch: #@ androidABIs - _: #@ template.replace(buildWrappers("./wrappers/build-android.sh --ARCH=${{ matrix.arch }}", "wrappers-android-${{ matrix.arch }}", enableLto = False, cacheVariable = "wrappers-android")) - #@yaml/map-key-override - if: #@ " || ".join([ "needs.check-cache.outputs.wrappers-android-" + x + " != 'true'" for x in androidABIs ]) - windows: - runs-on: windows-latest - name: Windows - strategy: - matrix: - arch: #@ windowsArchs - _: #@ template.replace(buildWrappers("pwsh ./wrappers/build.ps1 Windows -Platforms ${{ matrix.arch }} -ExtraCMakeArgs \"-T v143,version=14.35\"", "wrappers-windows-${{ matrix.arch }}", cacheVariable = "wrappers-windows", intermediateSteps = [setupMSVC()])) - #@yaml/map-key-override - if: #@ " || ".join([ "needs.check-cache.outputs.wrappers-windows-" + x + " != 'true'" for x in windowsArchs ]) - uwp: - runs-on: windows-latest - name: UWP - strategy: - matrix: - arch: #@ windowsUWPArchs - _: #@ template.replace(buildWrappers("pwsh ./wrappers/build.ps1 WindowsStore -Platforms ${{ matrix.arch }} -ExtraCMakeArgs \"-T v143,version=14.35\"", "wrappers-windows-uwp-${{ matrix.arch }}", cacheVariable = "wrappers-uwp", intermediateSteps = [setupMSVC()])) - #@yaml/map-key-override - if: #@ " || ".join([ "needs.check-cache.outputs.wrappers-windows-uwp-" + x + " != 'true'" for x in windowsUWPArchs ]) diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index 7bd7e909e7..5de53a6542 100755 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -342,7 +342,7 @@ jobs: with: xcode-version: latest-stable - name: Build Tests/Tests.Maui - run: dotnet build Tests/Tests.Maui -c Release -f net8.0-maccatalyst -p:RestoreConfigFile=Tests/Test.NuGet.Config -p:UseRealmNupkgsWithVersion=${{ needs.build-packages.outputs.package_version }} -p:RealmTestsStandaloneExe=true + run: dotnet build Tests/Tests.Maui -c Release -f net8.0-maccatalyst -r osx-arm64 -p:RestoreConfigFile=Tests/Test.NuGet.Config -p:UseRealmNupkgsWithVersion=${{ needs.build-packages.outputs.package_version }} -p:RealmTestsStandaloneExe=true - name: Run the tests run: 'Tests/Tests.Maui/bin/Release/net8.0-maccatalyst/maccatalyst-arm64/Tests.Maui.app/Contents/MacOS/Tests.Maui --headless --result=${{ github.workspace }}/TestResults.xml --labels=All ' - name: Transform Results @@ -551,7 +551,7 @@ jobs: if: ${{ runner.os == 'Windows' }} uses: microsoft/setup-msbuild@0b44c6745b7e81956596964100aadb92d667c497 - name: Build Tests/Tests.Android - run: msbuild Tests/Tests.Android -t SignAndroidPackage -restore -p:Configuration=Release -p:AndroidUseSharedRuntime=False -p:EmbedAssembliesIntoApk=True -p:RestoreConfigFile=Tests/Test.NuGet.Config -p:UseRealmNupkgsWithVersion=${{ needs.build-packages.outputs.package_version }} -p:RealmTestsStandaloneExe=true + run: msbuild Tests/Tests.Android -t:SignAndroidPackage -restore -p:Configuration=Release -p:AndroidUseSharedRuntime=False -p:EmbedAssembliesIntoApk=True -p:RestoreConfigFile=Tests/Test.NuGet.Config -p:UseRealmNupkgsWithVersion=${{ needs.build-packages.outputs.package_version }} -p:RealmTestsStandaloneExe=true - name: Configure AWS Credentials uses: aws-actions/configure-aws-credentials@v4.0.2 with: @@ -779,8 +779,7 @@ jobs: test-code-coverage: name: Test Code Coverage needs: - - build-packages - - deploy-baas + - build-wrappers if: always() && !cancelled() && !contains(needs.*.result, 'failure') && !contains(needs.*.result, 'cancelled') timeout-minutes: 60 runs-on: ubuntu-latest @@ -794,16 +793,106 @@ jobs: run: |- echo "::add-matcher::.github/problem-matchers/csc.json" echo "::add-matcher::.github/problem-matchers/msvc.json" - - name: Fetch Realm + - name: Fetch wrappers for macos uses: actions/download-artifact@v4 with: - name: Realm.${{ needs.build-packages.outputs.package_version }} - path: ${{ github.workspace }}/Realm/packages/ - - name: Fetch Realm.PlatformHelpers + name: wrappers-macos + path: wrappers/build + - name: Fetch wrappers for catalyst uses: actions/download-artifact@v4 with: - name: Realm.PlatformHelpers.${{ needs.build-packages.outputs.package_version }} - path: ${{ github.workspace }}/Realm/packages/ + name: wrappers-catalyst + path: wrappers/build + - name: Fetch wrappers for linux-x86_64 + uses: actions/download-artifact@v4 + with: + name: wrappers-linux-x86_64 + path: wrappers/build + - name: Fetch wrappers for linux-armhf + uses: actions/download-artifact@v4 + with: + name: wrappers-linux-armhf + path: wrappers/build + - name: Fetch wrappers for linux-aarch64 + uses: actions/download-artifact@v4 + with: + name: wrappers-linux-aarch64 + path: wrappers/build + - name: Fetch wrappers for android-armeabi-v7a + uses: actions/download-artifact@v4 + with: + name: wrappers-android-armeabi-v7a + path: wrappers/build + - name: Fetch wrappers for android-arm64-v8a + uses: actions/download-artifact@v4 + with: + name: wrappers-android-arm64-v8a + path: wrappers/build + - name: Fetch wrappers for android-x86 + uses: actions/download-artifact@v4 + with: + name: wrappers-android-x86 + path: wrappers/build + - name: Fetch wrappers for android-x86_64 + uses: actions/download-artifact@v4 + with: + name: wrappers-android-x86_64 + path: wrappers/build + - name: Fetch wrappers for windows-Win32 + uses: actions/download-artifact@v4 + with: + name: wrappers-windows-Win32 + path: wrappers/build + - name: Fetch wrappers for windows-x64 + uses: actions/download-artifact@v4 + with: + name: wrappers-windows-x64 + path: wrappers/build + - name: Fetch wrappers for windows-ARM64 + uses: actions/download-artifact@v4 + with: + name: wrappers-windows-ARM64 + path: wrappers/build + - name: Fetch wrappers for windows-uwp-Win32 + uses: actions/download-artifact@v4 + with: + name: wrappers-windows-uwp-Win32 + path: wrappers/build + - name: Fetch wrappers for windows-uwp-x64 + uses: actions/download-artifact@v4 + with: + name: wrappers-windows-uwp-x64 + path: wrappers/build + - name: Fetch wrappers for windows-uwp-ARM + uses: actions/download-artifact@v4 + with: + name: wrappers-windows-uwp-ARM + path: wrappers/build + - name: Fetch wrappers for windows-uwp-ARM64 + uses: actions/download-artifact@v4 + with: + name: wrappers-windows-uwp-ARM64 + path: wrappers/build + - name: Fetch wrappers for iOS-Device + uses: actions/download-artifact@v4 + with: + name: wrappers-iOS-Device + path: wrappers/build + - name: Fetch wrappers for iOS-Simulator + uses: actions/download-artifact@v4 + with: + name: wrappers-iOS-Simulator + path: wrappers/build + - name: Fetch wrappers for tvOS-Device + uses: actions/download-artifact@v4 + with: + name: wrappers-tvOS-Device + path: wrappers/build + - name: Fetch wrappers for tvOS-Simulator + uses: actions/download-artifact@v4 + with: + name: wrappers-tvOS-Simulator + path: wrappers/build - name: Deploy Apps working-directory: Tools/DeployApps run: dotnet run deploy-apps --baasaas-api-key=${{ secrets.BAASAAS_API_KEY }} --baas-differentiator=code-coverage-${{ github.run_id }}-${{ github.run_attempt }} From 5260e898bccb5971d6cd235b63f25089d4d42401 Mon Sep 17 00:00:00 2001 From: Nikola Irinchev Date: Thu, 16 May 2024 23:42:13 +0200 Subject: [PATCH 22/39] Disable some tests on AOT targets --- .github/pkl-workflows/helpers/Test.pkl | 4 +- .github/workflows/pr.yml | 4 +- .../Database/DynamicAccessTests.cs | 157 +++++------------- .../Database/DynamicEmbeddedTests.cs | 105 +++++++++++- .../Database/EmbeddedObjectsTests.cs | 5 + Tests/Realm.Tests/Database/InstanceTests.cs | 24 ++- Tests/Realm.Tests/Database/MigrationTests.cs | 23 +-- Tests/Realm.Tests/Database/PrimaryKeyTests.cs | 7 +- Tests/Realm.Tests/Sync/AppTests.cs | 2 +- .../Realm.Tests/Sync/AsymmetricObjectTests.cs | 16 +- Tests/Tests.Maui/Tests.Maui.csproj | 2 +- 11 files changed, 196 insertions(+), 153 deletions(-) diff --git a/.github/pkl-workflows/helpers/Test.pkl b/.github/pkl-workflows/helpers/Test.pkl index 09d4401a2b..5453bbe264 100644 --- a/.github/pkl-workflows/helpers/Test.pkl +++ b/.github/pkl-workflows/helpers/Test.pkl @@ -243,7 +243,7 @@ function macOS_Maui(_syncDifferentiators: Listing): g ...prepareTests(config) ...Steps.setupWorkloads("maui", null) Steps.setupXcode("latest-stable") - Steps.dotnetBuild("Tests/Tests.Maui", "net8.0-maccatalyst", "osx-arm64", getTestProps()) + Steps.dotnetBuild("Tests/Tests.Maui", "net8.0-maccatalyst", null, getTestProps()) new { name = "Run the tests" run = "Tests/Tests.Maui/bin/\(Common.configuration)/net8.0-maccatalyst/maccatalyst-arm64/Tests.Maui.app/Contents/MacOS/Tests.Maui --headless --result=${{ github.workspace }}/\(outputFile) --labels=All \(baasTestArgs(config))" @@ -359,7 +359,7 @@ function codeCoverage(wrappersJob: String, _syncDifferentiators: Listing enableCoreDumps(true) archiveCoreDump() ...Steps.publishCoverage("./report.lcov") diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index 5de53a6542..bd83e464c1 100755 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -342,7 +342,7 @@ jobs: with: xcode-version: latest-stable - name: Build Tests/Tests.Maui - run: dotnet build Tests/Tests.Maui -c Release -f net8.0-maccatalyst -r osx-arm64 -p:RestoreConfigFile=Tests/Test.NuGet.Config -p:UseRealmNupkgsWithVersion=${{ needs.build-packages.outputs.package_version }} -p:RealmTestsStandaloneExe=true + run: dotnet build Tests/Tests.Maui -c Release -f net8.0-maccatalyst -p:RestoreConfigFile=Tests/Test.NuGet.Config -p:UseRealmNupkgsWithVersion=${{ needs.build-packages.outputs.package_version }} -p:RealmTestsStandaloneExe=true - name: Run the tests run: 'Tests/Tests.Maui/bin/Release/net8.0-maccatalyst/maccatalyst-arm64/Tests.Maui.app/Contents/MacOS/Tests.Maui --headless --result=${{ github.workspace }}/TestResults.xml --labels=All ' - name: Transform Results @@ -911,7 +911,7 @@ jobs: env: DOTNET_DbgEnableMiniDump: 1 DOTNET_EnableCrashReport: 1 - run: ./tools/coverlet ./Tests/Realm.Tests/bin/Release/net8.0/linux-x64 -t ${{ steps.dotnet-publish.outputs.executable-path }}/Realm.Tests -a '--result=TestResults.xml --labels=After --baasaas-api-key=${{ secrets.BAASAAS_API_KEY}} --baas-differentiator=code-coverage-${{ github.run_id }}-${{ github.run_attempt }}' -f lcov -o ./report.lcov --exclude '[Realm.Tests]*' --exclude '[Realm.Fody]*' --exclude '[Realm.PlatformHelpers]*' + run: ./tools/coverlet ./Tests/Realm.Tests/bin/Release/net8.0/linux-x64 -t ${{ steps.dotnet-publish.outputs.executable-path }} -a '--result=TestResults.xml --labels=After --baasaas-api-key=${{ secrets.BAASAAS_API_KEY}} --baas-differentiator=code-coverage-${{ github.run_id }}-${{ github.run_attempt }}' -f lcov -o ./report.lcov --exclude '[Realm.Tests]*' --exclude '[Realm.Fody]*' --exclude '[Realm.PlatformHelpers]*' - name: Archive core dump if: ${{ failure() && runner.os != 'Windows' }} uses: actions/upload-artifact@v4 diff --git a/Tests/Realm.Tests/Database/DynamicAccessTests.cs b/Tests/Realm.Tests/Database/DynamicAccessTests.cs index 4e31047325..5cc9aa0ba6 100644 --- a/Tests/Realm.Tests/Database/DynamicAccessTests.cs +++ b/Tests/Realm.Tests/Database/DynamicAccessTests.cs @@ -62,14 +62,7 @@ public void SimpleTest() var allTypesObject = realm.Write(() => { var ato = realm.DynamicApi.CreateObject(nameof(AllTypesObject)); - if (isDynamic) - { - Assert.That(ato, Is.InstanceOf()); - } - else - { - Assert.That(ato, Is.InstanceOf()); - } + Assert.That(ato, isDynamic ? Is.InstanceOf() : Is.InstanceOf()); ato.DynamicApi.Set(nameof(AllTypesObject.CharProperty), 'F'); ato.DynamicApi.Set(nameof(AllTypesObject.NullableCharProperty), 'o'); @@ -82,18 +75,16 @@ public void SimpleTest() Assert.That(allTypesObject.DynamicApi.Get(nameof(AllTypesObject.NullableCharProperty)), Is.EqualTo('o')); Assert.That(allTypesObject.DynamicApi.Get(nameof(AllTypesObject.StringProperty)), Is.EqualTo("o")); + if (TestHelpers.IsAOTTarget) + { + return; + } + #if !UNITY var dynamicAto = realm.Write(() => { dynamic ato = realm.DynamicApi.CreateObject(nameof(AllTypesObject)); - if (isDynamic) - { - Assert.That(ato, Is.InstanceOf()); - } - else - { - Assert.That(ato, Is.InstanceOf()); - } + Assert.That(ato, isDynamic ? Is.InstanceOf() : Is.InstanceOf()); ato.CharProperty = 'F'; ato.NullableCharProperty = 'o'; @@ -241,6 +232,10 @@ public void RealmValueTests([ValueSource(nameof(RealmValues))] RealmValue rv) Assert.That(allTypesObject.DynamicApi.Get(nameof(AllTypesObject.RealmValueProperty)), Is.EqualTo(rv)); + if (TestHelpers.IsAOTTarget) + { + return; + } #if !UNITY var dynamicAto = realm.Write(() => { @@ -273,6 +268,11 @@ public void RealmValueTests_WithObject() Assert.That(ato.DynamicApi.Get(nameof(AllTypesObject.RealmValueProperty)), Is.EqualTo(rv)); + if (TestHelpers.IsAOTTarget) + { + return; + } + #if !UNITY var (dynamicAto, dynamicRV) = realm.Write(() => { @@ -297,10 +297,7 @@ public void GetProperty_WhenIncorrectType_Throws() { RunTestInAllModes((realm, _) => { - var allTypesObject = realm.Write(() => - { - return realm.DynamicApi.CreateObject(nameof(AllTypesObject)); - }); + var allTypesObject = realm.Write(() => realm.DynamicApi.CreateObject(nameof(AllTypesObject))); Assert.Throws(() => allTypesObject.DynamicApi.Get(nameof(AllTypesObject.Int32Property))); }); @@ -494,10 +491,7 @@ public void GetProperty_WhenPropertyIsMissing_Throws() { RunTestInAllModes((realm, _) => { - var allTypesObject = realm.Write(() => - { - return realm.DynamicApi.CreateObject(nameof(AllTypesObject)); - }); + var allTypesObject = realm.Write(() => realm.DynamicApi.CreateObject(nameof(AllTypesObject))); Assert.Throws(() => allTypesObject.DynamicApi.Get("idontexist")); }); @@ -508,10 +502,7 @@ public void GetProperty_WhenPropertyIsBacklinks_Throws() { RunTestInAllModes((realm, _) => { - var allTypesObject = realm.Write(() => - { - return realm.DynamicApi.CreateObject(nameof(IntPropertyObject), ObjectId.GenerateNewId()); - }); + var allTypesObject = realm.Write(() => realm.DynamicApi.CreateObject(nameof(IntPropertyObject), ObjectId.GenerateNewId())); var ex = Assert.Throws(() => allTypesObject.DynamicApi.Get(nameof(IntPropertyObject.ContainingCollections)))!; Assert.That(ex.Message, Does.Contain("IQueryable").And.Contains("GetBacklinks")); @@ -523,10 +514,7 @@ public void GetProperty_WhenPropertyIsList_Throws() { RunTestInAllModes((realm, _) => { - var allTypesObject = realm.Write(() => - { - return realm.DynamicApi.CreateObject(nameof(SyncCollectionsObject), ObjectId.GenerateNewId()); - }); + var allTypesObject = realm.Write(() => realm.DynamicApi.CreateObject(nameof(SyncCollectionsObject), ObjectId.GenerateNewId())); var ex = Assert.Throws(() => allTypesObject.DynamicApi.Get(nameof(SyncCollectionsObject.ObjectIdList)))!; Assert.That(ex.Message, Does.Contain("IList").And.Contains("GetList")); @@ -538,10 +526,7 @@ public void GetProperty_WhenPropertyIsSet_Throws() { RunTestInAllModes((realm, _) => { - var allTypesObject = realm.Write(() => - { - return realm.DynamicApi.CreateObject(nameof(SyncCollectionsObject), ObjectId.GenerateNewId()); - }); + var allTypesObject = realm.Write(() => realm.DynamicApi.CreateObject(nameof(SyncCollectionsObject), ObjectId.GenerateNewId())); var ex = Assert.Throws(() => allTypesObject.DynamicApi.Get(nameof(SyncCollectionsObject.BooleanSet)))!; Assert.That(ex.Message, Does.Contain("ISet").And.Contains("GetSet")); @@ -553,10 +538,7 @@ public void GetProperty_WhenPropertyIsDictionary_Throws() { RunTestInAllModes((realm, _) => { - var allTypesObject = realm.Write(() => - { - return realm.DynamicApi.CreateObject(nameof(SyncCollectionsObject), ObjectId.GenerateNewId()); - }); + var allTypesObject = realm.Write(() => realm.DynamicApi.CreateObject(nameof(SyncCollectionsObject), ObjectId.GenerateNewId())); var ex = Assert.Throws(() => allTypesObject.DynamicApi.Get(nameof(SyncCollectionsObject.DecimalDict)))!; Assert.That(ex.Message, Does.Contain("IDictionary").And.Contains("GetDictionary")); @@ -690,10 +672,7 @@ public void GetBacklinks_WhenPropertyIsMissing_Throws() { RunTestInAllModes((realm, _) => { - var obj = realm.Write(() => - { - return realm.DynamicApi.CreateObject(nameof(IntPropertyObject), ObjectId.GenerateNewId()); - }); + var obj = realm.Write(() => realm.DynamicApi.CreateObject(nameof(IntPropertyObject), ObjectId.GenerateNewId())); Assert.Throws(() => obj.DynamicApi.GetBacklinks("idontexist")); }); @@ -704,10 +683,7 @@ public void GetBacklinks_WhenPropertyIsWrongType_Throws() { RunTestInAllModes((realm, _) => { - var obj = realm.Write(() => - { - return realm.DynamicApi.CreateObject(nameof(IntPropertyObject), ObjectId.GenerateNewId()); - }); + var obj = realm.Write(() => realm.DynamicApi.CreateObject(nameof(IntPropertyObject), ObjectId.GenerateNewId())); var ex = Assert.Throws(() => obj.DynamicApi.GetBacklinks(nameof(IntPropertyObject.Int)))!; Assert.That(ex.Message, Does.Contain("Int64").And.Contains(nameof(DynamicObjectApi.GetBacklinks))); @@ -745,10 +721,7 @@ public void GetBacklinksFromType_WhenFromTypeIsInvalid_Throws() { RunTestInAllModes((realm, _) => { - var obj = realm.Write(() => - { - return realm.DynamicApi.CreateObject(nameof(IntPropertyObject), ObjectId.GenerateNewId()); - }); + var obj = realm.Write(() => realm.DynamicApi.CreateObject(nameof(IntPropertyObject), ObjectId.GenerateNewId())); var ex = Assert.Throws(() => obj.DynamicApi.GetBacklinksFromType("idontexist", "someprop"))!; Assert.That(ex.Message, Does.Contain("idontexist")); @@ -760,10 +733,7 @@ public void GetBacklinksFromType_WhenFromPropertyIsMissing_Throws() { RunTestInAllModes((realm, _) => { - var obj = realm.Write(() => - { - return realm.DynamicApi.CreateObject(nameof(IntPropertyObject), ObjectId.GenerateNewId()); - }); + var obj = realm.Write(() => realm.DynamicApi.CreateObject(nameof(IntPropertyObject), ObjectId.GenerateNewId())); var ex = Assert.Throws(() => obj.DynamicApi.GetBacklinksFromType(nameof(SyncCollectionsObject), "someprop"))!; Assert.That(ex.Message, Does.Contain("someprop")); @@ -804,10 +774,7 @@ public void GetList_WhenPropertyIsNull_Throws() { RunTestInAllModes((realm, _) => { - var obj = realm.Write(() => - { - return realm.DynamicApi.CreateObject(nameof(SyncCollectionsObject), ObjectId.GenerateNewId()); - }); + var obj = realm.Write(() => realm.DynamicApi.CreateObject(nameof(SyncCollectionsObject), ObjectId.GenerateNewId())); var ex = Assert.Throws(() => obj.DynamicApi.GetList(null!))!; Assert.That(ex.ParamName, Is.EqualTo("propertyName")); @@ -819,10 +786,7 @@ public void GetList_WhenPropertyIsMissing_Throws() { RunTestInAllModes((realm, _) => { - var obj = realm.Write(() => - { - return realm.DynamicApi.CreateObject(nameof(SyncCollectionsObject), ObjectId.GenerateNewId()); - }); + var obj = realm.Write(() => realm.DynamicApi.CreateObject(nameof(SyncCollectionsObject), ObjectId.GenerateNewId())); var ex = Assert.Throws(() => obj.DynamicApi.GetList("someprop"))!; Assert.That(ex.Message, Does.Contain("someprop")); @@ -834,10 +798,7 @@ public void GetList_WhenPropertyIsNotList_Throws() { RunTestInAllModes((realm, _) => { - var obj = realm.Write(() => - { - return realm.DynamicApi.CreateObject(nameof(SyncCollectionsObject), ObjectId.GenerateNewId()); - }); + var obj = realm.Write(() => realm.DynamicApi.CreateObject(nameof(SyncCollectionsObject), ObjectId.GenerateNewId())); var ex = Assert.Throws(() => obj.DynamicApi.GetList(nameof(SyncCollectionsObject.BooleanSet)))!; Assert.That(ex.Message, Does.Contain("ISet").And.Contain($"can't be accessed using {nameof(DynamicObjectApi.GetList)}")); @@ -849,10 +810,7 @@ public void GetList_WhenCastToRealmValue_Works() { RunTestInAllModes((realm, _) => { - var obj = realm.Write(() => - { - return realm.DynamicApi.CreateObject(nameof(SyncCollectionsObject), ObjectId.GenerateNewId()); - }); + var obj = realm.Write(() => realm.DynamicApi.CreateObject(nameof(SyncCollectionsObject), ObjectId.GenerateNewId())); var stringList = obj.DynamicApi.GetList(nameof(SyncCollectionsObject.StringList)); @@ -878,10 +836,7 @@ public void GetList_WhenCastToWrongValue_Throws() { RunTestInAllModes((realm, _) => { - var obj = realm.Write(() => - { - return realm.DynamicApi.CreateObject(nameof(SyncCollectionsObject), ObjectId.GenerateNewId()); - }); + var obj = realm.Write(() => realm.DynamicApi.CreateObject(nameof(SyncCollectionsObject), ObjectId.GenerateNewId())); var stringList = obj.DynamicApi.GetList(nameof(SyncCollectionsObject.StringList)); @@ -902,10 +857,7 @@ public void GetSet_WhenPropertyIsNull_Throws() { RunTestInAllModes((realm, _) => { - var obj = realm.Write(() => - { - return realm.DynamicApi.CreateObject(nameof(SyncCollectionsObject), ObjectId.GenerateNewId()); - }); + var obj = realm.Write(() => realm.DynamicApi.CreateObject(nameof(SyncCollectionsObject), ObjectId.GenerateNewId())); var ex = Assert.Throws(() => obj.DynamicApi.GetSet(null!))!; Assert.That(ex.ParamName, Is.EqualTo("propertyName")); @@ -917,10 +869,7 @@ public void GetSet_WhenPropertyIsMissing_Throws() { RunTestInAllModes((realm, _) => { - var obj = realm.Write(() => - { - return realm.DynamicApi.CreateObject(nameof(SyncCollectionsObject), ObjectId.GenerateNewId()); - }); + var obj = realm.Write(() => realm.DynamicApi.CreateObject(nameof(SyncCollectionsObject), ObjectId.GenerateNewId())); var ex = Assert.Throws(() => obj.DynamicApi.GetSet("someprop"))!; Assert.That(ex.Message, Does.Contain("someprop")); @@ -932,10 +881,7 @@ public void GetSet_WhenPropertyIsNotSet_Throws() { RunTestInAllModes((realm, _) => { - var obj = realm.Write(() => - { - return realm.DynamicApi.CreateObject(nameof(SyncCollectionsObject), ObjectId.GenerateNewId()); - }); + var obj = realm.Write(() => realm.DynamicApi.CreateObject(nameof(SyncCollectionsObject), ObjectId.GenerateNewId())); var ex = Assert.Throws(() => obj.DynamicApi.GetSet(nameof(SyncCollectionsObject.StringList)))!; Assert.That(ex.Message, Does.Contain("IList").And.Contain($"can't be accessed using {nameof(DynamicObjectApi.GetSet)}")); @@ -947,10 +893,7 @@ public void GetSet_WhenCastToRealmValue_Works() { RunTestInAllModes((realm, _) => { - var obj = realm.Write(() => - { - return realm.DynamicApi.CreateObject(nameof(SyncCollectionsObject), ObjectId.GenerateNewId()); - }); + var obj = realm.Write(() => realm.DynamicApi.CreateObject(nameof(SyncCollectionsObject), ObjectId.GenerateNewId())); var stringSet = obj.DynamicApi.GetSet(nameof(SyncCollectionsObject.StringSet)); @@ -976,10 +919,7 @@ public void GetSet_WhenCastToWrongValue_Throws() { RunTestInAllModes((realm, _) => { - var obj = realm.Write(() => - { - return realm.DynamicApi.CreateObject(nameof(SyncCollectionsObject), ObjectId.GenerateNewId()); - }); + var obj = realm.Write(() => realm.DynamicApi.CreateObject(nameof(SyncCollectionsObject), ObjectId.GenerateNewId())); var stringSet = obj.DynamicApi.GetSet(nameof(SyncCollectionsObject.StringSet)); @@ -1000,10 +940,7 @@ public void GetDictionary_WhenPropertyIsNull_Throws() { RunTestInAllModes((realm, _) => { - var obj = realm.Write(() => - { - return realm.DynamicApi.CreateObject(nameof(SyncCollectionsObject), ObjectId.GenerateNewId()); - }); + var obj = realm.Write(() => realm.DynamicApi.CreateObject(nameof(SyncCollectionsObject), ObjectId.GenerateNewId())); var ex = Assert.Throws(() => obj.DynamicApi.GetDictionary(null!))!; Assert.That(ex.ParamName, Is.EqualTo("propertyName")); @@ -1015,10 +952,7 @@ public void GetDictionary_WhenPropertyIsMissing_Throws() { RunTestInAllModes((realm, _) => { - var obj = realm.Write(() => - { - return realm.DynamicApi.CreateObject(nameof(SyncCollectionsObject), ObjectId.GenerateNewId()); - }); + var obj = realm.Write(() => realm.DynamicApi.CreateObject(nameof(SyncCollectionsObject), ObjectId.GenerateNewId())); var ex = Assert.Throws(() => obj.DynamicApi.GetDictionary("someprop"))!; Assert.That(ex.Message, Does.Contain("someprop")); @@ -1030,10 +964,7 @@ public void GetDictionary_WhenPropertyIsNotDictionary_Throws() { RunTestInAllModes((realm, _) => { - var obj = realm.Write(() => - { - return realm.DynamicApi.CreateObject(nameof(SyncCollectionsObject), ObjectId.GenerateNewId()); - }); + var obj = realm.Write(() => realm.DynamicApi.CreateObject(nameof(SyncCollectionsObject), ObjectId.GenerateNewId())); var ex = Assert.Throws(() => obj.DynamicApi.GetDictionary(nameof(SyncCollectionsObject.StringList)))!; Assert.That(ex.Message, Does.Contain("IList").And.Contain($"can't be accessed using {nameof(DynamicObjectApi.GetDictionary)}")); @@ -1045,10 +976,7 @@ public void GetDictionary_WhenCastToRealmValue_Works() { RunTestInAllModes((realm, _) => { - var obj = realm.Write(() => - { - return realm.DynamicApi.CreateObject(nameof(SyncCollectionsObject), ObjectId.GenerateNewId()); - }); + var obj = realm.Write(() => realm.DynamicApi.CreateObject(nameof(SyncCollectionsObject), ObjectId.GenerateNewId())); var stringDictionary = obj.DynamicApi.GetDictionary(nameof(SyncCollectionsObject.StringDict)); @@ -1075,10 +1003,7 @@ public void GetDictionary_WhenCastToWrongValue_Throws() { RunTestInAllModes((realm, _) => { - var obj = realm.Write(() => - { - return realm.DynamicApi.CreateObject(nameof(SyncCollectionsObject), ObjectId.GenerateNewId()); - }); + var obj = realm.Write(() => realm.DynamicApi.CreateObject(nameof(SyncCollectionsObject), ObjectId.GenerateNewId())); var stringDictionary = obj.DynamicApi.GetDictionary(nameof(SyncCollectionsObject.StringDict)); diff --git a/Tests/Realm.Tests/Database/DynamicEmbeddedTests.cs b/Tests/Realm.Tests/Database/DynamicEmbeddedTests.cs index 9bf6a8f037..288d55b2a7 100644 --- a/Tests/Realm.Tests/Database/DynamicEmbeddedTests.cs +++ b/Tests/Realm.Tests/Database/DynamicEmbeddedTests.cs @@ -16,10 +16,6 @@ // //////////////////////////////////////////////////////////////////////////// -using System; -using System.Collections.Generic; -using System.Linq; -using NUnit.Framework; #if TEST_WEAVER using TestAsymmetricObject = Realms.AsymmetricObject; using TestEmbeddedObject = Realms.EmbeddedObject; @@ -28,6 +24,10 @@ using TestEmbeddedObject = Realms.IEmbeddedObject; using TestRealmObject = Realms.IRealmObject; #endif +using System; +using System.Collections.Generic; +using System.Linq; +using NUnit.Framework; namespace Realms.Tests.Database { @@ -96,6 +96,11 @@ public void CreateObject_WhenEmbedded_CanAssignToParent() Assert.That(addedReport.DynamicApi.Get(nameof(CompletionReport.CompletionDate)), Is.EqualTo(now)); Assert.That(addedReport.DynamicApi.Get(nameof(CompletionReport.Remarks)), Is.EqualTo("success!")); + if (TestHelpers.IsAOTTarget) + { + return; + } + #if !UNITY var dynamicId = Guid.NewGuid().ToString(); var dynamicNow = DateTimeOffset.UtcNow; @@ -137,6 +142,11 @@ public void ListAdd_WhenEmbedded_Throws() Assert.That(ex.Message, Does.Contain($"{nameof(realm.DynamicApi)}.{nameof(realm.DynamicApi.AddEmbeddedObjectToList)}")); + if (TestHelpers.IsAOTTarget) + { + return; + } + #if !UNITY var dynamicEx = Assert.Throws(() => { @@ -171,6 +181,11 @@ public void DictionaryAdd_WhenEmbedded_Throws() Assert.That(ex.Message, Does.Contain($"{nameof(realm.DynamicApi)}.{nameof(realm.DynamicApi.AddEmbeddedObjectToDictionary)}")); + if (TestHelpers.IsAOTTarget) + { + return; + } + #if !UNITY var dynamicEx = Assert.Throws(() => { @@ -203,6 +218,11 @@ public void ListInsert_WhenEmbedded_Throws() Assert.That(ex.Message, Does.Contain($"{nameof(realm.DynamicApi)}.{nameof(realm.DynamicApi.InsertEmbeddedObjectInList)}")); + if (TestHelpers.IsAOTTarget) + { + return; + } + #if !UNITY var dynamicEx = Assert.Throws(() => { @@ -235,6 +255,11 @@ public void ListSet_WhenEmbedded_Throws() Assert.That(ex.Message, Does.Contain($"{nameof(realm.DynamicApi)}.{nameof(realm.DynamicApi.SetEmbeddedObjectInList)}")); + if (TestHelpers.IsAOTTarget) + { + return; + } + #if !UNITY var dynamicEx = Assert.Throws(() => { @@ -267,6 +292,11 @@ public void DictionarySet_WhenEmbedded_Throws() Assert.That(ex.Message, Does.Contain($"{nameof(realm.DynamicApi)}.{nameof(realm.DynamicApi.SetEmbeddedObjectInDictionary)}")); + if (TestHelpers.IsAOTTarget) + { + return; + } + #if !UNITY var dynamicEx = Assert.Throws(() => { @@ -322,6 +352,11 @@ public void RealmAddEmbeddedObjectToList() Assert.That(addedSubSubTasks.Count, Is.EqualTo(1)); Assert.That(addedSubSubTasks[0].DynamicApi.Get(nameof(DynamicSubSubTask.Summary)), Is.EqualTo("This is subtask level 2")); + if (TestHelpers.IsAOTTarget) + { + return; + } + #if !UNITY var dynamicId = Guid.NewGuid().ToString(); @@ -395,6 +430,11 @@ public void RealmAddEmbeddedObjectToDictionary() return; } + if (TestHelpers.IsAOTTarget) + { + return; + } + #if !UNITY var dynamicId = Guid.NewGuid().ToString(); @@ -463,6 +503,11 @@ public void RealmInsertEmbeddedObjectInList() Assert.That(subTasks[1].DynamicApi.Get(nameof(DynamicSubTask.Summary)), Is.EqualTo("This is now at 1")); Assert.That(subTasks[2].DynamicApi.Get(nameof(DynamicSubTask.Summary)), Is.EqualTo("This is now at 2")); + if (TestHelpers.IsAOTTarget) + { + return; + } + #if !UNITY var dynamicId = Guid.NewGuid().ToString(); @@ -539,6 +584,11 @@ public void RealmSetEmbeddedObjectInList() Assert.That(addedSubTasks[1].DynamicApi.Get(nameof(DynamicSubTask.Summary)), Is.EqualTo("new at 1")); Assert.That(addedSubTasks[2].DynamicApi.Get(nameof(DynamicSubTask.Summary)), Is.EqualTo("initial at 2")); + if (TestHelpers.IsAOTTarget) + { + return; + } + #if !UNITY var dynamicId = Guid.NewGuid().ToString(); @@ -620,6 +670,11 @@ public void RealmSetEmbeddedObjectInDictionary() return; } + if (TestHelpers.IsAOTTarget) + { + return; + } + #if !UNITY var dynamicId = Guid.NewGuid().ToString(); @@ -682,6 +737,11 @@ public void RealmSetEmbeddedObjectInList_WhenOutOfBounds_Throws() }); }); + if (TestHelpers.IsAOTTarget) + { + return; + } + #if !UNITY Assert.Throws(() => { @@ -718,7 +778,12 @@ public void RealmAddEmbeddedObjectInDictionary_WhenDuplicateKeys_Throws() realm.DynamicApi.AddEmbeddedObjectToDictionary(dict, "foo"); realm.DynamicApi.AddEmbeddedObjectToDictionary(dict, "foo"); }); - }, $"An item with the key 'foo' has already been added."); + }, "An item with the key 'foo' has already been added."); + + if (TestHelpers.IsAOTTarget) + { + return; + } #if !UNITY Assert.Throws(() => @@ -762,6 +827,11 @@ public void RealmInsertEmbeddedObjectInList_WhenOutOfBounds_Throws() }); }); + if (TestHelpers.IsAOTTarget) + { + return; + } + #if !UNITY Assert.Throws(() => { @@ -817,6 +887,11 @@ public void List_RemoveAt() Assert.That(list.Count, Is.EqualTo(1)); Assert.That(list[0].DynamicApi.Get(nameof(DynamicSubTask.Summary)), Is.EqualTo("second")); + if (TestHelpers.IsAOTTarget) + { + return; + } + #if !UNITY var dynamicId = Guid.NewGuid().ToString(); @@ -883,6 +958,11 @@ public void List_Remove() Assert.That(subTasks.Count, Is.EqualTo(0)); + if (TestHelpers.IsAOTTarget) + { + return; + } + #if !UNITY var dynamicId = Guid.NewGuid().ToString(); @@ -960,6 +1040,11 @@ public void Dictionary_Remove() Assert.That(dict.Count, Is.EqualTo(0)); + if (TestHelpers.IsAOTTarget) + { + return; + } + #if !UNITY var dynamicId = Guid.NewGuid().ToString(); @@ -1035,6 +1120,11 @@ public void Embedded_Backlinks() Assert.That(parentSubTask2.Count(), Is.EqualTo(1)); Assert.That(parentSubTask2.Single(), Is.EqualTo(addedSubTask)); + if (TestHelpers.IsAOTTarget) + { + return; + } + #if !UNITY var dynamicId = Guid.NewGuid().ToString(); realm.Write(() => @@ -1087,6 +1177,11 @@ public void Embedded_DynamicBacklinks() Assert.That(reportParents.Count(), Is.EqualTo(1)); Assert.That(reportParents.Single(), Is.EqualTo(addedTask)); + if (TestHelpers.IsAOTTarget) + { + return; + } + #if !UNITY var dynamicId = Guid.NewGuid().ToString(); realm.Write(() => diff --git a/Tests/Realm.Tests/Database/EmbeddedObjectsTests.cs b/Tests/Realm.Tests/Database/EmbeddedObjectsTests.cs index 05d3e5827a..c722af7d19 100644 --- a/Tests/Realm.Tests/Database/EmbeddedObjectsTests.cs +++ b/Tests/Realm.Tests/Database/EmbeddedObjectsTests.cs @@ -919,6 +919,11 @@ public void DynamicBacklinks_NewAPI() Assert.That(recursiveObjViaBacklinks, Is.EqualTo(parent.RecursiveObject)); Assert.That(recursiveObjViaBacklinks.DynamicApi.Get(nameof(EmbeddedLevel1.String)), Is.EqualTo("level 1")); + if (TestHelpers.IsAOTTarget) + { + return; + } + #if !UNITY dynamic dynamicParentViaBacklinks = topLevelBacklinks.Single(); Assert.That(dynamicParentViaBacklinks, Is.EqualTo(parent)); diff --git a/Tests/Realm.Tests/Database/InstanceTests.cs b/Tests/Realm.Tests/Database/InstanceTests.cs index 509d07f409..d9fbc03a43 100644 --- a/Tests/Realm.Tests/Database/InstanceTests.cs +++ b/Tests/Realm.Tests/Database/InstanceTests.cs @@ -16,6 +16,11 @@ // //////////////////////////////////////////////////////////////////////////// +#if TEST_WEAVER +using TestRealmObject = Realms.RealmObject; +#else +using TestRealmObject = Realms.IRealmObject; +#endif using System; using System.Collections.Generic; using System.Diagnostics; @@ -29,11 +34,6 @@ using Realms.Exceptions; using Realms.Logging; using Realms.Schema; -#if TEST_WEAVER -using TestRealmObject = Realms.RealmObject; -#else -using TestRealmObject = Realms.IRealmObject; -#endif namespace Realms.Tests.Database { @@ -761,8 +761,11 @@ public void GetInstance_WhenDynamic_ReadsSchemaFromDisk() Assert.That(ato.DynamicApi.Get(nameof(AllTypesObject.RequiredStringProperty)), Is.EqualTo("This is required!")); #if !UNITY - dynamic dynamicAto = dynamicRealm.DynamicApi.All(nameof(AllTypesObject)).Single(); - Assert.That(dynamicAto.RequiredStringProperty, Is.EqualTo("This is required!")); + if (!TestHelpers.IsAOTTarget) + { + dynamic dynamicAto = dynamicRealm.DynamicApi.All(nameof(AllTypesObject)).Single(); + Assert.That(dynamicAto.RequiredStringProperty, Is.EqualTo("This is required!")); + } #endif Assert.That(dynamicRealm.Schema.TryFindObjectSchema(nameof(EmbeddedAllTypesObject), out var embeddedAllTypesSchema), Is.True); @@ -777,8 +780,11 @@ public void GetInstance_WhenDynamic_ReadsSchemaFromDisk() Assert.That(embeddedChild.DynamicApi.Get(nameof(EmbeddedAllTypesObject.StringProperty)), Is.EqualTo("This is not required!")); #if !UNITY - dynamic dynamicEmbeddedParent = dynamicRealm.DynamicApi.All(nameof(ObjectWithEmbeddedProperties)).Single(); - Assert.That(dynamicEmbeddedParent.AllTypesObject.StringProperty, Is.EqualTo("This is not required!")); + if (!TestHelpers.IsAOTTarget) + { + dynamic dynamicEmbeddedParent = dynamicRealm.DynamicApi.All(nameof(ObjectWithEmbeddedProperties)).Single(); + Assert.That(dynamicEmbeddedParent.AllTypesObject.StringProperty, Is.EqualTo("This is not required!")); + } #endif } diff --git a/Tests/Realm.Tests/Database/MigrationTests.cs b/Tests/Realm.Tests/Database/MigrationTests.cs index 20ab122c9d..105a06ef36 100644 --- a/Tests/Realm.Tests/Database/MigrationTests.cs +++ b/Tests/Realm.Tests/Database/MigrationTests.cs @@ -16,13 +16,6 @@ // //////////////////////////////////////////////////////////////////////////// -using System; -using System.Collections.Generic; -using System.Linq; -using NUnit.Framework; -using Realms.Exceptions; -using Realms.Extensions; -using Realms.Schema; #if TEST_WEAVER using TestEmbeddedObject = Realms.EmbeddedObject; using TestRealmObject = Realms.RealmObject; @@ -30,6 +23,13 @@ using TestEmbeddedObject = Realms.IEmbeddedObject; using TestRealmObject = Realms.IRealmObject; #endif +using System; +using System.Collections.Generic; +using System.Linq; +using NUnit.Framework; +using Realms.Exceptions; +using Realms.Extensions; +using Realms.Schema; namespace Realms.Tests.Database { @@ -90,9 +90,12 @@ public void TriggerMigrationBySchemaEditing() newPerson.LastName = triggersSchemaFieldValue = oldPerson.DynamicApi.Get("TriggersSchema"); #if !UNITY - // Ensure we can still use the dynamic API during migrations - dynamic dynamicOldPerson = oldPeople.ElementAt(i); - Assert.That(dynamicOldPerson.TriggersSchema, Is.EqualTo(oldPerson.DynamicApi.Get("TriggersSchema"))); + if (!TestHelpers.IsAOTTarget) + { + // Ensure we can still use the dynamic API during migrations + dynamic dynamicOldPerson = oldPeople.ElementAt(i); + Assert.That(dynamicOldPerson.TriggersSchema, Is.EqualTo(oldPerson.DynamicApi.Get("TriggersSchema"))); + } #endif } } diff --git a/Tests/Realm.Tests/Database/PrimaryKeyTests.cs b/Tests/Realm.Tests/Database/PrimaryKeyTests.cs index af372e9d90..d6839aac9c 100644 --- a/Tests/Realm.Tests/Database/PrimaryKeyTests.cs +++ b/Tests/Realm.Tests/Database/PrimaryKeyTests.cs @@ -154,6 +154,11 @@ public void UpdatePrimaryKey_DynamicTests(Type type, object firstValue, object s Assert.That(ex.Message, Does.Contain(Operator.Convert(firstValue).ToString())); Assert.That(ex.Message, Does.Contain(Operator.Convert(secondValue).ToString())); + if (TestHelpers.IsAOTTarget) + { + return; + } + #if !UNITY dynamic dynamicObj = obj; @@ -165,7 +170,7 @@ public void UpdatePrimaryKey_DynamicTests(Type type, object firstValue, object s Assert.That(ex.Message, Does.Contain(Operator.Convert(firstValue).ToString())); Assert.That(ex.Message, Does.Contain(Operator.Convert(secondValue).ToString())); - void SetDynamicValue(object value) + void SetDynamicValue(object? value) { _realm.Write(() => { diff --git a/Tests/Realm.Tests/Sync/AppTests.cs b/Tests/Realm.Tests/Sync/AppTests.cs index 271bb10c31..4b89bd8926 100644 --- a/Tests/Realm.Tests/Sync/AppTests.cs +++ b/Tests/Realm.Tests/Sync/AppTests.cs @@ -85,7 +85,7 @@ static void AssertBundleId(params string?[] expectedValues) break; case "iOS": Assert.That(Platform.DeviceInfo.Name, Is.EqualTo("iPhone"), "Name"); - Assert.That(Platform.DeviceInfo.Version, Does.Contain("iPhone").Or.EqualTo("x86_64"), "Version"); + Assert.That(Platform.DeviceInfo.Version, Does.Contain("iPhone").Or.EqualTo("x86_64").Or.EqualTo("arm64"), "Version"); AssertBundleId("Tests.iOS", "Tests.Maui"); break; case "Android": diff --git a/Tests/Realm.Tests/Sync/AsymmetricObjectTests.cs b/Tests/Realm.Tests/Sync/AsymmetricObjectTests.cs index cea99a78f0..cab3fad4ea 100644 --- a/Tests/Realm.Tests/Sync/AsymmetricObjectTests.cs +++ b/Tests/Realm.Tests/Sync/AsymmetricObjectTests.cs @@ -16,6 +16,11 @@ // //////////////////////////////////////////////////////////////////////////// +#if TEST_WEAVER +using TestAsymmetricObject = Realms.AsymmetricObject; +#else +using TestAsymmetricObject = Realms.IAsymmetricObject; +#endif using System; using System.Collections.Generic; using System.Linq; @@ -23,15 +28,9 @@ using Baas; using MongoDB.Bson; using NUnit.Framework; -using NUnit.Framework.Internal; using Realms.Dynamic; using Realms.Exceptions; using Realms.Sync; -#if TEST_WEAVER -using TestAsymmetricObject = Realms.AsymmetricObject; -#else -using TestAsymmetricObject = Realms.IAsymmetricObject; -#endif namespace Realms.Tests.Sync { @@ -608,6 +607,11 @@ public void DynamicAccess([Values(true, false)] bool isDynamic) Assert.That(asymmetricObj.DynamicApi.Get(nameof(AllTypesObject.StringProperty)), Is.EqualTo("o")); }); + if (TestHelpers.IsAOTTarget) + { + return; + } + #if !UNITY realm.Write(() => { diff --git a/Tests/Tests.Maui/Tests.Maui.csproj b/Tests/Tests.Maui/Tests.Maui.csproj index 425fb6e55a..1286850e4f 100644 --- a/Tests/Tests.Maui/Tests.Maui.csproj +++ b/Tests/Tests.Maui/Tests.Maui.csproj @@ -23,7 +23,7 @@ 1 - True + True 11.0 13.2 From dedfcbe8dbcd92c2fee25f3b985755df82fd8713 Mon Sep 17 00:00:00 2001 From: Nikola Irinchev Date: Wed, 22 May 2024 23:18:13 +0200 Subject: [PATCH 23/39] Revert some changes --- .github/pkl-workflows/helpers/BaaS.pkl | 4 +- .github/pkl-workflows/helpers/Lint.pkl | 4 +- .github/pkl-workflows/helpers/Steps.pkl | 35 ++-- .github/pkl-workflows/helpers/Test.pkl | 44 ++-- .github/pkl-workflows/wrappers.pkl | 4 +- .github/workflows/pr.yml | 189 +++++------------- .../Database/DynamicAccessTests.cs | 14 -- .../Database/DynamicEmbeddedTests.cs | 117 +---------- .../Database/EmbeddedObjectsTests.cs | 5 - Tests/Realm.Tests/Database/InstanceTests.cs | 14 +- Tests/Realm.Tests/Database/MigrationTests.cs | 9 +- Tests/Realm.Tests/Database/PrimaryKeyTests.cs | 5 - .../Realm.Tests/Sync/AsymmetricObjectTests.cs | 5 - 13 files changed, 109 insertions(+), 340 deletions(-) diff --git a/.github/pkl-workflows/helpers/BaaS.pkl b/.github/pkl-workflows/helpers/BaaS.pkl index dfe2cb492c..84c4c245b6 100644 --- a/.github/pkl-workflows/helpers/BaaS.pkl +++ b/.github/pkl-workflows/helpers/BaaS.pkl @@ -14,7 +14,7 @@ function deploy(differentiators: Listing): gha.Matrix } `if` = Common.ifNotCanceledCondition steps { - ...Steps.checkout() + ...Steps.checkout(false) Steps.setupDotnet("6.0.x") ...deployStep("${{ matrix.differentiator }}", true) } @@ -36,7 +36,7 @@ function cleanup(differentiators: Listing): gha.Matri } `if` = Common.ifNotCanceledCondition steps { - ...Steps.checkout() + ...Steps.checkout(false) Steps.setupDotnet("6.0.x") new gha.Step { name = "Terminate Baas" diff --git a/.github/pkl-workflows/helpers/Lint.pkl b/.github/pkl-workflows/helpers/Lint.pkl index 0af1c4cd93..4c5aaec21a 100644 --- a/.github/pkl-workflows/helpers/Lint.pkl +++ b/.github/pkl-workflows/helpers/Lint.pkl @@ -8,7 +8,7 @@ function lint(): gha.Job = new { name = "Verify TODOs" `runs-on` = new gha.UbuntuLatest{} steps { - Steps.checkoutWithoutMatchers() + Steps.checkoutWithoutMatchers(false) new gha.Step { uses = "nirinchev/verify-todo@9be6f76daddad71433e5deb1b58c517490e5c66e" with { @@ -28,7 +28,7 @@ function verifyNamespaces(): gha.Job = new { Common.job_Packages } steps { - Steps.checkoutWithoutMatchers() + Steps.checkoutWithoutMatchers(false) ...Steps.fetchPackages(Common.job_Packages, null) new { run = "dotnet tool install ilspycmd -g --version 8.0.0.7345" diff --git a/.github/pkl-workflows/helpers/Steps.pkl b/.github/pkl-workflows/helpers/Steps.pkl index f30426900f..ce297a4e5a 100644 --- a/.github/pkl-workflows/helpers/Steps.pkl +++ b/.github/pkl-workflows/helpers/Steps.pkl @@ -5,24 +5,30 @@ const actionRunSimulator = "realm/ci-actions/run-ios-simulator@6418e15ed9bbdb19b const actionSetupJDK = "actions/setup-java@0ab4596768b603586c0de567f2430c30f5b0d2b0" const actionAWSConfigureCredentials = "aws-actions/configure-aws-credentials@v4.0.2" const actionCoveralls = "coverallsapp/github-action@v2.3.0" - -const function checkout(): Listing = new Listing { - checkoutWithoutMatchers() +const actionCheckout = "actions/checkout@v4" +const actionUploadArtifact = "actions/upload-artifact@v4" +const actionDownloadArtifact = "actions/download-artifact@v4" +const actionSetupXcode = "maxim-lobanov/setup-xcode@60606e260d2fc5762a71e64e74b2174e8ea3c8bd" +const actionSetupDotnet = "actions/setup-dotnet@607fce577a46308457984d59e4954e075820f10a" +const actionSetupMsBuild = "microsoft/setup-msbuild@0b44c6745b7e81956596964100aadb92d667c497" + +const function checkout(submodules: (Boolean | "recursive")): Listing = new Listing { + checkoutWithoutMatchers(submodules) registerProblemMatchers() } -const function checkoutWithoutMatchers(): gha.Step = new { +const function checkoutWithoutMatchers(submodules: (Boolean | "recursive")): gha.Step = new { name = "Checkout Code" - uses = "actions/checkout@v4" + uses = actionCheckout with { - ["submodules"] = "recursive" + ["submodules"] = submodules ["ref"] = "${{ github.event.pull_request.head.sha }}" } } const function uploadArtifacts(artifactName: String, relPath: String): gha.Step = new { name = "Store artifacts for \(artifactName)" - uses = "actions/upload-artifact@v4" + uses = actionUploadArtifact with { ["name"] = artifactName ["path"] = "${{ github.workspace }}/\(relPath)" @@ -33,7 +39,7 @@ const function uploadArtifacts(artifactName: String, relPath: String): gha.Step const function setupXcode(version: String): gha.Step = new gha.Step { name = "Setup Xcode" - uses = "maxim-lobanov/setup-xcode@60606e260d2fc5762a71e64e74b2174e8ea3c8bd" + uses = actionSetupXcode with { ["xcode-version"] = version } @@ -46,14 +52,14 @@ const function setupMSVC(edition: String): gha.Step = new { } const function setupDotnet(version: String?): gha.Step = new { - uses = "actions/setup-dotnet@607fce577a46308457984d59e4954e075820f10a" + uses = actionSetupDotnet with { ["dotnet-version"] = version ?? "8.0.x" } } const function registerProblemMatchers(): gha.Step = new { - name = "Register csc problem matcher" + name = "Register problem matchers" run = """ echo "::add-matcher::.github/problem-matchers/csc.json" echo "::add-matcher::.github/problem-matchers/msvc.json" @@ -62,16 +68,16 @@ const function registerProblemMatchers(): gha.Step = new { const function fetchPackages(packageJob: String, _packages: List?): List = (_packages ?? Common.packages).map((package) -> new gha.Step { name = "Fetch \(package)" - uses = "actions/download-artifact@v4" + uses = actionDownloadArtifact with { ["name"] = "\(package).${{ needs.\(packageJob).outputs.package_version }}" ["path"] = "${{ github.workspace }}/Realm/packages/" } }) -const function fetchWrappers(): List = Common.wrapperBinaryNames.map((wrapper) -> new gha.Step { +const function fetchWrappers(wrappers: List(every((wrapper) -> Common.wrapperBinaryNames.contains(wrapper)))): List = wrappers.map((wrapper) -> new gha.Step { name = "Fetch wrappers for \(wrapper)" - uses = "actions/download-artifact@v4" + uses = actionDownloadArtifact with { ["name"] = "wrappers-\(wrapper)" ["path"] = "wrappers/build" @@ -109,6 +115,7 @@ class MSBuildConfig { project: String target: String? properties: Mapping = new Mapping{} + standaloneExe: Boolean = false function getTargetForInvocation(): String = if (target != null) " -t:\(target)" else "" function getPropertiesForInvocation(): String = "-p:Configuration=\(Common.configuration)\(propertiesToString(properties))" @@ -194,7 +201,7 @@ class DeviceFarmConfig { local const function addMSBuildToPath(): gha.Step = new { name = "Add msbuild to PATH" - uses = "microsoft/setup-msbuild@0b44c6745b7e81956596964100aadb92d667c497" + uses = actionSetupMsBuild `if` = "${{ runner.os == 'Windows' }}" } diff --git a/.github/pkl-workflows/helpers/Test.pkl b/.github/pkl-workflows/helpers/Test.pkl index 5453bbe264..e4928a009e 100644 --- a/.github/pkl-workflows/helpers/Test.pkl +++ b/.github/pkl-workflows/helpers/Test.pkl @@ -73,7 +73,7 @@ function netCore(frameworks: Listing): gha.StepJobBase = te shell = "bash" } Steps.setupDotnet("${{ steps.get-net-version.outputs.version }}") - ...Steps.dotnetPublish("Tests/Realm.Tests", "${{ matrix.framework }}", "${{ matrix.os.runtime }}", getTestProps()) + ...Steps.dotnetPublish("Tests/Realm.Tests", "${{ matrix.framework }}", "${{ matrix.os.runtime }}", getTestProps(true)) ...dotnetRunTests(true) ...reportTestResults(config) }) @@ -94,7 +94,7 @@ function weaver(): gha.StepJobBase = testJob( } }, (config) -> new Listing { - ...Steps.checkout() + ...Steps.checkout(false) ...Steps.setupWorkloads(null, "6.0.x") ...Steps.dotnetPublish("Tests/Weaver/Realm.Fody.Tests", "net6.0", "${{ matrix.os.runtime }}", new Mapping{}).toList() ...dotnetRunTests(false) @@ -109,7 +109,7 @@ function sourceGeneration(): gha.StepJobBase = testJob( new gha.WindowsLatest{}, null, (config) -> new Listing { - ...Steps.checkout() + ...Steps.checkout(false) ...Steps.setupWorkloads(null, "6.0.x") ...Steps.dotnetPublish("Tests/SourceGenerators/Realm.SourceGenerator.Tests", "net6.0", "win-x64", new Mapping{}).toList() ...dotnetRunTests(false) @@ -125,7 +125,7 @@ function wovenClasses(): gha.StepJobBase = testJob( null, (config) -> new Listing { ...prepareTests(config) - ...Steps.dotnetPublish("Tests/Realm.Tests", "net8.0", "win-x64", (getTestProps()) { + ...Steps.dotnetPublish("Tests/Realm.Tests", "net8.0", "win-x64", (getTestProps(true)) { ["TestWeavedClasses"] = "true" }) ...dotnetRunTests(false) @@ -193,15 +193,15 @@ function iOS_Maui(_syncDifferentiators: Listing): gha syncDifferentiators = _syncDifferentiators transformResults = true }, - "macos-14", + "macos-13", null, (config) -> new Listing { ...prepareTests(config) ...Steps.setupWorkloads("maui", null) Steps.setupXcode("latest-stable") - Steps.dotnetBuild("Tests/Tests.Maui", "net8.0-ios", null, getTestProps()) + Steps.dotnetBuild("Tests/Tests.Maui", "net8.0-ios", null, getTestProps(false)) Steps.runSimulator(new Steps.SimulatorConfig{ - appPath = "Tests/Tests.Maui/bin/\(Common.configuration)/net8.0-ios/iossimulator-arm64/Tests.Maui.app" + appPath = "Tests/Tests.Maui/bin/\(Common.configuration)/net8.0-ios/iossimulator-x64/Tests.Maui.app" arguments = "--headless --result=${{ github.workspace }}/\(outputFile) --labels=All \(baasTestArgs(config))" bundleId = "io.realm.mauitests" iphoneToSimulate = "iPhone-15" @@ -237,16 +237,16 @@ function macOS_Maui(_syncDifferentiators: Listing): g syncDifferentiators = _syncDifferentiators transformResults = true }, - "macos-14", + "macos-13", null, (config) -> new Listing { ...prepareTests(config) ...Steps.setupWorkloads("maui", null) Steps.setupXcode("latest-stable") - Steps.dotnetBuild("Tests/Tests.Maui", "net8.0-maccatalyst", null, getTestProps()) + Steps.dotnetBuild("Tests/Tests.Maui", "net8.0-maccatalyst", null, getTestProps(false)) new { name = "Run the tests" - run = "Tests/Tests.Maui/bin/\(Common.configuration)/net8.0-maccatalyst/maccatalyst-arm64/Tests.Maui.app/Contents/MacOS/Tests.Maui --headless --result=${{ github.workspace }}/\(outputFile) --labels=All \(baasTestArgs(config))" + run = "Tests/Tests.Maui/bin/\(Common.configuration)/net8.0-maccatalyst/maccatalyst-x64/Tests.Maui.app/Contents/MacOS/Tests.Maui --headless --result=${{ github.workspace }}/\(outputFile) --labels=All \(baasTestArgs(config))" } ...reportTestResults(config) }) @@ -329,7 +329,7 @@ function android_Maui(_syncDifferentiators: Listing): Steps.setupJDK() ...prepareTests(config) ...Steps.setupWorkloads("maui", null) - ...Steps.dotnetPublish("Tests/Tests.Maui", "net8.0-android", /* runtime */ null, getTestProps()) + ...Steps.dotnetPublish("Tests/Tests.Maui", "net8.0-android", /* runtime */ null, getTestProps(false)) ...Steps.runDeviceFarm(new Steps.DeviceFarmConfig { apkPath = "${{ github.workspace }}/Tests/Tests.Maui/bin/Release/net8.0-android/publish/io.realm.mauitests-Signed.apk" appId = "io.realm.mauitests" @@ -342,7 +342,7 @@ function codeCoverage(wrappersJob: String, _syncDifferentiators: Listing = new Listing { - ...Steps.checkout() +local function prepareTests(config: TestConfig(needsPackages == true || !usedWrappers.isEmpty)): Listing = new Listing { + ...Steps.checkout(false) ...cleanWorkspace(config.shouldCleanWorkspace) - ...fetchTestArtifacts(Common.job_Packages, config.useWrappers) + ...fetchTestArtifacts(Common.job_Packages, config.usedWrappers) ...BaaS.deployStep(config.syncDifferentiator, config.runSyncTests) } @@ -405,13 +405,13 @@ local function cleanWorkspace(shouldClean: Boolean): Listing = new Lis } } -local function fetchTestArtifacts(packageJob: String, useWrappers: Boolean): List = if (useWrappers) - Steps.fetchWrappers() +local function fetchTestArtifacts(packageJob: String, wrappers: List(every((wrapper) -> Common.wrapperBinaryNames.contains(wrapper)))): List = + if (!wrappers.isEmpty) Steps.fetchWrappers(wrappers) else Steps.fetchPackages(packageJob, Common.nugetPackages) local function buildTests(config: Steps.MSBuildConfig): List = Steps.msbuild((config) { properties { - ...getTestProps() + ...getTestProps(config.standaloneExe) } }) @@ -442,10 +442,12 @@ local function reportTestResultsWithCustomFile(_outputFile: String, config: Test } } -local function getTestProps(): Mapping = new Mapping { +local function getTestProps(standaloneExe: Boolean): Mapping = new Mapping { ["RestoreConfigFile"] = "Tests/Test.NuGet.Config" ["UseRealmNupkgsWithVersion"] = "${{ needs.\(Common.job_Packages).outputs.package_version }}" - ["RealmTestsStandaloneExe"] = "true" + when (standaloneExe) { + ["RealmTestsStandaloneExe"] = "true" + } } local function dotnetRunTests(enableCoreDumps: Boolean): Listing = new Listing { @@ -485,7 +487,7 @@ local class MatrixOS { local class TestConfig { title: String needsPackages: Boolean = false - useWrappers: Boolean = false + usedWrappers: List(every((wrapper) -> Common.wrapperBinaryNames.contains(wrapper))) shouldCleanWorkspace: Boolean = false syncDifferentiator: Common.SyncDifferentiator? = null transformResults: Boolean = false diff --git a/.github/pkl-workflows/wrappers.pkl b/.github/pkl-workflows/wrappers.pkl index d1380df8b4..24a4bee71b 100644 --- a/.github/pkl-workflows/wrappers.pkl +++ b/.github/pkl-workflows/wrappers.pkl @@ -38,7 +38,7 @@ jobs { .toMap((platform) -> "wrappers-\(platform)",(platform) -> "${{ steps.check-cache-\(platform).outputs.cache-hit }}") .toMapping() steps { - Steps.checkoutWithoutMatchers() + Steps.checkoutWithoutMatchers("recursive") for (platform in Common.wrapperBinaryNames) { restoreCache(platform) |> withCondition(platform, null) Steps.uploadArtifacts("wrappers-\(platform)", "wrappers/build/**") |> withCondition(platform, "steps.check-cache-\(platform).outputs.cache-hit == 'true'") @@ -176,7 +176,7 @@ local function wrappersJob(config: JobConfig) = new Mixin { } `if` = config.ifCondition steps { - Steps.checkoutWithoutMatchers() + Steps.checkoutWithoutMatchers("recursive") checkCache(config.platform) ...config.intermediateSteps.toList().map((step) -> (step) { `if` = WrappersCacheCondition diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index bd83e464c1..32baef8787 100755 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -37,9 +37,9 @@ jobs: - name: Checkout Code uses: actions/checkout@v4 with: - submodules: recursive + submodules: false ref: ${{ github.event.pull_request.head.sha }} - - name: Register csc problem matcher + - name: Register problem matchers run: |- echo "::add-matcher::.github/problem-matchers/csc.json" echo "::add-matcher::.github/problem-matchers/msvc.json" @@ -91,9 +91,9 @@ jobs: - name: Checkout Code uses: actions/checkout@v4 with: - submodules: recursive + submodules: false ref: ${{ github.event.pull_request.head.sha }} - - name: Register csc problem matcher + - name: Register problem matchers run: |- echo "::add-matcher::.github/problem-matchers/csc.json" echo "::add-matcher::.github/problem-matchers/msvc.json" @@ -111,7 +111,7 @@ jobs: if: ${{ runner.os == 'Windows' }} uses: microsoft/setup-msbuild@0b44c6745b7e81956596964100aadb92d667c497 - name: Build Tests/Realm.Tests - run: msbuild Tests/Realm.Tests -restore -p:Configuration=Release -p:TargetFramework=net461 -p:RestoreConfigFile=Tests/Test.NuGet.Config -p:UseRealmNupkgsWithVersion=${{ needs.build-packages.outputs.package_version }} -p:RealmTestsStandaloneExe=true + run: msbuild Tests/Realm.Tests -restore -p:Configuration=Release -p:TargetFramework=net461 -p:RestoreConfigFile=Tests/Test.NuGet.Config -p:UseRealmNupkgsWithVersion=${{ needs.build-packages.outputs.package_version }} - name: Run the tests run: './Tests/Realm.Tests/bin/Release/net461/Realm.Tests.exe --result=TestResults.xml --labels=After ' - name: Publish Unit Test Results @@ -135,9 +135,9 @@ jobs: - name: Checkout Code uses: actions/checkout@v4 with: - submodules: recursive + submodules: false ref: ${{ github.event.pull_request.head.sha }} - - name: Register csc problem matcher + - name: Register problem matchers run: |- echo "::add-matcher::.github/problem-matchers/csc.json" echo "::add-matcher::.github/problem-matchers/msvc.json" @@ -162,7 +162,7 @@ jobs: if: ${{ runner.os == 'Windows' }} uses: microsoft/setup-msbuild@0b44c6745b7e81956596964100aadb92d667c497 - name: Build Tests/Tests.UWP - run: msbuild Tests/Tests.UWP -restore -p:Configuration=Release -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 -p:RestoreConfigFile=Tests/Test.NuGet.Config -p:UseRealmNupkgsWithVersion=${{ needs.build-packages.outputs.package_version }} -p:RealmTestsStandaloneExe=true + run: msbuild Tests/Tests.UWP -restore -p:Configuration=Release -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 -p:RestoreConfigFile=Tests/Test.NuGet.Config -p:UseRealmNupkgsWithVersion=${{ needs.build-packages.outputs.package_version }} - name: Run the tests run: ./Tests/Tests.UWP/RunTests.ps1 -ExtraAppArgs '' shell: powershell @@ -187,9 +187,9 @@ jobs: - name: Checkout Code uses: actions/checkout@v4 with: - submodules: recursive + submodules: false ref: ${{ github.event.pull_request.head.sha }} - - name: Register csc problem matcher + - name: Register problem matchers run: |- echo "::add-matcher::.github/problem-matchers/csc.json" echo "::add-matcher::.github/problem-matchers/msvc.json" @@ -272,9 +272,9 @@ jobs: - name: Checkout Code uses: actions/checkout@v4 with: - submodules: recursive + submodules: false ref: ${{ github.event.pull_request.head.sha }} - - name: Register csc problem matcher + - name: Register problem matchers run: |- echo "::add-matcher::.github/problem-matchers/csc.json" echo "::add-matcher::.github/problem-matchers/msvc.json" @@ -292,7 +292,7 @@ jobs: if: ${{ runner.os == 'Windows' }} uses: microsoft/setup-msbuild@0b44c6745b7e81956596964100aadb92d667c497 - name: Build Tests/Tests.XamarinMac - run: msbuild Tests/Tests.XamarinMac -restore -p:Configuration=Release -p:RestoreConfigFile=Tests/Test.NuGet.Config -p:UseRealmNupkgsWithVersion=${{ needs.build-packages.outputs.package_version }} -p:RealmTestsStandaloneExe=true + run: msbuild Tests/Tests.XamarinMac -restore -p:Configuration=Release -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 --result=${{ github.workspace }}/TestResults.xml --labels=All - name: Publish Unit Test Results @@ -311,14 +311,14 @@ jobs: - build-packages if: always() && !cancelled() && !contains(needs.*.result, 'failure') && !contains(needs.*.result, 'cancelled') timeout-minutes: 60 - runs-on: macos-14 + runs-on: macos-13 steps: - name: Checkout Code uses: actions/checkout@v4 with: - submodules: recursive + submodules: false ref: ${{ github.event.pull_request.head.sha }} - - name: Register csc problem matcher + - name: Register problem matchers run: |- echo "::add-matcher::.github/problem-matchers/csc.json" echo "::add-matcher::.github/problem-matchers/msvc.json" @@ -342,9 +342,9 @@ jobs: with: xcode-version: latest-stable - name: Build Tests/Tests.Maui - run: dotnet build Tests/Tests.Maui -c Release -f net8.0-maccatalyst -p:RestoreConfigFile=Tests/Test.NuGet.Config -p:UseRealmNupkgsWithVersion=${{ needs.build-packages.outputs.package_version }} -p:RealmTestsStandaloneExe=true + run: dotnet build Tests/Tests.Maui -c Release -f net8.0-maccatalyst -p:RestoreConfigFile=Tests/Test.NuGet.Config -p:UseRealmNupkgsWithVersion=${{ needs.build-packages.outputs.package_version }} - name: Run the tests - run: 'Tests/Tests.Maui/bin/Release/net8.0-maccatalyst/maccatalyst-arm64/Tests.Maui.app/Contents/MacOS/Tests.Maui --headless --result=${{ github.workspace }}/TestResults.xml --labels=All ' + run: 'Tests/Tests.Maui/bin/Release/net8.0-maccatalyst/maccatalyst-x64/Tests.Maui.app/Contents/MacOS/Tests.Maui --headless --result=${{ github.workspace }}/TestResults.xml --labels=All ' - name: Transform Results run: xsltproc --output TestResults.xml_transformed.xml Tests/Realm.Tests/EmbeddedResources/nunit3-junit.xslt TestResults.xml - name: Publish Unit Test Results @@ -368,9 +368,9 @@ jobs: - name: Checkout Code uses: actions/checkout@v4 with: - submodules: recursive + submodules: false ref: ${{ github.event.pull_request.head.sha }} - - name: Register csc problem matcher + - name: Register problem matchers run: |- echo "::add-matcher::.github/problem-matchers/csc.json" echo "::add-matcher::.github/problem-matchers/msvc.json" @@ -388,7 +388,7 @@ jobs: if: ${{ runner.os == 'Windows' }} uses: microsoft/setup-msbuild@0b44c6745b7e81956596964100aadb92d667c497 - name: Build Tests/Tests.iOS - run: msbuild Tests/Tests.iOS -restore -p:Configuration=Release -p:Platform=iPhoneSimulator -p:RestoreConfigFile=Tests/Test.NuGet.Config -p:UseRealmNupkgsWithVersion=${{ needs.build-packages.outputs.package_version }} -p:RealmTestsStandaloneExe=true + run: msbuild Tests/Tests.iOS -restore -p:Configuration=Release -p:Platform=iPhoneSimulator -p:RestoreConfigFile=Tests/Test.NuGet.Config -p:UseRealmNupkgsWithVersion=${{ needs.build-packages.outputs.package_version }} - name: Run on Simulator uses: realm/ci-actions/run-ios-simulator@6418e15ed9bbdb19b7d456a347e5623779f95cdf with: @@ -413,14 +413,14 @@ jobs: - build-packages if: always() && !cancelled() && !contains(needs.*.result, 'failure') && !contains(needs.*.result, 'cancelled') timeout-minutes: 60 - runs-on: macos-14 + runs-on: macos-13 steps: - name: Checkout Code uses: actions/checkout@v4 with: - submodules: recursive + submodules: false ref: ${{ github.event.pull_request.head.sha }} - - name: Register csc problem matcher + - name: Register problem matchers run: |- echo "::add-matcher::.github/problem-matchers/csc.json" echo "::add-matcher::.github/problem-matchers/msvc.json" @@ -444,11 +444,11 @@ jobs: with: xcode-version: latest-stable - name: Build Tests/Tests.Maui - run: dotnet build Tests/Tests.Maui -c Release -f net8.0-ios -p:RestoreConfigFile=Tests/Test.NuGet.Config -p:UseRealmNupkgsWithVersion=${{ needs.build-packages.outputs.package_version }} -p:RealmTestsStandaloneExe=true + run: dotnet build Tests/Tests.Maui -c Release -f net8.0-ios -p:RestoreConfigFile=Tests/Test.NuGet.Config -p:UseRealmNupkgsWithVersion=${{ needs.build-packages.outputs.package_version }} - name: Run on Simulator uses: realm/ci-actions/run-ios-simulator@6418e15ed9bbdb19b7d456a347e5623779f95cdf with: - appPath: Tests/Tests.Maui/bin/Release/net8.0-ios/iossimulator-arm64/Tests.Maui.app + appPath: Tests/Tests.Maui/bin/Release/net8.0-ios/iossimulator-x64/Tests.Maui.app bundleId: io.realm.mauitests iphoneToSimulate: iPhone-15 arguments: '--headless --result=${{ github.workspace }}/TestResults.xml --labels=All ' @@ -476,9 +476,9 @@ jobs: - name: Checkout Code uses: actions/checkout@v4 with: - submodules: recursive + submodules: false ref: ${{ github.event.pull_request.head.sha }} - - name: Register csc problem matcher + - name: Register problem matchers run: |- echo "::add-matcher::.github/problem-matchers/csc.json" echo "::add-matcher::.github/problem-matchers/msvc.json" @@ -496,7 +496,7 @@ jobs: if: ${{ runner.os == 'Windows' }} uses: microsoft/setup-msbuild@0b44c6745b7e81956596964100aadb92d667c497 - name: Build Tests/Tests.XamarinTVOS - run: msbuild Tests/Tests.XamarinTVOS -restore -p:Configuration=Release -p:Platform=iPhoneSimulator -p:RestoreConfigFile=Tests/Test.NuGet.Config -p:UseRealmNupkgsWithVersion=${{ needs.build-packages.outputs.package_version }} -p:RealmTestsStandaloneExe=true + run: msbuild Tests/Tests.XamarinTVOS -restore -p:Configuration=Release -p:Platform=iPhoneSimulator -p:RestoreConfigFile=Tests/Test.NuGet.Config -p:UseRealmNupkgsWithVersion=${{ needs.build-packages.outputs.package_version }} - name: Run on Simulator uses: realm/ci-actions/run-ios-simulator@6418e15ed9bbdb19b7d456a347e5623779f95cdf with: @@ -531,9 +531,9 @@ jobs: - name: Checkout Code uses: actions/checkout@v4 with: - submodules: recursive + submodules: false ref: ${{ github.event.pull_request.head.sha }} - - name: Register csc problem matcher + - name: Register problem matchers run: |- echo "::add-matcher::.github/problem-matchers/csc.json" echo "::add-matcher::.github/problem-matchers/msvc.json" @@ -551,7 +551,7 @@ jobs: if: ${{ runner.os == 'Windows' }} uses: microsoft/setup-msbuild@0b44c6745b7e81956596964100aadb92d667c497 - name: Build Tests/Tests.Android - run: msbuild Tests/Tests.Android -t:SignAndroidPackage -restore -p:Configuration=Release -p:AndroidUseSharedRuntime=False -p:EmbedAssembliesIntoApk=True -p:RestoreConfigFile=Tests/Test.NuGet.Config -p:UseRealmNupkgsWithVersion=${{ needs.build-packages.outputs.package_version }} -p:RealmTestsStandaloneExe=true + run: msbuild Tests/Tests.Android -t:SignAndroidPackage -restore -p:Configuration=Release -p:AndroidUseSharedRuntime=False -p:EmbedAssembliesIntoApk=True -p:RestoreConfigFile=Tests/Test.NuGet.Config -p:UseRealmNupkgsWithVersion=${{ needs.build-packages.outputs.package_version }} - name: Configure AWS Credentials uses: aws-actions/configure-aws-credentials@v4.0.2 with: @@ -592,9 +592,9 @@ jobs: - name: Checkout Code uses: actions/checkout@v4 with: - submodules: recursive + submodules: false ref: ${{ github.event.pull_request.head.sha }} - - name: Register csc problem matcher + - name: Register problem matchers run: |- echo "::add-matcher::.github/problem-matchers/csc.json" echo "::add-matcher::.github/problem-matchers/msvc.json" @@ -614,7 +614,7 @@ jobs: - name: Setup workloads run: dotnet workload install maui - name: Publish Tests/Tests.Maui - run: dotnet publish Tests/Tests.Maui -c Release -f net8.0-android -p:RestoreConfigFile=Tests/Test.NuGet.Config -p:UseRealmNupkgsWithVersion=${{ needs.build-packages.outputs.package_version }} -p:RealmTestsStandaloneExe=true --no-self-contained + run: dotnet publish Tests/Tests.Maui -c Release -f net8.0-android -p:RestoreConfigFile=Tests/Test.NuGet.Config -p:UseRealmNupkgsWithVersion=${{ needs.build-packages.outputs.package_version }} --no-self-contained - name: Output executable path id: dotnet-publish run: echo 'executable-path=./Tests/Tests.Maui/bin/Release/net8.0-android/null/Tests.Maui' >> $GITHUB_OUTPUT @@ -656,9 +656,9 @@ jobs: - name: Checkout Code uses: actions/checkout@v4 with: - submodules: recursive + submodules: false ref: ${{ github.event.pull_request.head.sha }} - - name: Register csc problem matcher + - name: Register problem matchers run: |- echo "::add-matcher::.github/problem-matchers/csc.json" echo "::add-matcher::.github/problem-matchers/msvc.json" @@ -699,9 +699,9 @@ jobs: - name: Checkout Code uses: actions/checkout@v4 with: - submodules: recursive + submodules: false ref: ${{ github.event.pull_request.head.sha }} - - name: Register csc problem matcher + - name: Register problem matchers run: |- echo "::add-matcher::.github/problem-matchers/csc.json" echo "::add-matcher::.github/problem-matchers/msvc.json" @@ -737,9 +737,9 @@ jobs: - name: Checkout Code uses: actions/checkout@v4 with: - submodules: recursive + submodules: false ref: ${{ github.event.pull_request.head.sha }} - - name: Register csc problem matcher + - name: Register problem matchers run: |- echo "::add-matcher::.github/problem-matchers/csc.json" echo "::add-matcher::.github/problem-matchers/msvc.json" @@ -787,112 +787,17 @@ jobs: - name: Checkout Code uses: actions/checkout@v4 with: - submodules: recursive + submodules: false ref: ${{ github.event.pull_request.head.sha }} - - name: Register csc problem matcher + - name: Register problem matchers run: |- echo "::add-matcher::.github/problem-matchers/csc.json" echo "::add-matcher::.github/problem-matchers/msvc.json" - - name: Fetch wrappers for macos - uses: actions/download-artifact@v4 - with: - name: wrappers-macos - path: wrappers/build - - name: Fetch wrappers for catalyst - uses: actions/download-artifact@v4 - with: - name: wrappers-catalyst - path: wrappers/build - name: Fetch wrappers for linux-x86_64 uses: actions/download-artifact@v4 with: name: wrappers-linux-x86_64 path: wrappers/build - - name: Fetch wrappers for linux-armhf - uses: actions/download-artifact@v4 - with: - name: wrappers-linux-armhf - path: wrappers/build - - name: Fetch wrappers for linux-aarch64 - uses: actions/download-artifact@v4 - with: - name: wrappers-linux-aarch64 - path: wrappers/build - - name: Fetch wrappers for android-armeabi-v7a - uses: actions/download-artifact@v4 - with: - name: wrappers-android-armeabi-v7a - path: wrappers/build - - name: Fetch wrappers for android-arm64-v8a - uses: actions/download-artifact@v4 - with: - name: wrappers-android-arm64-v8a - path: wrappers/build - - name: Fetch wrappers for android-x86 - uses: actions/download-artifact@v4 - with: - name: wrappers-android-x86 - path: wrappers/build - - name: Fetch wrappers for android-x86_64 - uses: actions/download-artifact@v4 - with: - name: wrappers-android-x86_64 - path: wrappers/build - - name: Fetch wrappers for windows-Win32 - uses: actions/download-artifact@v4 - with: - name: wrappers-windows-Win32 - path: wrappers/build - - name: Fetch wrappers for windows-x64 - uses: actions/download-artifact@v4 - with: - name: wrappers-windows-x64 - path: wrappers/build - - name: Fetch wrappers for windows-ARM64 - uses: actions/download-artifact@v4 - with: - name: wrappers-windows-ARM64 - path: wrappers/build - - name: Fetch wrappers for windows-uwp-Win32 - uses: actions/download-artifact@v4 - with: - name: wrappers-windows-uwp-Win32 - path: wrappers/build - - name: Fetch wrappers for windows-uwp-x64 - uses: actions/download-artifact@v4 - with: - name: wrappers-windows-uwp-x64 - path: wrappers/build - - name: Fetch wrappers for windows-uwp-ARM - uses: actions/download-artifact@v4 - with: - name: wrappers-windows-uwp-ARM - path: wrappers/build - - name: Fetch wrappers for windows-uwp-ARM64 - uses: actions/download-artifact@v4 - with: - name: wrappers-windows-uwp-ARM64 - path: wrappers/build - - name: Fetch wrappers for iOS-Device - uses: actions/download-artifact@v4 - with: - name: wrappers-iOS-Device - path: wrappers/build - - name: Fetch wrappers for iOS-Simulator - uses: actions/download-artifact@v4 - with: - name: wrappers-iOS-Simulator - path: wrappers/build - - name: Fetch wrappers for tvOS-Device - uses: actions/download-artifact@v4 - with: - name: wrappers-tvOS-Device - path: wrappers/build - - name: Fetch wrappers for tvOS-Simulator - uses: actions/download-artifact@v4 - with: - name: wrappers-tvOS-Simulator - path: wrappers/build - name: Deploy Apps working-directory: Tools/DeployApps run: dotnet run deploy-apps --baasaas-api-key=${{ secrets.BAASAAS_API_KEY }} --baas-differentiator=code-coverage-${{ github.run_id }}-${{ github.run_attempt }} @@ -948,9 +853,9 @@ jobs: - name: Checkout Code uses: actions/checkout@v4 with: - submodules: recursive + submodules: false ref: ${{ github.event.pull_request.head.sha }} - - name: Register csc problem matcher + - name: Register problem matchers run: |- echo "::add-matcher::.github/problem-matchers/csc.json" echo "::add-matcher::.github/problem-matchers/msvc.json" @@ -974,7 +879,7 @@ jobs: - name: Checkout Code uses: actions/checkout@v4 with: - submodules: recursive + submodules: false ref: ${{ github.event.pull_request.head.sha }} - name: Fetch Realm uses: actions/download-artifact@v4 @@ -1031,7 +936,7 @@ jobs: - name: Checkout Code uses: actions/checkout@v4 with: - submodules: recursive + submodules: false ref: ${{ github.event.pull_request.head.sha }} - uses: nirinchev/verify-todo@9be6f76daddad71433e5deb1b58c517490e5c66e with: diff --git a/Tests/Realm.Tests/Database/DynamicAccessTests.cs b/Tests/Realm.Tests/Database/DynamicAccessTests.cs index 5cc9aa0ba6..2cc7017a26 100644 --- a/Tests/Realm.Tests/Database/DynamicAccessTests.cs +++ b/Tests/Realm.Tests/Database/DynamicAccessTests.cs @@ -75,11 +75,6 @@ public void SimpleTest() Assert.That(allTypesObject.DynamicApi.Get(nameof(AllTypesObject.NullableCharProperty)), Is.EqualTo('o')); Assert.That(allTypesObject.DynamicApi.Get(nameof(AllTypesObject.StringProperty)), Is.EqualTo("o")); - if (TestHelpers.IsAOTTarget) - { - return; - } - #if !UNITY var dynamicAto = realm.Write(() => { @@ -232,10 +227,6 @@ public void RealmValueTests([ValueSource(nameof(RealmValues))] RealmValue rv) Assert.That(allTypesObject.DynamicApi.Get(nameof(AllTypesObject.RealmValueProperty)), Is.EqualTo(rv)); - if (TestHelpers.IsAOTTarget) - { - return; - } #if !UNITY var dynamicAto = realm.Write(() => { @@ -268,11 +259,6 @@ public void RealmValueTests_WithObject() Assert.That(ato.DynamicApi.Get(nameof(AllTypesObject.RealmValueProperty)), Is.EqualTo(rv)); - if (TestHelpers.IsAOTTarget) - { - return; - } - #if !UNITY var (dynamicAto, dynamicRV) = realm.Write(() => { diff --git a/Tests/Realm.Tests/Database/DynamicEmbeddedTests.cs b/Tests/Realm.Tests/Database/DynamicEmbeddedTests.cs index 288d55b2a7..7511078c6a 100644 --- a/Tests/Realm.Tests/Database/DynamicEmbeddedTests.cs +++ b/Tests/Realm.Tests/Database/DynamicEmbeddedTests.cs @@ -96,11 +96,6 @@ public void CreateObject_WhenEmbedded_CanAssignToParent() Assert.That(addedReport.DynamicApi.Get(nameof(CompletionReport.CompletionDate)), Is.EqualTo(now)); Assert.That(addedReport.DynamicApi.Get(nameof(CompletionReport.Remarks)), Is.EqualTo("success!")); - if (TestHelpers.IsAOTTarget) - { - return; - } - #if !UNITY var dynamicId = Guid.NewGuid().ToString(); var dynamicNow = DateTimeOffset.UtcNow; @@ -142,11 +137,6 @@ public void ListAdd_WhenEmbedded_Throws() Assert.That(ex.Message, Does.Contain($"{nameof(realm.DynamicApi)}.{nameof(realm.DynamicApi.AddEmbeddedObjectToList)}")); - if (TestHelpers.IsAOTTarget) - { - return; - } - #if !UNITY var dynamicEx = Assert.Throws(() => { @@ -181,11 +171,6 @@ public void DictionaryAdd_WhenEmbedded_Throws() Assert.That(ex.Message, Does.Contain($"{nameof(realm.DynamicApi)}.{nameof(realm.DynamicApi.AddEmbeddedObjectToDictionary)}")); - if (TestHelpers.IsAOTTarget) - { - return; - } - #if !UNITY var dynamicEx = Assert.Throws(() => { @@ -218,11 +203,6 @@ public void ListInsert_WhenEmbedded_Throws() Assert.That(ex.Message, Does.Contain($"{nameof(realm.DynamicApi)}.{nameof(realm.DynamicApi.InsertEmbeddedObjectInList)}")); - if (TestHelpers.IsAOTTarget) - { - return; - } - #if !UNITY var dynamicEx = Assert.Throws(() => { @@ -255,11 +235,6 @@ public void ListSet_WhenEmbedded_Throws() Assert.That(ex.Message, Does.Contain($"{nameof(realm.DynamicApi)}.{nameof(realm.DynamicApi.SetEmbeddedObjectInList)}")); - if (TestHelpers.IsAOTTarget) - { - return; - } - #if !UNITY var dynamicEx = Assert.Throws(() => { @@ -292,11 +267,6 @@ public void DictionarySet_WhenEmbedded_Throws() Assert.That(ex.Message, Does.Contain($"{nameof(realm.DynamicApi)}.{nameof(realm.DynamicApi.SetEmbeddedObjectInDictionary)}")); - if (TestHelpers.IsAOTTarget) - { - return; - } - #if !UNITY var dynamicEx = Assert.Throws(() => { @@ -352,11 +322,6 @@ public void RealmAddEmbeddedObjectToList() Assert.That(addedSubSubTasks.Count, Is.EqualTo(1)); Assert.That(addedSubSubTasks[0].DynamicApi.Get(nameof(DynamicSubSubTask.Summary)), Is.EqualTo("This is subtask level 2")); - if (TestHelpers.IsAOTTarget) - { - return; - } - #if !UNITY var dynamicId = Guid.NewGuid().ToString(); @@ -425,16 +390,6 @@ public void RealmAddEmbeddedObjectToDictionary() Assert.That(addedDict.Count, Is.EqualTo(2)); Assert.That(addedDict["bar"].DynamicApi.Get(nameof(DynamicSubTask.Summary)), Is.EqualTo("This is a second subtask level 1")); - if (TestHelpers.IsAOTTarget) - { - return; - } - - if (TestHelpers.IsAOTTarget) - { - return; - } - #if !UNITY var dynamicId = Guid.NewGuid().ToString(); @@ -503,11 +458,6 @@ public void RealmInsertEmbeddedObjectInList() Assert.That(subTasks[1].DynamicApi.Get(nameof(DynamicSubTask.Summary)), Is.EqualTo("This is now at 1")); Assert.That(subTasks[2].DynamicApi.Get(nameof(DynamicSubTask.Summary)), Is.EqualTo("This is now at 2")); - if (TestHelpers.IsAOTTarget) - { - return; - } - #if !UNITY var dynamicId = Guid.NewGuid().ToString(); @@ -584,11 +534,6 @@ public void RealmSetEmbeddedObjectInList() Assert.That(addedSubTasks[1].DynamicApi.Get(nameof(DynamicSubTask.Summary)), Is.EqualTo("new at 1")); Assert.That(addedSubTasks[2].DynamicApi.Get(nameof(DynamicSubTask.Summary)), Is.EqualTo("initial at 2")); - if (TestHelpers.IsAOTTarget) - { - return; - } - #if !UNITY var dynamicId = Guid.NewGuid().ToString(); @@ -665,16 +610,6 @@ public void RealmSetEmbeddedObjectInDictionary() Assert.That(subTasks["b"].DynamicApi.Get(nameof(DynamicSubTask.Summary)), Is.EqualTo("new at b")); Assert.That(subTasks["c"].DynamicApi.Get(nameof(DynamicSubTask.Summary)), Is.EqualTo("initial at c")); - if (TestHelpers.IsAOTTarget) - { - return; - } - - if (TestHelpers.IsAOTTarget) - { - return; - } - #if !UNITY var dynamicId = Guid.NewGuid().ToString(); @@ -737,11 +672,6 @@ public void RealmSetEmbeddedObjectInList_WhenOutOfBounds_Throws() }); }); - if (TestHelpers.IsAOTTarget) - { - return; - } - #if !UNITY Assert.Throws(() => { @@ -780,11 +710,6 @@ public void RealmAddEmbeddedObjectInDictionary_WhenDuplicateKeys_Throws() }); }, "An item with the key 'foo' has already been added."); - if (TestHelpers.IsAOTTarget) - { - return; - } - #if !UNITY Assert.Throws(() => { @@ -827,11 +752,6 @@ public void RealmInsertEmbeddedObjectInList_WhenOutOfBounds_Throws() }); }); - if (TestHelpers.IsAOTTarget) - { - return; - } - #if !UNITY Assert.Throws(() => { @@ -887,11 +807,6 @@ public void List_RemoveAt() Assert.That(list.Count, Is.EqualTo(1)); Assert.That(list[0].DynamicApi.Get(nameof(DynamicSubTask.Summary)), Is.EqualTo("second")); - if (TestHelpers.IsAOTTarget) - { - return; - } - #if !UNITY var dynamicId = Guid.NewGuid().ToString(); @@ -958,11 +873,6 @@ public void List_Remove() Assert.That(subTasks.Count, Is.EqualTo(0)); - if (TestHelpers.IsAOTTarget) - { - return; - } - #if !UNITY var dynamicId = Guid.NewGuid().ToString(); @@ -1040,15 +950,10 @@ public void Dictionary_Remove() Assert.That(dict.Count, Is.EqualTo(0)); - if (TestHelpers.IsAOTTarget) - { - return; - } - #if !UNITY var dynamicId = Guid.NewGuid().ToString(); - dynamic dynamicSecond = realm.Write(() => + realm.Write(() => { dynamic parent = realm.DynamicApi.CreateObject(nameof(DynamicTask), dynamicId); dynamic first = realm.DynamicApi.AddEmbeddedObjectToDictionary(parent.SubTasksDictionary, "first"); @@ -1056,8 +961,6 @@ public void Dictionary_Remove() first.Summary = "first"; second.Summary = "second"; - - return second; }); dynamic dynamicParent = realm.DynamicApi.Find(nameof(DynamicTask), dynamicId)!; @@ -1097,10 +1000,10 @@ public void Embedded_Backlinks() subTask.DynamicApi.Set(nameof(DynamicSubTask.Summary), "This is level 1 subtask"); var subSubTasks = task.DynamicApi.GetList(nameof(DynamicTask.SubSubTasks)); - var subSubTask1 = realm.DynamicApi.AddEmbeddedObjectToList(subSubTasks); + _ = realm.DynamicApi.AddEmbeddedObjectToList(subSubTasks); var subTaskSubSubTasks = subTask.DynamicApi.GetList(nameof(DynamicSubTask.SubSubTasks)); - var subSubtask2 = realm.DynamicApi.AddEmbeddedObjectToList(subTaskSubSubTasks); + _ = realm.DynamicApi.AddEmbeddedObjectToList(subTaskSubSubTasks); }); var addedTask = realm.DynamicApi.Find(nameof(DynamicTask), id)!; @@ -1120,11 +1023,6 @@ public void Embedded_Backlinks() Assert.That(parentSubTask2.Count(), Is.EqualTo(1)); Assert.That(parentSubTask2.Single(), Is.EqualTo(addedSubTask)); - if (TestHelpers.IsAOTTarget) - { - return; - } - #if !UNITY var dynamicId = Guid.NewGuid().ToString(); realm.Write(() => @@ -1135,8 +1033,8 @@ public void Embedded_Backlinks() dynamic subTask = realm.DynamicApi.AddEmbeddedObjectToList(task.SubTasks); subTask.Summary = "This is level 1 subtask"; - dynamic subSubTask1 = realm.DynamicApi.AddEmbeddedObjectToList(task.SubSubTasks); - dynamic subSubtask2 = realm.DynamicApi.AddEmbeddedObjectToList(subTask.SubSubTasks); + _ = realm.DynamicApi.AddEmbeddedObjectToList(task.SubSubTasks); + _ = realm.DynamicApi.AddEmbeddedObjectToList(subTask.SubSubTasks); }); dynamic dynamicTask = realm.DynamicApi.Find(nameof(DynamicTask), dynamicId)!; @@ -1177,11 +1075,6 @@ public void Embedded_DynamicBacklinks() Assert.That(reportParents.Count(), Is.EqualTo(1)); Assert.That(reportParents.Single(), Is.EqualTo(addedTask)); - if (TestHelpers.IsAOTTarget) - { - return; - } - #if !UNITY var dynamicId = Guid.NewGuid().ToString(); realm.Write(() => diff --git a/Tests/Realm.Tests/Database/EmbeddedObjectsTests.cs b/Tests/Realm.Tests/Database/EmbeddedObjectsTests.cs index c722af7d19..05d3e5827a 100644 --- a/Tests/Realm.Tests/Database/EmbeddedObjectsTests.cs +++ b/Tests/Realm.Tests/Database/EmbeddedObjectsTests.cs @@ -919,11 +919,6 @@ public void DynamicBacklinks_NewAPI() Assert.That(recursiveObjViaBacklinks, Is.EqualTo(parent.RecursiveObject)); Assert.That(recursiveObjViaBacklinks.DynamicApi.Get(nameof(EmbeddedLevel1.String)), Is.EqualTo("level 1")); - if (TestHelpers.IsAOTTarget) - { - return; - } - #if !UNITY dynamic dynamicParentViaBacklinks = topLevelBacklinks.Single(); Assert.That(dynamicParentViaBacklinks, Is.EqualTo(parent)); diff --git a/Tests/Realm.Tests/Database/InstanceTests.cs b/Tests/Realm.Tests/Database/InstanceTests.cs index d9fbc03a43..91b956c96b 100644 --- a/Tests/Realm.Tests/Database/InstanceTests.cs +++ b/Tests/Realm.Tests/Database/InstanceTests.cs @@ -761,11 +761,8 @@ public void GetInstance_WhenDynamic_ReadsSchemaFromDisk() Assert.That(ato.DynamicApi.Get(nameof(AllTypesObject.RequiredStringProperty)), Is.EqualTo("This is required!")); #if !UNITY - if (!TestHelpers.IsAOTTarget) - { - dynamic dynamicAto = dynamicRealm.DynamicApi.All(nameof(AllTypesObject)).Single(); - Assert.That(dynamicAto.RequiredStringProperty, Is.EqualTo("This is required!")); - } + dynamic dynamicAto = dynamicRealm.DynamicApi.All(nameof(AllTypesObject)).Single(); + Assert.That(dynamicAto.RequiredStringProperty, Is.EqualTo("This is required!")); #endif Assert.That(dynamicRealm.Schema.TryFindObjectSchema(nameof(EmbeddedAllTypesObject), out var embeddedAllTypesSchema), Is.True); @@ -780,11 +777,8 @@ public void GetInstance_WhenDynamic_ReadsSchemaFromDisk() Assert.That(embeddedChild.DynamicApi.Get(nameof(EmbeddedAllTypesObject.StringProperty)), Is.EqualTo("This is not required!")); #if !UNITY - if (!TestHelpers.IsAOTTarget) - { - dynamic dynamicEmbeddedParent = dynamicRealm.DynamicApi.All(nameof(ObjectWithEmbeddedProperties)).Single(); - Assert.That(dynamicEmbeddedParent.AllTypesObject.StringProperty, Is.EqualTo("This is not required!")); - } + dynamic dynamicEmbeddedParent = dynamicRealm.DynamicApi.All(nameof(ObjectWithEmbeddedProperties)).Single(); + Assert.That(dynamicEmbeddedParent.AllTypesObject.StringProperty, Is.EqualTo("This is not required!")); #endif } diff --git a/Tests/Realm.Tests/Database/MigrationTests.cs b/Tests/Realm.Tests/Database/MigrationTests.cs index 105a06ef36..0ddfbdaa8d 100644 --- a/Tests/Realm.Tests/Database/MigrationTests.cs +++ b/Tests/Realm.Tests/Database/MigrationTests.cs @@ -90,12 +90,9 @@ public void TriggerMigrationBySchemaEditing() newPerson.LastName = triggersSchemaFieldValue = oldPerson.DynamicApi.Get("TriggersSchema"); #if !UNITY - if (!TestHelpers.IsAOTTarget) - { - // Ensure we can still use the dynamic API during migrations - dynamic dynamicOldPerson = oldPeople.ElementAt(i); - Assert.That(dynamicOldPerson.TriggersSchema, Is.EqualTo(oldPerson.DynamicApi.Get("TriggersSchema"))); - } + // Ensure we can still use the dynamic API during migrations + dynamic dynamicOldPerson = oldPeople.ElementAt(i); + Assert.That(dynamicOldPerson.TriggersSchema, Is.EqualTo(oldPerson.DynamicApi.Get("TriggersSchema"))); #endif } } diff --git a/Tests/Realm.Tests/Database/PrimaryKeyTests.cs b/Tests/Realm.Tests/Database/PrimaryKeyTests.cs index d6839aac9c..ecab20f06d 100644 --- a/Tests/Realm.Tests/Database/PrimaryKeyTests.cs +++ b/Tests/Realm.Tests/Database/PrimaryKeyTests.cs @@ -154,11 +154,6 @@ public void UpdatePrimaryKey_DynamicTests(Type type, object firstValue, object s Assert.That(ex.Message, Does.Contain(Operator.Convert(firstValue).ToString())); Assert.That(ex.Message, Does.Contain(Operator.Convert(secondValue).ToString())); - if (TestHelpers.IsAOTTarget) - { - return; - } - #if !UNITY dynamic dynamicObj = obj; diff --git a/Tests/Realm.Tests/Sync/AsymmetricObjectTests.cs b/Tests/Realm.Tests/Sync/AsymmetricObjectTests.cs index cab3fad4ea..21c83b068e 100644 --- a/Tests/Realm.Tests/Sync/AsymmetricObjectTests.cs +++ b/Tests/Realm.Tests/Sync/AsymmetricObjectTests.cs @@ -607,11 +607,6 @@ public void DynamicAccess([Values(true, false)] bool isDynamic) Assert.That(asymmetricObj.DynamicApi.Get(nameof(AllTypesObject.StringProperty)), Is.EqualTo("o")); }); - if (TestHelpers.IsAOTTarget) - { - return; - } - #if !UNITY realm.Write(() => { From 3059d04113a10af38bebbd195f832e31d818eacd Mon Sep 17 00:00:00 2001 From: Nikola Irinchev Date: Thu, 23 May 2024 00:10:05 +0200 Subject: [PATCH 24/39] Fix some tests --- .github/pkl-workflows/helpers/Lint.pkl | 4 +- .github/pkl-workflows/helpers/Steps.pkl | 2 +- .github/pkl-workflows/helpers/Test.pkl | 1 + .github/workflows/pr.yml | 20 +++--- .../Database/DynamicEmbeddedTests.cs | 10 +++ Tests/Realm.Tests/Database/MigrationTests.cs | 69 +++++++++---------- 6 files changed, 57 insertions(+), 49 deletions(-) diff --git a/.github/pkl-workflows/helpers/Lint.pkl b/.github/pkl-workflows/helpers/Lint.pkl index 4c5aaec21a..d897c121cb 100644 --- a/.github/pkl-workflows/helpers/Lint.pkl +++ b/.github/pkl-workflows/helpers/Lint.pkl @@ -4,13 +4,15 @@ import "../GithubAction/GithubAction.pkl" as gha import "Steps.pkl" import "Common.pkl" +const actionVerifyTODO = "nirinchev/verify-todo@ffa352ac028b4cdc8bc626471d33aa341b3ab7c9" + function lint(): gha.Job = new { name = "Verify TODOs" `runs-on` = new gha.UbuntuLatest{} steps { Steps.checkoutWithoutMatchers(false) new gha.Step { - uses = "nirinchev/verify-todo@9be6f76daddad71433e5deb1b58c517490e5c66e" + uses = actionVerifyTODO with { ["token"] = "${{ secrets.GITHUB_TOKEN }}" ["include"] = "**/*.+(cs|cpp|hpp)" diff --git a/.github/pkl-workflows/helpers/Steps.pkl b/.github/pkl-workflows/helpers/Steps.pkl index ce297a4e5a..018c75ad8f 100644 --- a/.github/pkl-workflows/helpers/Steps.pkl +++ b/.github/pkl-workflows/helpers/Steps.pkl @@ -9,7 +9,7 @@ const actionCheckout = "actions/checkout@v4" const actionUploadArtifact = "actions/upload-artifact@v4" const actionDownloadArtifact = "actions/download-artifact@v4" const actionSetupXcode = "maxim-lobanov/setup-xcode@60606e260d2fc5762a71e64e74b2174e8ea3c8bd" -const actionSetupDotnet = "actions/setup-dotnet@607fce577a46308457984d59e4954e075820f10a" +const actionSetupDotnet = "actions/setup-dotnet@5d1464d5da459f3d7085106d52e499f4dc5d0f59" const actionSetupMsBuild = "microsoft/setup-msbuild@0b44c6745b7e81956596964100aadb92d667c497" const function checkout(submodules: (Boolean | "recursive")): Listing = new Listing { diff --git a/.github/pkl-workflows/helpers/Test.pkl b/.github/pkl-workflows/helpers/Test.pkl index e4928a009e..095c93c755 100644 --- a/.github/pkl-workflows/helpers/Test.pkl +++ b/.github/pkl-workflows/helpers/Test.pkl @@ -24,6 +24,7 @@ function netFramework(_syncDifferentiators: Listing): gha.StepJobBase = properties { ["TargetFramework"] = "net461" } + standaloneExe = true }) new gha.Step { name = "Run the tests" diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index 32baef8787..276af729e5 100755 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -43,7 +43,7 @@ jobs: run: |- echo "::add-matcher::.github/problem-matchers/csc.json" echo "::add-matcher::.github/problem-matchers/msvc.json" - - uses: actions/setup-dotnet@607fce577a46308457984d59e4954e075820f10a + - uses: actions/setup-dotnet@5d1464d5da459f3d7085106d52e499f4dc5d0f59 with: dotnet-version: 6.0.x - name: Deploy Apps @@ -111,7 +111,7 @@ jobs: if: ${{ runner.os == 'Windows' }} uses: microsoft/setup-msbuild@0b44c6745b7e81956596964100aadb92d667c497 - name: Build Tests/Realm.Tests - run: msbuild Tests/Realm.Tests -restore -p:Configuration=Release -p:TargetFramework=net461 -p:RestoreConfigFile=Tests/Test.NuGet.Config -p:UseRealmNupkgsWithVersion=${{ needs.build-packages.outputs.package_version }} + run: msbuild Tests/Realm.Tests -restore -p:Configuration=Release -p:TargetFramework=net461 -p:RestoreConfigFile=Tests/Test.NuGet.Config -p:UseRealmNupkgsWithVersion=${{ needs.build-packages.outputs.package_version }} -p:RealmTestsStandaloneExe=true - name: Run the tests run: './Tests/Realm.Tests/bin/Release/net461/Realm.Tests.exe --result=TestResults.xml --labels=After ' - name: Publish Unit Test Results @@ -214,7 +214,7 @@ jobs: NET_VERSION=$(echo '${{ matrix.framework }}.x' | sed 's/net//g') echo "version=$NET_VERSION" >> $GITHUB_OUTPUT shell: bash - - uses: actions/setup-dotnet@607fce577a46308457984d59e4954e075820f10a + - uses: actions/setup-dotnet@5d1464d5da459f3d7085106d52e499f4dc5d0f59 with: dotnet-version: ${{ steps.get-net-version.outputs.version }} - name: Publish Tests/Realm.Tests @@ -332,7 +332,7 @@ jobs: with: name: Realm.PlatformHelpers.${{ needs.build-packages.outputs.package_version }} path: ${{ github.workspace }}/Realm/packages/ - - uses: actions/setup-dotnet@607fce577a46308457984d59e4954e075820f10a + - uses: actions/setup-dotnet@5d1464d5da459f3d7085106d52e499f4dc5d0f59 with: dotnet-version: 8.0.x - name: Setup workloads @@ -434,7 +434,7 @@ jobs: with: name: Realm.PlatformHelpers.${{ needs.build-packages.outputs.package_version }} path: ${{ github.workspace }}/Realm/packages/ - - uses: actions/setup-dotnet@607fce577a46308457984d59e4954e075820f10a + - uses: actions/setup-dotnet@5d1464d5da459f3d7085106d52e499f4dc5d0f59 with: dotnet-version: 8.0.x - name: Setup workloads @@ -608,7 +608,7 @@ jobs: with: name: Realm.PlatformHelpers.${{ needs.build-packages.outputs.package_version }} path: ${{ github.workspace }}/Realm/packages/ - - uses: actions/setup-dotnet@607fce577a46308457984d59e4954e075820f10a + - uses: actions/setup-dotnet@5d1464d5da459f3d7085106d52e499f4dc5d0f59 with: dotnet-version: 8.0.x - name: Setup workloads @@ -705,7 +705,7 @@ jobs: run: |- echo "::add-matcher::.github/problem-matchers/csc.json" echo "::add-matcher::.github/problem-matchers/msvc.json" - - uses: actions/setup-dotnet@607fce577a46308457984d59e4954e075820f10a + - uses: actions/setup-dotnet@5d1464d5da459f3d7085106d52e499f4dc5d0f59 with: dotnet-version: 6.0.x - name: Setup workloads @@ -743,7 +743,7 @@ jobs: run: |- echo "::add-matcher::.github/problem-matchers/csc.json" echo "::add-matcher::.github/problem-matchers/msvc.json" - - uses: actions/setup-dotnet@607fce577a46308457984d59e4954e075820f10a + - uses: actions/setup-dotnet@5d1464d5da459f3d7085106d52e499f4dc5d0f59 with: dotnet-version: 6.0.x - name: Setup workloads @@ -859,7 +859,7 @@ jobs: run: |- echo "::add-matcher::.github/problem-matchers/csc.json" echo "::add-matcher::.github/problem-matchers/msvc.json" - - uses: actions/setup-dotnet@607fce577a46308457984d59e4954e075820f10a + - uses: actions/setup-dotnet@5d1464d5da459f3d7085106d52e499f4dc5d0f59 with: dotnet-version: 6.0.x - name: Terminate Baas @@ -938,7 +938,7 @@ jobs: with: submodules: false ref: ${{ github.event.pull_request.head.sha }} - - uses: nirinchev/verify-todo@9be6f76daddad71433e5deb1b58c517490e5c66e + - uses: nirinchev/verify-todo@ffa352ac028b4cdc8bc626471d33aa341b3ab7c9 with: token: ${{ secrets.GITHUB_TOKEN }} include: '**/*.+(cs|cpp|hpp)' diff --git a/Tests/Realm.Tests/Database/DynamicEmbeddedTests.cs b/Tests/Realm.Tests/Database/DynamicEmbeddedTests.cs index 7511078c6a..fc4f843254 100644 --- a/Tests/Realm.Tests/Database/DynamicEmbeddedTests.cs +++ b/Tests/Realm.Tests/Database/DynamicEmbeddedTests.cs @@ -390,6 +390,11 @@ public void RealmAddEmbeddedObjectToDictionary() Assert.That(addedDict.Count, Is.EqualTo(2)); Assert.That(addedDict["bar"].DynamicApi.Get(nameof(DynamicSubTask.Summary)), Is.EqualTo("This is a second subtask level 1")); + if (TestHelpers.IsAOTTarget) + { + return; + } + #if !UNITY var dynamicId = Guid.NewGuid().ToString(); @@ -610,6 +615,11 @@ public void RealmSetEmbeddedObjectInDictionary() Assert.That(subTasks["b"].DynamicApi.Get(nameof(DynamicSubTask.Summary)), Is.EqualTo("new at b")); Assert.That(subTasks["c"].DynamicApi.Get(nameof(DynamicSubTask.Summary)), Is.EqualTo("initial at c")); + if (TestHelpers.IsAOTTarget) + { + return; + } + #if !UNITY var dynamicId = Guid.NewGuid().ToString(); diff --git a/Tests/Realm.Tests/Database/MigrationTests.cs b/Tests/Realm.Tests/Database/MigrationTests.cs index f79ec5bee1..b913064762 100644 --- a/Tests/Realm.Tests/Database/MigrationTests.cs +++ b/Tests/Realm.Tests/Database/MigrationTests.cs @@ -34,7 +34,7 @@ namespace Realms.Tests.Database { [TestFixture, Preserve(AllMembers = true)] - public partial class MigrationTests : RealmInstanceTest + public class MigrationTests : RealmInstanceTest { private const string FileToMigrate = "ForMigrationsToCopyAndMigrate.realm"; @@ -116,10 +116,7 @@ public void ExceptionInMigrationCallback() var configuration = new RealmConfiguration(Guid.NewGuid().ToString()) { SchemaVersion = 100, - MigrationCallback = (migration, oldSchemaVersion) => - { - throw dummyException; - } + MigrationCallback = (_, _) => throw dummyException }; TestHelpers.CopyBundledFileToDocuments(FileToMigrate, configuration.DatabasePath); @@ -138,7 +135,7 @@ public void MigrationTriggersDelete() IsDynamic = true, Schema = new RealmSchema.Builder { - new ObjectSchema.Builder("Person", ObjectSchema.ObjectType.RealmObject) + new ObjectSchema.Builder("Person") { Property.FromType("Name") } @@ -160,7 +157,7 @@ public void MigrationTriggersDelete() ShouldDeleteIfMigrationNeeded = true, Schema = new RealmSchema.Builder { - new ObjectSchema.Builder("Person", ObjectSchema.ObjectType.RealmObject) + new ObjectSchema.Builder("Person") { Property.FromType("Name") } @@ -185,7 +182,7 @@ public void MigrationRenameProperty() var configuration = new RealmConfiguration(Guid.NewGuid().ToString()) { SchemaVersion = 100, - MigrationCallback = (migration, oldSchemaVersion) => + MigrationCallback = (migration, _) => { migration.RenameProperty(nameof(Person), "TriggersSchema", nameof(Person.OptionalAddress)); @@ -212,12 +209,10 @@ public void MigrationRenameProperty() [Test] public void MigrationRenamePropertyErrors() { - var oldPropertyValues = new List(); - var configuration = new RealmConfiguration(Guid.NewGuid().ToString()) { SchemaVersion = 100, - MigrationCallback = (migration, oldSchemaVersion) => + MigrationCallback = (migration, _) => { migration.RenameProperty(nameof(Person), "TriggersSchema", "PropertyNotInNewSchema"); } @@ -231,7 +226,7 @@ public void MigrationRenamePropertyErrors() configuration = new RealmConfiguration(configuration.DatabasePath) { SchemaVersion = 100, - MigrationCallback = (migration, oldSchemaVersion) => + MigrationCallback = (migration, _) => { migration.RenameProperty(nameof(Person), "PropertyNotInOldSchema", nameof(Person.OptionalAddress)); } @@ -243,7 +238,7 @@ public void MigrationRenamePropertyErrors() configuration = new RealmConfiguration(configuration.DatabasePath) { SchemaVersion = 100, - MigrationCallback = (migration, oldSchemaVersion) => + MigrationCallback = (migration, _) => { migration.RenameProperty("NonExistingType", "TriggersSchema", nameof(Person.OptionalAddress)); } @@ -255,7 +250,7 @@ public void MigrationRenamePropertyErrors() configuration = new RealmConfiguration(configuration.DatabasePath) { SchemaVersion = 100, - MigrationCallback = (migration, oldSchemaVersion) => + MigrationCallback = (migration, _) => { migration.RenameProperty(nameof(Person), "TriggersSchema", nameof(Person.Birthday)); } @@ -267,7 +262,7 @@ public void MigrationRenamePropertyErrors() configuration = new RealmConfiguration(configuration.DatabasePath) { SchemaVersion = 100, - MigrationCallback = (migration, oldSchemaVersion) => + MigrationCallback = (migration, _) => { migration.RenameProperty(nameof(Person), nameof(Person.Latitude), nameof(Person.Longitude)); } @@ -283,7 +278,7 @@ public void MigrationRenamePropertyInvalidArguments() var configuration = new RealmConfiguration(Guid.NewGuid().ToString()) { SchemaVersion = 100, - MigrationCallback = (migration, oldSchemaVersion) => + MigrationCallback = (migration, _) => { Assert.Throws(() => migration.RenameProperty(null!, "TriggersSchema", "OptionalAddress")); Assert.Throws(() => migration.RenameProperty("Person", null!, "OptionalAddress")); @@ -309,7 +304,7 @@ public void MigrationRemoveTypeInSchema() Schema = new[] { typeof(Dog), typeof(Owner), typeof(Person) }, }; - using (var oldRealm = GetRealm(oldRealmConfig)) + using (GetRealm(oldRealmConfig)) { } @@ -317,7 +312,7 @@ public void MigrationRemoveTypeInSchema() { SchemaVersion = 1, Schema = new[] { typeof(PrimaryKeyObjectIdObject), typeof(Person) }, - MigrationCallback = (migration, oldSchemaVersion) => + MigrationCallback = (migration, _) => { migration.RemoveType(nameof(Person)); } @@ -349,7 +344,7 @@ public void MigrationRemoveTypeNotInSchema() { SchemaVersion = 1, Schema = new[] { typeof(Dog), typeof(Owner) }, - MigrationCallback = (migration, oldSchemaVersion) => + MigrationCallback = (migration, _) => { migrationCallbackCalled = true; @@ -397,7 +392,7 @@ public void MigrationRemoveTypeInvalidArguments() Schema = new[] { typeof(Dog), typeof(Owner), typeof(Person) }, }; - using (var oldRealm = GetRealm(oldRealmConfig)) + using (GetRealm(oldRealmConfig)) { } @@ -405,7 +400,7 @@ public void MigrationRemoveTypeInvalidArguments() { SchemaVersion = 1, Schema = new[] { typeof(PrimaryKeyObjectIdObject), typeof(Person) }, - MigrationCallback = (migration, oldSchemaVersion) => + MigrationCallback = (migration, _) => { Assert.Throws(() => migration.RemoveType(null!)); Assert.Throws(() => migration.RemoveType(string.Empty)); @@ -419,7 +414,7 @@ public void MigrationRemoveTypeInvalidArguments() public void Migration_WhenDone_DisposesAllObjectsAndLists() { var config = new RealmConfiguration(Guid.NewGuid().ToString()); - using (var oldRealm = GetRealm(config)) + using (GetRealm(config)) { } @@ -433,7 +428,7 @@ public void Migration_WhenDone_DisposesAllObjectsAndLists() var newConfig = new RealmConfiguration(config.DatabasePath) { SchemaVersion = 1, - MigrationCallback = (migration, oldSchemaVersion) => + MigrationCallback = (migration, _) => { standaloneObject = migration.NewRealm.Add(new AllTypesObject { RequiredStringProperty = string.Empty }); Assert.That(standaloneObject.IsValid); @@ -476,7 +471,7 @@ public void Migration_WhenDone_DisposesAllObjectsAndLists() } }; - using (var newRealm = Realm.GetInstance(newConfig)) + using (Realm.GetInstance(newConfig)) { // Here we should see all objects accessed during the migration get disposed, even though // newRealm is still open. @@ -583,7 +578,7 @@ public void Migration_ChangePrimaryKey_Dynamic() var newRealmConfig = new RealmConfiguration(oldRealmConfig.DatabasePath) { SchemaVersion = 1, - MigrationCallback = (migration, oldSchemaVersion) => + MigrationCallback = (migration, _) => { var value = migration.NewRealm.DynamicApi.Find(nameof(IntPrimaryKeyWithValueObject), 123)!; value.DynamicApi.Set("_id", 456); @@ -619,7 +614,7 @@ public void Migration_ChangePrimaryKey_Static() var newRealmConfig = new RealmConfiguration(oldRealmConfig.DatabasePath) { SchemaVersion = 1, - MigrationCallback = (migration, oldSchemaVersion) => + MigrationCallback = (migration, _) => { var value = migration.NewRealm.Find(123)!; value.Id = 456; @@ -666,7 +661,7 @@ public void Migration_ChangePrimaryKeyType() { SchemaVersion = 1, Schema = new[] { typeof(ObjectV2) }, - MigrationCallback = (migration, oldSchemaVersion) => + MigrationCallback = (migration, _) => { foreach (var oldObj in migration.OldRealm.DynamicApi.All("Object")) { @@ -706,7 +701,7 @@ public void Migration_ChangePrimaryKey_WithDuplicates_Throws() var newRealmConfig = new RealmConfiguration(oldRealmConfig.DatabasePath) { SchemaVersion = 1, - MigrationCallback = (migration, oldSchemaVersion) => + MigrationCallback = (migration, _) => { var value = migration.NewRealm.Find(1)!; value.Id = 2; @@ -744,7 +739,7 @@ public void Migration_ToEmbedded_DuplicatesObjects() Value = "foo" }); - var container1 = oldRealm.Add(new ObjectContainerV1 + oldRealm.Add(new ObjectContainerV1 { Value = "container1", Link = obj, @@ -757,7 +752,7 @@ public void Migration_ToEmbedded_DuplicatesObjects() Value = "bar" }); - var container2 = oldRealm.Add(new ObjectContainerV1 + oldRealm.Add(new ObjectContainerV1 { Value = "container2", Link = obj, @@ -805,13 +800,13 @@ public void Migration_ToEmbedded_DeletesOrphans() Value = "foo" }); - var orphanedObj = oldRealm.Add(new ObjectV1 + oldRealm.Add(new ObjectV1 { Id = 2, Value = "bar" }); - var container = oldRealm.Add(new ObjectContainerV1 + oldRealm.Add(new ObjectContainerV1 { Value = "container", Link = obj @@ -862,7 +857,7 @@ public void Migration_FindInNewRealm_WhenObjectIsDeleted_ReturnsNull() typeof(Dotnet_3597) }, SchemaVersion = 2, - MigrationCallback = (migration, version) => + MigrationCallback = (migration, _) => { var oldObjects = migration.OldRealm.DynamicApi.All(nameof(Dotnet_3597)).ToArray(); var old1 = oldObjects.First(o => o.DynamicApi.Get("IntProp") == 1); @@ -921,7 +916,7 @@ public void Migration_MigratesListOfFloats() typeof(Dotnet_3597) }, SchemaVersion = 2, - MigrationCallback = (migration, version) => + MigrationCallback = (migration, _) => { foreach (var item in migration.OldRealm.DynamicApi.All(nameof(Dotnet_3597))) { @@ -1000,7 +995,7 @@ public partial class Dotnet_3597_Old : TestRealmObject public float? FloatProp { get; set; } - public IList FloatList { get; } + public IList FloatList { get; } = null!; } [Explicit] @@ -1009,8 +1004,8 @@ public partial class Dotnet_3597 : TestRealmObject { public int IntProp { get; set; } - public string FloatProp { get; set; } + public string FloatProp { get; set; } = string.Empty; - public IList FloatList { get; } + public IList FloatList { get; } = null!; } } From 359384b210e8449e10f144b8867db5c36a6f97c2 Mon Sep 17 00:00:00 2001 From: Nikola Irinchev Date: Thu, 23 May 2024 00:42:06 +0200 Subject: [PATCH 25/39] Try to use the original action --- .github/pkl-workflows/helpers/Steps.pkl | 22 +++++----- .github/pkl-workflows/helpers/Test.pkl | 11 ++--- .github/workflows/pr.yml | 32 ++++++++------- .github/workflows/wrappers.yml | 54 ++++++++++++------------- 4 files changed, 62 insertions(+), 57 deletions(-) diff --git a/.github/pkl-workflows/helpers/Steps.pkl b/.github/pkl-workflows/helpers/Steps.pkl index 018c75ad8f..2ad140d28f 100644 --- a/.github/pkl-workflows/helpers/Steps.pkl +++ b/.github/pkl-workflows/helpers/Steps.pkl @@ -1,16 +1,16 @@ import "../GithubAction/GithubAction.pkl" as gha import "Common.pkl" -const actionRunSimulator = "realm/ci-actions/run-ios-simulator@6418e15ed9bbdb19b7d456a347e5623779f95cdf" -const actionSetupJDK = "actions/setup-java@0ab4596768b603586c0de567f2430c30f5b0d2b0" -const actionAWSConfigureCredentials = "aws-actions/configure-aws-credentials@v4.0.2" -const actionCoveralls = "coverallsapp/github-action@v2.3.0" -const actionCheckout = "actions/checkout@v4" -const actionUploadArtifact = "actions/upload-artifact@v4" -const actionDownloadArtifact = "actions/download-artifact@v4" -const actionSetupXcode = "maxim-lobanov/setup-xcode@60606e260d2fc5762a71e64e74b2174e8ea3c8bd" -const actionSetupDotnet = "actions/setup-dotnet@5d1464d5da459f3d7085106d52e499f4dc5d0f59" -const actionSetupMsBuild = "microsoft/setup-msbuild@0b44c6745b7e81956596964100aadb92d667c497" +local const actionRunSimulator = "realm/ci-actions/run-ios-simulator@6418e15ed9bbdb19b7d456a347e5623779f95cdf" +local const actionSetupJDK = "actions/setup-java@0ab4596768b603586c0de567f2430c30f5b0d2b0" +local const actionAWSConfigureCredentials = "aws-actions/configure-aws-credentials@v4.0.2" +local const actionCoveralls = "coverallsapp/github-action@v2.3.0" +local const actionCheckout = "actions/checkout@v4" +local const actionUploadArtifact = "actions/upload-artifact@v4" +local const actionDownloadArtifact = "actions/download-artifact@v4" +local const actionSetupXcode = "maxim-lobanov/setup-xcode@60606e260d2fc5762a71e64e74b2174e8ea3c8bd" +local const actionSetupDotnet = "actions/setup-dotnet@5d1464d5da459f3d7085106d52e499f4dc5d0f59" +local const actionSetupMsBuild = "microsoft/setup-msbuild@0b44c6745b7e81956596964100aadb92d667c497" const function checkout(submodules: (Boolean | "recursive")): Listing = new Listing { checkoutWithoutMatchers(submodules) @@ -31,7 +31,7 @@ const function uploadArtifacts(artifactName: String, relPath: String): gha.Step uses = actionUploadArtifact with { ["name"] = artifactName - ["path"] = "${{ github.workspace }}/\(relPath)" + ["path"] = relPath ["retention-days"] = "${{ github.event_name != 'pull_request' && 30 || 1 }}" ["if-no-files-found"] = "error" } diff --git a/.github/pkl-workflows/helpers/Test.pkl b/.github/pkl-workflows/helpers/Test.pkl index 095c93c755..9ceb5772f0 100644 --- a/.github/pkl-workflows/helpers/Test.pkl +++ b/.github/pkl-workflows/helpers/Test.pkl @@ -5,6 +5,8 @@ import "Common.pkl" import "Steps.pkl" import "BaaS.pkl" +local const actionReportTestResults = "dorny/test-reporter@31a54ee7ebcacc03a09ea97a7e5465a47b84aea5" + local const outputFile = "TestResults.xml" // Public test targets @@ -430,7 +432,7 @@ local function reportTestResultsWithCustomFile(_outputFile: String, config: Test } new gha.Step { name = "Publish Unit Test Results" - uses = "LaPeste/test-reporter@510caf50a955b1003bec48a6494be4d6537f3a0b" + uses = actionReportTestResults `if` = "always()" with { ["name"] = "Results \(config.title)" @@ -470,13 +472,12 @@ local function enableCoreDumps(enable: Boolean): Mixin = new Mixin Date: Thu, 23 May 2024 00:47:08 +0200 Subject: [PATCH 26/39] Update setup-java action --- .github/pkl-workflows/helpers/Steps.pkl | 4 ++-- .github/pkl-workflows/helpers/Test.pkl | 2 +- .github/workflows/pr.yml | 16 ++++++++-------- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/.github/pkl-workflows/helpers/Steps.pkl b/.github/pkl-workflows/helpers/Steps.pkl index 2ad140d28f..dfd929e5bf 100644 --- a/.github/pkl-workflows/helpers/Steps.pkl +++ b/.github/pkl-workflows/helpers/Steps.pkl @@ -2,7 +2,7 @@ import "../GithubAction/GithubAction.pkl" as gha import "Common.pkl" local const actionRunSimulator = "realm/ci-actions/run-ios-simulator@6418e15ed9bbdb19b7d456a347e5623779f95cdf" -local const actionSetupJDK = "actions/setup-java@0ab4596768b603586c0de567f2430c30f5b0d2b0" +local const actionSetupJDK = "actions/setup-java@2e74cbce18569d23ca8b812590dbb83f13ac7c5a" local const actionAWSConfigureCredentials = "aws-actions/configure-aws-credentials@v4.0.2" local const actionCoveralls = "coverallsapp/github-action@v2.3.0" local const actionCheckout = "actions/checkout@v4" @@ -10,7 +10,7 @@ local const actionUploadArtifact = "actions/upload-artifact@v4" local const actionDownloadArtifact = "actions/download-artifact@v4" local const actionSetupXcode = "maxim-lobanov/setup-xcode@60606e260d2fc5762a71e64e74b2174e8ea3c8bd" local const actionSetupDotnet = "actions/setup-dotnet@5d1464d5da459f3d7085106d52e499f4dc5d0f59" -local const actionSetupMsBuild = "microsoft/setup-msbuild@0b44c6745b7e81956596964100aadb92d667c497" +local const actionSetupMsBuild = "microsoft/setup-msbuild@70b70342ae97ca98d5eaad06cafd26d30f9592a9" const function checkout(submodules: (Boolean | "recursive")): Listing = new Listing { checkoutWithoutMatchers(submodules) diff --git a/.github/pkl-workflows/helpers/Test.pkl b/.github/pkl-workflows/helpers/Test.pkl index 9ceb5772f0..baaee75cff 100644 --- a/.github/pkl-workflows/helpers/Test.pkl +++ b/.github/pkl-workflows/helpers/Test.pkl @@ -476,7 +476,7 @@ local function archiveCoreDump(): gha.Step = (Steps.uploadArtifacts("crash-repor name = "Archive core dump" `if` = "${{ failure() && runner.os != 'Windows' }}" with { - ["retention-days"] = 30 + ["retention-days"] = 30 ["if-no-files-found"] = "warn" } } diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index 0a02f46583..ab9a040a5d 100755 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -109,7 +109,7 @@ jobs: path: ${{ github.workspace }}/Realm/packages/ - name: Add msbuild to PATH if: ${{ runner.os == 'Windows' }} - uses: microsoft/setup-msbuild@0b44c6745b7e81956596964100aadb92d667c497 + uses: microsoft/setup-msbuild@70b70342ae97ca98d5eaad06cafd26d30f9592a9 - name: Build Tests/Realm.Tests run: msbuild Tests/Realm.Tests -restore -p:Configuration=Release -p:TargetFramework=net461 -p:RestoreConfigFile=Tests/Test.NuGet.Config -p:UseRealmNupkgsWithVersion=${{ needs.build-packages.outputs.package_version }} -p:RealmTestsStandaloneExe=true - name: Run the tests @@ -160,7 +160,7 @@ jobs: shell: powershell - name: Add msbuild to PATH if: ${{ runner.os == 'Windows' }} - uses: microsoft/setup-msbuild@0b44c6745b7e81956596964100aadb92d667c497 + uses: microsoft/setup-msbuild@70b70342ae97ca98d5eaad06cafd26d30f9592a9 - name: Build Tests/Tests.UWP run: msbuild Tests/Tests.UWP -restore -p:Configuration=Release -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 -p:RestoreConfigFile=Tests/Test.NuGet.Config -p:UseRealmNupkgsWithVersion=${{ needs.build-packages.outputs.package_version }} - name: Run the tests @@ -292,7 +292,7 @@ jobs: path: ${{ github.workspace }}/Realm/packages/ - name: Add msbuild to PATH if: ${{ runner.os == 'Windows' }} - uses: microsoft/setup-msbuild@0b44c6745b7e81956596964100aadb92d667c497 + uses: microsoft/setup-msbuild@70b70342ae97ca98d5eaad06cafd26d30f9592a9 - name: Build Tests/Tests.XamarinMac run: msbuild Tests/Tests.XamarinMac -restore -p:Configuration=Release -p:RestoreConfigFile=Tests/Test.NuGet.Config -p:UseRealmNupkgsWithVersion=${{ needs.build-packages.outputs.package_version }} - name: Run the tests @@ -388,7 +388,7 @@ jobs: path: ${{ github.workspace }}/Realm/packages/ - name: Add msbuild to PATH if: ${{ runner.os == 'Windows' }} - uses: microsoft/setup-msbuild@0b44c6745b7e81956596964100aadb92d667c497 + uses: microsoft/setup-msbuild@70b70342ae97ca98d5eaad06cafd26d30f9592a9 - name: Build Tests/Tests.iOS run: msbuild Tests/Tests.iOS -restore -p:Configuration=Release -p:Platform=iPhoneSimulator -p:RestoreConfigFile=Tests/Test.NuGet.Config -p:UseRealmNupkgsWithVersion=${{ needs.build-packages.outputs.package_version }} - name: Run on Simulator @@ -496,7 +496,7 @@ jobs: path: ${{ github.workspace }}/Realm/packages/ - name: Add msbuild to PATH if: ${{ runner.os == 'Windows' }} - uses: microsoft/setup-msbuild@0b44c6745b7e81956596964100aadb92d667c497 + uses: microsoft/setup-msbuild@70b70342ae97ca98d5eaad06cafd26d30f9592a9 - name: Build Tests/Tests.XamarinTVOS run: msbuild Tests/Tests.XamarinTVOS -restore -p:Configuration=Release -p:Platform=iPhoneSimulator -p:RestoreConfigFile=Tests/Test.NuGet.Config -p:UseRealmNupkgsWithVersion=${{ needs.build-packages.outputs.package_version }} - name: Run on Simulator @@ -526,7 +526,7 @@ jobs: runs-on: windows-latest steps: - name: Setup JDK - uses: actions/setup-java@0ab4596768b603586c0de567f2430c30f5b0d2b0 + uses: actions/setup-java@2e74cbce18569d23ca8b812590dbb83f13ac7c5a with: distribution: microsoft java-version: 11 @@ -551,7 +551,7 @@ jobs: path: ${{ github.workspace }}/Realm/packages/ - name: Add msbuild to PATH if: ${{ runner.os == 'Windows' }} - uses: microsoft/setup-msbuild@0b44c6745b7e81956596964100aadb92d667c497 + uses: microsoft/setup-msbuild@70b70342ae97ca98d5eaad06cafd26d30f9592a9 - name: Build Tests/Tests.Android run: msbuild Tests/Tests.Android -t:SignAndroidPackage -restore -p:Configuration=Release -p:AndroidUseSharedRuntime=False -p:EmbedAssembliesIntoApk=True -p:RestoreConfigFile=Tests/Test.NuGet.Config -p:UseRealmNupkgsWithVersion=${{ needs.build-packages.outputs.package_version }} - name: Configure AWS Credentials @@ -587,7 +587,7 @@ jobs: runs-on: windows-latest steps: - name: Setup JDK - uses: actions/setup-java@0ab4596768b603586c0de567f2430c30f5b0d2b0 + uses: actions/setup-java@2e74cbce18569d23ca8b812590dbb83f13ac7c5a with: distribution: microsoft java-version: 11 From 9c470df811339f7063555a49e44076674bb256a3 Mon Sep 17 00:00:00 2001 From: Nikola Irinchev Date: Thu, 23 May 2024 08:02:08 +0200 Subject: [PATCH 27/39] Ignore a few tests temporarily --- Tests/Realm.Tests/Sync/SyncMigrationTests.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Tests/Realm.Tests/Sync/SyncMigrationTests.cs b/Tests/Realm.Tests/Sync/SyncMigrationTests.cs index 54c175bfe1..cd1bc86343 100644 --- a/Tests/Realm.Tests/Sync/SyncMigrationTests.cs +++ b/Tests/Realm.Tests/Sync/SyncMigrationTests.cs @@ -109,7 +109,7 @@ private async Task OpenRealm(ObjectId differentiator, Type schema, ulong return realm; } - [Test] + [Test, Ignore("TODO: restore once https://mongodb.slack.com/archives/C04NACGT7J7/p1716383151806129 is resolved")] public void Model_CanMigratePropertyOptionality() { SyncTestHelpers.RunBaasTestAsync(async () => @@ -258,7 +258,7 @@ public void Migration_FailsWithFutureVersion() }); } - [Test] + [Test, Ignore("TODO: restore once https://mongodb.slack.com/archives/C04NACGT7J7/p1716383151806129 is resolved")] public void SameRealm_CanBeMigratedThroughConsecutiveVersions() { SyncTestHelpers.RunBaasTestAsync(async () => @@ -326,7 +326,7 @@ public void SameRealm_CanBeMigratedThroughConsecutiveVersions() }); } - [Test] + [Test, Ignore("TODO: restore once https://mongodb.slack.com/archives/C04NACGT7J7/p1716383151806129 is resolved")] public void SameRealm_CanBeMigratedSkippingVersions() { SyncTestHelpers.RunBaasTestAsync(async () => From 360706dff7840df238fba456959e951c495ad513 Mon Sep 17 00:00:00 2001 From: Nikola Irinchev Date: Thu, 23 May 2024 09:39:53 +0200 Subject: [PATCH 28/39] Migrate unity builds --- .../GithubAction/GithubAction.pkl | 4 +- .github/pkl-workflows/helpers/Actions.pkl | 15 + .github/pkl-workflows/helpers/Common.pkl | 1 + .github/pkl-workflows/helpers/Lint.pkl | 2 +- .github/pkl-workflows/helpers/Package.pkl | 130 ++++++ .github/pkl-workflows/helpers/Steps.pkl | 84 ++-- .github/pkl-workflows/helpers/Test.pkl | 110 ++++- .github/pkl-workflows/pr.pkl | 45 +- .github/pkl-workflows/wrappers.pkl | 5 +- .github/templates/build-packages.yml | 112 ----- .github/templates/build-unity.yml | 31 -- .github/templates/test-unity.yml | 96 ---- .github/workflows/build-packages.yml | 260 ----------- .github/workflows/build-unity.yml | 70 --- .github/workflows/pr.yml | 414 +++++++++++++++++- .github/workflows/test-unity.yml | 137 ------ 16 files changed, 703 insertions(+), 813 deletions(-) create mode 100644 .github/pkl-workflows/helpers/Actions.pkl create mode 100644 .github/pkl-workflows/helpers/Package.pkl delete mode 100644 .github/templates/build-packages.yml delete mode 100644 .github/templates/build-unity.yml delete mode 100644 .github/templates/test-unity.yml delete mode 100755 .github/workflows/build-packages.yml delete mode 100755 .github/workflows/build-unity.yml delete mode 100755 .github/workflows/test-unity.yml diff --git a/.github/pkl-workflows/GithubAction/GithubAction.pkl b/.github/pkl-workflows/GithubAction/GithubAction.pkl index 2dd6637194..5c600de0e4 100644 --- a/.github/pkl-workflows/GithubAction/GithubAction.pkl +++ b/.github/pkl-workflows/GithubAction/GithubAction.pkl @@ -571,7 +571,7 @@ abstract class JobBase { } abstract class StepJobBase extends JobBase { - `runs-on`: Machine|String + `runs-on`: Machine|String|Listing steps: Listing(stepsHasOnlyRunOrUses(this)) } @@ -673,7 +673,7 @@ output { text = "# Do not modify!\n# This file was generated from a template using https://github.com/apple/pkl\n\n\(super.text)" renderer = new YamlRenderer { converters { - ["runs-on"] = (runsOn: String|Machine) -> if (runsOn is Machine) runsOn.name else runsOn + ["runs-on"] = (runsOn: String|Machine|Listing) -> if (runsOn is Machine) runsOn.name else runsOn ["schedule"] = (schedule: Schedule?) -> schedule.ifNonNull((_) -> schedule.cron.toList().map((cr) -> Map("cron", new RenderDirective { text = " " + jsonRenderer.renderValue(cr) })) ) diff --git a/.github/pkl-workflows/helpers/Actions.pkl b/.github/pkl-workflows/helpers/Actions.pkl new file mode 100644 index 0000000000..4f4160878a --- /dev/null +++ b/.github/pkl-workflows/helpers/Actions.pkl @@ -0,0 +1,15 @@ +module actions + +const runSimulator = "realm/ci-actions/run-ios-simulator@6418e15ed9bbdb19b7d456a347e5623779f95cdf" +const setupJDK = "actions/setup-java@2e74cbce18569d23ca8b812590dbb83f13ac7c5a" +const awsConfigureCredentials = "aws-actions/configure-aws-credentials@v4.0.2" +const coveralls = "coverallsapp/github-action@v2.3.0" +const checkout = "actions/checkout@v4" +const uploadArtifact = "actions/upload-artifact@v4" +const downloadArtifact = "actions/download-artifact@v4" +const setupXcode = "maxim-lobanov/setup-xcode@60606e260d2fc5762a71e64e74b2174e8ea3c8bd" +const setupDotnet = "actions/setup-dotnet@5d1464d5da459f3d7085106d52e499f4dc5d0f59" +const setupMsBuild = "microsoft/setup-msbuild@70b70342ae97ca98d5eaad06cafd26d30f9592a9" +const setupAndroid = "android-actions/setup-android@e1f5280adf78cf863c0fa43ffabc64a9cd08153f" +const restoreCache = "actions/cache/restore@v4" +const cache = "actions/cache@v4" diff --git a/.github/pkl-workflows/helpers/Common.pkl b/.github/pkl-workflows/helpers/Common.pkl index a586345d3f..ab89f06c2a 100644 --- a/.github/pkl-workflows/helpers/Common.pkl +++ b/.github/pkl-workflows/helpers/Common.pkl @@ -12,6 +12,7 @@ const appleTargets: List = List("Device", "Simulator") const job_Packages: String = "build-packages" const job_Baas: String = "deploy-baas" +const job_Unity: String = "build-unity" typealias NetFramework = "net6.0" | "net8.0" | String(startsWith("${{ matrix")) | String(startsWith("net8")) typealias NetRuntime = "win-x64" | "linux-x64" | "osx-x64" | "osx-arm64" | String(startsWith("${{ matrix")) diff --git a/.github/pkl-workflows/helpers/Lint.pkl b/.github/pkl-workflows/helpers/Lint.pkl index d897c121cb..16c1ae04bb 100644 --- a/.github/pkl-workflows/helpers/Lint.pkl +++ b/.github/pkl-workflows/helpers/Lint.pkl @@ -31,7 +31,7 @@ function verifyNamespaces(): gha.Job = new { } steps { Steps.checkoutWithoutMatchers(false) - ...Steps.fetchPackages(Common.job_Packages, null) + ...Steps.fetchPackages(null) new { run = "dotnet tool install ilspycmd -g --version 8.0.0.7345" } diff --git a/.github/pkl-workflows/helpers/Package.pkl b/.github/pkl-workflows/helpers/Package.pkl new file mode 100644 index 0000000000..b5e0d601b1 --- /dev/null +++ b/.github/pkl-workflows/helpers/Package.pkl @@ -0,0 +1,130 @@ +module package + +import "../GithubAction/GithubAction.pkl" as gha +import "Common.pkl" +import "Steps.pkl" +import "Actions.pkl" + +const versionOutput = "package_version" +const unityPkgName = "io.realm.unity-${{ needs.\(Common.job_Packages).outputs.\(versionOutput) }}.tgz" + +local const getVersionStep = "get-version" +local const setVersionSuffixStep = "set-version-suffix" +local const checkDocfxCacheStep = "check-docfx-cache" + +local const buildSuffixOutput = "build_suffix" + +function nuget(shouldBuildDocsCondition: String): gha.Job = new gha.Job { + name = "Package NuGet" + `runs-on` = new gha.WindowsLatest{} + outputs { + [versionOutput] = "${{ steps.\(getVersionStep).outputs.\(versionOutput) }}" + } + `timeout-minutes` = 30 + steps { + ...Steps.checkout(false) + ...Steps.setupAndroid() + ...Steps.setupWorkloads("tvos ios maccatalyst android", "8.0.x") + setVersionSuffix + ...Steps.fetchWrappers(null) + ...Steps.msbuild(new Steps.MSBuildConfig { + projects = Common.nugetPackages.map((pkg) -> "Realm/\(pkg)").toListing() + target = "Pack" + properties { + ["PackageOutputPath"] = "${{ github.workspace }}/Realm/packages" + ["VersionSuffix"] = "${{ steps.\(setVersionSuffixStep).outputs.\(buildSuffixOutput) }}" + } + }) + readVersionFromPackage + for (pkgName in Common.nugetPackages) { + let (finalPkgName = "\(pkgName).${{ steps.\(getVersionStep).outputs.\(versionOutput) }}") + Steps.uploadArtifacts(finalPkgName, "Realm/packages/\(finalPkgName).*nupkg") + } + Steps.uploadArtifacts("ExtractedChangelog", "Realm/Realm/ExtractedChangelog.md") + ...buildDocs(shouldBuildDocsCondition) + } +} +function unity(): gha.Job = new gha.Job { + name = "Package Unity" + `runs-on` = new gha.WindowsLatest{} + `timeout-minutes` = 30 + `if` = Common.ifNotCanceledCondition + needs { + Common.job_Packages + } + steps { + ...Steps.checkout(false) + ...Steps.fetchPackages(null) + new { + name = "Build Unity" + run = "dotnet run --project Tools/SetupUnityPackage/ -- realm --packages-path Realm/packages --pack" + } + Steps.uploadArtifacts(unityPkgName, "Realm/Realm.Unity/\(unityPkgName)") + new { + name = "Build Tests" + run = "dotnet run --project Tools/SetupUnityPackage/ -- tests --realm-package Realm/Realm.Unity/\(unityPkgName)" + } + Steps.uploadArtifacts("UnityTests", "Tests/Tests.Unity") + } +} + +local const setVersionSuffix = new gha.Step { + name = "Set version suffix" + id = setVersionSuffixStep + // Build suffix is pr-1234.5 for pr builds or alpha.123 for branch builds. + run = """ + $suffix = "" + if ($env:GITHUB_EVENT_NAME -eq "pull_request") + { + if (-Not "${{ github.head_ref }}".Contains("release")) + { + $suffix = "pr-${{ github.event.number }}.$env:GITHUB_RUN_NUMBER" + } + } + else + { + $suffix = "alpha.$env:GITHUB_RUN_NUMBER" + } + echo "\(buildSuffixOutput)=$suffix" >> $Env:GITHUB_OUTPUT + """ + shell = "pwsh" +} + +local const readVersionFromPackage = new gha.Step { + name = "Read version" + id = getVersionStep + run = """ + cd Realm/packages + pkgVersion=$(find . -type f -regex ".*Realm.[1-9].*.nupkg" -exec basename {} \\; | sed -n 's/Realm\\.\\(.*\\)\\.nupkg$/\\1/p') + echo "\(versionOutput)=$pkgVersion" >> $GITHUB_OUTPUT + """ +} + +local const function buildDocs(condition: String) = new Listing { + new { + name = "Check Docfx cache" + id = checkDocfxCacheStep + `if` = condition + uses = Actions.cache + with { + ["path"] = "C:\\docfx" + ["key"] = "docfx-2.75.2" + } + } + new { + name = "Download docfx" + `if` = "\(condition) && steps.\(checkDocfxCacheStep).outputs.cache-hit != 'true'" + run = """ + Invoke-WebRequest -Uri https://github.com/dotnet/docfx/releases/download/v2.75.2/docfx-win-x64-v2.75.2.zip -OutFile C:\\docfx.zip + Expand-Archive -Path C:\\docfx.zip -DestinationPath C:\\docfx + """ + } + new { + name = "Build docs" + `if` = condition + env { + ["DOCFX_SOURCE_BRANCH_NAME"] = "${{ github.head_ref }}" + } + run = "C:\\docfx\\docfx Docs/docfx.json" + } +} \ No newline at end of file diff --git a/.github/pkl-workflows/helpers/Steps.pkl b/.github/pkl-workflows/helpers/Steps.pkl index dfd929e5bf..66193e8380 100644 --- a/.github/pkl-workflows/helpers/Steps.pkl +++ b/.github/pkl-workflows/helpers/Steps.pkl @@ -1,16 +1,7 @@ import "../GithubAction/GithubAction.pkl" as gha import "Common.pkl" - -local const actionRunSimulator = "realm/ci-actions/run-ios-simulator@6418e15ed9bbdb19b7d456a347e5623779f95cdf" -local const actionSetupJDK = "actions/setup-java@2e74cbce18569d23ca8b812590dbb83f13ac7c5a" -local const actionAWSConfigureCredentials = "aws-actions/configure-aws-credentials@v4.0.2" -local const actionCoveralls = "coverallsapp/github-action@v2.3.0" -local const actionCheckout = "actions/checkout@v4" -local const actionUploadArtifact = "actions/upload-artifact@v4" -local const actionDownloadArtifact = "actions/download-artifact@v4" -local const actionSetupXcode = "maxim-lobanov/setup-xcode@60606e260d2fc5762a71e64e74b2174e8ea3c8bd" -local const actionSetupDotnet = "actions/setup-dotnet@5d1464d5da459f3d7085106d52e499f4dc5d0f59" -local const actionSetupMsBuild = "microsoft/setup-msbuild@70b70342ae97ca98d5eaad06cafd26d30f9592a9" +import "Package.pkl" +import "Actions.pkl" const function checkout(submodules: (Boolean | "recursive")): Listing = new Listing { checkoutWithoutMatchers(submodules) @@ -19,7 +10,7 @@ const function checkout(submodules: (Boolean | "recursive")): Listing const function checkoutWithoutMatchers(submodules: (Boolean | "recursive")): gha.Step = new { name = "Checkout Code" - uses = actionCheckout + uses = Actions.checkout with { ["submodules"] = submodules ["ref"] = "${{ github.event.pull_request.head.sha }}" @@ -28,7 +19,7 @@ const function checkoutWithoutMatchers(submodules: (Boolean | "recursive")): gha const function uploadArtifacts(artifactName: String, relPath: String): gha.Step = new { name = "Store artifacts for \(artifactName)" - uses = actionUploadArtifact + uses = Actions.uploadArtifact with { ["name"] = artifactName ["path"] = relPath @@ -37,9 +28,18 @@ const function uploadArtifacts(artifactName: String, relPath: String): gha.Step } } +const function downloadArtifacts(artifactName: String, relPath: String): gha.Step = new { + name = "Fetch \(artifactName)" + uses = Actions.downloadArtifact + with { + ["name"] = artifactName + ["path"] = relPath + } +} + const function setupXcode(version: String): gha.Step = new gha.Step { name = "Setup Xcode" - uses = actionSetupXcode + uses = Actions.setupXcode with { ["xcode-version"] = version } @@ -52,7 +52,7 @@ const function setupMSVC(edition: String): gha.Step = new { } const function setupDotnet(version: String?): gha.Step = new { - uses = actionSetupDotnet + uses = Actions.setupDotnet with { ["dotnet-version"] = version ?? "8.0.x" } @@ -66,18 +66,18 @@ const function registerProblemMatchers(): gha.Step = new { """ } -const function fetchPackages(packageJob: String, _packages: List?): List = (_packages ?? Common.packages).map((package) -> new gha.Step { +const function fetchPackages(_packages: List(every((package) -> Common.packages.contains(package)))?): List = (_packages ?? Common.packages).map((package) -> new gha.Step { name = "Fetch \(package)" - uses = actionDownloadArtifact + uses = Actions.downloadArtifact with { - ["name"] = "\(package).${{ needs.\(packageJob).outputs.package_version }}" + ["name"] = "\(package).${{ needs.\(Common.job_Packages).outputs.\(Package.versionOutput) }}" ["path"] = "${{ github.workspace }}/Realm/packages/" } }) -const function fetchWrappers(wrappers: List(every((wrapper) -> Common.wrapperBinaryNames.contains(wrapper)))): List = wrappers.map((wrapper) -> new gha.Step { +const function fetchWrappers(wrappers: List(every((wrapper) -> Common.wrapperBinaryNames.contains(wrapper)))?): List = (wrappers ?? Common.wrapperBinaryNames).map((wrapper) -> new gha.Step { name = "Fetch wrappers for \(wrapper)" - uses = actionDownloadArtifact + uses = Actions.downloadArtifact with { ["name"] = "wrappers-\(wrapper)" ["path"] = "wrappers/build" @@ -94,16 +94,28 @@ const function setupWorkloads(workloads: String?, dotnetVersion: String?): Listi const function setupJDK(): gha.Step = new { name = "Setup JDK" - uses = actionSetupJDK + uses = Actions.setupJDK with { ["distribution"] = "microsoft" ["java-version"] = 11 } } +const function setupAndroid(): Listing = new Listing { + new { + name = "Setup Android" + uses = Actions.setupAndroid + } + new { + name = "Install SDK platform 21" + run = "sdkmanager --install \"platforms;android-21\"" + } + setupJDK() +} + const function configureAWSCredentials(accessKey: String, secretKey: String, region: String): gha.Step = new { name = "Configure AWS Credentials" - uses = actionAWSConfigureCredentials + uses = Actions.awsConfigureCredentials with { ["aws-access-key-id"] = "${{ secrets.\(accessKey) }}" ["aws-secret-access-key"] = "${{ secrets.\(secretKey) }}" @@ -112,7 +124,7 @@ const function configureAWSCredentials(accessKey: String, secretKey: String, reg } class MSBuildConfig { - project: String + projects: Listing target: String? properties: Mapping = new Mapping{} standaloneExe: Boolean = false @@ -121,13 +133,16 @@ class MSBuildConfig { function getPropertiesForInvocation(): String = "-p:Configuration=\(Common.configuration)\(propertiesToString(properties))" } -const function msbuild(config: MSBuildConfig): List = List( - addMSBuildToPath(), - new gha.Step { - name = "Build \(config.project)" - run = "msbuild \(config.project)\(config.getTargetForInvocation()) -restore \(config.getPropertiesForInvocation())" +const function msbuild(config: MSBuildConfig): Listing = new Listing { + addMSBuildToPath() + + for (project in config.projects) { + new gha.Step { + name = "Build \(project)" + run = "msbuild \(project)\(config.getTargetForInvocation()) -restore \(config.getPropertiesForInvocation())" + } } -) +} const function dotnetPublish(project: String, framework: Common.NetFramework, runtime: Common.NetRuntime?, properties: Mapping): Listing = new Listing { new gha.Step { @@ -149,7 +164,7 @@ const function dotnetBuild(project: String, framework: Common.NetFramework, runt const function runSimulator(config: SimulatorConfig): gha.Step = new { name = "Run on Simulator" - uses = actionRunSimulator + uses = Actions.runSimulator with = config.toMap().toMapping() } @@ -172,7 +187,7 @@ const function publishCoverage(file: String): Listing = new Listing = new Listing): gha.StepJobBase = (config) -> new Listing { ...prepareTests(config) ...buildTests(new Steps.MSBuildConfig { - project = "Tests/Realm.Tests" + projects { + "Tests/Realm.Tests" + } properties { ["TargetFramework"] = "net461" } @@ -148,7 +151,9 @@ function tvOS(_syncDifferentiators: Listing): gha.Ste (config) -> new Listing { ...prepareTests(config) ...buildTests(new Steps.MSBuildConfig { - project = "Tests/Tests.XamarinTVOS" + projects { + "Tests/Tests.XamarinTVOS" + } properties { ["Platform"] = "iPhoneSimulator" } @@ -173,7 +178,9 @@ function iOS_Xamarin(): gha.StepJobBase = testJob( (config) -> new Listing { ...prepareTests(config) ...buildTests(new Steps.MSBuildConfig { - project = "Tests/Tests.iOS" + projects { + "Tests/Tests.iOS" + } properties { ["Platform"] = "iPhoneSimulator" } @@ -223,7 +230,9 @@ function macOS_Xamarin(): gha.StepJobBase = testJob( (config) -> new Listing { ...prepareTests(config) ...buildTests(new Steps.MSBuildConfig { - project = "Tests/Tests.XamarinMac" + projects { + "Tests/Tests.XamarinMac" + } }) new { name = "Run the tests" @@ -276,7 +285,9 @@ function uwp(_syncDifferentiators: Listing): gha.Step shell = "powershell" } ...buildTests(new Steps.MSBuildConfig { - project = "Tests/Tests.UWP" + projects { + "Tests/Tests.UWP" + } properties { ["AppxBundle"] = "Always" ["PackageCertificateKeyFile"] = "${{ github.workspace }}\\Tests\\Tests.UWP\\Tests.UWP_TemporaryKey.pfx" @@ -304,7 +315,9 @@ function android_Xamarin(): gha.StepJobBase = testJob( Steps.setupJDK() ...prepareTests(config) ...buildTests(new Steps.MSBuildConfig { - project = "Tests/Tests.Android" + projects { + "Tests/Tests.Android" + } target = "SignAndroidPackage" properties { ["AndroidUseSharedRuntime"] = "False" @@ -373,6 +386,76 @@ function codeCoverage(wrappersJob: String, _syncDifferentiators: Listing = new Mapping { + ["build-unity-tests-\(config.os)"] = new gha.Job { + name = "Build Unity \(config.os)" + `runs-on` = new Listing { + "unity" + config.os + } + `timeout-minutes` = 30 + `if` = Common.ifNotCanceledCondition + steps { + ...Steps.checkout(false) + Steps.cleanupWorkspace() + Steps.downloadArtifacts(Package.unityPkgName, "Realm/Realm.Unity") + Steps.downloadArtifacts("UnityTests", "Tests/Tests.Unity") + new gha.Step { + name = "Build Unity Tests" + run = "unity-editor -runTests -batchmode -projectPath ${{ github.workspace }}/Tests/Tests.Unity -testPlatform Standalone\(config.platform()) -testSettingsFile ${{ github.workspace }}/Tests/Tests.Unity/.TestConfigs/\(config.settings).json -logFile \(if (config.os == "windows") "build.log" else "-")" + } + Steps.uploadArtifacts("UnityTestsRunner.\(config.os)", "Tests/Tests.Unity/Player_Standalone\(config.platform())_\(config.settings)/") + } + } + ["run-unity-tests-\(config.os)"] = new gha.Job { + name = "Test Unity \(config.os)" + `runs-on` = config.runsOn() + `timeout-minutes` = 30 + `if` = Common.ifNotCanceledCondition + needs { + "build-unity-tests-\(config.os)" + } + steps { + ...Steps.checkout(false) + Steps.downloadArtifacts("UnityTestsRunner.\(config.os)", "TestRunner") + when (config.os == "linux") { + new gha.Step { + name = "Install xvfb" + run = "sudo apt install -y xvfb libglu1 libxcursor1" + } + new gha.Step { + name = "Run Tests" + run = """ + chmod +x ${{ github.workspace }}/TestRunner/PlayerWithTests.x86_64 + xvfb-run --auto-servernum --server-args='-screen 0 640x480x24:32' ${{ github.workspace }}/TestRunner/PlayerWithTests.x86_64 -logFile - --result=${{ github.workspace }}/\(outputFile) + """ + } + } + when (config.os == "windows") { + new gha.Step { + name = "Run Tests" + run = """ + Start-Process ${{ github.workspace }}\\TestRunner\\PlayerWithTests.exe -Wait -ArgumentList "-logFile","${{ github.workspace }}\\test.log","--result=${{ github.workspace }}\\\(outputFile)" + cat ${{ github.workspace }}\test.log + """ + shell = "pwsh" + } + } + ...reportTestResults(new TestConfig { + title = "Unity \(config.os) \(config.settings)" + }) + } + } +} + +class UnityTestConfig { + os: "windows" | "linux" + settings: String = "Mono-Net4" + + function platform() = "\(os.capitalize())64" + function runsOn():gha.Machine = if (os == "windows") new gha.WindowsLatest{} else if (os == "linux") new gha.UbuntuLatest{} else throw("invalid os: \(os)") +} + // Private helpers local function testJob(config: TestConfig, runsOn: gha.Machine | String, _strategy: gha.MatrixStrategy?, _steps: Function1>): gha.StepJobBase = (if (_strategy != null) new gha.MatrixJob{ strategy = _strategy @@ -395,24 +478,21 @@ local function testJob(config: TestConfig, runsOn: gha.Machine | String, _strate local function prepareTests(config: TestConfig(needsPackages == true || !usedWrappers.isEmpty)): Listing = new Listing { ...Steps.checkout(false) ...cleanWorkspace(config.shouldCleanWorkspace) - ...fetchTestArtifacts(Common.job_Packages, config.usedWrappers) + ...fetchTestArtifacts(config.usedWrappers) ...BaaS.deployStep(config.syncDifferentiator, config.runSyncTests) } local function cleanWorkspace(shouldClean: Boolean): Listing = new Listing { when (shouldClean) { - new gha.Step { - name = "Cleanup Workspace" - run = "git clean -fdx" - } + Steps.cleanupWorkspace() } } -local function fetchTestArtifacts(packageJob: String, wrappers: List(every((wrapper) -> Common.wrapperBinaryNames.contains(wrapper)))): List = +local function fetchTestArtifacts(wrappers: List(every((wrapper) -> Common.wrapperBinaryNames.contains(wrapper)))): List = if (!wrappers.isEmpty) Steps.fetchWrappers(wrappers) - else Steps.fetchPackages(packageJob, Common.nugetPackages) + else Steps.fetchPackages(Common.nugetPackages) -local function buildTests(config: Steps.MSBuildConfig): List = Steps.msbuild((config) { +local function buildTests(config: Steps.MSBuildConfig): Listing = Steps.msbuild((config) { properties { ...getTestProps(config.standaloneExe) } @@ -447,7 +527,7 @@ local function reportTestResultsWithCustomFile(_outputFile: String, config: Test local function getTestProps(standaloneExe: Boolean): Mapping = new Mapping { ["RestoreConfigFile"] = "Tests/Test.NuGet.Config" - ["UseRealmNupkgsWithVersion"] = "${{ needs.\(Common.job_Packages).outputs.package_version }}" + ["UseRealmNupkgsWithVersion"] = "${{ needs.\(Common.job_Packages).outputs.\(Package.versionOutput) }}" when (standaloneExe) { ["RealmTestsStandaloneExe"] = "true" } diff --git a/.github/pkl-workflows/pr.pkl b/.github/pkl-workflows/pr.pkl index b31846f70c..a66d3d7f04 100644 --- a/.github/pkl-workflows/pr.pkl +++ b/.github/pkl-workflows/pr.pkl @@ -3,13 +3,13 @@ module pr amends "GithubAction/GithubAction.pkl" import "helpers/Common.pkl" +import "helpers/Package.pkl" import "helpers/BaaS.pkl" import "helpers/Lint.pkl" import "helpers/Test.pkl" as TestJobs local class JobNamesDefition { const wrappers: String = "build-wrappers" - const unity: String = "build-unity" const coverage: String = "test-code-coverage" } @@ -54,41 +54,14 @@ jobs { name = "Wrappers" } [Common.job_Baas] = BaaS.deploy(baasDifferentiators) // TODO: run baasaas tests for more targets - [Common.job_Packages] = new ReusableWorkflowJob { - uses = "./.github/workflows/build-packages.yml" - name = "Package" - needs { - JobNames.wrappers - } - with { - ["build-docs"] = "${{ contains(github.head_ref, 'release') }}" - } - } - [JobNames.unity] = new ReusableWorkflowJob { - uses = "./.github/workflows/build-unity.yml" - name = "Package" - with { - ["version"] = "${{ needs.build-packages.outputs.package_version }}" - } - needs { - Common.job_Packages - } - `if` = Common.ifNotCanceledCondition - } - ["test-unity"] = new ReusableWorkflowJob { - uses = "./.github/workflows/test-unity.yml" - name = "Test" - with { - ["version"] = "${{ needs.build-packages.outputs.package_version }}" - ["settings"] = "[\"Mono-Net4\"]" - ["platform"] = "[{ \"os\": \"windows\", \"testPlatform\": \"Windows64\" }, { \"os\": \"linux\", \"testPlatform\": \"Linux64\" }]" - } - needs { - JobNames.unity - Common.job_Packages - } - `if` = Common.ifNotCanceledCondition - } + [Common.job_Packages] = Package.nuget("contains(github.head_ref, 'release')") + [Common.job_Unity] = Package.unity() + ...TestJobs.unity(new TestJobs.UnityTestConfig { + os = "linux" + }) + ...TestJobs.unity(new TestJobs.UnityTestConfig { + os = "windows" + }) ["test-net-framework"] = TestJobs.netFramework(baasDifferentiators) ["test-uwp"] = TestJobs.uwp(baasDifferentiators) ["test-net-core"] = TestJobs.netCore(new Listing { "net8.0" }) diff --git a/.github/pkl-workflows/wrappers.pkl b/.github/pkl-workflows/wrappers.pkl index 24a4bee71b..8c2b009716 100644 --- a/.github/pkl-workflows/wrappers.pkl +++ b/.github/pkl-workflows/wrappers.pkl @@ -4,6 +4,7 @@ amends "GithubAction/GithubAction.pkl" import "helpers/Common.pkl" import "helpers/Steps.pkl" +import "helpers/Actions.pkl" local class JobNamesDefition { const checkCache: String = "check-cache" @@ -153,11 +154,11 @@ local function withCondition(platform: String, _conditionToAppend: String?) = ne } local function restoreCache(platform: String): Step = new Step { - uses = "actions/cache/restore@v4" + uses = Actions.restoreCache } |> cacheStep(platform, platform) local function checkCache(platform: String): Step = new Step { - uses = "actions/cache@v4" + uses = Actions.cache } |> cacheStep(platform, null) local function cacheStep(platform: String, idSuffix: String?) = new Mixin { diff --git a/.github/templates/build-packages.yml b/.github/templates/build-packages.yml deleted file mode 100644 index 5337ee4153..0000000000 --- a/.github/templates/build-packages.yml +++ /dev/null @@ -1,112 +0,0 @@ -#@ load("@ytt:template", "template") -#@ load("common.lib.yml", "checkoutCode", "fetchWrapperBinaries", "msBuildMultiple", "readVersionFromPackage", "uploadArtifacts", "actionCache", "nugetPackages", "setupDotnet", "setupWorkloads", "setupAndroid") - -#@ def buildDocs(): - - name: Check Docfx cache - id: check-docfx-cache - if: inputs.build-docs - uses: #@ actionCache - with: - path: 'C:\docfx' - key: docfx-2.75.2 - - name: Download docfx - if: inputs.build-docs && steps.check-docfx-cache.outputs.cache-hit != 'true' - run: | - Invoke-WebRequest -Uri https://github.com/dotnet/docfx/releases/download/v2.75.2/docfx-win-x64-v2.75.2.zip -OutFile C:\docfx.zip - Expand-Archive -Path C:\docfx.zip -DestinationPath C:\docfx - shell: powershell - - _: #@ template.replace(setupDotnet(ifCondition = "inputs.build-docs")) - - name: Build docs - if: inputs.build-docs - env: - DOCFX_SOURCE_BRANCH_NAME: ${{ github.head_ref }} - run: | - C:\docfx\docfx Docs/docfx.json - -#! the link generated by docfx is incorrect - it points to -#! https://github.com/realm/realm-dotnet/new/main/Docs/apispec/new?filename=... -#! instead of -#! https://github.com/realm/realm-dotnet/new/main/Docs/apispec?filename=... - - name: Update Improve this doc links - run: | - Get-ChildItem Docs/_site -Filter *.html -Recurse -File | - ForEach-Object { - $content = ($_ | Get-Content -Raw) - $content = $content -replace "/Docs/apispec/new\?filename", "/Docs/apispec?filename" - Set-Content $_.FullName $content - } - shell: pwsh - - - name: Archive docs - if: inputs.build-docs - run: | - Compress-Archive -Path Docs/_site -DestinationPath "Realm/packages/Docs.zip" - - _: #@ template.replace(uploadArtifacts("Docs.zip", "Realm/packages/Docs.zip")) - if: inputs.build-docs -#@ end - -#@ def uploadPackageArtifacts(): -#@ for pkgName in nugetPackages: -#@ finalPkgName = pkgName + ".${{ steps.get-version.outputs.version }}" - - #@ uploadArtifacts(finalPkgName, "Realm/packages/" + finalPkgName + ".*nupkg") -#@ end -#@ end - -#@ def mainPackagePaths(): -#@ result = [] -#@ for pkg in nugetPackages: -#@ result.append("Realm/" + pkg) -#@ end -#@ return result -#@ end - ---- -name: build-packages -"on": - workflow_call: - inputs: - build-docs: - type: boolean - required: false - default: false - outputs: - package_version: - value: ${{ jobs.build-packages.outputs.package_version }} -env: - REALM_DISABLE_ANALYTICS: true - DOTNET_NOLOGO: true -jobs: - build-packages: - runs-on: windows-latest - name: NuGet - outputs: - package_version: ${{ steps.get-version.outputs.version }} - timeout-minutes: 30 - steps: - - #@ template.replace(checkoutCode()) - - #@ template.replace(setupAndroid()) - - #@ template.replace(setupWorkloads('tvos ios maccatalyst android')) - - name: Set version suffix - id: set-version-suffix - #! Build suffix is pr-1234.5 for pr builds or alpha.123 for branch builds. - run: | - $suffix = "" - if ($env:GITHUB_EVENT_NAME -eq "pull_request") - { - if (-Not "${{ github.head_ref }}".Contains("release")) - { - $suffix = "pr-${{ github.event.number }}.$env:GITHUB_RUN_NUMBER" - } - } - else - { - $suffix = "alpha.$env:GITHUB_RUN_NUMBER" - } - echo "build_suffix=$suffix" >> $Env:GITHUB_OUTPUT - - #@ template.replace(fetchWrapperBinaries()) - - #@ template.replace(msBuildMultiple(mainPackagePaths(), target="Pack", PackageOutputPath="${{ github.workspace }}/Realm/packages", VersionSuffix="${{ steps.set-version-suffix.outputs.build_suffix }}")) - - #@ template.replace(readVersionFromPackage()) - - #@ template.replace(uploadPackageArtifacts()) - - #@ uploadArtifacts("ExtractedChangelog", "Realm/Realm/ExtractedChangelog.md") - - #@ template.replace(buildDocs()) - diff --git a/.github/templates/build-unity.yml b/.github/templates/build-unity.yml deleted file mode 100644 index 789932c070..0000000000 --- a/.github/templates/build-unity.yml +++ /dev/null @@ -1,31 +0,0 @@ -#@ load("@ytt:template", "template") -#@ load("common.lib.yml", "checkoutCode", "uploadArtifacts", "nugetPackages", "actionDownloadArtifact", "fetchPackageArtifacts") - -#@ unityPkgName = "io.realm.unity-${{ inputs.version }}.tgz" - ---- -name: build-unity -"on": - workflow_call: - inputs: - version: - type: string - required: true -env: - REALM_DISABLE_ANALYTICS: true - DOTNET_NOLOGO: true -jobs: - prepare-unity-packages: - runs-on: windows-latest - name: Unity - timeout-minutes: 30 - steps: - - #@ template.replace(checkoutCode()) - - #@ template.replace(fetchPackageArtifacts(packages = nugetPackages)) - - name: Build Unity - run: dotnet run --project Tools/SetupUnityPackage/ -- realm --packages-path Realm/packages --pack - - #@ uploadArtifacts(unityPkgName, "Realm/Realm.Unity/" + unityPkgName) - - #@ uploadArtifacts("AssetStorePublisher-${{ inputs.version }}", "Tools/AssetStorePublisher", "${{ (github.event_name != 'pull_request' || contains(github.head_ref, 'release')) && 30 || 1 }}") - - name: Build Tests - run: #@ "dotnet run --project Tools/SetupUnityPackage/ -- tests --realm-package Realm/Realm.Unity/" + unityPkgName - - #@ uploadArtifacts("UnityTests", "Tests/Tests.Unity") diff --git a/.github/templates/test-unity.yml b/.github/templates/test-unity.yml deleted file mode 100644 index 18ce107bd9..0000000000 --- a/.github/templates/test-unity.yml +++ /dev/null @@ -1,96 +0,0 @@ -#@ load("@ytt:template", "template") -#@ load("common.lib.yml", "uploadArtifacts", "actionDownloadArtifact", "checkoutCode") -#@ load("test.lib.yml", "publishTestsResults") - -#@ unityPkgName = "io.realm.unity-${{ inputs.version }}.tgz" - ---- -name: test-unity -"on": - workflow_call: - inputs: - version: - type: string - required: true - platform: - type: string - required: true - settings: - type: string - required: true -env: - REALM_DISABLE_ANALYTICS: true - DOTNET_NOLOGO: true -jobs: - build-tests: - runs-on: - - unity - - ${{ matrix.platform.os }} - name: Build Unity ${{ matrix.platform.os }} - strategy: - fail-fast: false - matrix: - platform: ${{ fromJson(inputs.platform) }} - settings: ${{ fromJson(inputs.settings) }} - timeout-minutes: 30 - steps: - - #@ template.replace(checkoutCode()) - - name: Cleanup Workspace - run: git clean -fdx - - name: Fetch Unity Package - uses: #@ actionDownloadArtifact - with: - name: #@ unityPkgName - path: Realm/Realm.Unity - - name: Fetch Unity Tests - uses: #@ actionDownloadArtifact - with: - name: UnityTests - path: Tests/Tests.Unity - - name: Build Unity Tests - run: | - unity-editor -runTests -batchmode -projectPath ${{ github.workspace }}/Tests/Tests.Unity -testPlatform Standalone${{ matrix.platform.testPlatform }} -testSettingsFile ${{ github.workspace }}/Tests/Tests.Unity/.TestConfigs/${{ matrix.settings }}.json -logFile ${{ matrix.platform.os == 'windows' && 'build.log' || '-'}} - - #@ uploadArtifacts("UnityTestsRunner.${{ matrix.platform.os }}", "Tests/Tests.Unity/Player_Standalone${{ matrix.platform.testPlatform }}_${{ matrix.settings }}/") - - run-tests-linux: - runs-on: ubuntu-latest - name: Unity Linux - timeout-minutes: 30 - needs: - - build-tests - if: ${{ contains(inputs.platform, 'Linux') }} - steps: - - #@ template.replace(checkoutCode()) - - name: Download Test Runner - uses: #@ actionDownloadArtifact - with: - name: UnityTestsRunner.linux - path: TestRunner - - name: Install xvfb - run: sudo apt install -y xvfb libglu1 libxcursor1 - - name: Run Tests - run: | - chmod +x ${{ github.workspace }}/TestRunner/PlayerWithTests.x86_64 - xvfb-run --auto-servernum --server-args='-screen 0 640x480x24:32' ${{ github.workspace }}/TestRunner/PlayerWithTests.x86_64 -logFile - --result=${{ github.workspace }}/TestResults.xml - - #@ template.replace(publishTestsResults("TestResults.xml", "Unity Linux Mono_Net4")) - - run-tests-windows: - runs-on: windows-latest - name: Unity Windows - if: ${{ contains(inputs.platform, 'Windows') }} - timeout-minutes: 30 - needs: - - build-tests - steps: - - #@ template.replace(checkoutCode()) - - name: Download Test Runner - uses: #@ actionDownloadArtifact - with: - name: UnityTestsRunner.windows - path: TestRunner - - name: Run Tests - run: | - Start-Process ${{ github.workspace }}\TestRunner\PlayerWithTests.exe -Wait -ArgumentList "-logFile","${{ github.workspace }}\test.log","--result=${{ github.workspace }}\TestResults.xml" - cat ${{ github.workspace }}\test.log - shell: powershell - - #@ template.replace(publishTestsResults("TestResults.xml", "Unity Windows Mono_Net4")) diff --git a/.github/workflows/build-packages.yml b/.github/workflows/build-packages.yml deleted file mode 100755 index 6f78bf3620..0000000000 --- a/.github/workflows/build-packages.yml +++ /dev/null @@ -1,260 +0,0 @@ -name: build-packages -"on": - workflow_call: - inputs: - build-docs: - type: boolean - required: false - default: false - outputs: - package_version: - value: ${{ jobs.build-packages.outputs.package_version }} -env: - REALM_DISABLE_ANALYTICS: true - DOTNET_NOLOGO: true -jobs: - build-packages: - runs-on: windows-latest - name: NuGet - outputs: - package_version: ${{ steps.get-version.outputs.version }} - timeout-minutes: 30 - 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: Setup Android - uses: android-actions/setup-android@7c5672355aaa8fde5f97a91aa9a99616d1ace6bc - - name: Install SDK platform 21 - run: sdkmanager --install "platforms;android-21" - - name: Setup JDK - uses: actions/setup-java@0ab4596768b603586c0de567f2430c30f5b0d2b0 - with: - distribution: microsoft - java-version: 11 - - name: Configure .NET - uses: actions/setup-dotnet@3e6b9fe3930cac7c59c651af5de1514b47a805b9 - with: - dotnet-version: 8.0.x - - name: Setup workloads - run: dotnet workload install tvos ios maccatalyst android - - name: Set version suffix - id: set-version-suffix - run: | - $suffix = "" - if ($env:GITHUB_EVENT_NAME -eq "pull_request") - { - if (-Not "${{ github.head_ref }}".Contains("release")) - { - $suffix = "pr-${{ github.event.number }}.$env:GITHUB_RUN_NUMBER" - } - } - else - { - $suffix = "alpha.$env:GITHUB_RUN_NUMBER" - } - echo "build_suffix=$suffix" >> $Env:GITHUB_OUTPUT - - name: Fetch artifacts for macos - uses: actions/download-artifact@v4 - with: - name: wrappers-macos - path: wrappers/build - - name: Fetch artifacts for catalyst - uses: actions/download-artifact@v4 - with: - name: wrappers-catalyst - path: wrappers/build - - name: Fetch artifacts for linux-x86_64 - uses: actions/download-artifact@v4 - with: - name: wrappers-linux-x86_64 - path: wrappers/build - - name: Fetch artifacts for linux-armhf - uses: actions/download-artifact@v4 - with: - name: wrappers-linux-armhf - path: wrappers/build - - name: Fetch artifacts for linux-aarch64 - uses: actions/download-artifact@v4 - with: - name: wrappers-linux-aarch64 - path: wrappers/build - - name: Fetch artifacts for iOS-Device - uses: actions/download-artifact@v4 - with: - name: wrappers-iOS-Device - path: wrappers/build - - name: Fetch artifacts for iOS-Simulator - uses: actions/download-artifact@v4 - with: - name: wrappers-iOS-Simulator - path: wrappers/build - - name: Fetch artifacts for tvOS-Device - uses: actions/download-artifact@v4 - with: - name: wrappers-tvOS-Device - path: wrappers/build - - name: Fetch artifacts for tvOS-Simulator - uses: actions/download-artifact@v4 - with: - name: wrappers-tvOS-Simulator - path: wrappers/build - - name: Fetch artifacts for android-armeabi-v7a - uses: actions/download-artifact@v4 - with: - name: wrappers-android-armeabi-v7a - path: wrappers/build - - name: Fetch artifacts for android-arm64-v8a - uses: actions/download-artifact@v4 - with: - name: wrappers-android-arm64-v8a - path: wrappers/build - - name: Fetch artifacts for android-x86 - uses: actions/download-artifact@v4 - with: - name: wrappers-android-x86 - path: wrappers/build - - name: Fetch artifacts for android-x86_64 - uses: actions/download-artifact@v4 - with: - name: wrappers-android-x86_64 - path: wrappers/build - - name: Fetch artifacts for windows-Win32 - uses: actions/download-artifact@v4 - with: - name: wrappers-windows-Win32 - path: wrappers/build - - name: Fetch artifacts for windows-x64 - uses: actions/download-artifact@v4 - with: - name: wrappers-windows-x64 - path: wrappers/build - - name: Fetch artifacts for windows-ARM64 - uses: actions/download-artifact@v4 - with: - name: wrappers-windows-ARM64 - path: wrappers/build - - name: Fetch artifacts for windows-uwp-Win32 - uses: actions/download-artifact@v4 - with: - name: wrappers-windows-uwp-Win32 - path: wrappers/build - - name: Fetch artifacts for windows-uwp-x64 - uses: actions/download-artifact@v4 - with: - name: wrappers-windows-uwp-x64 - path: wrappers/build - - name: Fetch artifacts for windows-uwp-ARM - uses: actions/download-artifact@v4 - with: - name: wrappers-windows-uwp-ARM - path: wrappers/build - - name: Fetch artifacts for windows-uwp-ARM64 - uses: actions/download-artifact@v4 - with: - name: wrappers-windows-uwp-ARM64 - path: wrappers/build - - name: Add msbuild to PATH - uses: microsoft/setup-msbuild@0b44c6745b7e81956596964100aadb92d667c497 - if: ${{ runner.os == 'Windows' }} - - name: Build Realm/Realm.PlatformHelpers - run: msbuild Realm/Realm.PlatformHelpers -t:Pack -p:Configuration=Release -restore -p:PackageOutputPath=${{ github.workspace }}/Realm/packages -p:VersionSuffix=${{ steps.set-version-suffix.outputs.build_suffix }} - - name: Build Realm/Realm - run: msbuild Realm/Realm -t:Pack -p:Configuration=Release -restore -p:PackageOutputPath=${{ github.workspace }}/Realm/packages -p:VersionSuffix=${{ steps.set-version-suffix.outputs.build_suffix }} - - name: Build Realm/Realm.UnityUtils - run: msbuild Realm/Realm.UnityUtils -t:Pack -p:Configuration=Release -restore -p:PackageOutputPath=${{ github.workspace }}/Realm/packages -p:VersionSuffix=${{ steps.set-version-suffix.outputs.build_suffix }} - - name: Build Realm/Realm.UnityWeaver - run: msbuild Realm/Realm.UnityWeaver -t:Pack -p:Configuration=Release -restore -p:PackageOutputPath=${{ github.workspace }}/Realm/packages -p:VersionSuffix=${{ steps.set-version-suffix.outputs.build_suffix }} - - name: Read version - id: get-version - run: | - cd Realm/packages - pkgVersion=$(find . -type f -regex ".*Realm.[1-9].*.nupkg" -exec basename {} \; | sed -n 's/Realm\.\(.*\)\.nupkg$/\1/p') - echo "version=$pkgVersion" >> $GITHUB_OUTPUT - shell: bash - - name: Store artifacts for Realm.PlatformHelpers.${{ steps.get-version.outputs.version }} - uses: actions/upload-artifact@v4 - with: - name: Realm.PlatformHelpers.${{ steps.get-version.outputs.version }} - path: ${{ github.workspace }}/Realm/packages/Realm.PlatformHelpers.${{ steps.get-version.outputs.version }}.*nupkg - retention-days: ${{ github.event_name != 'pull_request' && 30 || 1 }} - if-no-files-found: error - - name: Store artifacts for Realm.${{ steps.get-version.outputs.version }} - uses: actions/upload-artifact@v4 - with: - name: Realm.${{ steps.get-version.outputs.version }} - path: ${{ github.workspace }}/Realm/packages/Realm.${{ steps.get-version.outputs.version }}.*nupkg - retention-days: ${{ github.event_name != 'pull_request' && 30 || 1 }} - if-no-files-found: error - - name: Store artifacts for Realm.UnityUtils.${{ steps.get-version.outputs.version }} - uses: actions/upload-artifact@v4 - with: - name: Realm.UnityUtils.${{ steps.get-version.outputs.version }} - path: ${{ github.workspace }}/Realm/packages/Realm.UnityUtils.${{ steps.get-version.outputs.version }}.*nupkg - retention-days: ${{ github.event_name != 'pull_request' && 30 || 1 }} - if-no-files-found: error - - name: Store artifacts for Realm.UnityWeaver.${{ steps.get-version.outputs.version }} - uses: actions/upload-artifact@v4 - with: - name: Realm.UnityWeaver.${{ steps.get-version.outputs.version }} - path: ${{ github.workspace }}/Realm/packages/Realm.UnityWeaver.${{ steps.get-version.outputs.version }}.*nupkg - retention-days: ${{ github.event_name != 'pull_request' && 30 || 1 }} - if-no-files-found: error - - name: Store artifacts for ExtractedChangelog - uses: actions/upload-artifact@v4 - with: - name: ExtractedChangelog - path: ${{ github.workspace }}/Realm/Realm/ExtractedChangelog.md - retention-days: ${{ github.event_name != 'pull_request' && 30 || 1 }} - if-no-files-found: error - - name: Check Docfx cache - id: check-docfx-cache - if: inputs.build-docs - uses: nirinchev/cache@29e8e4dd9148ea81f9e188480132072cb6cc92d8 - with: - path: C:\docfx - key: docfx-2.75.2 - - name: Download docfx - if: inputs.build-docs && steps.check-docfx-cache.outputs.cache-hit != 'true' - run: | - Invoke-WebRequest -Uri https://github.com/dotnet/docfx/releases/download/v2.75.2/docfx-win-x64-v2.75.2.zip -OutFile C:\docfx.zip - Expand-Archive -Path C:\docfx.zip -DestinationPath C:\docfx - shell: powershell - - name: Configure .NET - uses: actions/setup-dotnet@3e6b9fe3930cac7c59c651af5de1514b47a805b9 - if: inputs.build-docs - with: - dotnet-version: 8.0.x - - name: Build docs - if: inputs.build-docs - env: - DOCFX_SOURCE_BRANCH_NAME: ${{ github.head_ref }} - run: | - C:\docfx\docfx Docs/docfx.json - - name: Update Improve this doc links - run: | - Get-ChildItem Docs/_site -Filter *.html -Recurse -File | - ForEach-Object { - $content = ($_ | Get-Content -Raw) - $content = $content -replace "/Docs/apispec/new\?filename", "/Docs/apispec?filename" - Set-Content $_.FullName $content - } - shell: pwsh - - name: Archive docs - if: inputs.build-docs - run: | - Compress-Archive -Path Docs/_site -DestinationPath "Realm/packages/Docs.zip" - - name: Store artifacts for Docs.zip - uses: actions/upload-artifact@v4 - with: - name: Docs.zip - path: ${{ github.workspace }}/Realm/packages/Docs.zip - retention-days: ${{ github.event_name != 'pull_request' && 30 || 1 }} - if-no-files-found: error - if: inputs.build-docs diff --git a/.github/workflows/build-unity.yml b/.github/workflows/build-unity.yml deleted file mode 100755 index 354ba7f97f..0000000000 --- a/.github/workflows/build-unity.yml +++ /dev/null @@ -1,70 +0,0 @@ -name: build-unity -"on": - workflow_call: - inputs: - version: - type: string - required: true -env: - REALM_DISABLE_ANALYTICS: true - DOTNET_NOLOGO: true -jobs: - prepare-unity-packages: - runs-on: windows-latest - name: Unity - timeout-minutes: 30 - 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@v4 - with: - name: Realm.PlatformHelpers.${{ inputs.version }} - path: ${{ github.workspace }}/Realm/packages/ - - name: Fetch Realm - uses: actions/download-artifact@v4 - with: - name: Realm.${{ inputs.version }} - path: ${{ github.workspace }}/Realm/packages/ - - name: Fetch Realm.UnityUtils - uses: actions/download-artifact@v4 - with: - name: Realm.UnityUtils.${{ inputs.version }} - path: ${{ github.workspace }}/Realm/packages/ - - name: Fetch Realm.UnityWeaver - uses: actions/download-artifact@v4 - with: - name: Realm.UnityWeaver.${{ inputs.version }} - path: ${{ github.workspace }}/Realm/packages/ - - name: Build Unity - run: dotnet run --project Tools/SetupUnityPackage/ -- realm --packages-path Realm/packages --pack - - name: Store artifacts for io.realm.unity-${{ inputs.version }}.tgz - uses: actions/upload-artifact@v4 - with: - name: io.realm.unity-${{ inputs.version }}.tgz - path: ${{ github.workspace }}/Realm/Realm.Unity/io.realm.unity-${{ inputs.version }}.tgz - retention-days: ${{ github.event_name != 'pull_request' && 30 || 1 }} - if-no-files-found: error - - name: Store artifacts for AssetStorePublisher-${{ inputs.version }} - uses: actions/upload-artifact@v4 - with: - name: AssetStorePublisher-${{ inputs.version }} - path: ${{ github.workspace }}/Tools/AssetStorePublisher - retention-days: ${{ (github.event_name != 'pull_request' || contains(github.head_ref, 'release')) && 30 || 1 }} - if-no-files-found: error - - name: Build Tests - run: dotnet run --project Tools/SetupUnityPackage/ -- tests --realm-package Realm/Realm.Unity/io.realm.unity-${{ inputs.version }}.tgz - - name: Store artifacts for UnityTests - uses: actions/upload-artifact@v4 - with: - name: UnityTests - path: ${{ github.workspace }}/Tests/Tests.Unity - retention-days: ${{ github.event_name != 'pull_request' && 30 || 1 }} - if-no-files-found: error diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index ab9a040a5d..3184aa585e 100755 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -55,31 +55,407 @@ jobs: - code-coverage fail-fast: false build-packages: - name: Package - needs: - - build-wrappers - uses: ./.github/workflows/build-packages.yml - with: - build-docs: ${{ contains(github.head_ref, 'release') }} + name: Package NuGet + outputs: + package_version: ${{ steps.get-version.outputs.package_version }} + timeout-minutes: 30 + runs-on: windows-latest + steps: + - name: Checkout Code + uses: actions/checkout@v4 + with: + submodules: false + ref: ${{ github.event.pull_request.head.sha }} + - name: Register problem matchers + run: |- + echo "::add-matcher::.github/problem-matchers/csc.json" + echo "::add-matcher::.github/problem-matchers/msvc.json" + - name: Setup Android + uses: android-actions/setup-android@e1f5280adf78cf863c0fa43ffabc64a9cd08153f + - name: Install SDK platform 21 + run: sdkmanager --install "platforms;android-21" + - name: Setup JDK + uses: actions/setup-java@2e74cbce18569d23ca8b812590dbb83f13ac7c5a + with: + distribution: microsoft + java-version: 11 + - uses: actions/setup-dotnet@5d1464d5da459f3d7085106d52e499f4dc5d0f59 + with: + dotnet-version: 8.0.x + - name: Setup workloads + run: dotnet workload install tvos ios maccatalyst android + - name: Set version suffix + id: set-version-suffix + run: |- + $suffix = "" + if ($env:GITHUB_EVENT_NAME -eq "pull_request") + { + if (-Not "${{ github.head_ref }}".Contains("release")) + { + $suffix = "pr-${{ github.event.number }}.$env:GITHUB_RUN_NUMBER" + } + } + else + { + $suffix = "alpha.$env:GITHUB_RUN_NUMBER" + } + echo "build_suffix=$suffix" >> $Env:GITHUB_OUTPUT + shell: pwsh + - name: Fetch wrappers for macos + uses: actions/download-artifact@v4 + with: + name: wrappers-macos + path: wrappers/build + - name: Fetch wrappers for catalyst + uses: actions/download-artifact@v4 + with: + name: wrappers-catalyst + path: wrappers/build + - name: Fetch wrappers for linux-x86_64 + uses: actions/download-artifact@v4 + with: + name: wrappers-linux-x86_64 + path: wrappers/build + - name: Fetch wrappers for linux-armhf + uses: actions/download-artifact@v4 + with: + name: wrappers-linux-armhf + path: wrappers/build + - name: Fetch wrappers for linux-aarch64 + uses: actions/download-artifact@v4 + with: + name: wrappers-linux-aarch64 + path: wrappers/build + - name: Fetch wrappers for android-armeabi-v7a + uses: actions/download-artifact@v4 + with: + name: wrappers-android-armeabi-v7a + path: wrappers/build + - name: Fetch wrappers for android-arm64-v8a + uses: actions/download-artifact@v4 + with: + name: wrappers-android-arm64-v8a + path: wrappers/build + - name: Fetch wrappers for android-x86 + uses: actions/download-artifact@v4 + with: + name: wrappers-android-x86 + path: wrappers/build + - name: Fetch wrappers for android-x86_64 + uses: actions/download-artifact@v4 + with: + name: wrappers-android-x86_64 + path: wrappers/build + - name: Fetch wrappers for windows-Win32 + uses: actions/download-artifact@v4 + with: + name: wrappers-windows-Win32 + path: wrappers/build + - name: Fetch wrappers for windows-x64 + uses: actions/download-artifact@v4 + with: + name: wrappers-windows-x64 + path: wrappers/build + - name: Fetch wrappers for windows-ARM64 + uses: actions/download-artifact@v4 + with: + name: wrappers-windows-ARM64 + path: wrappers/build + - name: Fetch wrappers for windows-uwp-Win32 + uses: actions/download-artifact@v4 + with: + name: wrappers-windows-uwp-Win32 + path: wrappers/build + - name: Fetch wrappers for windows-uwp-x64 + uses: actions/download-artifact@v4 + with: + name: wrappers-windows-uwp-x64 + path: wrappers/build + - name: Fetch wrappers for windows-uwp-ARM + uses: actions/download-artifact@v4 + with: + name: wrappers-windows-uwp-ARM + path: wrappers/build + - name: Fetch wrappers for windows-uwp-ARM64 + uses: actions/download-artifact@v4 + with: + name: wrappers-windows-uwp-ARM64 + path: wrappers/build + - name: Fetch wrappers for iOS-Device + uses: actions/download-artifact@v4 + with: + name: wrappers-iOS-Device + path: wrappers/build + - name: Fetch wrappers for iOS-Simulator + uses: actions/download-artifact@v4 + with: + name: wrappers-iOS-Simulator + path: wrappers/build + - name: Fetch wrappers for tvOS-Device + uses: actions/download-artifact@v4 + with: + name: wrappers-tvOS-Device + path: wrappers/build + - name: Fetch wrappers for tvOS-Simulator + uses: actions/download-artifact@v4 + with: + name: wrappers-tvOS-Simulator + path: wrappers/build + - name: Add msbuild to PATH + if: ${{ runner.os == 'Windows' }} + uses: microsoft/setup-msbuild@70b70342ae97ca98d5eaad06cafd26d30f9592a9 + - name: Build Realm/Realm + run: msbuild Realm/Realm -t:Pack -restore -p:Configuration=Release -p:PackageOutputPath=${{ github.workspace }}/Realm/packages -p:VersionSuffix=${{ steps.set-version-suffix.outputs.build_suffix }} + - name: Build Realm/Realm.PlatformHelpers + run: msbuild Realm/Realm.PlatformHelpers -t:Pack -restore -p:Configuration=Release -p:PackageOutputPath=${{ github.workspace }}/Realm/packages -p:VersionSuffix=${{ steps.set-version-suffix.outputs.build_suffix }} + - name: Read version + id: get-version + run: |- + cd Realm/packages + pkgVersion=$(find . -type f -regex ".*Realm.[1-9].*.nupkg" -exec basename {} \; | sed -n 's/Realm\.\(.*\)\.nupkg$/\1/p') + echo "package_version=$pkgVersion" >> $GITHUB_OUTPUT + - name: Store artifacts for Realm.${{ steps.get-version.outputs.package_version }} + uses: actions/upload-artifact@v4 + with: + name: Realm.${{ steps.get-version.outputs.package_version }} + path: Realm/packages/Realm.${{ steps.get-version.outputs.package_version }}.*nupkg + retention-days: ${{ github.event_name != 'pull_request' && 30 || 1 }} + if-no-files-found: error + - name: Store artifacts for Realm.PlatformHelpers.${{ steps.get-version.outputs.package_version }} + uses: actions/upload-artifact@v4 + with: + name: Realm.PlatformHelpers.${{ steps.get-version.outputs.package_version }} + path: Realm/packages/Realm.PlatformHelpers.${{ steps.get-version.outputs.package_version }}.*nupkg + retention-days: ${{ github.event_name != 'pull_request' && 30 || 1 }} + if-no-files-found: error + - name: Store artifacts for ExtractedChangelog + uses: actions/upload-artifact@v4 + with: + name: ExtractedChangelog + path: Realm/Realm/ExtractedChangelog.md + retention-days: ${{ github.event_name != 'pull_request' && 30 || 1 }} + if-no-files-found: error + - name: Check Docfx cache + id: check-docfx-cache + if: contains(github.head_ref, 'release') + uses: actions/cache@v4 + with: + path: C:\docfx + key: docfx-2.75.2 + - name: Download docfx + if: contains(github.head_ref, 'release') && steps.check-docfx-cache.outputs.cache-hit != 'true' + run: |- + Invoke-WebRequest -Uri https://github.com/dotnet/docfx/releases/download/v2.75.2/docfx-win-x64-v2.75.2.zip -OutFile C:\docfx.zip + Expand-Archive -Path C:\docfx.zip -DestinationPath C:\docfx + - name: Build docs + if: contains(github.head_ref, 'release') + env: + DOCFX_SOURCE_BRANCH_NAME: ${{ github.head_ref }} + run: C:\docfx\docfx Docs/docfx.json build-unity: - name: Package + name: Package Unity needs: - build-packages if: always() && !cancelled() && !contains(needs.*.result, 'failure') && !contains(needs.*.result, 'cancelled') - uses: ./.github/workflows/build-unity.yml - with: - version: ${{ needs.build-packages.outputs.package_version }} - test-unity: - name: Test + timeout-minutes: 30 + runs-on: windows-latest + steps: + - name: Checkout Code + uses: actions/checkout@v4 + with: + submodules: false + ref: ${{ github.event.pull_request.head.sha }} + - name: Register problem matchers + run: |- + echo "::add-matcher::.github/problem-matchers/csc.json" + echo "::add-matcher::.github/problem-matchers/msvc.json" + - name: Fetch Realm + uses: actions/download-artifact@v4 + with: + name: Realm.${{ needs.build-packages.outputs.package_version }} + path: ${{ github.workspace }}/Realm/packages/ + - name: Fetch Realm.PlatformHelpers + uses: actions/download-artifact@v4 + with: + name: Realm.PlatformHelpers.${{ needs.build-packages.outputs.package_version }} + path: ${{ github.workspace }}/Realm/packages/ + - name: Fetch Realm.UnityUtils + uses: actions/download-artifact@v4 + with: + name: Realm.UnityUtils.${{ needs.build-packages.outputs.package_version }} + path: ${{ github.workspace }}/Realm/packages/ + - name: Fetch Realm.UnityWeaver + uses: actions/download-artifact@v4 + with: + name: Realm.UnityWeaver.${{ needs.build-packages.outputs.package_version }} + path: ${{ github.workspace }}/Realm/packages/ + - name: Build Unity + run: dotnet run --project Tools/SetupUnityPackage/ -- realm --packages-path Realm/packages --pack + - name: Store artifacts for io.realm.unity-${{ needs.build-packages.outputs.package_version }}.tgz + uses: actions/upload-artifact@v4 + with: + name: io.realm.unity-${{ needs.build-packages.outputs.package_version }}.tgz + path: Realm/Realm.Unity/io.realm.unity-${{ needs.build-packages.outputs.package_version }}.tgz + retention-days: ${{ github.event_name != 'pull_request' && 30 || 1 }} + if-no-files-found: error + - name: Build Tests + run: dotnet run --project Tools/SetupUnityPackage/ -- tests --realm-package Realm/Realm.Unity/io.realm.unity-${{ needs.build-packages.outputs.package_version }}.tgz + - name: Store artifacts for UnityTests + uses: actions/upload-artifact@v4 + with: + name: UnityTests + path: Tests/Tests.Unity + retention-days: ${{ github.event_name != 'pull_request' && 30 || 1 }} + if-no-files-found: error + build-unity-tests-linux: + name: Build Unity linux + if: always() && !cancelled() && !contains(needs.*.result, 'failure') && !contains(needs.*.result, 'cancelled') + timeout-minutes: 30 + runs-on: + - unity + - linux + steps: + - name: Checkout Code + uses: actions/checkout@v4 + with: + submodules: false + ref: ${{ github.event.pull_request.head.sha }} + - name: Register problem matchers + run: |- + echo "::add-matcher::.github/problem-matchers/csc.json" + echo "::add-matcher::.github/problem-matchers/msvc.json" + - name: Cleanup Workspace + run: git clean -fdx + - name: Fetch io.realm.unity-${{ needs.build-packages.outputs.package_version }}.tgz + uses: actions/download-artifact@v4 + with: + name: io.realm.unity-${{ needs.build-packages.outputs.package_version }}.tgz + path: Realm/Realm.Unity + - name: Fetch UnityTests + uses: actions/download-artifact@v4 + with: + name: UnityTests + path: Tests/Tests.Unity + - name: Build Unity Tests + run: unity-editor -runTests -batchmode -projectPath ${{ github.workspace }}/Tests/Tests.Unity -testPlatform StandaloneLinux64 -testSettingsFile ${{ github.workspace }}/Tests/Tests.Unity/.TestConfigs/Mono-Net4.json -logFile - + - name: Store artifacts for UnityTestsRunner.linux + uses: actions/upload-artifact@v4 + with: + name: UnityTestsRunner.linux + path: Tests/Tests.Unity/Player_StandaloneLinux64_Mono-Net4/ + retention-days: ${{ github.event_name != 'pull_request' && 30 || 1 }} + if-no-files-found: error + run-unity-tests-linux: + name: Test Unity linux needs: - - build-unity - - build-packages + - build-unity-tests-linux if: always() && !cancelled() && !contains(needs.*.result, 'failure') && !contains(needs.*.result, 'cancelled') - uses: ./.github/workflows/test-unity.yml - with: - version: ${{ needs.build-packages.outputs.package_version }} - settings: '["Mono-Net4"]' - platform: '[{ "os": "windows", "testPlatform": "Windows64" }, { "os": "linux", "testPlatform": "Linux64" }]' + timeout-minutes: 30 + runs-on: ubuntu-latest + steps: + - name: Checkout Code + uses: actions/checkout@v4 + with: + submodules: false + ref: ${{ github.event.pull_request.head.sha }} + - name: Register problem matchers + run: |- + echo "::add-matcher::.github/problem-matchers/csc.json" + echo "::add-matcher::.github/problem-matchers/msvc.json" + - name: Fetch UnityTestsRunner.linux + uses: actions/download-artifact@v4 + with: + name: UnityTestsRunner.linux + path: TestRunner + - name: Install xvfb + run: sudo apt install -y xvfb libglu1 libxcursor1 + - name: Run Tests + run: |- + chmod +x ${{ github.workspace }}/TestRunner/PlayerWithTests.x86_64 + xvfb-run --auto-servernum --server-args='-screen 0 640x480x24:32' ${{ github.workspace }}/TestRunner/PlayerWithTests.x86_64 -logFile - --result=${{ github.workspace }}/TestResults.xml + - name: Publish Unit Test Results + if: always() + uses: dorny/test-reporter@31a54ee7ebcacc03a09ea97a7e5465a47b84aea5 + with: + name: Results Unity linux Mono-Net4 + path: TestResults.xml + reporter: java-junit + list-suites: failed + path-replace-backslashes: true + fail-on-error: true + build-unity-tests-windows: + name: Build Unity windows + if: always() && !cancelled() && !contains(needs.*.result, 'failure') && !contains(needs.*.result, 'cancelled') + timeout-minutes: 30 + runs-on: + - unity + - windows + steps: + - name: Checkout Code + uses: actions/checkout@v4 + with: + submodules: false + ref: ${{ github.event.pull_request.head.sha }} + - name: Register problem matchers + run: |- + echo "::add-matcher::.github/problem-matchers/csc.json" + echo "::add-matcher::.github/problem-matchers/msvc.json" + - name: Cleanup Workspace + run: git clean -fdx + - name: Fetch io.realm.unity-${{ needs.build-packages.outputs.package_version }}.tgz + uses: actions/download-artifact@v4 + with: + name: io.realm.unity-${{ needs.build-packages.outputs.package_version }}.tgz + path: Realm/Realm.Unity + - name: Fetch UnityTests + uses: actions/download-artifact@v4 + with: + name: UnityTests + path: Tests/Tests.Unity + - name: Build Unity Tests + run: unity-editor -runTests -batchmode -projectPath ${{ github.workspace }}/Tests/Tests.Unity -testPlatform StandaloneWindows64 -testSettingsFile ${{ github.workspace }}/Tests/Tests.Unity/.TestConfigs/Mono-Net4.json -logFile build.log + - name: Store artifacts for UnityTestsRunner.windows + uses: actions/upload-artifact@v4 + with: + name: UnityTestsRunner.windows + path: Tests/Tests.Unity/Player_StandaloneWindows64_Mono-Net4/ + retention-days: ${{ github.event_name != 'pull_request' && 30 || 1 }} + if-no-files-found: error + run-unity-tests-windows: + name: Test Unity windows + needs: + - build-unity-tests-windows + if: always() && !cancelled() && !contains(needs.*.result, 'failure') && !contains(needs.*.result, 'cancelled') + timeout-minutes: 30 + runs-on: windows-latest + steps: + - name: Checkout Code + uses: actions/checkout@v4 + with: + submodules: false + ref: ${{ github.event.pull_request.head.sha }} + - name: Register problem matchers + run: |- + echo "::add-matcher::.github/problem-matchers/csc.json" + echo "::add-matcher::.github/problem-matchers/msvc.json" + - name: Fetch UnityTestsRunner.windows + uses: actions/download-artifact@v4 + with: + name: UnityTestsRunner.windows + path: TestRunner + - name: Run Tests + run: "Start-Process ${{ github.workspace }}\TestRunner\PlayerWithTests.exe -Wait -ArgumentList \"-logFile\",\"${{ github.workspace }}\test.log\",\"--result=${{ github.workspace }}\TestResults.xml\"\ncat ${{ github.workspace }}\test.log" + shell: pwsh + - name: Publish Unit Test Results + if: always() + uses: dorny/test-reporter@31a54ee7ebcacc03a09ea97a7e5465a47b84aea5 + with: + name: Results Unity windows Mono-Net4 + path: TestResults.xml + reporter: java-junit + list-suites: failed + path-replace-backslashes: true + fail-on-error: true test-net-framework: name: Test .NET Framework needs: diff --git a/.github/workflows/test-unity.yml b/.github/workflows/test-unity.yml deleted file mode 100755 index dd89d4ef00..0000000000 --- a/.github/workflows/test-unity.yml +++ /dev/null @@ -1,137 +0,0 @@ -name: test-unity -"on": - workflow_call: - inputs: - version: - type: string - required: true - platform: - type: string - required: true - settings: - type: string - required: true -env: - REALM_DISABLE_ANALYTICS: true - DOTNET_NOLOGO: true -jobs: - build-tests: - runs-on: - - unity - - ${{ matrix.platform.os }} - name: Build Unity ${{ matrix.platform.os }} - strategy: - fail-fast: false - matrix: - platform: ${{ fromJson(inputs.platform) }} - settings: ${{ fromJson(inputs.settings) }} - timeout-minutes: 30 - 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: Cleanup Workspace - run: git clean -fdx - - name: Fetch Unity Package - uses: actions/download-artifact@v4 - with: - name: io.realm.unity-${{ inputs.version }}.tgz - path: Realm/Realm.Unity - - name: Fetch Unity Tests - uses: actions/download-artifact@v4 - with: - name: UnityTests - path: Tests/Tests.Unity - - name: Build Unity Tests - run: | - unity-editor -runTests -batchmode -projectPath ${{ github.workspace }}/Tests/Tests.Unity -testPlatform Standalone${{ matrix.platform.testPlatform }} -testSettingsFile ${{ github.workspace }}/Tests/Tests.Unity/.TestConfigs/${{ matrix.settings }}.json -logFile ${{ matrix.platform.os == 'windows' && 'build.log' || '-'}} - - name: Store artifacts for UnityTestsRunner.${{ matrix.platform.os }} - uses: actions/upload-artifact@v4 - with: - name: UnityTestsRunner.${{ matrix.platform.os }} - path: ${{ github.workspace }}/Tests/Tests.Unity/Player_Standalone${{ matrix.platform.testPlatform }}_${{ matrix.settings }}/ - retention-days: ${{ github.event_name != 'pull_request' && 30 || 1 }} - if-no-files-found: error - run-tests-linux: - runs-on: ubuntu-latest - name: Unity Linux - timeout-minutes: 30 - needs: - - build-tests - if: ${{ contains(inputs.platform, 'Linux') }} - 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: Download Test Runner - uses: actions/download-artifact@v4 - with: - name: UnityTestsRunner.linux - path: TestRunner - - name: Install xvfb - run: sudo apt install -y xvfb libglu1 libxcursor1 - - name: Run Tests - run: | - chmod +x ${{ github.workspace }}/TestRunner/PlayerWithTests.x86_64 - xvfb-run --auto-servernum --server-args='-screen 0 640x480x24:32' ${{ github.workspace }}/TestRunner/PlayerWithTests.x86_64 -logFile - --result=${{ github.workspace }}/TestResults.xml - - name: Publish Unit Test Results - uses: LaPeste/test-reporter@510caf50a955b1003bec48a6494be4d6537f3a0b - if: always() - with: - name: Results Unity Linux Mono_Net4 - path: TestResults.xml - reporter: java-junit - list-suites: failed - list-tests: failed - path-replace-backslashes: true - fail-on-error: true - run-tests-windows: - runs-on: windows-latest - name: Unity Windows - if: ${{ contains(inputs.platform, 'Windows') }} - timeout-minutes: 30 - needs: - - build-tests - 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: Download Test Runner - uses: actions/download-artifact@v4 - with: - name: UnityTestsRunner.windows - path: TestRunner - - name: Run Tests - run: | - Start-Process ${{ github.workspace }}\TestRunner\PlayerWithTests.exe -Wait -ArgumentList "-logFile","${{ github.workspace }}\test.log","--result=${{ github.workspace }}\TestResults.xml" - cat ${{ github.workspace }}\test.log - shell: powershell - - name: Publish Unit Test Results - uses: LaPeste/test-reporter@510caf50a955b1003bec48a6494be4d6537f3a0b - if: always() - with: - name: Results Unity Windows Mono_Net4 - path: TestResults.xml - reporter: java-junit - list-suites: failed - list-tests: failed - path-replace-backslashes: true - fail-on-error: true From a41b931ae0a1e0821d2dc1e1891979efc9e63dc1 Mon Sep 17 00:00:00 2001 From: Nikola Irinchev Date: Thu, 23 May 2024 11:31:39 +0200 Subject: [PATCH 29/39] fix unity yaml --- .github/pkl-workflows/helpers/Test.pkl | 9 ++++++--- .github/workflows/pr.yml | 8 +++++++- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/.github/pkl-workflows/helpers/Test.pkl b/.github/pkl-workflows/helpers/Test.pkl index 5dbdef59ab..3fcd76a2fd 100644 --- a/.github/pkl-workflows/helpers/Test.pkl +++ b/.github/pkl-workflows/helpers/Test.pkl @@ -393,6 +393,9 @@ function unity(config: UnityTestConfig): Mapping = new Mapping< "unity" config.os } + needs { + Common.job_Packages + } `timeout-minutes` = 30 `if` = Common.ifNotCanceledCondition steps { @@ -434,10 +437,10 @@ function unity(config: UnityTestConfig): Mapping = new Mapping< when (config.os == "windows") { new gha.Step { name = "Run Tests" - run = """ - Start-Process ${{ github.workspace }}\\TestRunner\\PlayerWithTests.exe -Wait -ArgumentList "-logFile","${{ github.workspace }}\\test.log","--result=${{ github.workspace }}\\\(outputFile)" + run = #""" + Start-Process ${{ github.workspace }}\TestRunner\PlayerWithTests.exe -Wait -ArgumentList "-logFile","${{ github.workspace }}\test.log","--result=${{ github.workspace }}\\#(outputFile)" cat ${{ github.workspace }}\test.log - """ + """# shell = "pwsh" } } diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index 3184aa585e..2e5fc3682f 100755 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -309,6 +309,8 @@ jobs: if-no-files-found: error build-unity-tests-linux: name: Build Unity linux + needs: + - build-packages if: always() && !cancelled() && !contains(needs.*.result, 'failure') && !contains(needs.*.result, 'cancelled') timeout-minutes: 30 runs-on: @@ -385,6 +387,8 @@ jobs: fail-on-error: true build-unity-tests-windows: name: Build Unity windows + needs: + - build-packages if: always() && !cancelled() && !contains(needs.*.result, 'failure') && !contains(needs.*.result, 'cancelled') timeout-minutes: 30 runs-on: @@ -444,7 +448,9 @@ jobs: name: UnityTestsRunner.windows path: TestRunner - name: Run Tests - run: "Start-Process ${{ github.workspace }}\TestRunner\PlayerWithTests.exe -Wait -ArgumentList \"-logFile\",\"${{ github.workspace }}\test.log\",\"--result=${{ github.workspace }}\TestResults.xml\"\ncat ${{ github.workspace }}\test.log" + run: |- + Start-Process ${{ github.workspace }}\TestRunner\PlayerWithTests.exe -Wait -ArgumentList "-logFile","${{ github.workspace }}\test.log","--result=${{ github.workspace }}\TestResults.xml" + cat ${{ github.workspace }}\test.log shell: pwsh - name: Publish Unit Test Results if: always() From 39b63debac260a83c444ccc1ef86b58217dbfbf0 Mon Sep 17 00:00:00 2001 From: Nikola Irinchev Date: Thu, 23 May 2024 11:57:41 +0200 Subject: [PATCH 30/39] Try to use newer java --- .github/pkl-workflows/helpers/Steps.pkl | 4 ++-- .github/workflows/pr.yml | 14 +++++++------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/.github/pkl-workflows/helpers/Steps.pkl b/.github/pkl-workflows/helpers/Steps.pkl index 66193e8380..43d035b0fb 100644 --- a/.github/pkl-workflows/helpers/Steps.pkl +++ b/.github/pkl-workflows/helpers/Steps.pkl @@ -97,11 +97,12 @@ const function setupJDK(): gha.Step = new { uses = Actions.setupJDK with { ["distribution"] = "microsoft" - ["java-version"] = 11 + ["java-version"] = 21 } } const function setupAndroid(): Listing = new Listing { + setupJDK() new { name = "Setup Android" uses = Actions.setupAndroid @@ -110,7 +111,6 @@ const function setupAndroid(): Listing = new Listing { name = "Install SDK platform 21" run = "sdkmanager --install \"platforms;android-21\"" } - setupJDK() } const function configureAWSCredentials(accessKey: String, secretKey: String, region: String): gha.Step = new { diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index 2e5fc3682f..3fd791b9d8 100755 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -70,15 +70,15 @@ jobs: run: |- echo "::add-matcher::.github/problem-matchers/csc.json" echo "::add-matcher::.github/problem-matchers/msvc.json" - - name: Setup Android - uses: android-actions/setup-android@e1f5280adf78cf863c0fa43ffabc64a9cd08153f - - name: Install SDK platform 21 - run: sdkmanager --install "platforms;android-21" - name: Setup JDK uses: actions/setup-java@2e74cbce18569d23ca8b812590dbb83f13ac7c5a with: distribution: microsoft - java-version: 11 + java-version: 21 + - name: Setup Android + uses: android-actions/setup-android@e1f5280adf78cf863c0fa43ffabc64a9cd08153f + - name: Install SDK platform 21 + run: sdkmanager --install "platforms;android-21" - uses: actions/setup-dotnet@5d1464d5da459f3d7085106d52e499f4dc5d0f59 with: dotnet-version: 8.0.x @@ -911,7 +911,7 @@ jobs: uses: actions/setup-java@2e74cbce18569d23ca8b812590dbb83f13ac7c5a with: distribution: microsoft - java-version: 11 + java-version: 21 - name: Checkout Code uses: actions/checkout@v4 with: @@ -972,7 +972,7 @@ jobs: uses: actions/setup-java@2e74cbce18569d23ca8b812590dbb83f13ac7c5a with: distribution: microsoft - java-version: 11 + java-version: 21 - name: Checkout Code uses: actions/checkout@v4 with: From 753599ceb6ef9ac5a5e11d8f0b959414496d1d7b Mon Sep 17 00:00:00 2001 From: Nikola Irinchev Date: Thu, 23 May 2024 11:59:53 +0200 Subject: [PATCH 31/39] Add correct needs for nuget package --- .github/pkl-workflows/pr.pkl | 6 +++++- .github/workflows/pr.yml | 2 ++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/.github/pkl-workflows/pr.pkl b/.github/pkl-workflows/pr.pkl index a66d3d7f04..75601e918e 100644 --- a/.github/pkl-workflows/pr.pkl +++ b/.github/pkl-workflows/pr.pkl @@ -54,7 +54,11 @@ jobs { name = "Wrappers" } [Common.job_Baas] = BaaS.deploy(baasDifferentiators) // TODO: run baasaas tests for more targets - [Common.job_Packages] = Package.nuget("contains(github.head_ref, 'release')") + [Common.job_Packages] = (Package.nuget("contains(github.head_ref, 'release')")){ + needs { + JobNames.wrappers + } + } [Common.job_Unity] = Package.unity() ...TestJobs.unity(new TestJobs.UnityTestConfig { os = "linux" diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index 3fd791b9d8..fe90fb0905 100755 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -56,6 +56,8 @@ jobs: fail-fast: false build-packages: name: Package NuGet + needs: + - build-wrappers outputs: package_version: ${{ steps.get-version.outputs.package_version }} timeout-minutes: 30 From 0dc3c67c9bfc2581b1fec0363cb29d33279b4dc5 Mon Sep 17 00:00:00 2001 From: Nikola Irinchev Date: Thu, 23 May 2024 12:17:09 +0200 Subject: [PATCH 32/39] Use JDK 17 --- .github/pkl-workflows/helpers/Steps.pkl | 2 +- .github/workflows/pr.yml | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/pkl-workflows/helpers/Steps.pkl b/.github/pkl-workflows/helpers/Steps.pkl index 43d035b0fb..c0b6b77535 100644 --- a/.github/pkl-workflows/helpers/Steps.pkl +++ b/.github/pkl-workflows/helpers/Steps.pkl @@ -97,7 +97,7 @@ const function setupJDK(): gha.Step = new { uses = Actions.setupJDK with { ["distribution"] = "microsoft" - ["java-version"] = 21 + ["java-version"] = 17 } } diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index fe90fb0905..2de8db6fcd 100755 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -76,7 +76,7 @@ jobs: uses: actions/setup-java@2e74cbce18569d23ca8b812590dbb83f13ac7c5a with: distribution: microsoft - java-version: 21 + java-version: 17 - name: Setup Android uses: android-actions/setup-android@e1f5280adf78cf863c0fa43ffabc64a9cd08153f - name: Install SDK platform 21 @@ -913,7 +913,7 @@ jobs: uses: actions/setup-java@2e74cbce18569d23ca8b812590dbb83f13ac7c5a with: distribution: microsoft - java-version: 21 + java-version: 17 - name: Checkout Code uses: actions/checkout@v4 with: @@ -974,7 +974,7 @@ jobs: uses: actions/setup-java@2e74cbce18569d23ca8b812590dbb83f13ac7c5a with: distribution: microsoft - java-version: 21 + java-version: 17 - name: Checkout Code uses: actions/checkout@v4 with: From 8d2d44779d8c833cad8dcf7647302017512a8f55 Mon Sep 17 00:00:00 2001 From: Nikola Irinchev Date: Thu, 23 May 2024 13:08:36 +0200 Subject: [PATCH 33/39] Migrate codeql, publish-prerelease --- .../GithubAction/GithubAction.pkl | 1 + .github/pkl-workflows/codeql.pkl | 75 +++++++++++++++++++ .github/pkl-workflows/helpers/Actions.pkl | 4 + .github/pkl-workflows/helpers/Common.pkl | 2 + .github/pkl-workflows/helpers/Package.pkl | 20 +---- .github/pkl-workflows/helpers/Steps.pkl | 49 +++++++++++- .github/pkl-workflows/helpers/Test.pkl | 2 +- .github/pkl-workflows/publish-prerelease.pkl | 38 ++++++++++ .github/templates/codeql.yml | 63 ---------------- .github/templates/publish-prerelease.yml | 16 ---- .github/workflows/codeql.yml | 61 ++++++++------- .github/workflows/pr.yml | 1 + .github/workflows/publish-prerelease.yml | 39 +++++----- 13 files changed, 225 insertions(+), 146 deletions(-) create mode 100644 .github/pkl-workflows/codeql.pkl create mode 100644 .github/pkl-workflows/publish-prerelease.pkl delete mode 100644 .github/templates/codeql.yml delete mode 100644 .github/templates/publish-prerelease.yml diff --git a/.github/pkl-workflows/GithubAction/GithubAction.pkl b/.github/pkl-workflows/GithubAction/GithubAction.pkl index 5c600de0e4..776b54d2f0 100644 --- a/.github/pkl-workflows/GithubAction/GithubAction.pkl +++ b/.github/pkl-workflows/GithubAction/GithubAction.pkl @@ -568,6 +568,7 @@ abstract class JobBase { env: EnvironmentVariables? outputs: Mapping? `timeout-minutes`: Int? + permissions: (*Permissions|"read-all"|"write-all")? } abstract class StepJobBase extends JobBase { diff --git a/.github/pkl-workflows/codeql.pkl b/.github/pkl-workflows/codeql.pkl new file mode 100644 index 0000000000..6782585e7c --- /dev/null +++ b/.github/pkl-workflows/codeql.pkl @@ -0,0 +1,75 @@ +module codeql + +amends "GithubAction/GithubAction.pkl" + +import "helpers/Common.pkl" +import "helpers/Steps.pkl" +import "helpers/Actions.pkl" + +name = "CodeQL" +on { + push { + branches { + Common.mainBranch + } + } + pull_request { + branches { + Common.mainBranch + } + paths { + "**.cs" + "**.cpp" + "**.hpp" + "**.csproj" + ".github/workflows/codeql.yml" + } + } +} +env { + ["REALM_DISABLE_ANALYTICS"] = true +} +concurrency { + group = "codeql-${{ github.head_ref || github.run_id }}" + `cancel-in-progress` = true +} +jobs { + ["analyze-csharp"] = new Job { + name = "Analyze C#" + `runs-on` = new WindowsLatest{} + permissions { + actions = "read" + contents = "read" + `security-events` = "write" + } + steps { + Steps.checkoutWithoutMatchers(false) + new Step { + name = "Initialize CodeQL" + uses = Actions.codeQLInit + with { + ["languages"] = "csharp" + ["config"] = """ + queries: + - uses: security-and-quality + query-filters: + - exclude: cs/call-to-unmanaged-code + - exclude: cs/unmanaged-code + """ + } + } + ...Steps.setupAndroid() + ...Steps.setupWorkloads("tvos ios maccatalyst android", "8.0.x") + ...Steps.msbuild(new Steps.MSBuildConfig { + projects = Common.packages.map((pkg) -> "Realm/\(pkg)").toListing() + properties { + ["UseSharedCompilation"] = "false" + } + }) + new Step { + name = "Perform CodeQL Analysis" + uses = Actions.codeQLAnalyze + } + } + } +} \ No newline at end of file diff --git a/.github/pkl-workflows/helpers/Actions.pkl b/.github/pkl-workflows/helpers/Actions.pkl index 4f4160878a..902280a632 100644 --- a/.github/pkl-workflows/helpers/Actions.pkl +++ b/.github/pkl-workflows/helpers/Actions.pkl @@ -7,9 +7,13 @@ const coveralls = "coverallsapp/github-action@v2.3.0" const checkout = "actions/checkout@v4" const uploadArtifact = "actions/upload-artifact@v4" const downloadArtifact = "actions/download-artifact@v4" +const downloadAllArtifacts = "dawidd6/action-download-artifact@09f2f74827fd3a8607589e5ad7f9398816f540fe" // 3.1.4 const setupXcode = "maxim-lobanov/setup-xcode@60606e260d2fc5762a71e64e74b2174e8ea3c8bd" const setupDotnet = "actions/setup-dotnet@5d1464d5da459f3d7085106d52e499f4dc5d0f59" const setupMsBuild = "microsoft/setup-msbuild@70b70342ae97ca98d5eaad06cafd26d30f9592a9" const setupAndroid = "android-actions/setup-android@e1f5280adf78cf863c0fa43ffabc64a9cd08153f" +const setupNode = "actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8" // 4.0.2 const restoreCache = "actions/cache/restore@v4" const cache = "actions/cache@v4" +const codeQLInit = "github/codeql-action/init@a57c67b89589d2d13d5ac85a9fc4679c7539f94c" +const codeQLAnalyze = "github/codeql-action/analyze@a57c67b89589d2d13d5ac85a9fc4679c7539f94c" diff --git a/.github/pkl-workflows/helpers/Common.pkl b/.github/pkl-workflows/helpers/Common.pkl index ab89f06c2a..327fde6b34 100644 --- a/.github/pkl-workflows/helpers/Common.pkl +++ b/.github/pkl-workflows/helpers/Common.pkl @@ -14,6 +14,8 @@ const job_Packages: String = "build-packages" const job_Baas: String = "deploy-baas" const job_Unity: String = "build-unity" +const mainBranch: String = "main" + typealias NetFramework = "net6.0" | "net8.0" | String(startsWith("${{ matrix")) | String(startsWith("net8")) typealias NetRuntime = "win-x64" | "linux-x64" | "osx-x64" | "osx-arm64" | String(startsWith("${{ matrix")) typealias SyncDifferentiator = "ios-maui" | "android-maui" | "tvos" | "macos-maui" | "code-coverage" | "uwp" | "net-framework" | String(startsWith("${{ matrix")) diff --git a/.github/pkl-workflows/helpers/Package.pkl b/.github/pkl-workflows/helpers/Package.pkl index b5e0d601b1..d21e5d21b5 100644 --- a/.github/pkl-workflows/helpers/Package.pkl +++ b/.github/pkl-workflows/helpers/Package.pkl @@ -5,10 +5,8 @@ import "Common.pkl" import "Steps.pkl" import "Actions.pkl" -const versionOutput = "package_version" -const unityPkgName = "io.realm.unity-${{ needs.\(Common.job_Packages).outputs.\(versionOutput) }}.tgz" +const unityPkgName = "io.realm.unity-${{ needs.\(Common.job_Packages).outputs.\(Steps.getVersionOutput) }}.tgz" -local const getVersionStep = "get-version" local const setVersionSuffixStep = "set-version-suffix" local const checkDocfxCacheStep = "check-docfx-cache" @@ -18,7 +16,7 @@ function nuget(shouldBuildDocsCondition: String): gha.Job = new gha.Job { name = "Package NuGet" `runs-on` = new gha.WindowsLatest{} outputs { - [versionOutput] = "${{ steps.\(getVersionStep).outputs.\(versionOutput) }}" + [Steps.getVersionOutput] = "${{ steps.\(Steps.getVersionStepName).outputs.\(Steps.getVersionOutput) }}" } `timeout-minutes` = 30 steps { @@ -35,9 +33,9 @@ function nuget(shouldBuildDocsCondition: String): gha.Job = new gha.Job { ["VersionSuffix"] = "${{ steps.\(setVersionSuffixStep).outputs.\(buildSuffixOutput) }}" } }) - readVersionFromPackage + Steps.readVersionFromPackage() for (pkgName in Common.nugetPackages) { - let (finalPkgName = "\(pkgName).${{ steps.\(getVersionStep).outputs.\(versionOutput) }}") + let (finalPkgName = "\(pkgName).${{ steps.\(Steps.getVersionStepName).outputs.\(Steps.getVersionOutput) }}") Steps.uploadArtifacts(finalPkgName, "Realm/packages/\(finalPkgName).*nupkg") } Steps.uploadArtifacts("ExtractedChangelog", "Realm/Realm/ExtractedChangelog.md") @@ -90,16 +88,6 @@ local const setVersionSuffix = new gha.Step { shell = "pwsh" } -local const readVersionFromPackage = new gha.Step { - name = "Read version" - id = getVersionStep - run = """ - cd Realm/packages - pkgVersion=$(find . -type f -regex ".*Realm.[1-9].*.nupkg" -exec basename {} \\; | sed -n 's/Realm\\.\\(.*\\)\\.nupkg$/\\1/p') - echo "\(versionOutput)=$pkgVersion" >> $GITHUB_OUTPUT - """ -} - local const function buildDocs(condition: String) = new Listing { new { name = "Check Docfx cache" diff --git a/.github/pkl-workflows/helpers/Steps.pkl b/.github/pkl-workflows/helpers/Steps.pkl index c0b6b77535..01f5a29473 100644 --- a/.github/pkl-workflows/helpers/Steps.pkl +++ b/.github/pkl-workflows/helpers/Steps.pkl @@ -1,8 +1,10 @@ import "../GithubAction/GithubAction.pkl" as gha import "Common.pkl" -import "Package.pkl" import "Actions.pkl" +const getVersionStepName = "get-version" +const getVersionOutput = "package_version" + const function checkout(submodules: (Boolean | "recursive")): Listing = new Listing { checkoutWithoutMatchers(submodules) registerProblemMatchers() @@ -37,6 +39,17 @@ const function downloadArtifacts(artifactName: String, relPath: String): gha.Ste } } +const function downloadAllArtifacts(): gha.Step = new { + name = "Download all artifacts" + uses = Actions.downloadAllArtifacts + with { + ["workflow"] = "pr.yml" + ["commit"] = "${{ github.sha }}" + ["path"] = "Realm/packages/" + ["workflow_conclusion"] = "completed" + } +} + const function setupXcode(version: String): gha.Step = new gha.Step { name = "Setup Xcode" uses = Actions.setupXcode @@ -70,7 +83,7 @@ const function fetchPackages(_packages: List(every((package) -> Common.p name = "Fetch \(package)" uses = Actions.downloadArtifact with { - ["name"] = "\(package).${{ needs.\(Common.job_Packages).outputs.\(Package.versionOutput) }}" + ["name"] = "\(package).${{ needs.\(Common.job_Packages).outputs.\(getVersionOutput) }}" ["path"] = "${{ github.workspace }}/Realm/packages/" } }) @@ -113,7 +126,7 @@ const function setupAndroid(): Listing = new Listing { } } -const function configureAWSCredentials(accessKey: String, secretKey: String, region: String): gha.Step = new { +const function configureAWSCredentials(accessKey: String, secretKey: String, region: "us-east-1" | "us-west-2"): gha.Step = new { name = "Configure AWS Credentials" uses = Actions.awsConfigureCredentials with { @@ -123,6 +136,36 @@ const function configureAWSCredentials(accessKey: String, secretKey: String, reg } } +const function readVersionFromPackage(): gha.Step = new { + name = "Read version" + id = getVersionStepName + run = #""" + cd Realm/packages + pkgVersion=$(find . -type f -regex ".*Realm.[1-9].*.nupkg" -exec basename {} \; | sed -n 's/Realm\.\(.*\)\.nupkg$/\1/p') + echo "\#(getVersionOutput)=$pkgVersion" >> $GITHUB_OUTPUT + """# + shell = "bash" +} + +const function uploadToNPM(tag: "latest" | "alpha"): Listing = new Listing { + local packageName = "io.realm.unity-${{ steps.\(getVersionStepName).outputs.\(getVersionOutput) }}.tgz" + + new gha.Step { + uses = Actions.setupNode + with { + ["node-version"] = "16.x" + ["registry-url"] = "https://registry.npmjs.org" + } + } + new gha.Step { + name = "NPM publish \(packageName)" + run = "npm publish ${{ github.workspace }}/Realm/packages/\(packageName)/\(packageName) --tag \(tag)" + env { + ["NODE_AUTH_TOKEN"] = "${{ secrets.NPM_TOKEN }}" + } + } +} + class MSBuildConfig { projects: Listing target: String? diff --git a/.github/pkl-workflows/helpers/Test.pkl b/.github/pkl-workflows/helpers/Test.pkl index 3fcd76a2fd..d416250a90 100644 --- a/.github/pkl-workflows/helpers/Test.pkl +++ b/.github/pkl-workflows/helpers/Test.pkl @@ -530,7 +530,7 @@ local function reportTestResultsWithCustomFile(_outputFile: String, config: Test local function getTestProps(standaloneExe: Boolean): Mapping = new Mapping { ["RestoreConfigFile"] = "Tests/Test.NuGet.Config" - ["UseRealmNupkgsWithVersion"] = "${{ needs.\(Common.job_Packages).outputs.\(Package.versionOutput) }}" + ["UseRealmNupkgsWithVersion"] = "${{ needs.\(Common.job_Packages).outputs.\(Steps.getVersionOutput) }}" when (standaloneExe) { ["RealmTestsStandaloneExe"] = "true" } diff --git a/.github/pkl-workflows/publish-prerelease.pkl b/.github/pkl-workflows/publish-prerelease.pkl new file mode 100644 index 0000000000..ec3307b3f5 --- /dev/null +++ b/.github/pkl-workflows/publish-prerelease.pkl @@ -0,0 +1,38 @@ +module prerelease + +amends "GithubAction/GithubAction.pkl" + +import "helpers/Common.pkl" +import "helpers/Steps.pkl" +import "helpers/Actions.pkl" + +name = "Publish Prerelease" +on { + workflow_dispatch{} +} +jobs { + ["main"] = new Job { + `runs-on` = new UbuntuLatest{} + name = "Publish package to S3" + steps { + Steps.checkoutWithoutMatchers(false) + Steps.downloadAllArtifacts() + Steps.readVersionFromPackage() + Steps.setupDotnet(null) + new Step { + name = "Install sleet" + run = "dotnet tool install -g sleet" + } + + Steps.configureAWSCredentials("NUGET_S3_ACCESS_KEY", "NUGET_S3_SECRET_KEY", "us-east-1") + for (package in Common.nugetPackages) { + let (packageWithVersion = "\(package).${{ steps.\(Steps.getVersionStepName).outputs.\(Steps.getVersionOutput) }}") + new Step { + name = "NuGet Publish \(packageWithVersion)" + run = "sleet push ${{ github.workspace }}/Realm/packages/\(packageWithVersion)/\(packageWithVersion).nupkg --config ${{ github.workspace }}/.github/sleet.json --source NugetSource" + } + } + ...Steps.uploadToNPM("alpha") + } + } +} diff --git a/.github/templates/codeql.yml b/.github/templates/codeql.yml deleted file mode 100644 index 66a77aaf86..0000000000 --- a/.github/templates/codeql.yml +++ /dev/null @@ -1,63 +0,0 @@ -#@ load("@ytt:template", "template") -#@ load("common.lib.yml", "configuration", "nugetPackages", "checkoutCode", "actionCodeQLInit", "actionCodeQLAnalyze", "actionSetupMSBuild", "setupAndroid", "setupWorkloads") - -#@ def runCodeQL(language, buildSteps = []): - - name: Initialize CodeQL - uses: #@ actionCodeQLInit - with: - languages: #@ language - config: | - queries: - - uses: security-and-quality - query-filters: - - exclude: cs/call-to-unmanaged-code - - exclude: cs/unmanaged-code - #@ for step in buildSteps: - - #@ template.replace(step) - #@ end - - name: Perform CodeQL Analysis - uses: #@ actionCodeQLAnalyze -#@ end - -#@ def buildPackages(): - - #@ template.replace(setupAndroid()) - - #@ template.replace(setupWorkloads('tvos ios maccatalyst android')) - - name: Add msbuild to PATH - uses: #@ actionSetupMSBuild -#@ for pkgName in nugetPackages: - - name: #@ "Build " + pkgName - run: #@ "msbuild Realm/" + pkgName + " -p:UseSharedCompilation=false -restore -p:Configuration=" + configuration -#@ end -#@ end - ---- -name: "CodeQL" -"on": - push: - branches: - - main - pull_request: - branches: - - main - paths: - - '**.cs' - - '**.cpp' - - '**.hpp' - - '**.csproj' - - '.github/workflows/codeql.yml' -env: - REALM_DISABLE_ANALYTICS: true -concurrency: - group: codeql-${{ github.head_ref || github.run_id }} - cancel-in-progress: true -jobs: - analyze-csharp: - name: Analyze C# - runs-on: windows-latest - permissions: - actions: read - contents: read - security-events: write - steps: - - #@ template.replace(checkoutCode(False, False)) - - #@ template.replace(runCodeQL("csharp", [buildPackages()])) diff --git a/.github/templates/publish-prerelease.yml b/.github/templates/publish-prerelease.yml deleted file mode 100644 index f01a307182..0000000000 --- a/.github/templates/publish-prerelease.yml +++ /dev/null @@ -1,16 +0,0 @@ -#@ load("@ytt:template", "template") -#@ load("common.lib.yml", "checkoutCode", "downloadAllArtifacts", "readVersionFromPackage", "uploadPackagesToSleet", "uploadToNpm") - ---- -name: Publish Prerelease -"on": workflow_dispatch -jobs: - main: - runs-on: ubuntu-latest - name: Publish package to S3 - steps: - - #@ template.replace(checkoutCode(False, False)) - - #@ template.replace(downloadAllArtifacts("completed")) - - #@ template.replace(readVersionFromPackage()) - - #@ template.replace(uploadPackagesToSleet()) - - #@ template.replace(uploadToNpm("alpha")) diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index 533a060bec..c3e23fa31d 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -1,17 +1,20 @@ +# Do not modify! +# This file was generated from a template using https://github.com/apple/pkl + name: CodeQL -"on": - push: - branches: - - main +'on': pull_request: - branches: - - main paths: - '**.cs' - '**.cpp' - '**.hpp' - '**.csproj' - .github/workflows/codeql.yml + branches: + - main + push: + branches: + - main env: REALM_DISABLE_ANALYTICS: true concurrency: @@ -20,51 +23,51 @@ concurrency: jobs: analyze-csharp: name: Analyze C# - runs-on: windows-latest permissions: actions: read contents: read security-events: write + runs-on: windows-latest steps: - - name: Checkout code - uses: actions/checkout@v3 + - name: Checkout Code + uses: actions/checkout@v4 with: submodules: false ref: ${{ github.event.pull_request.head.sha }} - name: Initialize CodeQL - uses: github/codeql-action/init@40542d38bc4936c2ca7da883aeb050a6081b4b31 + uses: github/codeql-action/init@a57c67b89589d2d13d5ac85a9fc4679c7539f94c with: languages: csharp - config: | + config: |- queries: - uses: security-and-quality query-filters: - exclude: cs/call-to-unmanaged-code - exclude: cs/unmanaged-code - - name: Setup Android - uses: android-actions/setup-android@7c5672355aaa8fde5f97a91aa9a99616d1ace6bc - - name: Install SDK platform 21 - run: sdkmanager --install "platforms;android-21" - name: Setup JDK - uses: actions/setup-java@0ab4596768b603586c0de567f2430c30f5b0d2b0 + uses: actions/setup-java@2e74cbce18569d23ca8b812590dbb83f13ac7c5a with: distribution: microsoft - java-version: 11 - - name: Configure .NET - uses: actions/setup-dotnet@3e6b9fe3930cac7c59c651af5de1514b47a805b9 + java-version: 17 + - name: Setup Android + uses: android-actions/setup-android@e1f5280adf78cf863c0fa43ffabc64a9cd08153f + - name: Install SDK platform 21 + run: sdkmanager --install "platforms;android-21" + - uses: actions/setup-dotnet@5d1464d5da459f3d7085106d52e499f4dc5d0f59 with: dotnet-version: 8.0.x - name: Setup workloads run: dotnet workload install tvos ios maccatalyst android - name: Add msbuild to PATH - uses: microsoft/setup-msbuild@0b44c6745b7e81956596964100aadb92d667c497 - - name: Build Realm.PlatformHelpers - run: msbuild Realm/Realm.PlatformHelpers -p:UseSharedCompilation=false -restore -p:Configuration=Release - - name: Build Realm - run: msbuild Realm/Realm -p:UseSharedCompilation=false -restore -p:Configuration=Release - - name: Build Realm.UnityUtils - run: msbuild Realm/Realm.UnityUtils -p:UseSharedCompilation=false -restore -p:Configuration=Release - - name: Build Realm.UnityWeaver - run: msbuild Realm/Realm.UnityWeaver -p:UseSharedCompilation=false -restore -p:Configuration=Release + if: ${{ runner.os == 'Windows' }} + uses: microsoft/setup-msbuild@70b70342ae97ca98d5eaad06cafd26d30f9592a9 + - name: Build Realm/Realm + run: msbuild Realm/Realm -restore -p:Configuration=Release -p:UseSharedCompilation=false + - name: Build Realm/Realm.PlatformHelpers + run: msbuild Realm/Realm.PlatformHelpers -restore -p:Configuration=Release -p:UseSharedCompilation=false + - name: Build Realm/Realm.UnityUtils + run: msbuild Realm/Realm.UnityUtils -restore -p:Configuration=Release -p:UseSharedCompilation=false + - name: Build Realm/Realm.UnityWeaver + run: msbuild Realm/Realm.UnityWeaver -restore -p:Configuration=Release -p:UseSharedCompilation=false - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@40542d38bc4936c2ca7da883aeb050a6081b4b31 + uses: github/codeql-action/analyze@a57c67b89589d2d13d5ac85a9fc4679c7539f94c diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index 2de8db6fcd..1a7f9be055 100755 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -216,6 +216,7 @@ jobs: cd Realm/packages pkgVersion=$(find . -type f -regex ".*Realm.[1-9].*.nupkg" -exec basename {} \; | sed -n 's/Realm\.\(.*\)\.nupkg$/\1/p') echo "package_version=$pkgVersion" >> $GITHUB_OUTPUT + shell: bash - name: Store artifacts for Realm.${{ steps.get-version.outputs.package_version }} uses: actions/upload-artifact@v4 with: diff --git a/.github/workflows/publish-prerelease.yml b/.github/workflows/publish-prerelease.yml index f5c9a36f02..bd63896a3e 100644 --- a/.github/workflows/publish-prerelease.yml +++ b/.github/workflows/publish-prerelease.yml @@ -1,50 +1,53 @@ +# Do not modify! +# This file was generated from a template using https://github.com/apple/pkl + name: Publish Prerelease -"on": workflow_dispatch +'on': + workflow_dispatch: {} jobs: main: - runs-on: ubuntu-latest name: Publish package to S3 + runs-on: ubuntu-latest steps: - - name: Checkout code - uses: actions/checkout@v3 + - name: Checkout Code + uses: actions/checkout@v4 with: submodules: false ref: ${{ github.event.pull_request.head.sha }} - name: Download all artifacts - uses: dawidd6/action-download-artifact@46b4ae883bf0726f5949d025d31cb62c7a5ac70c + uses: dawidd6/action-download-artifact@09f2f74827fd3a8607589e5ad7f9398816f540fe with: workflow: pr.yml commit: ${{ github.sha }} - path: ${{ github.workspace }}/Realm/packages/ + path: Realm/packages/ workflow_conclusion: completed - name: Read version id: get-version - run: | + run: |- cd Realm/packages pkgVersion=$(find . -type f -regex ".*Realm.[1-9].*.nupkg" -exec basename {} \; | sed -n 's/Realm\.\(.*\)\.nupkg$/\1/p') - echo "version=$pkgVersion" >> $GITHUB_OUTPUT + echo "package_version=$pkgVersion" >> $GITHUB_OUTPUT shell: bash - - name: Configure .NET - uses: actions/setup-dotnet@3e6b9fe3930cac7c59c651af5de1514b47a805b9 + - uses: actions/setup-dotnet@5d1464d5da459f3d7085106d52e499f4dc5d0f59 with: dotnet-version: 8.0.x - name: Install sleet run: dotnet tool install -g sleet - name: Configure AWS Credentials - uses: aws-actions/configure-aws-credentials@v1-node16 + uses: aws-actions/configure-aws-credentials@v4.0.2 with: aws-access-key-id: ${{ secrets.NUGET_S3_ACCESS_KEY }} aws-secret-access-key: ${{ secrets.NUGET_S3_SECRET_KEY }} aws-region: us-east-1 - - name: NuGet Publish Realm.PlatformHelpers.${{ steps.get-version.outputs.version }} - run: sleet push ${{ github.workspace }}/Realm/packages/Realm.PlatformHelpers.${{ steps.get-version.outputs.version }}/Realm.PlatformHelpers.${{ steps.get-version.outputs.version }}.nupkg --config ${{ github.workspace }}/.github/sleet.json --source NugetSource - - name: NuGet Publish Realm.${{ steps.get-version.outputs.version }} - run: sleet push ${{ github.workspace }}/Realm/packages/Realm.${{ steps.get-version.outputs.version }}/Realm.${{ steps.get-version.outputs.version }}.nupkg --config ${{ github.workspace }}/.github/sleet.json --source NugetSource - - uses: actions/setup-node@16352bb09bc672a073e326c2cc1d3d7d2a3e577e + - name: NuGet Publish Realm.${{ steps.get-version.outputs.package_version }} + run: sleet push ${{ github.workspace }}/Realm/packages/Realm.${{ steps.get-version.outputs.package_version }}/Realm.${{ steps.get-version.outputs.package_version }}.nupkg --config ${{ github.workspace }}/.github/sleet.json --source NugetSource + - name: NuGet Publish Realm.PlatformHelpers.${{ steps.get-version.outputs.package_version }} + run: sleet push ${{ github.workspace }}/Realm/packages/Realm.PlatformHelpers.${{ steps.get-version.outputs.package_version }}/Realm.PlatformHelpers.${{ steps.get-version.outputs.package_version }}.nupkg --config ${{ github.workspace }}/.github/sleet.json --source NugetSource + - uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 with: node-version: 16.x registry-url: https://registry.npmjs.org - - name: Npm Publish io.realm.unity-${{steps.get-version.outputs.version}}.tgz - run: npm publish ${{ github.workspace }}/Realm/packages/io.realm.unity-${{steps.get-version.outputs.version}}.tgz/io.realm.unity-${{steps.get-version.outputs.version}}.tgz --tag alpha + - name: NPM publish io.realm.unity-${{ steps.get-version.outputs.package_version }}.tgz env: NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} + run: npm publish ${{ github.workspace }}/Realm/packages/io.realm.unity-${{ steps.get-version.outputs.package_version }}.tgz/io.realm.unity-${{ steps.get-version.outputs.package_version }}.tgz --tag alpha From 7daf5c25844b9ea9c3095366e3a14e79355a5dd4 Mon Sep 17 00:00:00 2001 From: Nikola Irinchev Date: Thu, 23 May 2024 14:44:01 +0200 Subject: [PATCH 34/39] Fix some workflows --- .../GithubAction/GithubAction.pkl | 1 + .github/pkl-workflows/codeql.pkl | 6 ++++-- .github/pkl-workflows/helpers/Actions.pkl | 3 +++ .github/pkl-workflows/helpers/Package.pkl | 8 ++++---- .github/pkl-workflows/helpers/Steps.pkl | 6 ++++-- .github/pkl-workflows/helpers/Test.pkl | 1 + .github/pkl-workflows/publish-prerelease.pkl | 3 +-- .github/workflows/codeql.yml | 6 ++++-- .github/workflows/pr.yml | 20 +++++++++++++++++++ 9 files changed, 42 insertions(+), 12 deletions(-) diff --git a/.github/pkl-workflows/GithubAction/GithubAction.pkl b/.github/pkl-workflows/GithubAction/GithubAction.pkl index 776b54d2f0..d99ca79acd 100644 --- a/.github/pkl-workflows/GithubAction/GithubAction.pkl +++ b/.github/pkl-workflows/GithubAction/GithubAction.pkl @@ -569,6 +569,7 @@ abstract class JobBase { outputs: Mapping? `timeout-minutes`: Int? permissions: (*Permissions|"read-all"|"write-all")? + environment: String? } abstract class StepJobBase extends JobBase { diff --git a/.github/pkl-workflows/codeql.pkl b/.github/pkl-workflows/codeql.pkl index 6782585e7c..d738695978 100644 --- a/.github/pkl-workflows/codeql.pkl +++ b/.github/pkl-workflows/codeql.pkl @@ -53,8 +53,10 @@ jobs { queries: - uses: security-and-quality query-filters: - - exclude: cs/call-to-unmanaged-code - - exclude: cs/unmanaged-code + - exclude: + id: cs/call-to-unmanaged-code + - exclude: + id: cs/unmanaged-code """ } } diff --git a/.github/pkl-workflows/helpers/Actions.pkl b/.github/pkl-workflows/helpers/Actions.pkl index 902280a632..c7cf608298 100644 --- a/.github/pkl-workflows/helpers/Actions.pkl +++ b/.github/pkl-workflows/helpers/Actions.pkl @@ -17,3 +17,6 @@ const restoreCache = "actions/cache/restore@v4" const cache = "actions/cache@v4" const codeQLInit = "github/codeql-action/init@a57c67b89589d2d13d5ac85a9fc4679c7539f94c" const codeQLAnalyze = "github/codeql-action/analyze@a57c67b89589d2d13d5ac85a9fc4679c7539f94c" +const findPR = "juliangruber/find-pull-request-action@48b6133aa6c826f267ebd33aa2d29470f9d9e7d0" // 1.9.0 +const mergePR = "juliangruber/merge-pull-request-action@9234b8714dda9a08f3d1df5b2a6a3abd7b695353" // 1.3.1 +const publishGithubRelease = "ncipollo/release-action@2c591bcc8ecdcd2db72b97d6147f871fcd833ba5" // 1.14.0 diff --git a/.github/pkl-workflows/helpers/Package.pkl b/.github/pkl-workflows/helpers/Package.pkl index d21e5d21b5..a8ffd837f3 100644 --- a/.github/pkl-workflows/helpers/Package.pkl +++ b/.github/pkl-workflows/helpers/Package.pkl @@ -16,7 +16,7 @@ function nuget(shouldBuildDocsCondition: String): gha.Job = new gha.Job { name = "Package NuGet" `runs-on` = new gha.WindowsLatest{} outputs { - [Steps.getVersionOutput] = "${{ steps.\(Steps.getVersionStepName).outputs.\(Steps.getVersionOutput) }}" + [Steps.getVersionOutput] = Steps.getVersionExpresssion } `timeout-minutes` = 30 steps { @@ -26,7 +26,7 @@ function nuget(shouldBuildDocsCondition: String): gha.Job = new gha.Job { setVersionSuffix ...Steps.fetchWrappers(null) ...Steps.msbuild(new Steps.MSBuildConfig { - projects = Common.nugetPackages.map((pkg) -> "Realm/\(pkg)").toListing() + projects = Common.packages.map((pkg) -> "Realm/\(pkg)").toListing() target = "Pack" properties { ["PackageOutputPath"] = "${{ github.workspace }}/Realm/packages" @@ -34,8 +34,8 @@ function nuget(shouldBuildDocsCondition: String): gha.Job = new gha.Job { } }) Steps.readVersionFromPackage() - for (pkgName in Common.nugetPackages) { - let (finalPkgName = "\(pkgName).${{ steps.\(Steps.getVersionStepName).outputs.\(Steps.getVersionOutput) }}") + for (pkgName in Common.packages) { + let (finalPkgName = "\(pkgName).\(Steps.getVersionExpresssion)") Steps.uploadArtifacts(finalPkgName, "Realm/packages/\(finalPkgName).*nupkg") } Steps.uploadArtifacts("ExtractedChangelog", "Realm/Realm/ExtractedChangelog.md") diff --git a/.github/pkl-workflows/helpers/Steps.pkl b/.github/pkl-workflows/helpers/Steps.pkl index 01f5a29473..666529cd87 100644 --- a/.github/pkl-workflows/helpers/Steps.pkl +++ b/.github/pkl-workflows/helpers/Steps.pkl @@ -5,6 +5,8 @@ import "Actions.pkl" const getVersionStepName = "get-version" const getVersionOutput = "package_version" +const getVersionExpresssion = "${{ steps.\(getVersionStepName).outputs.\(getVersionOutput) }}" + const function checkout(submodules: (Boolean | "recursive")): Listing = new Listing { checkoutWithoutMatchers(submodules) registerProblemMatchers() @@ -126,7 +128,7 @@ const function setupAndroid(): Listing = new Listing { } } -const function configureAWSCredentials(accessKey: String, secretKey: String, region: "us-east-1" | "us-west-2"): gha.Step = new { +const function configureAWSCredentials(accessKey: String, secretKey: String, region: "us-east-1" | "us-west-2" | "us-east-2"): gha.Step = new { name = "Configure AWS Credentials" uses = Actions.awsConfigureCredentials with { @@ -148,7 +150,7 @@ const function readVersionFromPackage(): gha.Step = new { } const function uploadToNPM(tag: "latest" | "alpha"): Listing = new Listing { - local packageName = "io.realm.unity-${{ steps.\(getVersionStepName).outputs.\(getVersionOutput) }}.tgz" + local packageName = "io.realm.unity-\(getVersionExpresssion).tgz" new gha.Step { uses = Actions.setupNode diff --git a/.github/pkl-workflows/helpers/Test.pkl b/.github/pkl-workflows/helpers/Test.pkl index d416250a90..eea7cf411b 100644 --- a/.github/pkl-workflows/helpers/Test.pkl +++ b/.github/pkl-workflows/helpers/Test.pkl @@ -395,6 +395,7 @@ function unity(config: UnityTestConfig): Mapping = new Mapping< } needs { Common.job_Packages + Common.job_Unity } `timeout-minutes` = 30 `if` = Common.ifNotCanceledCondition diff --git a/.github/pkl-workflows/publish-prerelease.pkl b/.github/pkl-workflows/publish-prerelease.pkl index ec3307b3f5..e553e7ade4 100644 --- a/.github/pkl-workflows/publish-prerelease.pkl +++ b/.github/pkl-workflows/publish-prerelease.pkl @@ -4,7 +4,6 @@ amends "GithubAction/GithubAction.pkl" import "helpers/Common.pkl" import "helpers/Steps.pkl" -import "helpers/Actions.pkl" name = "Publish Prerelease" on { @@ -26,7 +25,7 @@ jobs { Steps.configureAWSCredentials("NUGET_S3_ACCESS_KEY", "NUGET_S3_SECRET_KEY", "us-east-1") for (package in Common.nugetPackages) { - let (packageWithVersion = "\(package).${{ steps.\(Steps.getVersionStepName).outputs.\(Steps.getVersionOutput) }}") + let (packageWithVersion = "\(package).\(Steps.getVersionExpresssion)") new Step { name = "NuGet Publish \(packageWithVersion)" run = "sleet push ${{ github.workspace }}/Realm/packages/\(packageWithVersion)/\(packageWithVersion).nupkg --config ${{ github.workspace }}/.github/sleet.json --source NugetSource" diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index c3e23fa31d..a7d2f8b2bf 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -42,8 +42,10 @@ jobs: queries: - uses: security-and-quality query-filters: - - exclude: cs/call-to-unmanaged-code - - exclude: cs/unmanaged-code + - exclude: + id: cs/call-to-unmanaged-code + - exclude: + id: cs/unmanaged-code - name: Setup JDK uses: actions/setup-java@2e74cbce18569d23ca8b812590dbb83f13ac7c5a with: diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index 1a7f9be055..e50e7f65b2 100755 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -210,6 +210,10 @@ jobs: run: msbuild Realm/Realm -t:Pack -restore -p:Configuration=Release -p:PackageOutputPath=${{ github.workspace }}/Realm/packages -p:VersionSuffix=${{ steps.set-version-suffix.outputs.build_suffix }} - name: Build Realm/Realm.PlatformHelpers run: msbuild Realm/Realm.PlatformHelpers -t:Pack -restore -p:Configuration=Release -p:PackageOutputPath=${{ github.workspace }}/Realm/packages -p:VersionSuffix=${{ steps.set-version-suffix.outputs.build_suffix }} + - name: Build Realm/Realm.UnityUtils + run: msbuild Realm/Realm.UnityUtils -t:Pack -restore -p:Configuration=Release -p:PackageOutputPath=${{ github.workspace }}/Realm/packages -p:VersionSuffix=${{ steps.set-version-suffix.outputs.build_suffix }} + - name: Build Realm/Realm.UnityWeaver + run: msbuild Realm/Realm.UnityWeaver -t:Pack -restore -p:Configuration=Release -p:PackageOutputPath=${{ github.workspace }}/Realm/packages -p:VersionSuffix=${{ steps.set-version-suffix.outputs.build_suffix }} - name: Read version id: get-version run: |- @@ -231,6 +235,20 @@ jobs: path: Realm/packages/Realm.PlatformHelpers.${{ steps.get-version.outputs.package_version }}.*nupkg retention-days: ${{ github.event_name != 'pull_request' && 30 || 1 }} if-no-files-found: error + - name: Store artifacts for Realm.UnityUtils.${{ steps.get-version.outputs.package_version }} + uses: actions/upload-artifact@v4 + with: + name: Realm.UnityUtils.${{ steps.get-version.outputs.package_version }} + path: Realm/packages/Realm.UnityUtils.${{ steps.get-version.outputs.package_version }}.*nupkg + retention-days: ${{ github.event_name != 'pull_request' && 30 || 1 }} + if-no-files-found: error + - name: Store artifacts for Realm.UnityWeaver.${{ steps.get-version.outputs.package_version }} + uses: actions/upload-artifact@v4 + with: + name: Realm.UnityWeaver.${{ steps.get-version.outputs.package_version }} + path: Realm/packages/Realm.UnityWeaver.${{ steps.get-version.outputs.package_version }}.*nupkg + retention-days: ${{ github.event_name != 'pull_request' && 30 || 1 }} + if-no-files-found: error - name: Store artifacts for ExtractedChangelog uses: actions/upload-artifact@v4 with: @@ -314,6 +332,7 @@ jobs: name: Build Unity linux needs: - build-packages + - build-unity if: always() && !cancelled() && !contains(needs.*.result, 'failure') && !contains(needs.*.result, 'cancelled') timeout-minutes: 30 runs-on: @@ -392,6 +411,7 @@ jobs: name: Build Unity windows needs: - build-packages + - build-unity if: always() && !cancelled() && !contains(needs.*.result, 'failure') && !contains(needs.*.result, 'cancelled') timeout-minutes: 30 runs-on: From d38596a9c217971410a0a43ce5cb518745ca84cf Mon Sep 17 00:00:00 2001 From: Nikola Irinchev Date: Thu, 23 May 2024 14:53:48 +0200 Subject: [PATCH 35/39] Migrate publish-release.yml --- .github/pkl-workflows/helpers/Actions.pkl | 2 + .github/pkl-workflows/publish-release.pkl | 141 ++++++++++++++++++++++ .github/templates/publish-release.yml | 110 ----------------- .github/workflows/publish-release.yml | 61 +++++----- 4 files changed, 176 insertions(+), 138 deletions(-) create mode 100644 .github/pkl-workflows/publish-release.pkl delete mode 100644 .github/templates/publish-release.yml diff --git a/.github/pkl-workflows/helpers/Actions.pkl b/.github/pkl-workflows/helpers/Actions.pkl index c7cf608298..c7d54b3d54 100644 --- a/.github/pkl-workflows/helpers/Actions.pkl +++ b/.github/pkl-workflows/helpers/Actions.pkl @@ -19,4 +19,6 @@ const codeQLInit = "github/codeql-action/init@a57c67b89589d2d13d5ac85a9fc4679c75 const codeQLAnalyze = "github/codeql-action/analyze@a57c67b89589d2d13d5ac85a9fc4679c7539f94c" const findPR = "juliangruber/find-pull-request-action@48b6133aa6c826f267ebd33aa2d29470f9d9e7d0" // 1.9.0 const mergePR = "juliangruber/merge-pull-request-action@9234b8714dda9a08f3d1df5b2a6a3abd7b695353" // 1.3.1 +const createPR = "peter-evans/create-pull-request@6d6857d36972b65feb161a90e484f2984215f83e" // 6.0.5 const publishGithubRelease = "ncipollo/release-action@2c591bcc8ecdcd2db72b97d6147f871fcd833ba5" // 1.14.0 +const releaseToSlack = "realm/ci-actions/release-to-slack@6418e15ed9bbdb19b7d456a347e5623779f95cdf" diff --git a/.github/pkl-workflows/publish-release.pkl b/.github/pkl-workflows/publish-release.pkl new file mode 100644 index 0000000000..babfcf58f8 --- /dev/null +++ b/.github/pkl-workflows/publish-release.pkl @@ -0,0 +1,141 @@ +module release + +amends "GithubAction/GithubAction.pkl" + +import "helpers/Common.pkl" +import "helpers/Steps.pkl" +import "helpers/Actions.pkl" + +name = "Publish Release" +on { + workflow_dispatch{} +} +jobs { + ["main"] = new Job { + `runs-on` = new WindowsLatest{} + name = "Publish Release" + environment = "Production" + steps { + Steps.checkoutWithoutMatchers(false) + Steps.downloadAllArtifacts() + Steps.readVersionFromPackage() + Steps.configureAWSCredentials("DOCS_S3_ACCESS_KEY", "DOCS_S3_SECRET_KEY", "us-east-2") + uploadDocs() + ...uploadToNuGet() + ...Steps.uploadToNPM("latest") + ...mergeReleasePR() + publishGithubReleasee() + ...updateChangelogForvNext() + postReleaseToSlack() + } + } +} + +local function uploadDocs(): Step = new Step { + name = "Upload docs" + run = #""" + Expand-Archive -Path Realm/packages/Docs.zip/Docs.zip -DestinationPath Realm/packages + $versions = "${{ steps.\#(Steps.getVersionStepName).outputs.\#(Steps.getVersionOutput) }}", "latest" + Foreach ($ver in $versions) + { + aws s3 sync --acl public-read "${{ github.workspace }}\Realm\packages\_site" s3://realm-sdks/docs/realm-sdks/dotnet/$ver/ + } + """# +} + +local function uploadToNuGet(): Listing = new Listing { + for (package in Common.nugetPackages) { + let (packageWithVersion = "\(package).\(Steps.getVersionExpresssion)") + new Step { + name = "NuGet Publish \(packageWithVersion)" + run = "dotnet nuget push ${{ github.workspace }}/Realm/packages/\(packageWithVersion)/\(packageWithVersion).nupkg --skip-duplicate --api-key ${{ secrets.NUGET_API_KEY }} --source https://api.nuget.org/v3/index.json" + } + } +} + +local function mergeReleasePR(): Listing = new Listing { + local find_pr_step = "find-pull-request" + new Step { + name = "Find Release PR" + uses = Actions.findPR + id = find_pr_step + with { + ["branch"] = "${{ github.ref }}" + } + } + mergePR("${{ steps.\(find_pr_step).outputs.number }}") +} + +local function mergePR(numberExpression: String): Step = new Step { + name = "Merge Pull Request" + uses = Actions.mergePR + with { + ["github-token"] = "${{ secrets.GITHUB_TOKEN }}" + ["number"] = numberExpression + ["method"] = "squash" + } +} + +local function publishGithubReleasee(): Step = new Step { + name = "Publish Github Release" + uses = Actions.publishGithubRelease + with { + ["artifacts"] = "Realm/packages/io.realm.unity-\(Steps.getVersionExpresssion).tgz/io.realm.unity-\(Steps.getVersionExpresssion).tgz" + ["bodyFile"] = "Realm/packages/ExtractedChangelog/ExtractedChangelog.md" + ["name"] = Steps.getVersionExpresssion + ["commit"] = Common.mainBranch + ["tag"] = Steps.getVersionExpresssion + ["token"] = "${{ secrets.GITHUB_TOKEN }}" + ["draft"] = false + } +} + +local function updateChangelogForvNext(): Listing = new Listing { + local create_pr_step = "vnext-pr" + new Step { + name = "Update Changelog" + run = """ + echo "## vNext (TBD) + + ### Enhancements + * None + + ### Fixed + * None + + ### Compatibility + * Realm Studio: 15.0.0 or later. + + ### Internal + * Using Core x.y.z. + " | cat - CHANGELOG.md >> temp + mv temp CHANGELOG.md + """ + shell = "bash" + } + new Step { + name = "Create vNext PR" + id = create_pr_step + uses = Actions.createPR + with { + ["branch"] = "prepare-vnext" + ["title"] = "Prepare for vNext" + ["body"] = "Update Changelog for vNext" + ["delete-branch"] = true + ["base"] = Common.mainBranch + ["commit-message"] = "Prepare for vNext" + } + } + mergePR("${{ steps.\(create_pr_step).outputs.pull-request-number }}") +} + +local function postReleaseToSlack(): Step = new Step { + name = "Post to #realm-releases" + uses = Actions.releaseToSlack + with { + ["changelog"] = "Realm/packages/ExtractedChangelog/ExtractedChangelog.md" + ["sdk"] = ".NET" + ["webhook-url"] = "${{ secrets.SLACK_RELEASE_WEBHOOK }}" + ["version"] = Steps.getVersionExpresssion + } +} diff --git a/.github/templates/publish-release.yml b/.github/templates/publish-release.yml deleted file mode 100644 index 91f8210713..0000000000 --- a/.github/templates/publish-release.yml +++ /dev/null @@ -1,110 +0,0 @@ -#@ load("@ytt:template", "template") -#@ load("common.lib.yml", "checkoutCode", "actionSetupNode", "actionGithubRelease", "actionReleaseToSlack", "actionFindPR", "actionMergePR", "actionCreatePR", "mainBranch", "downloadAllArtifacts", "readVersionFromPackage", "configureAWSCredentials", "uploadToNpm") - -#@ def uploadToNuget(packageName): - - name: #@ "NuGet Publish " + packageName + ".${{ steps.get-version.outputs.version }}" - run: #@ "dotnet nuget push ${{ github.workspace }}/Realm/packages/" + packageName + ".${{ steps.get-version.outputs.version }}/" + packageName + ".${{ steps.get-version.outputs.version }}.nupkg --skip-duplicate --api-key ${{ secrets.NUGET_API_KEY }} --source https://api.nuget.org/v3/index.json" -#@ end - -#@ def publishGithubRelease(): - - name: Publish Github Release - uses: #@ actionGithubRelease - with: - artifacts: Realm/packages/io.realm.unity-${{ steps.get-version.outputs.version }}.tgz/io.realm.unity-${{ steps.get-version.outputs.version }}.tgz - bodyFile: Realm/packages/ExtractedChangelog/ExtractedChangelog.md - name: ${{ steps.get-version.outputs.version }} - commit: #@ mainBranch - tag: ${{ steps.get-version.outputs.version }} - token: ${{ secrets.GITHUB_TOKEN }} - draft: false -#@ end - -#@ def mergePR(number): - - name: Merge Pull Request - uses: #@ actionMergePR - with: - github-token: ${{ secrets.GITHUB_TOKEN }} - number: #@ number - method: squash -#@ end - -#@ def mergeReleasePR(): - - name: Find Release PR - uses: #@ actionFindPR - id: find-pull-request - with: - branch: ${{ github.ref }} - - #@ template.replace(mergePR("${{ steps.find-pull-request.outputs.number }}")) -#@ end - -#@ def uploadDocsToS3(): - - #@ template.replace(configureAWSCredentials("DOCS_S3_ACCESS_KEY", "DOCS_S3_SECRET_KEY", "us-east-2")) - - name: Upload docs - run: | - Expand-Archive -Path Realm/packages/Docs.zip/Docs.zip -DestinationPath Realm/packages - $versions = "${{ steps.get-version.outputs.version }}", "latest" - Foreach ($ver in $versions) - { - aws s3 sync --acl public-read "${{ github.workspace }}\Realm\packages\_site" s3://realm-sdks/docs/realm-sdks/dotnet/$ver/ - } -#@ end - -#@ def updateChangelogForvNext(): - - name: Update Changelog - run: | - echo "## vNext (TBD) - - ### Enhancements - * None - - ### Fixed - * None - - ### Compatibility - * Realm Studio: 15.0.0 or later. - - ### Internal - * Using Core x.y.z. - " | cat - CHANGELOG.md >> temp - mv temp CHANGELOG.md - shell: bash - - name: Create vNext PR - id: vnext-pr - uses: #@ actionCreatePR - with: - branch: prepare-vnext - title: Prepare for vNext - body: Update Changelog for vNext - delete-branch: true - base: #@ mainBranch - commit-message: Prepare for vNext - - #@ template.replace(mergePR("${{ steps.vnext-pr.outputs.pull-request-number }}")) -#@ end ---- -name: Publish Release -"on": - workflow_dispatch - -jobs: - main: - runs-on: windows-latest - environment: Production - steps: - - #@ template.replace(checkoutCode(False, False)) - - #@ template.replace(downloadAllArtifacts()) - - #@ template.replace(readVersionFromPackage()) - - #@ template.replace(uploadDocsToS3()) - - #@ template.replace(uploadToNuget("Realm.PlatformHelpers")) - - #@ template.replace(uploadToNuget("Realm")) - - #@ template.replace(uploadToNpm()) - - #@ template.replace(mergeReleasePR()) - - #@ template.replace(publishGithubRelease()) - - #@ template.replace(updateChangelogForvNext()) - - name: 'Post to #realm-releases' - uses: #@ actionReleaseToSlack - with: - changelog: Realm/packages/ExtractedChangelog/ExtractedChangelog.md - sdk: .NET - webhook-url: ${{ secrets.SLACK_RELEASE_WEBHOOK }} - version: ${{ steps.get-version.outputs.version }} - diff --git a/.github/workflows/publish-release.yml b/.github/workflows/publish-release.yml index e04b5a7aaa..ff83d242db 100755 --- a/.github/workflows/publish-release.yml +++ b/.github/workflows/publish-release.yml @@ -1,78 +1,83 @@ +# Do not modify! +# This file was generated from a template using https://github.com/apple/pkl + name: Publish Release -"on": workflow_dispatch +'on': + workflow_dispatch: {} jobs: main: - runs-on: windows-latest + name: Publish Release environment: Production + runs-on: windows-latest steps: - - name: Checkout code - uses: actions/checkout@v3 + - name: Checkout Code + uses: actions/checkout@v4 with: submodules: false ref: ${{ github.event.pull_request.head.sha }} - name: Download all artifacts - uses: dawidd6/action-download-artifact@46b4ae883bf0726f5949d025d31cb62c7a5ac70c + uses: dawidd6/action-download-artifact@09f2f74827fd3a8607589e5ad7f9398816f540fe with: workflow: pr.yml commit: ${{ github.sha }} - path: ${{ github.workspace }}/Realm/packages/ + path: Realm/packages/ workflow_conclusion: completed - name: Read version id: get-version - run: | + run: |- cd Realm/packages pkgVersion=$(find . -type f -regex ".*Realm.[1-9].*.nupkg" -exec basename {} \; | sed -n 's/Realm\.\(.*\)\.nupkg$/\1/p') - echo "version=$pkgVersion" >> $GITHUB_OUTPUT + echo "package_version=$pkgVersion" >> $GITHUB_OUTPUT shell: bash - name: Configure AWS Credentials - uses: aws-actions/configure-aws-credentials@v1-node16 + uses: aws-actions/configure-aws-credentials@v4.0.2 with: aws-access-key-id: ${{ secrets.DOCS_S3_ACCESS_KEY }} aws-secret-access-key: ${{ secrets.DOCS_S3_SECRET_KEY }} aws-region: us-east-2 - name: Upload docs - run: | + run: |- Expand-Archive -Path Realm/packages/Docs.zip/Docs.zip -DestinationPath Realm/packages - $versions = "${{ steps.get-version.outputs.version }}", "latest" + $versions = "${{ steps.get-version.outputs.package_version }}", "latest" Foreach ($ver in $versions) { aws s3 sync --acl public-read "${{ github.workspace }}\Realm\packages\_site" s3://realm-sdks/docs/realm-sdks/dotnet/$ver/ } - - name: NuGet Publish Realm.PlatformHelpers.${{ steps.get-version.outputs.version }} - run: dotnet nuget push ${{ github.workspace }}/Realm/packages/Realm.PlatformHelpers.${{ steps.get-version.outputs.version }}/Realm.PlatformHelpers.${{ steps.get-version.outputs.version }}.nupkg --skip-duplicate --api-key ${{ secrets.NUGET_API_KEY }} --source https://api.nuget.org/v3/index.json - - name: NuGet Publish Realm.${{ steps.get-version.outputs.version }} - run: dotnet nuget push ${{ github.workspace }}/Realm/packages/Realm.${{ steps.get-version.outputs.version }}/Realm.${{ steps.get-version.outputs.version }}.nupkg --skip-duplicate --api-key ${{ secrets.NUGET_API_KEY }} --source https://api.nuget.org/v3/index.json - - uses: actions/setup-node@16352bb09bc672a073e326c2cc1d3d7d2a3e577e + - name: NuGet Publish Realm.${{ steps.get-version.outputs.package_version }} + run: dotnet nuget push ${{ github.workspace }}/Realm/packages/Realm.${{ steps.get-version.outputs.package_version }}/Realm.${{ steps.get-version.outputs.package_version }}.nupkg --skip-duplicate --api-key ${{ secrets.NUGET_API_KEY }} --source https://api.nuget.org/v3/index.json + - name: NuGet Publish Realm.PlatformHelpers.${{ steps.get-version.outputs.package_version }} + run: dotnet nuget push ${{ github.workspace }}/Realm/packages/Realm.PlatformHelpers.${{ steps.get-version.outputs.package_version }}/Realm.PlatformHelpers.${{ steps.get-version.outputs.package_version }}.nupkg --skip-duplicate --api-key ${{ secrets.NUGET_API_KEY }} --source https://api.nuget.org/v3/index.json + - uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 with: node-version: 16.x registry-url: https://registry.npmjs.org - - name: Npm Publish io.realm.unity-${{steps.get-version.outputs.version}}.tgz - run: npm publish ${{ github.workspace }}/Realm/packages/io.realm.unity-${{steps.get-version.outputs.version}}.tgz/io.realm.unity-${{steps.get-version.outputs.version}}.tgz --tag latest + - name: NPM publish io.realm.unity-${{ steps.get-version.outputs.package_version }}.tgz env: NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} + run: npm publish ${{ github.workspace }}/Realm/packages/io.realm.unity-${{ steps.get-version.outputs.package_version }}.tgz/io.realm.unity-${{ steps.get-version.outputs.package_version }}.tgz --tag latest - name: Find Release PR - uses: juliangruber/find-pull-request-action@afdd62ccd2d4c55f5bdb154b489b85fc4cbcb9c1 id: find-pull-request + uses: juliangruber/find-pull-request-action@48b6133aa6c826f267ebd33aa2d29470f9d9e7d0 with: branch: ${{ github.ref }} - name: Merge Pull Request - uses: juliangruber/merge-pull-request-action@333730196b34b74936aad75a4e31c23a57582d14 + uses: juliangruber/merge-pull-request-action@9234b8714dda9a08f3d1df5b2a6a3abd7b695353 with: github-token: ${{ secrets.GITHUB_TOKEN }} number: ${{ steps.find-pull-request.outputs.number }} method: squash - name: Publish Github Release - uses: ncipollo/release-action@3ac4132803a6419fa2a7f4e9dbd1d93fceb690b9 + uses: ncipollo/release-action@2c591bcc8ecdcd2db72b97d6147f871fcd833ba5 with: - artifacts: Realm/packages/io.realm.unity-${{ steps.get-version.outputs.version }}.tgz/io.realm.unity-${{ steps.get-version.outputs.version }}.tgz + artifacts: Realm/packages/io.realm.unity-${{ steps.get-version.outputs.package_version }}.tgz/io.realm.unity-${{ steps.get-version.outputs.package_version }}.tgz bodyFile: Realm/packages/ExtractedChangelog/ExtractedChangelog.md - name: ${{ steps.get-version.outputs.version }} + name: ${{ steps.get-version.outputs.package_version }} commit: main - tag: ${{ steps.get-version.outputs.version }} + tag: ${{ steps.get-version.outputs.package_version }} token: ${{ secrets.GITHUB_TOKEN }} draft: false - name: Update Changelog - run: | + run: |- echo "## vNext (TBD) ### Enhancements @@ -91,7 +96,7 @@ jobs: shell: bash - name: Create vNext PR id: vnext-pr - uses: peter-evans/create-pull-request@6c704eb7a8ba1daa13da0dcea9bb93a4fe530275 + uses: peter-evans/create-pull-request@6d6857d36972b65feb161a90e484f2984215f83e with: branch: prepare-vnext title: Prepare for vNext @@ -100,7 +105,7 @@ jobs: base: main commit-message: Prepare for vNext - name: Merge Pull Request - uses: juliangruber/merge-pull-request-action@333730196b34b74936aad75a4e31c23a57582d14 + uses: juliangruber/merge-pull-request-action@9234b8714dda9a08f3d1df5b2a6a3abd7b695353 with: github-token: ${{ secrets.GITHUB_TOKEN }} number: ${{ steps.vnext-pr.outputs.pull-request-number }} @@ -111,4 +116,4 @@ jobs: changelog: Realm/packages/ExtractedChangelog/ExtractedChangelog.md sdk: .NET webhook-url: ${{ secrets.SLACK_RELEASE_WEBHOOK }} - version: ${{ steps.get-version.outputs.version }} + version: ${{ steps.get-version.outputs.package_version }} From b3c0c37d0488bded5857dbb1db901c0404273fc9 Mon Sep 17 00:00:00 2001 From: Nikola Irinchev Date: Thu, 23 May 2024 16:01:36 +0200 Subject: [PATCH 36/39] Migrate main.pkl --- .github/pkl-workflows/Readme.md | 20 + .github/pkl-workflows/helpers/Common.pkl | 50 +- .github/pkl-workflows/helpers/Package.pkl | 1 + .github/pkl-workflows/helpers/Steps.pkl | 18 + .github/pkl-workflows/helpers/Test.pkl | 70 +- .github/pkl-workflows/main.pkl | 67 + .github/pkl-workflows/pr.pkl | 47 +- .github/pkl-workflows/publish-prerelease.pkl | 16 +- .github/pkl-workflows/publish-release.pkl | 1 + .github/templates/Readme.md | 24 - .github/templates/build.lib.yml | 128 -- .github/templates/common.lib.yml | 259 --- .github/templates/main.yml | 101 -- .github/templates/test.lib.yml | 99 -- .github/workflows/main.yml | 1565 ++++++++++++++++-- .github/workflows/pr.yml | 3 +- .github/workflows/publish-prerelease.yml | 3 + .github/workflows/publish-release.yml | 3 + 18 files changed, 1639 insertions(+), 836 deletions(-) create mode 100644 .github/pkl-workflows/Readme.md create mode 100644 .github/pkl-workflows/main.pkl delete mode 100644 .github/templates/Readme.md delete mode 100644 .github/templates/build.lib.yml delete mode 100644 .github/templates/common.lib.yml delete mode 100644 .github/templates/main.yml delete mode 100644 .github/templates/test.lib.yml diff --git a/.github/pkl-workflows/Readme.md b/.github/pkl-workflows/Readme.md new file mode 100644 index 0000000000..dce79a1387 --- /dev/null +++ b/.github/pkl-workflows/Readme.md @@ -0,0 +1,20 @@ +# Preprocessing the GA workflows + +We're using [pkl](http://github.com/apple/pkl) to generate the github actions workflows. + +## Prerequisites + +Install pkl: https://pkl-lang.org/main/current/pkl-cli/index.html#installation + +For macOS, this is simply + +```bash +brew install pkl +``` + +## Building the workflows + +```bash +cd $SolutionDir/.github/pkl-workflows +for file in *.pkl ; do pkl eval $file -o ../workflows/$(echo $file | sed s/pkl/yml/) ; done +``` diff --git a/.github/pkl-workflows/helpers/Common.pkl b/.github/pkl-workflows/helpers/Common.pkl index 327fde6b34..bfc68dfa9c 100644 --- a/.github/pkl-workflows/helpers/Common.pkl +++ b/.github/pkl-workflows/helpers/Common.pkl @@ -1,5 +1,11 @@ module common +import "../GithubAction/GithubAction.pkl" as gha +import "BaaS.pkl" +import "Lint.pkl" +import "Package.pkl" +import "Test.pkl" as TestJobs + const configuration: String = "Release" const linuxArchs: List = List("x86_64", "armhf", "aarch64") @@ -14,6 +20,9 @@ const job_Packages: String = "build-packages" const job_Baas: String = "deploy-baas" const job_Unity: String = "build-unity" +local const job_Wrappers: String = "build-wrappers" +local const job_Coverage: String = "test-code-coverage" + const mainBranch: String = "main" typealias NetFramework = "net6.0" | "net8.0" | String(startsWith("${{ matrix")) | String(startsWith("net8")) @@ -40,4 +49,43 @@ const ifNotCanceledCondition = "always() && !cancelled() && !contains(needs.*.re const nugetPackages: List = List("Realm", "Realm.PlatformHelpers") const packages: List = nugetPackages + List("Realm.UnityUtils", "Realm.UnityWeaver") -const testTimeout = 60 +const testTimeout: Int = 60 + +const function defaultBuildJobs(baasDifferentiators: Listing, netCoreVersions: Listing): Mapping = new Mapping { + [job_Wrappers] = new gha.ReusableWorkflowJob { + uses = "./.github/workflows/wrappers.yml" + name = "Wrappers" + } + [job_Baas] = BaaS.deploy(baasDifferentiators) + [job_Packages] = (Package.nuget("contains(github.head_ref, 'release')")){ + needs { + job_Wrappers + } + } + [job_Unity] = Package.unity() + ...TestJobs.unity(new TestJobs.UnityTestConfig { + os = "linux" + }) + ...TestJobs.unity(new TestJobs.UnityTestConfig { + os = "windows" + }) + ["test-net-framework"] = TestJobs.netFramework(baasDifferentiators) + ["test-uwp"] = TestJobs.uwp(baasDifferentiators) + ["test-net-core"] = TestJobs.netCore(netCoreVersions) + ["test-macos-xamarin"] = TestJobs.macOS_Xamarin() + ["test-macos-maui"] = TestJobs.macOS_Maui(baasDifferentiators) + ["test-ios-xamarin"] = TestJobs.iOS_Xamarin() + ["test-ios-maui"] = TestJobs.iOS_Maui(baasDifferentiators) + ["test-tvos"] = TestJobs.tvOS(baasDifferentiators) + ["test-android-xamarin"] = TestJobs.android_Xamarin() + ["test-android-maui"] = TestJobs.android_Maui(baasDifferentiators) + ["test-woven-classes"] = TestJobs.wovenClasses() + ["test-source-generation"] = TestJobs.sourceGeneration() + ["test-weaver"] = TestJobs.weaver() + ["test-code-coverage"] = TestJobs.codeCoverage(job_Wrappers, baasDifferentiators) + ["cleanup-baas"] = (BaaS.cleanup(baasDifferentiators)) { + needs = baasDifferentiators.toList().map((d) -> "test-\(d)").toListing() + } + ["verify-namespaces"] = Lint.verifyNamespaces() + ["lint"] = Lint.lint() +} diff --git a/.github/pkl-workflows/helpers/Package.pkl b/.github/pkl-workflows/helpers/Package.pkl index a8ffd837f3..16cbe65283 100644 --- a/.github/pkl-workflows/helpers/Package.pkl +++ b/.github/pkl-workflows/helpers/Package.pkl @@ -15,6 +15,7 @@ local const buildSuffixOutput = "build_suffix" function nuget(shouldBuildDocsCondition: String): gha.Job = new gha.Job { name = "Package NuGet" `runs-on` = new gha.WindowsLatest{} + `if` = Common.ifNotCanceledCondition outputs { [Steps.getVersionOutput] = Steps.getVersionExpresssion } diff --git a/.github/pkl-workflows/helpers/Steps.pkl b/.github/pkl-workflows/helpers/Steps.pkl index 666529cd87..b963cecfa7 100644 --- a/.github/pkl-workflows/helpers/Steps.pkl +++ b/.github/pkl-workflows/helpers/Steps.pkl @@ -168,6 +168,24 @@ const function uploadToNPM(tag: "latest" | "alpha"): Listing = new Lis } } +const function uploadPackagesToSleet(versionExpression: String, expectShortPath: Boolean): Listing = new { + setupDotnet(null) + new gha.Step { + name = "Install sleet" + run = "dotnet tool install -g sleet" + } + + configureAWSCredentials("NUGET_S3_ACCESS_KEY", "NUGET_S3_SECRET_KEY", "us-east-1") + for (package in Common.nugetPackages) { + let (packageWithVersion = "\(package).\(versionExpression)") + let (packagePath = "\(if (expectShortPath) "" else "\(packageWithVersion)/")\(packageWithVersion).nupkg") + new gha.Step { + name = "NuGet Publish \(packageWithVersion)" + run = "sleet push ${{ github.workspace }}/Realm/packages/\(packagePath) --config ${{ github.workspace }}/.github/sleet.json --source NugetSource" + } + } +} + class MSBuildConfig { projects: Listing target: String? diff --git a/.github/pkl-workflows/helpers/Test.pkl b/.github/pkl-workflows/helpers/Test.pkl index eea7cf411b..51a44ca6eb 100644 --- a/.github/pkl-workflows/helpers/Test.pkl +++ b/.github/pkl-workflows/helpers/Test.pkl @@ -9,6 +9,7 @@ import "Package.pkl" local const actionReportTestResults = "dorny/test-reporter@31a54ee7ebcacc03a09ea97a7e5465a47b84aea5" local const outputFile = "TestResults.xml" +local const executableExpression = "${{ steps.dotnet-publish.outputs.executable-path }}" // Public test targets function netFramework(_syncDifferentiators: Listing): gha.StepJobBase = testJob( @@ -105,8 +106,23 @@ function weaver(): gha.StepJobBase = testJob( ...Steps.dotnetPublish("Tests/Weaver/Realm.Fody.Tests", "net6.0", "${{ matrix.os.runtime }}", new Mapping{}).toList() ...dotnetRunTests(false) ...reportTestResults(config) - } -) + }) + +function xunit(): gha.StepJobBase = testJob( + new TestConfig { + title = "xUnit Compatibility" + needsPackages = true + }, + new gha.WindowsLatest{}, + null, + (config) -> new Listing { + ...prepareTests(config) + ...Steps.dotnetPublish("Tests/Tests.XUnit", "net6.0", "win-x64", new Mapping{}).toList() + new gha.Step { + name = "Run Tests" + run = "dotnet test \(executableExpression)/Tests.XUnit.dll --logger GitHubActions" + } + }) function sourceGeneration(): gha.StepJobBase = testJob( new TestConfig { @@ -375,7 +391,7 @@ function codeCoverage(wrappersJob: String, _syncDifferentiators: Listing enableCoreDumps(true) archiveCoreDump() ...Steps.publishCoverage("./report.lcov") @@ -452,6 +468,52 @@ function unity(config: UnityTestConfig): Mapping = new Mapping< } } +function benchmark(): gha.StepJobBase = testJob( + new TestConfig { + title = "Benchmark" + shouldCleanWorkspace = true + needsPackages = true + }, + "performance-tests", + null, + (config) -> new Listing { + local find_results_step = "find-results-file" + local find_results_output = "benchmark-results" + + ...prepareTests(config) + // To avoid NU5037 error + new gha.Step { + name = "Clear nuget cache" + run = "dotnet nuget locals all --clear" + } + ...Steps.dotnetPublish("Tests/Benchmarks/PerformanceTests", "net6.0", "linux-x64", getTestProps(true)) + new gha.Step { + name = "Run the tests" + run = "\(executableExpression)/PerformanceTests -f \"*\" --join" + } + new gha.Step { + name = "Find Results file" + run = """ + cd BenchmarkDotNet.Artifacts/results + file=$(basename BenchmarkRun*json) + echo "\(find_results_output)=$file" >> $GITHUB_OUTPUT + """ + shell = "bash" + id = find_results_step + } + new gha.Step { + name = "Publish Benchmark Results" + uses = "./github/actions/benchmark-uploader" + with { + ["realm-token"] = "${{ secrets.Realm_Token }}" + ["file"] = "${{ github.workspace }}/BenchmarkDotNet.Artifacts/results/${{ steps.\(find_results_step).outputs.\(find_results_output) }}" + ["dashboard-path"] = "dashboard.charts" + ["nuget-package"] = "${{ github.workspace }}/Realm/packages/Realm.${{ needs.\(Common.job_Packages).outputs.\(Steps.getVersionOutput) }}.nupkg" + } + } + Steps.uploadArtifacts("dashboard.charts", "dashboard.charts") + }) + class UnityTestConfig { os: "windows" | "linux" settings: String = "Mono-Net4" @@ -540,7 +602,7 @@ local function getTestProps(standaloneExe: Boolean): Mapping = n local function dotnetRunTests(enableCoreDumps: Boolean): Listing = new Listing { new gha.Step { name = "Run the tests" - run = "${{ steps.dotnet-publish.outputs.executable-path }} --result=\(outputFile) --labels=After" + run = "\(executableExpression) --result=\(outputFile) --labels=After" } |> enableCoreDumps(enableCoreDumps) when (enableCoreDumps) { archiveCoreDump() diff --git a/.github/pkl-workflows/main.pkl b/.github/pkl-workflows/main.pkl new file mode 100644 index 0000000000..b6a7e6b931 --- /dev/null +++ b/.github/pkl-workflows/main.pkl @@ -0,0 +1,67 @@ +module main + +amends "GithubAction/GithubAction.pkl" + +import "helpers/Common.pkl" +import "helpers/Steps.pkl" +import "helpers/Test.pkl" as TestJobs + +local baasDifferentiators: Listing = new { + "code-coverage" + "net-framework" + "uwp" + "macos-maui" + "android-maui" + "ios-maui" + "macos-maui" +} + +local netCoreFrameworks: Listing = new { + "net6.0" + "net8.0" +} + +name = "Main Build" +on { + push { + branches { + Common.mainBranch + } + } + workflow_dispatch { + inputs { + ["publish-prerelease"] = new WorkflowInput { + description = "Indicates whether to publish the package to Sleet/npm" + required = false + type = "boolean" + } + ["run-benchmark"] = new WorkflowInput { + description = "Indicates whether to run the benchmark tests" + required = false + type = "boolean" + } + } + } +} + +env = Common.defaultEnv + +jobs = (Common.defaultBuildJobs(baasDifferentiators, netCoreFrameworks)) { + ["publish-packages-to-sleet"] = new Job { + `runs-on` = new UbuntuLatest{} + name = "Publish package to S3" + needs { + Common.job_Packages + } + `if` = "${{ \(Common.ifNotCanceledCondition) && (github.event_name == 'push' || github.event.inputs.publish-prerelease) }}" + steps { + Steps.checkoutWithoutMatchers(false) + ...Steps.fetchPackages(Common.nugetPackages) + ...Steps.uploadPackagesToSleet("${{ needs.\(Common.job_Packages).outputs.\(Steps.getVersionOutput) }}", true) + } + } + ["test-xunit"] = TestJobs.xunit() + ["benchmark-linux"] = (TestJobs.benchmark()) { + `if` = "${{ \(Common.ifNotCanceledCondition) && (github.event_name == 'push' || github.event.inputs.run-benchmark) }}" + } +} diff --git a/.github/pkl-workflows/pr.pkl b/.github/pkl-workflows/pr.pkl index 75601e918e..738ec7d018 100644 --- a/.github/pkl-workflows/pr.pkl +++ b/.github/pkl-workflows/pr.pkl @@ -3,10 +3,6 @@ module pr amends "GithubAction/GithubAction.pkl" import "helpers/Common.pkl" -import "helpers/Package.pkl" -import "helpers/BaaS.pkl" -import "helpers/Lint.pkl" -import "helpers/Test.pkl" as TestJobs local class JobNamesDefition { const wrappers: String = "build-wrappers" @@ -19,6 +15,10 @@ local baasDifferentiators: Listing = new { "code-coverage" } +local netCoreFrameworks: Listing = new { + "net6.0" +} + name = "PR Build" on { pull_request { @@ -48,41 +48,4 @@ concurrency { `cancel-in-progress` = true } -jobs { - [JobNames.wrappers] = new ReusableWorkflowJob { - uses = "./.github/workflows/wrappers.yml" - name = "Wrappers" - } - [Common.job_Baas] = BaaS.deploy(baasDifferentiators) // TODO: run baasaas tests for more targets - [Common.job_Packages] = (Package.nuget("contains(github.head_ref, 'release')")){ - needs { - JobNames.wrappers - } - } - [Common.job_Unity] = Package.unity() - ...TestJobs.unity(new TestJobs.UnityTestConfig { - os = "linux" - }) - ...TestJobs.unity(new TestJobs.UnityTestConfig { - os = "windows" - }) - ["test-net-framework"] = TestJobs.netFramework(baasDifferentiators) - ["test-uwp"] = TestJobs.uwp(baasDifferentiators) - ["test-net-core"] = TestJobs.netCore(new Listing { "net8.0" }) - ["test-macos-xamarin"] = TestJobs.macOS_Xamarin() - ["test-macos-maui"] = TestJobs.macOS_Maui(baasDifferentiators) - ["test-ios-xamarin"] = TestJobs.iOS_Xamarin() - ["test-ios-maui"] = TestJobs.iOS_Maui(baasDifferentiators) - ["test-tvos"] = TestJobs.tvOS(baasDifferentiators) - ["test-android-xamarin"] = TestJobs.android_Xamarin() - ["test-android-maui"] = TestJobs.android_Maui(baasDifferentiators) - ["test-woven-classes"] = TestJobs.wovenClasses() - ["test-source-generation"] = TestJobs.sourceGeneration() - ["test-weaver"] = TestJobs.weaver() - ["test-code-coverage"] = TestJobs.codeCoverage(JobNames.wrappers, baasDifferentiators) - ["cleanup-baas"] = (BaaS.cleanup(baasDifferentiators)) { - needs = baasDifferentiators.toList().map((d) -> "test-\(d)").toListing() - } - ["verify-namespaces"] = Lint.verifyNamespaces() - ["lint"] = Lint.lint() -} +jobs = Common.defaultBuildJobs(baasDifferentiators, netCoreFrameworks) \ No newline at end of file diff --git a/.github/pkl-workflows/publish-prerelease.pkl b/.github/pkl-workflows/publish-prerelease.pkl index e553e7ade4..af5c685994 100644 --- a/.github/pkl-workflows/publish-prerelease.pkl +++ b/.github/pkl-workflows/publish-prerelease.pkl @@ -9,6 +9,7 @@ name = "Publish Prerelease" on { workflow_dispatch{} } +env = Common.defaultEnv jobs { ["main"] = new Job { `runs-on` = new UbuntuLatest{} @@ -17,20 +18,7 @@ jobs { Steps.checkoutWithoutMatchers(false) Steps.downloadAllArtifacts() Steps.readVersionFromPackage() - Steps.setupDotnet(null) - new Step { - name = "Install sleet" - run = "dotnet tool install -g sleet" - } - - Steps.configureAWSCredentials("NUGET_S3_ACCESS_KEY", "NUGET_S3_SECRET_KEY", "us-east-1") - for (package in Common.nugetPackages) { - let (packageWithVersion = "\(package).\(Steps.getVersionExpresssion)") - new Step { - name = "NuGet Publish \(packageWithVersion)" - run = "sleet push ${{ github.workspace }}/Realm/packages/\(packageWithVersion)/\(packageWithVersion).nupkg --config ${{ github.workspace }}/.github/sleet.json --source NugetSource" - } - } + ...Steps.uploadPackagesToSleet(Steps.getVersionExpresssion, false) ...Steps.uploadToNPM("alpha") } } diff --git a/.github/pkl-workflows/publish-release.pkl b/.github/pkl-workflows/publish-release.pkl index babfcf58f8..7709ac3123 100644 --- a/.github/pkl-workflows/publish-release.pkl +++ b/.github/pkl-workflows/publish-release.pkl @@ -10,6 +10,7 @@ name = "Publish Release" on { workflow_dispatch{} } +env = Common.defaultEnv jobs { ["main"] = new Job { `runs-on` = new WindowsLatest{} diff --git a/.github/templates/Readme.md b/.github/templates/Readme.md deleted file mode 100644 index 984c8e7f0b..0000000000 --- a/.github/templates/Readme.md +++ /dev/null @@ -1,24 +0,0 @@ -# Preprocessing the GA workflows - -We're using [ytt](https://github.com/vmware-tanzu/carvel-ytt) to generate the github actions workflows. - -## Prerequisites - -Get ytt from your package manager of choice. If: -1. on Windows and use chocolatey you can run: -`choco install ytt -y` -1. on MacOS and use brew you can run: -`brew tap vmware-tanzu/carvel` -`brew install ytt` - -If instead ytt isn't in your packager manager or you don't use one you can manually get ytt as follows: - -1. Download the executable for your platform from the [releases page](https://github.com/vmware-tanzu/carvel-ytt/releases). -1. Rename it to `ytt`. -1. Place it in your PATH. - -## Building the docs -1. `cd $SolutionDir/.github/templates` -1. `ytt -f . --output-files ../workflows/` ==> to target all files -or -`ytt -f YOUR_FILE --output-files ../workflows/` ==> for a specific file \ No newline at end of file diff --git a/.github/templates/build.lib.yml b/.github/templates/build.lib.yml deleted file mode 100644 index f2e760d71c..0000000000 --- a/.github/templates/build.lib.yml +++ /dev/null @@ -1,128 +0,0 @@ -#@ load("@ytt:template", "template") -#@ load("common.lib.yml", "checkoutCode") - -#@ isRelease = "contains(github.head_ref, 'release')" - -#@ ignoreSkippedJobsCondition = "always() && !cancelled() && !contains(needs.*.result, 'failure') && !contains(needs.*.result, 'cancelled')" - -#@ secret_BaaSaasApiKey = "${{ secrets.BAASAAS_API_KEY }}" - -#@ def getJobName(prefix, name): -#@ if (prefix != ""): -#@ prefix = prefix + "-" -#@ end -#@ return prefix + name.replace(".", "").replace(" ", "-").lower() -#@ end - -#@ def deployBaas(targets = []): -#@ differentiators = [] -#@ for target in targets: -#@ differentiators.append('"' + getJobName("", target) + '"') -#@ end -deploy-baas: - uses: ./.github/workflows/deploy-baas.yml - with: - differentiators: #@ '[' + ", ".join(differentiators) + ']' - secrets: - BaaSaasApiKey: #@ secret_BaaSaasApiKey -#@ end - -#! 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-baas"] -#@ differentiators = [] -#@ for dependency in dependencies: -#@ needs.append(getJobName("test", dependency)) -#@ end -#@ for target in targets: -#@ differentiators.append('"' + getJobName("", target) + '"') -#@ end -cleanup-baas: - uses: ./.github/workflows/cleanup-baas.yml - if: always() - name: Cleanup - needs: #@ needs - with: - differentiators: #@ '[' + ", ".join(differentiators) + ']' - secrets: - BaaSaasApiKey: #@ secret_BaaSaasApiKey -#@ end - -#@ def runTests(name, runSyncTests = True, additionalSecrets = []): -#@yaml/text-templated-strings -(@= getJobName("test", name) @): - uses: #@ "./.github/workflows/" + getJobName("test", name) + ".yml" - name: Test - if: #@ ignoreSkippedJobsCondition - needs: - - build-packages - #@ if runSyncTests: - - deploy-baas - #@ end - with: - version: ${{ needs.build-packages.outputs.package_version }} - secrets: - #@ if runSyncTests: - BaaSaasApiKey: #@ secret_BaaSaasApiKey - #@ end - #@ for secret in additionalSecrets: - #@yaml/text-templated-strings - (@= secret @): #@ "${{ secrets." + secret + " }}" - #@ end -#@ end - -#@ def runNetCoreTests(frameworks): -test-net-core: - if: #@ ignoreSkippedJobsCondition - name: Test - needs: - - build-packages - uses: "./.github/workflows/test-net-core.yml" - with: - version: ${{ needs.build-packages.outputs.package_version }} - framework: #@ frameworks -#@ end - -#@ def runWovenClassesTests(): -test-weaved-classes: - if: #@ ignoreSkippedJobsCondition - name: Test - needs: - - build-packages - uses: "./.github/workflows/test-woven-classes.yml" - with: - version: ${{ needs.build-packages.outputs.package_version }} -#@ end - -#@ def runSourceGenerationTests(): -test-source-generation: - if: #@ ignoreSkippedJobsCondition - name: Test - uses: "./.github/workflows/test-source-generation.yml" -#@ end - -#@ def buildUnity(): -build-unity: - uses: ./.github/workflows/build-unity.yml - name: Package - with: - version: ${{ needs.build-packages.outputs.package_version }} - needs: - - build-packages - if: #@ ignoreSkippedJobsCondition -#@ end - -#@ def testUnity(settings, platforms): -test-unity: - uses: ./.github/workflows/test-unity.yml - name: Test - with: - version: ${{ needs.build-packages.outputs.package_version }} - settings: #@ settings - platform: #@ platforms - needs: - - build-packages - - build-unity - if: #@ ignoreSkippedJobsCondition -#@ end \ No newline at end of file diff --git a/.github/templates/common.lib.yml b/.github/templates/common.lib.yml deleted file mode 100644 index fd6b8aae5f..0000000000 --- a/.github/templates/common.lib.yml +++ /dev/null @@ -1,259 +0,0 @@ -#@ load("@ytt:template", "template") - -#@ configuration = "Release" -#@ publishedPackages = [ 'Realm.PlatformHelpers', 'Realm' ] -#@ nugetPackages = publishedPackages + [ 'Realm.UnityUtils', 'Realm.UnityWeaver' ] -#@ actionCheckout = "actions/checkout@v3" -#@ actionCache = "nirinchev/cache@29e8e4dd9148ea81f9e188480132072cb6cc92d8" -#@ actionUploadArtifact = "actions/upload-artifact@v4" -#@ actionDownloadArtifact = "actions/download-artifact@v4" -#@ actionSetupMSBuild = "microsoft/setup-msbuild@0b44c6745b7e81956596964100aadb92d667c497" -#@ actionSetupDotnet = "actions/setup-dotnet@3e6b9fe3930cac7c59c651af5de1514b47a805b9" #! 4.0.0 -#@ actionCodeQLInit = "github/codeql-action/init@40542d38bc4936c2ca7da883aeb050a6081b4b31" -#@ actionCodeQLAnalyze = "github/codeql-action/analyze@40542d38bc4936c2ca7da883aeb050a6081b4b31" -#@ actionSetupNode = "actions/setup-node@16352bb09bc672a073e326c2cc1d3d7d2a3e577e" -#@ actionAWSConfigureCredentials = "aws-actions/configure-aws-credentials@v1-node16" -#@ actionRuniOSSimulator = "realm/ci-actions/run-ios-simulator@6418e15ed9bbdb19b7d456a347e5623779f95cdf" -#@ actionReleaseToSlack = "realm/ci-actions/release-to-slack@6418e15ed9bbdb19b7d456a347e5623779f95cdf" -#@ actionSetupXcode = "maxim-lobanov/setup-xcode@60606e260d2fc5762a71e64e74b2174e8ea3c8bd" -#@ actionSetupAndroid = "android-actions/setup-android@7c5672355aaa8fde5f97a91aa9a99616d1ace6bc" -#@ actionSetupJDK = "actions/setup-java@0ab4596768b603586c0de567f2430c30f5b0d2b0" - -#@ androidABIs = [ 'armeabi-v7a', 'arm64-v8a', 'x86', 'x86_64' ] -#@ windowsArchs = [ 'Win32', 'x64', 'ARM64' ] -#@ linuxArchs = [ 'x86_64', 'armhf', 'aarch64' ] -#@ windowsUWPArchs = [ 'Win32', 'x64', 'ARM', 'ARM64' ] -#@ applePlatforms = [ 'iOS', 'tvOS' ] - -#@ actionDockerLayerCaching = "jpribyl/action-docker-layer-caching@c632825d12ec837065f49726ea27ddd40bcc7894" #! 0.1.1 -#@ actionDockerBuild = "docker/build-push-action@6e95f19fb8c9e00a1a391941edbc0ae30c1799f7" #! 2.7.0 -#@ actionDockerRun = "addnab/docker-run-action@3e77f186b7a929ef010f183a9e24c0f9955ea609" #! v3 -#@ actionCoveralls = "coverallsapp/github-action@95b1a2355bd0e526ad2fd62da9fd386ad4c98474" #! v2.2.1 -#@ actionDeleteArtifact = "geekyeggo/delete-artifact@dc8092f14c4245ef6a3501b1669b171c12899167" #! v1 -#@ actionGithubRelease = "ncipollo/release-action@3ac4132803a6419fa2a7f4e9dbd1d93fceb690b9" #! v1.8.8 -#@ actionDownloadAllArtifacts = "dawidd6/action-download-artifact@46b4ae883bf0726f5949d025d31cb62c7a5ac70c" #! v2.14.1 -#@ actionCreatePR = "peter-evans/create-pull-request@6c704eb7a8ba1daa13da0dcea9bb93a4fe530275" #! 3.10.1 -#@ actionFindPR = "juliangruber/find-pull-request-action@afdd62ccd2d4c55f5bdb154b489b85fc4cbcb9c1" #! 1.5.0 -#@ actionMergePR = "juliangruber/merge-pull-request-action@333730196b34b74936aad75a4e31c23a57582d14" #! 1.0.6 - -#@ mainBranch = "main" ---- - -#@ def setupNugetCache(projectPaths = []): -#@ globs = [] -#@ for projectPath in projectPaths: -#@ globs.append("'" + projectPath + "/*.csproj'") -#@ end -uses: actions/cache@v2 -with: - path: ~/.nuget/packages - key: #@ "${{ runner.os }}-nuget-${{ hashFiles(" + ", ".join(globs) + ") }}" -#@ end ---- -#@ def msbuild(projectPath, **properties): -#@ return msBuildMultiple([projectPath], **properties) -#@ end - -#@ def msBuildMultiple(projectPaths, **properties): -#@ parsedProps = "" -#@ target = "" -#@ for prop in properties.keys(): -#@ if prop == "target": -#@ target = " -t:" + properties[prop] -#@ else: -#@ parsedProps += " -p:" + prop + "=" + properties[prop] -#@ end -#@ end -#@ -- name: Add msbuild to PATH - uses: #@ actionSetupMSBuild - if: ${{ runner.os == 'Windows' }} -#@ for projectPath in projectPaths: -- name: #@ "Build " + projectPath - run: #@ "msbuild " + projectPath + target + " -p:Configuration=" + configuration + " -restore" + parsedProps -#@ end -#@ end ---- -#@ def dotnetPublish(projectPath, framework, runtime, properties = {}): -#@ propsArg = "" -#@ for prop in properties.keys(): -#@ propsArg += " -p:" + prop + "=" + properties[prop] -#@ end - - name: #@ "Publish " + projectPath - run: #@ "dotnet publish " + projectPath + " -c " + configuration + " -f " + framework + " -r " + runtime + propsArg + " --no-self-contained" - - name: Output executable path - id: dotnet-publish - run: #@ "echo 'executable-path=./" + projectPath + "/bin/" + configuration + "/" + framework + "/" + runtime + "' >> $GITHUB_OUTPUT" - shell: bash -#@ end ---- -#@ def checkoutCode(submodules=False, registerProblemMatchers=True): - - name: Checkout code - uses: #@ actionCheckout - with: - submodules: #@ submodules - ref: ${{ github.event.pull_request.head.sha }} -#@ if registerProblemMatchers: - - 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" -#@ end -#@ end - -#@ def downloadAllArtifacts(conclusion = "completed"): - - name: Download all artifacts - uses: #@ actionDownloadAllArtifacts - with: - workflow: pr.yml - commit: ${{ github.sha }} - path: ${{ github.workspace }}/Realm/packages/ - workflow_conclusion: #@ conclusion -#@ end - -#@ def readVersionFromPackage(): - - name: Read version - id: get-version - run: | - cd Realm/packages - pkgVersion=$(find . -type f -regex ".*Realm.[1-9].*.nupkg" -exec basename {} \; | sed -n 's/Realm\.\(.*\)\.nupkg$/\1/p') - echo "version=$pkgVersion" >> $GITHUB_OUTPUT - shell: bash -#@ end - -#@ def configureAWSCredentials(accessKey, secretKey, region = "us-east-1"): - - name: Configure AWS Credentials - uses: #@ actionAWSConfigureCredentials - with: - aws-access-key-id: #@ "${{ secrets." + accessKey + " }}" - aws-secret-access-key: #@ "${{ secrets." + secretKey + " }}" - aws-region: #@ region -#@ end - -#@ def uploadPackagesToSleet(versionExpression = "steps.get-version.outputs.version", expectShortPath = False): - - #@ setupDotnet() - - name: Install sleet - run: dotnet tool install -g sleet - - #@ template.replace(configureAWSCredentials("NUGET_S3_ACCESS_KEY", "NUGET_S3_SECRET_KEY")) -#@ for pkg in publishedPackages: -#@ pkg = pkg + ".${{ " + versionExpression + " }}" -#@ pkgPath = "" if expectShortPath else pkg + "/" - - name: #@ "NuGet Publish " + pkg - run: #@ "sleet push ${{ github.workspace }}/Realm/packages/" + pkgPath + pkg + ".nupkg --config ${{ github.workspace }}/.github/sleet.json --source NugetSource" -#@ end -#@ end - -#@ def cleanupWorkspace(): - - name: Cleanup Workspace - run: rm -rf "${{ github.workspace }}/*" -#@ end - -#@ def getWrapperBinaryNames(): -#@ wrapperPlatforms = [ 'macos', 'catalyst' ] -#@ for linuxArch in linuxArchs: -#@ wrapperPlatforms.append("linux-" + linuxArch) -#@ end -#@ for platform in applePlatforms: -#@ wrapperPlatforms.append(platform + "-Device") -#@ wrapperPlatforms.append(platform + "-Simulator") -#@ end -#@ for androidABI in androidABIs: -#@ wrapperPlatforms.append("android-" + androidABI) -#@ end -#@ for windowsArch in windowsArchs: -#@ wrapperPlatforms.append("windows-" + windowsArch) -#@ end -#@ for uwpArch in windowsUWPArchs: -#@ wrapperPlatforms.append("windows-uwp-" + uwpArch) -#@ end -#@ -#@ return wrapperPlatforms -#@ end - -#@ def fetchWrapperBinaries(): -#@ for platform in getWrapperBinaryNames(): - - name: #@ "Fetch artifacts for " + platform - uses: #@ actionDownloadArtifact - with: - name: #@ "wrappers-" + platform - path: wrappers/build -#@ end -#@ end ---- -#@ def uploadArtifacts(artifactName, relPath, retentionDays = "${{ github.event_name != 'pull_request' && 30 || 1 }}"): -name: #@ "Store artifacts for " + artifactName -uses: #@ actionUploadArtifact -with: - name: #@ artifactName - path: #@ "${{ github.workspace }}/" + relPath - retention-days: #@ retentionDays - if-no-files-found: error -#@ end ---- -#@ def setupDotnet(version = "8.0.x", ifCondition = ""): -name: Configure .NET -uses: #@ actionSetupDotnet -#@ if (ifCondition != ""): -if: #@ ifCondition -#@ end -with: - dotnet-version: #@ version -#@ end ---- -#@ def setupXcode(version = "14.0.1"): -name: Setup Xcode -uses: #@ actionSetupXcode -with: - xcode-version: #@ version -#@ end ---- -#@ def uploadToNpm(tag = "latest", versionExpression = "steps.get-version.outputs.version", expectShortPath = False): -#@ package = "io.realm.unity-${{" + versionExpression + "}}.tgz" -#@ pkgPath = "" if expectShortPath else package + "/" - - uses: #@ actionSetupNode - with: - node-version: '16.x' - registry-url: 'https://registry.npmjs.org' - - name: #@ "Npm Publish " + package - run: #@ "npm publish ${{ github.workspace }}/Realm/packages/" + pkgPath + package + " --tag " + tag - env: - NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} -#@ end ---- -#@ def fetchPackageArtifacts(versionExpression = "inputs.version", packages = publishedPackages): -#@ for pkg in packages: - - name: #@ "Fetch " + pkg - uses: #@ actionDownloadArtifact - with: - name: #@ pkg + ".${{ " + versionExpression + " }}" - path: ${{ github.workspace }}/Realm/packages/ -#@ end -#@ end ---- -#@ def setupWorkloads(workloads = 'maui'): - - _: #@ template.replace(setupDotnet()) - - name: Setup workloads - run: #@ "dotnet workload install " + workloads -#@ end ---- -#@ def restoreWorkloads(workingDirectory = 'Realm/Realm.PlatformHelpers'): -name: Restore workloads -run: dotnet workload restore -working-directory: #@ "${{ github.workspace }}/" + workingDirectory -#@ end ---- -#@ def setupAndroid(): - - name: Setup Android - uses: #@ actionSetupAndroid - - name: Install SDK platform 21 - run: sdkmanager --install "platforms;android-21" - - #@ setupJDK() -#@ end ---- -#@ def setupJDK(): -name: Setup JDK -uses: #@ actionSetupJDK -with: - distribution: microsoft - java-version: 11 -#@ end \ No newline at end of file diff --git a/.github/templates/main.yml b/.github/templates/main.yml deleted file mode 100644 index 10cfc77bd4..0000000000 --- a/.github/templates/main.yml +++ /dev/null @@ -1,101 +0,0 @@ -#@ load("@ytt:template", "template") -#@ load("common.lib.yml", "checkoutCode", "uploadArtifacts", "uploadPackagesToSleet", "cleanupWorkspace", "dotnetPublish", "actionDownloadArtifact", "fetchPackageArtifacts") -#@ load("test.lib.yml", "dotnetBuildTests") -#@ load("build.lib.yml", "deployBaas", "cleanupBaas", "runTests", "runNetCoreTests", "ignoreSkippedJobsCondition", "buildUnity") - ---- -name: main -"on": - push: - branches: - - main - workflow_dispatch: - inputs: - publish-prerelease: - description: Indicates whether to publish the package to Sleet/npm - required: false - type: boolean - run-benchmark: - description: Indicates whether to run the benchmark tests - required: false - type: boolean -env: - REALM_DISABLE_ANALYTICS: true - DOTNET_NOLOGO: true -jobs: - build-wrappers: - uses: ./.github/workflows/wrappers.yml - name: Wrappers - _: #@ template.replace(deployBaas([".NET Framework", "Code Coverage", "UWP Managed", "Xamarin.macOS", "iOS", "Android", "MacCatalyst"])) - build-packages: - uses: ./.github/workflows/build-packages.yml - name: Package - needs: - - build-wrappers - publish-packages-to-sleet: - runs-on: ubuntu-latest - name: Publish package to S3 - needs: - - build-packages - if: #@ ignoreSkippedJobsCondition + " && (github.event_name == 'push' || github.event.inputs.publish-prerelease)" - steps: - - #@ template.replace(checkoutCode(False, False)) - - #@ template.replace(fetchPackageArtifacts("needs.build-packages.outputs.package_version")) - - #@ 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(runNetCoreTests("[\"net6.0\", \"net8.0\"]")) - _: #@ template.replace(runTests("macOS")) - _: #@ template.replace(runTests("iOS")) - _: #@ template.replace(runTests("tvOS", runSyncTests = False)) - _: #@ template.replace(runTests("Android", additionalSecrets=["AWS_DEVICEFARM_ACCESS_KEY_ID", "AWS_DEVICEFARM_SECRET_ACCESS_KEY", "DEVICEFARM_PROJECT_ARN", "DEVICEFARM_ANDROID_POOL_ARN"])) - test-xunit: - runs-on: windows-latest - name: Test xUnit Compatibility - timeout-minutes: 10 - needs: - - build-packages - if: #@ ignoreSkippedJobsCondition - steps: - - #@ template.replace(checkoutCode()) - - #@ template.replace(fetchPackageArtifacts("needs.build-packages.outputs.package_version")) - - #@ template.replace(dotnetPublish("Tests/Tests.XUnit", "net6.0", "win-x64", { "RestoreConfigFile": "Tests/Test.NuGet.Config", "UseRealmNupkgsWithVersion": "${{ needs.build-packages.outputs.package_version }}" })) - - name: Run Tests - run: dotnet test ${{ steps.dotnet-publish.outputs.executable-path }}/Tests.XUnit.dll --logger GitHubActions - test-weaver: - uses: ./.github/workflows/test-weaver.yml - name: Test - _: #@ template.replace(runTests("Code Coverage")) - benchmark-linux: - name: Benchmark Linux - needs: build-packages - runs-on: performance-tests - if: #@ ignoreSkippedJobsCondition + " && (github.event_name == 'push' || github.event.inputs.run-benchmark)" - timeout-minutes: 60 - steps: - - #@ template.replace(cleanupWorkspace()) - - #@ template.replace(checkoutCode()) - - #@ template.replace(fetchPackageArtifacts("needs.build-packages.outputs.package_version")) - #! To avoid NU5037 error - - name: Clear nuget cache - run: dotnet nuget locals all --clear - - #@ template.replace(dotnetBuildTests("Tests/Benchmarks/PerformanceTests", "net6.0", "linux-x64", "needs.build-packages.outputs.package_version")) - - name: Run the tests - run: #@ "${{ steps.dotnet-publish.outputs.executable-path }}/PerformanceTests -f \"*\" --join" - - name: Find Results file - id: find-results-file - run: | - cd BenchmarkDotNet.Artifacts/results - file=$(basename BenchmarkRun*json) - echo "benchmark-results=$file" >> $GITHUB_OUTPUT - shell: bash - - name: Publish Benchmark Results - uses: ./.github/actions/benchmark-uploader - with: - realm-token: ${{ secrets.Realm_Token }} - file: ${{ github.workspace }}/BenchmarkDotNet.Artifacts/results/${{ steps.find-results-file.outputs.benchmark-results }} - 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(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/test.lib.yml b/.github/templates/test.lib.yml deleted file mode 100644 index 87a3723dc5..0000000000 --- a/.github/templates/test.lib.yml +++ /dev/null @@ -1,99 +0,0 @@ -#@ load("@ytt:template", "template") -#@ load("common.lib.yml", "actionDownloadArtifact", "msbuild", "dotnetPublish", "fetchWrapperBinaries", "checkoutCode", "fetchPackageArtifacts") - -#@ def baasTestArgs(differentiator): -#@ return " --baasaas-api-key=${{ secrets.BaaSaasApiKey}} --baas-differentiator=" + differentiator + "-${{ github.run_id }}-${{ github.run_attempt }}" -#@ end ---- -#@ def publishTestsResults(file, test_title, run_transform=False): - #@ output_file = file - #@ if run_transform: - #@ output_file = file + "_transformed.xml" - - name: Transform Results - run: #@ "xsltproc --output " + output_file + " Tests/Realm.Tests/EmbeddedResources/nunit3-junit.xslt " + file - shell: bash - #@ end - - name: Publish Unit Test Results - uses: LaPeste/test-reporter@510caf50a955b1003bec48a6494be4d6537f3a0b - if: always() - with: - name: #@ "Results " + test_title - path: #@ output_file - reporter: java-junit - list-suites: failed - list-tests: failed - path-replace-backslashes: true - fail-on-error: true -#@ end ---- -#@ def testDefinition(additionalSecrets = [], additionalInputs = []): -"on": - workflow_call: - inputs: - version: - required: true - type: string - #@ for input in additionalInputs: - #@yaml/text-templated-strings - (@= input @): - required: true - type: string - #@ end - secrets: - BaaSaasApiKey: - required: false - #@ for secret in additionalSecrets: - #@yaml/text-templated-strings - (@= secret @): - required: true - #@ end -env: - REALM_DISABLE_ANALYTICS: true - DOTNET_NOLOGO: true -#@ end ---- -#@ def buildTests(projectPath, **properties): -#@ return msbuild(projectPath, RestoreConfigFile="Tests/Test.NuGet.Config", UseRealmNupkgsWithVersion="${{ inputs.version }}", **properties) -#@ end - -#@ def dotnetBuildTests(projectPath, framework, runtime, version = "inputs.version"): -#@ properties = { -#@ "RestoreConfigFile": "Tests/Test.NuGet.Config", -#@ "UseRealmNupkgsWithVersion": "${{ " + version + " }}", -#@ "RealmTestsStandaloneExe": "true" -#@ } -#@ return dotnetPublish(projectPath, framework, runtime, properties) -#@ end - -#@ def wovenClassesBuildTests(projectPath, framework, runtime, version = "inputs.version"): -#@ properties = { -#@ "RestoreConfigFile": "Tests/Test.NuGet.Config", -#@ "UseRealmNupkgsWithVersion": "${{ " + version + " }}", -#@ "TestWeavedClasses": "true", -#@ "RealmTestsStandaloneExe": "true" -#@ } -#@ return dotnetPublish(projectPath, framework, runtime, properties) -#@ end ---- -#@ def prepareTest(differentiator = "", fetchWrappers = False, cleanupWorkspace = False): -- #@ template.replace(checkoutCode()) -#@ if cleanupWorkspace: -- name: Cleanup Workspace - run: git clean -fdx -#@ end -#@ if fetchWrappers: -- #@ template.replace(fetchWrapperBinaries()) -#@ else: -- #@ template.replace(fetchPackageArtifacts()) -#@ end -#@ if (differentiator != ""): -#! The following is used in case we need to re-run the action and the main deploy baas job is not re-run too (because successful) -- name: Deploy Baas (alternative) - #! Secrets cannot be used directly in if - env: - apiKey: ${{ secrets.BaaSaasApiKey }} - if: ${{ env.apiKey }} - run: #@ "dotnet run deploy-apps --baasaas-api-key=${{ secrets.BaaSaasApiKey }} --baas-differentiator=" + differentiator + "-${{ github.run_id }}-${{ github.run_attempt }}" - working-directory: Tools/DeployApps -#@ end -#@ end \ No newline at end of file diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index bcd338f625..fd0775c1f1 100755 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -1,5 +1,8 @@ -name: main -"on": +# Do not modify! +# This file was generated from a template using https://github.com/apple/pkl + +name: Main Build +'on': push: branches: - main @@ -18,220 +21,1472 @@ env: DOTNET_NOLOGO: true jobs: build-wrappers: - uses: ./.github/workflows/wrappers.yml name: Wrappers + uses: ./.github/workflows/wrappers.yml deploy-baas: - uses: ./.github/workflows/deploy-baas.yml - with: - differentiators: '["net-framework", "code-coverage", "uwp-managed", "xamarinmacos", "ios", "android", "maccatalyst"]' - secrets: - BaaSaasApiKey: ${{ secrets.BAASAAS_API_KEY }} + name: Deploy BaaS + if: always() && !cancelled() && !contains(needs.*.result, 'failure') && !contains(needs.*.result, 'cancelled') + runs-on: ubuntu-latest + steps: + - name: Checkout Code + uses: actions/checkout@v4 + with: + submodules: false + ref: ${{ github.event.pull_request.head.sha }} + - name: Register problem matchers + run: |- + echo "::add-matcher::.github/problem-matchers/csc.json" + echo "::add-matcher::.github/problem-matchers/msvc.json" + - uses: actions/setup-dotnet@5d1464d5da459f3d7085106d52e499f4dc5d0f59 + with: + dotnet-version: 6.0.x + - name: Deploy Apps + working-directory: Tools/DeployApps + run: dotnet run deploy-apps --baasaas-api-key=${{ secrets.BAASAAS_API_KEY }} --baas-differentiator=${{ matrix.differentiator }}-${{ github.run_id }}-${{ github.run_attempt }} + strategy: + matrix: + differentiator: + - code-coverage + - net-framework + - uwp + - macos-maui + - android-maui + - ios-maui + - macos-maui + fail-fast: false build-packages: - uses: ./.github/workflows/build-packages.yml - name: Package + name: Package NuGet needs: - build-wrappers - publish-packages-to-sleet: + if: always() && !cancelled() && !contains(needs.*.result, 'failure') && !contains(needs.*.result, 'cancelled') + outputs: + package_version: ${{ steps.get-version.outputs.package_version }} + timeout-minutes: 30 + runs-on: windows-latest + steps: + - name: Checkout Code + uses: actions/checkout@v4 + with: + submodules: false + ref: ${{ github.event.pull_request.head.sha }} + - name: Register problem matchers + run: |- + echo "::add-matcher::.github/problem-matchers/csc.json" + echo "::add-matcher::.github/problem-matchers/msvc.json" + - name: Setup JDK + uses: actions/setup-java@2e74cbce18569d23ca8b812590dbb83f13ac7c5a + with: + distribution: microsoft + java-version: 17 + - name: Setup Android + uses: android-actions/setup-android@e1f5280adf78cf863c0fa43ffabc64a9cd08153f + - name: Install SDK platform 21 + run: sdkmanager --install "platforms;android-21" + - uses: actions/setup-dotnet@5d1464d5da459f3d7085106d52e499f4dc5d0f59 + with: + dotnet-version: 8.0.x + - name: Setup workloads + run: dotnet workload install tvos ios maccatalyst android + - name: Set version suffix + id: set-version-suffix + run: |- + $suffix = "" + if ($env:GITHUB_EVENT_NAME -eq "pull_request") + { + if (-Not "${{ github.head_ref }}".Contains("release")) + { + $suffix = "pr-${{ github.event.number }}.$env:GITHUB_RUN_NUMBER" + } + } + else + { + $suffix = "alpha.$env:GITHUB_RUN_NUMBER" + } + echo "build_suffix=$suffix" >> $Env:GITHUB_OUTPUT + shell: pwsh + - name: Fetch wrappers for macos + uses: actions/download-artifact@v4 + with: + name: wrappers-macos + path: wrappers/build + - name: Fetch wrappers for catalyst + uses: actions/download-artifact@v4 + with: + name: wrappers-catalyst + path: wrappers/build + - name: Fetch wrappers for linux-x86_64 + uses: actions/download-artifact@v4 + with: + name: wrappers-linux-x86_64 + path: wrappers/build + - name: Fetch wrappers for linux-armhf + uses: actions/download-artifact@v4 + with: + name: wrappers-linux-armhf + path: wrappers/build + - name: Fetch wrappers for linux-aarch64 + uses: actions/download-artifact@v4 + with: + name: wrappers-linux-aarch64 + path: wrappers/build + - name: Fetch wrappers for android-armeabi-v7a + uses: actions/download-artifact@v4 + with: + name: wrappers-android-armeabi-v7a + path: wrappers/build + - name: Fetch wrappers for android-arm64-v8a + uses: actions/download-artifact@v4 + with: + name: wrappers-android-arm64-v8a + path: wrappers/build + - name: Fetch wrappers for android-x86 + uses: actions/download-artifact@v4 + with: + name: wrappers-android-x86 + path: wrappers/build + - name: Fetch wrappers for android-x86_64 + uses: actions/download-artifact@v4 + with: + name: wrappers-android-x86_64 + path: wrappers/build + - name: Fetch wrappers for windows-Win32 + uses: actions/download-artifact@v4 + with: + name: wrappers-windows-Win32 + path: wrappers/build + - name: Fetch wrappers for windows-x64 + uses: actions/download-artifact@v4 + with: + name: wrappers-windows-x64 + path: wrappers/build + - name: Fetch wrappers for windows-ARM64 + uses: actions/download-artifact@v4 + with: + name: wrappers-windows-ARM64 + path: wrappers/build + - name: Fetch wrappers for windows-uwp-Win32 + uses: actions/download-artifact@v4 + with: + name: wrappers-windows-uwp-Win32 + path: wrappers/build + - name: Fetch wrappers for windows-uwp-x64 + uses: actions/download-artifact@v4 + with: + name: wrappers-windows-uwp-x64 + path: wrappers/build + - name: Fetch wrappers for windows-uwp-ARM + uses: actions/download-artifact@v4 + with: + name: wrappers-windows-uwp-ARM + path: wrappers/build + - name: Fetch wrappers for windows-uwp-ARM64 + uses: actions/download-artifact@v4 + with: + name: wrappers-windows-uwp-ARM64 + path: wrappers/build + - name: Fetch wrappers for iOS-Device + uses: actions/download-artifact@v4 + with: + name: wrappers-iOS-Device + path: wrappers/build + - name: Fetch wrappers for iOS-Simulator + uses: actions/download-artifact@v4 + with: + name: wrappers-iOS-Simulator + path: wrappers/build + - name: Fetch wrappers for tvOS-Device + uses: actions/download-artifact@v4 + with: + name: wrappers-tvOS-Device + path: wrappers/build + - name: Fetch wrappers for tvOS-Simulator + uses: actions/download-artifact@v4 + with: + name: wrappers-tvOS-Simulator + path: wrappers/build + - name: Add msbuild to PATH + if: ${{ runner.os == 'Windows' }} + uses: microsoft/setup-msbuild@70b70342ae97ca98d5eaad06cafd26d30f9592a9 + - name: Build Realm/Realm + run: msbuild Realm/Realm -t:Pack -restore -p:Configuration=Release -p:PackageOutputPath=${{ github.workspace }}/Realm/packages -p:VersionSuffix=${{ steps.set-version-suffix.outputs.build_suffix }} + - name: Build Realm/Realm.PlatformHelpers + run: msbuild Realm/Realm.PlatformHelpers -t:Pack -restore -p:Configuration=Release -p:PackageOutputPath=${{ github.workspace }}/Realm/packages -p:VersionSuffix=${{ steps.set-version-suffix.outputs.build_suffix }} + - name: Build Realm/Realm.UnityUtils + run: msbuild Realm/Realm.UnityUtils -t:Pack -restore -p:Configuration=Release -p:PackageOutputPath=${{ github.workspace }}/Realm/packages -p:VersionSuffix=${{ steps.set-version-suffix.outputs.build_suffix }} + - name: Build Realm/Realm.UnityWeaver + run: msbuild Realm/Realm.UnityWeaver -t:Pack -restore -p:Configuration=Release -p:PackageOutputPath=${{ github.workspace }}/Realm/packages -p:VersionSuffix=${{ steps.set-version-suffix.outputs.build_suffix }} + - name: Read version + id: get-version + run: |- + cd Realm/packages + pkgVersion=$(find . -type f -regex ".*Realm.[1-9].*.nupkg" -exec basename {} \; | sed -n 's/Realm\.\(.*\)\.nupkg$/\1/p') + echo "package_version=$pkgVersion" >> $GITHUB_OUTPUT + shell: bash + - name: Store artifacts for Realm.${{ steps.get-version.outputs.package_version }} + uses: actions/upload-artifact@v4 + with: + name: Realm.${{ steps.get-version.outputs.package_version }} + path: Realm/packages/Realm.${{ steps.get-version.outputs.package_version }}.*nupkg + retention-days: ${{ github.event_name != 'pull_request' && 30 || 1 }} + if-no-files-found: error + - name: Store artifacts for Realm.PlatformHelpers.${{ steps.get-version.outputs.package_version }} + uses: actions/upload-artifact@v4 + with: + name: Realm.PlatformHelpers.${{ steps.get-version.outputs.package_version }} + path: Realm/packages/Realm.PlatformHelpers.${{ steps.get-version.outputs.package_version }}.*nupkg + retention-days: ${{ github.event_name != 'pull_request' && 30 || 1 }} + if-no-files-found: error + - name: Store artifacts for Realm.UnityUtils.${{ steps.get-version.outputs.package_version }} + uses: actions/upload-artifact@v4 + with: + name: Realm.UnityUtils.${{ steps.get-version.outputs.package_version }} + path: Realm/packages/Realm.UnityUtils.${{ steps.get-version.outputs.package_version }}.*nupkg + retention-days: ${{ github.event_name != 'pull_request' && 30 || 1 }} + if-no-files-found: error + - name: Store artifacts for Realm.UnityWeaver.${{ steps.get-version.outputs.package_version }} + uses: actions/upload-artifact@v4 + with: + name: Realm.UnityWeaver.${{ steps.get-version.outputs.package_version }} + path: Realm/packages/Realm.UnityWeaver.${{ steps.get-version.outputs.package_version }}.*nupkg + retention-days: ${{ github.event_name != 'pull_request' && 30 || 1 }} + if-no-files-found: error + - name: Store artifacts for ExtractedChangelog + uses: actions/upload-artifact@v4 + with: + name: ExtractedChangelog + path: Realm/Realm/ExtractedChangelog.md + retention-days: ${{ github.event_name != 'pull_request' && 30 || 1 }} + if-no-files-found: error + - name: Check Docfx cache + id: check-docfx-cache + if: contains(github.head_ref, 'release') + uses: actions/cache@v4 + with: + path: C:\docfx + key: docfx-2.75.2 + - name: Download docfx + if: contains(github.head_ref, 'release') && steps.check-docfx-cache.outputs.cache-hit != 'true' + run: |- + Invoke-WebRequest -Uri https://github.com/dotnet/docfx/releases/download/v2.75.2/docfx-win-x64-v2.75.2.zip -OutFile C:\docfx.zip + Expand-Archive -Path C:\docfx.zip -DestinationPath C:\docfx + - name: Build docs + if: contains(github.head_ref, 'release') + env: + DOCFX_SOURCE_BRANCH_NAME: ${{ github.head_ref }} + run: C:\docfx\docfx Docs/docfx.json + build-unity: + name: Package Unity + needs: + - build-packages + if: always() && !cancelled() && !contains(needs.*.result, 'failure') && !contains(needs.*.result, 'cancelled') + timeout-minutes: 30 + runs-on: windows-latest + steps: + - name: Checkout Code + uses: actions/checkout@v4 + with: + submodules: false + ref: ${{ github.event.pull_request.head.sha }} + - name: Register problem matchers + run: |- + echo "::add-matcher::.github/problem-matchers/csc.json" + echo "::add-matcher::.github/problem-matchers/msvc.json" + - name: Fetch Realm + uses: actions/download-artifact@v4 + with: + name: Realm.${{ needs.build-packages.outputs.package_version }} + path: ${{ github.workspace }}/Realm/packages/ + - name: Fetch Realm.PlatformHelpers + uses: actions/download-artifact@v4 + with: + name: Realm.PlatformHelpers.${{ needs.build-packages.outputs.package_version }} + path: ${{ github.workspace }}/Realm/packages/ + - name: Fetch Realm.UnityUtils + uses: actions/download-artifact@v4 + with: + name: Realm.UnityUtils.${{ needs.build-packages.outputs.package_version }} + path: ${{ github.workspace }}/Realm/packages/ + - name: Fetch Realm.UnityWeaver + uses: actions/download-artifact@v4 + with: + name: Realm.UnityWeaver.${{ needs.build-packages.outputs.package_version }} + path: ${{ github.workspace }}/Realm/packages/ + - name: Build Unity + run: dotnet run --project Tools/SetupUnityPackage/ -- realm --packages-path Realm/packages --pack + - name: Store artifacts for io.realm.unity-${{ needs.build-packages.outputs.package_version }}.tgz + uses: actions/upload-artifact@v4 + with: + name: io.realm.unity-${{ needs.build-packages.outputs.package_version }}.tgz + path: Realm/Realm.Unity/io.realm.unity-${{ needs.build-packages.outputs.package_version }}.tgz + retention-days: ${{ github.event_name != 'pull_request' && 30 || 1 }} + if-no-files-found: error + - name: Build Tests + run: dotnet run --project Tools/SetupUnityPackage/ -- tests --realm-package Realm/Realm.Unity/io.realm.unity-${{ needs.build-packages.outputs.package_version }}.tgz + - name: Store artifacts for UnityTests + uses: actions/upload-artifact@v4 + with: + name: UnityTests + path: Tests/Tests.Unity + retention-days: ${{ github.event_name != 'pull_request' && 30 || 1 }} + if-no-files-found: error + build-unity-tests-linux: + name: Build Unity linux + needs: + - build-packages + - build-unity + if: always() && !cancelled() && !contains(needs.*.result, 'failure') && !contains(needs.*.result, 'cancelled') + timeout-minutes: 30 + runs-on: + - unity + - linux + steps: + - name: Checkout Code + uses: actions/checkout@v4 + with: + submodules: false + ref: ${{ github.event.pull_request.head.sha }} + - name: Register problem matchers + run: |- + echo "::add-matcher::.github/problem-matchers/csc.json" + echo "::add-matcher::.github/problem-matchers/msvc.json" + - name: Cleanup Workspace + run: git clean -fdx + - name: Fetch io.realm.unity-${{ needs.build-packages.outputs.package_version }}.tgz + uses: actions/download-artifact@v4 + with: + name: io.realm.unity-${{ needs.build-packages.outputs.package_version }}.tgz + path: Realm/Realm.Unity + - name: Fetch UnityTests + uses: actions/download-artifact@v4 + with: + name: UnityTests + path: Tests/Tests.Unity + - name: Build Unity Tests + run: unity-editor -runTests -batchmode -projectPath ${{ github.workspace }}/Tests/Tests.Unity -testPlatform StandaloneLinux64 -testSettingsFile ${{ github.workspace }}/Tests/Tests.Unity/.TestConfigs/Mono-Net4.json -logFile - + - name: Store artifacts for UnityTestsRunner.linux + uses: actions/upload-artifact@v4 + with: + name: UnityTestsRunner.linux + path: Tests/Tests.Unity/Player_StandaloneLinux64_Mono-Net4/ + retention-days: ${{ github.event_name != 'pull_request' && 30 || 1 }} + if-no-files-found: error + run-unity-tests-linux: + name: Test Unity linux + needs: + - build-unity-tests-linux + if: always() && !cancelled() && !contains(needs.*.result, 'failure') && !contains(needs.*.result, 'cancelled') + timeout-minutes: 30 runs-on: ubuntu-latest - name: Publish package to S3 + steps: + - name: Checkout Code + uses: actions/checkout@v4 + with: + submodules: false + ref: ${{ github.event.pull_request.head.sha }} + - name: Register problem matchers + run: |- + echo "::add-matcher::.github/problem-matchers/csc.json" + echo "::add-matcher::.github/problem-matchers/msvc.json" + - name: Fetch UnityTestsRunner.linux + uses: actions/download-artifact@v4 + with: + name: UnityTestsRunner.linux + path: TestRunner + - name: Install xvfb + run: sudo apt install -y xvfb libglu1 libxcursor1 + - name: Run Tests + run: |- + chmod +x ${{ github.workspace }}/TestRunner/PlayerWithTests.x86_64 + xvfb-run --auto-servernum --server-args='-screen 0 640x480x24:32' ${{ github.workspace }}/TestRunner/PlayerWithTests.x86_64 -logFile - --result=${{ github.workspace }}/TestResults.xml + - name: Publish Unit Test Results + if: always() + uses: dorny/test-reporter@31a54ee7ebcacc03a09ea97a7e5465a47b84aea5 + with: + name: Results Unity linux Mono-Net4 + path: TestResults.xml + reporter: java-junit + list-suites: failed + path-replace-backslashes: true + fail-on-error: true + build-unity-tests-windows: + name: Build Unity windows + needs: + - build-packages + - build-unity + if: always() && !cancelled() && !contains(needs.*.result, 'failure') && !contains(needs.*.result, 'cancelled') + timeout-minutes: 30 + runs-on: + - unity + - windows + steps: + - name: Checkout Code + uses: actions/checkout@v4 + with: + submodules: false + ref: ${{ github.event.pull_request.head.sha }} + - name: Register problem matchers + run: |- + echo "::add-matcher::.github/problem-matchers/csc.json" + echo "::add-matcher::.github/problem-matchers/msvc.json" + - name: Cleanup Workspace + run: git clean -fdx + - name: Fetch io.realm.unity-${{ needs.build-packages.outputs.package_version }}.tgz + uses: actions/download-artifact@v4 + with: + name: io.realm.unity-${{ needs.build-packages.outputs.package_version }}.tgz + path: Realm/Realm.Unity + - name: Fetch UnityTests + uses: actions/download-artifact@v4 + with: + name: UnityTests + path: Tests/Tests.Unity + - name: Build Unity Tests + run: unity-editor -runTests -batchmode -projectPath ${{ github.workspace }}/Tests/Tests.Unity -testPlatform StandaloneWindows64 -testSettingsFile ${{ github.workspace }}/Tests/Tests.Unity/.TestConfigs/Mono-Net4.json -logFile build.log + - name: Store artifacts for UnityTestsRunner.windows + uses: actions/upload-artifact@v4 + with: + name: UnityTestsRunner.windows + path: Tests/Tests.Unity/Player_StandaloneWindows64_Mono-Net4/ + retention-days: ${{ github.event_name != 'pull_request' && 30 || 1 }} + if-no-files-found: error + run-unity-tests-windows: + name: Test Unity windows + needs: + - build-unity-tests-windows + if: always() && !cancelled() && !contains(needs.*.result, 'failure') && !contains(needs.*.result, 'cancelled') + timeout-minutes: 30 + runs-on: windows-latest + steps: + - name: Checkout Code + uses: actions/checkout@v4 + with: + submodules: false + ref: ${{ github.event.pull_request.head.sha }} + - name: Register problem matchers + run: |- + echo "::add-matcher::.github/problem-matchers/csc.json" + echo "::add-matcher::.github/problem-matchers/msvc.json" + - name: Fetch UnityTestsRunner.windows + uses: actions/download-artifact@v4 + with: + name: UnityTestsRunner.windows + path: TestRunner + - name: Run Tests + run: |- + Start-Process ${{ github.workspace }}\TestRunner\PlayerWithTests.exe -Wait -ArgumentList "-logFile","${{ github.workspace }}\test.log","--result=${{ github.workspace }}\TestResults.xml" + cat ${{ github.workspace }}\test.log + shell: pwsh + - name: Publish Unit Test Results + if: always() + uses: dorny/test-reporter@31a54ee7ebcacc03a09ea97a7e5465a47b84aea5 + with: + name: Results Unity windows Mono-Net4 + path: TestResults.xml + reporter: java-junit + list-suites: failed + path-replace-backslashes: true + fail-on-error: true + test-net-framework: + name: Test .NET Framework + needs: + - build-packages + - deploy-baas + if: always() && !cancelled() && !contains(needs.*.result, 'failure') && !contains(needs.*.result, 'cancelled') + timeout-minutes: 60 + runs-on: windows-latest + steps: + - name: Checkout Code + uses: actions/checkout@v4 + with: + submodules: false + ref: ${{ github.event.pull_request.head.sha }} + - name: Register problem matchers + run: |- + echo "::add-matcher::.github/problem-matchers/csc.json" + echo "::add-matcher::.github/problem-matchers/msvc.json" + - name: Fetch Realm + uses: actions/download-artifact@v4 + with: + name: Realm.${{ needs.build-packages.outputs.package_version }} + path: ${{ github.workspace }}/Realm/packages/ + - name: Fetch Realm.PlatformHelpers + uses: actions/download-artifact@v4 + with: + name: Realm.PlatformHelpers.${{ needs.build-packages.outputs.package_version }} + path: ${{ github.workspace }}/Realm/packages/ + - name: Deploy Apps + working-directory: Tools/DeployApps + run: dotnet run deploy-apps --baasaas-api-key=${{ secrets.BAASAAS_API_KEY }} --baas-differentiator=net-framework-${{ github.run_id }}-${{ github.run_attempt }} + - name: Add msbuild to PATH + if: ${{ runner.os == 'Windows' }} + uses: microsoft/setup-msbuild@70b70342ae97ca98d5eaad06cafd26d30f9592a9 + - name: Build Tests/Realm.Tests + run: msbuild Tests/Realm.Tests -restore -p:Configuration=Release -p:TargetFramework=net461 -p:RestoreConfigFile=Tests/Test.NuGet.Config -p:UseRealmNupkgsWithVersion=${{ needs.build-packages.outputs.package_version }} -p:RealmTestsStandaloneExe=true + - name: Run the tests + run: ./Tests/Realm.Tests/bin/Release/net461/Realm.Tests.exe --result=TestResults.xml --labels=After --baasaas-api-key=${{ secrets.BAASAAS_API_KEY}} --baas-differentiator=net-framework-${{ github.run_id }}-${{ github.run_attempt }} + - name: Publish Unit Test Results + if: always() + uses: dorny/test-reporter@31a54ee7ebcacc03a09ea97a7e5465a47b84aea5 + with: + name: Results .NET Framework + path: TestResults.xml + reporter: java-junit + list-suites: failed + path-replace-backslashes: true + fail-on-error: true + test-uwp: + name: Test UWP + needs: + - build-packages + - deploy-baas + if: always() && !cancelled() && !contains(needs.*.result, 'failure') && !contains(needs.*.result, 'cancelled') + timeout-minutes: 60 + runs-on: windows-latest + steps: + - name: Checkout Code + uses: actions/checkout@v4 + with: + submodules: false + ref: ${{ github.event.pull_request.head.sha }} + - name: Register problem matchers + run: |- + echo "::add-matcher::.github/problem-matchers/csc.json" + echo "::add-matcher::.github/problem-matchers/msvc.json" + - name: Fetch Realm + uses: actions/download-artifact@v4 + with: + name: Realm.${{ needs.build-packages.outputs.package_version }} + path: ${{ github.workspace }}/Realm/packages/ + - name: Fetch Realm.PlatformHelpers + uses: actions/download-artifact@v4 + with: + name: Realm.PlatformHelpers.${{ needs.build-packages.outputs.package_version }} + path: ${{ github.workspace }}/Realm/packages/ + - name: Deploy Apps + working-directory: Tools/DeployApps + run: dotnet run deploy-apps --baasaas-api-key=${{ secrets.BAASAAS_API_KEY }} --baas-differentiator=uwp-${{ github.run_id }}-${{ github.run_attempt }} + - 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 + if: ${{ runner.os == 'Windows' }} + uses: microsoft/setup-msbuild@70b70342ae97ca98d5eaad06cafd26d30f9592a9 + - name: Build Tests/Tests.UWP + run: msbuild Tests/Tests.UWP -restore -p:Configuration=Release -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 -p:RestoreConfigFile=Tests/Test.NuGet.Config -p:UseRealmNupkgsWithVersion=${{ needs.build-packages.outputs.package_version }} + - name: Run the tests + run: ./Tests/Tests.UWP/RunTests.ps1 -ExtraAppArgs ' --baasaas-api-key=${{ secrets.BAASAAS_API_KEY}} --baas-differentiator=uwp-${{ github.run_id }}-${{ github.run_attempt }}' + shell: powershell + - name: Publish Unit Test Results + if: always() + uses: dorny/test-reporter@31a54ee7ebcacc03a09ea97a7e5465a47b84aea5 + with: + name: Results UWP + path: ${{ env.TEST_RESULTS }} + reporter: java-junit + list-suites: failed + path-replace-backslashes: true + fail-on-error: true + test-net-core: + name: Test ${{ matrix.framework }}, ${{ (matrix.os.runner == 'win81' && 'win81') || matrix.os.runtime }} + needs: + - build-packages + if: always() && !cancelled() && !contains(needs.*.result, 'failure') && !contains(needs.*.result, 'cancelled') + timeout-minutes: 60 + runs-on: ${{ matrix.os.runner }} + steps: + - name: Checkout Code + uses: actions/checkout@v4 + with: + submodules: false + ref: ${{ github.event.pull_request.head.sha }} + - name: Register problem matchers + run: |- + echo "::add-matcher::.github/problem-matchers/csc.json" + echo "::add-matcher::.github/problem-matchers/msvc.json" + - name: Cleanup Workspace + run: git clean -fdx + - name: Fetch Realm + uses: actions/download-artifact@v4 + with: + name: Realm.${{ needs.build-packages.outputs.package_version }} + path: ${{ github.workspace }}/Realm/packages/ + - name: Fetch Realm.PlatformHelpers + uses: actions/download-artifact@v4 + with: + name: Realm.PlatformHelpers.${{ needs.build-packages.outputs.package_version }} + path: ${{ github.workspace }}/Realm/packages/ + - name: Clear nuget cache + if: ${{ matrix.os.runner == 'win81' }} + run: dotnet nuget locals all --clear + - name: Extract .NET version + id: get-net-version + run: |2- + NET_VERSION=$(echo '${{ matrix.framework }}.x' | sed 's/net//g') + echo "version=$NET_VERSION" >> $GITHUB_OUTPUT + shell: bash + - uses: actions/setup-dotnet@5d1464d5da459f3d7085106d52e499f4dc5d0f59 + with: + dotnet-version: ${{ steps.get-net-version.outputs.version }} + - 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=${{ needs.build-packages.outputs.package_version }} -p:RealmTestsStandaloneExe=true --no-self-contained + - name: Output executable path + id: dotnet-publish + run: echo 'executable-path=./Tests/Realm.Tests/bin/Release/${{ matrix.framework }}/${{ matrix.os.runtime }}/Realm.Tests' >> $GITHUB_OUTPUT + shell: bash + - name: Run the tests + env: + DOTNET_DbgEnableMiniDump: 1 + DOTNET_EnableCrashReport: 1 + run: ${{ steps.dotnet-publish.outputs.executable-path }} --result=TestResults.xml --labels=After + - name: Archive core dump + if: ${{ failure() && runner.os != 'Windows' }} + uses: actions/upload-artifact@v4 + with: + name: crash-report-net-core-${{ runner.os }}-${{ runner.arch }} + path: /tmp/coredump* + retention-days: 30 + if-no-files-found: warn + - name: Publish Unit Test Results + if: always() + uses: dorny/test-reporter@31a54ee7ebcacc03a09ea97a7e5465a47b84aea5 + with: + name: Results ${{ matrix.framework }}, ${{ (matrix.os.runner == 'win81' && 'win81') || matrix.os.runtime }} + path: TestResults.xml + reporter: java-junit + list-suites: failed + path-replace-backslashes: true + fail-on-error: true + strategy: + matrix: + framework: + - net6.0 + - net8.0 + os: + - runner: windows-latest + runtime: win-x64 + - runner: ubuntu-latest + runtime: linux-x64 + - runner: macos-13 + runtime: osx-x64 + include: + - framework: net8.0 + os: + runner: macos-14 + runtime: osx-arm64 + fail-fast: false + test-macos-xamarin: + name: Test Xamarin.macOS + needs: + - build-packages + if: always() && !cancelled() && !contains(needs.*.result, 'failure') && !contains(needs.*.result, 'cancelled') + timeout-minutes: 60 + runs-on: macos-12 + steps: + - name: Checkout Code + uses: actions/checkout@v4 + with: + submodules: false + ref: ${{ github.event.pull_request.head.sha }} + - name: Register problem matchers + run: |- + echo "::add-matcher::.github/problem-matchers/csc.json" + echo "::add-matcher::.github/problem-matchers/msvc.json" + - name: Fetch Realm + uses: actions/download-artifact@v4 + with: + name: Realm.${{ needs.build-packages.outputs.package_version }} + path: ${{ github.workspace }}/Realm/packages/ + - name: Fetch Realm.PlatformHelpers + uses: actions/download-artifact@v4 + with: + name: Realm.PlatformHelpers.${{ needs.build-packages.outputs.package_version }} + path: ${{ github.workspace }}/Realm/packages/ + - name: Add msbuild to PATH + if: ${{ runner.os == 'Windows' }} + uses: microsoft/setup-msbuild@70b70342ae97ca98d5eaad06cafd26d30f9592a9 + - name: Build Tests/Tests.XamarinMac + run: msbuild Tests/Tests.XamarinMac -restore -p:Configuration=Release -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 --result=${{ github.workspace }}/TestResults.xml --labels=All + - name: Publish Unit Test Results + if: always() + uses: dorny/test-reporter@31a54ee7ebcacc03a09ea97a7e5465a47b84aea5 + with: + name: Results Xamarin.macOS + path: TestResults.xml + reporter: java-junit + list-suites: failed + path-replace-backslashes: true + fail-on-error: true + test-macos-maui: + name: Test Maui.MacCatalyst + needs: + - build-packages + - deploy-baas + if: always() && !cancelled() && !contains(needs.*.result, 'failure') && !contains(needs.*.result, 'cancelled') + timeout-minutes: 60 + runs-on: macos-13 + steps: + - name: Checkout Code + uses: actions/checkout@v4 + with: + submodules: false + ref: ${{ github.event.pull_request.head.sha }} + - name: Register problem matchers + run: |- + echo "::add-matcher::.github/problem-matchers/csc.json" + echo "::add-matcher::.github/problem-matchers/msvc.json" + - name: Fetch Realm + uses: actions/download-artifact@v4 + with: + name: Realm.${{ needs.build-packages.outputs.package_version }} + path: ${{ github.workspace }}/Realm/packages/ + - name: Fetch Realm.PlatformHelpers + uses: actions/download-artifact@v4 + with: + name: Realm.PlatformHelpers.${{ needs.build-packages.outputs.package_version }} + path: ${{ github.workspace }}/Realm/packages/ + - name: Deploy Apps + working-directory: Tools/DeployApps + run: dotnet run deploy-apps --baasaas-api-key=${{ secrets.BAASAAS_API_KEY }} --baas-differentiator=macos-maui-${{ github.run_id }}-${{ github.run_attempt }} + - uses: actions/setup-dotnet@5d1464d5da459f3d7085106d52e499f4dc5d0f59 + with: + dotnet-version: 8.0.x + - name: Setup workloads + run: dotnet workload install maui + - name: Setup Xcode + uses: maxim-lobanov/setup-xcode@60606e260d2fc5762a71e64e74b2174e8ea3c8bd + with: + xcode-version: latest-stable + - name: Build Tests/Tests.Maui + run: dotnet build Tests/Tests.Maui -c Release -f net8.0-maccatalyst -p:RestoreConfigFile=Tests/Test.NuGet.Config -p:UseRealmNupkgsWithVersion=${{ needs.build-packages.outputs.package_version }} + - name: Run the tests + run: Tests/Tests.Maui/bin/Release/net8.0-maccatalyst/maccatalyst-x64/Tests.Maui.app/Contents/MacOS/Tests.Maui --headless --result=${{ github.workspace }}/TestResults.xml --labels=All --baasaas-api-key=${{ secrets.BAASAAS_API_KEY}} --baas-differentiator=macos-maui-${{ github.run_id }}-${{ github.run_attempt }} + - name: Transform Results + run: xsltproc --output TestResults.xml_transformed.xml Tests/Realm.Tests/EmbeddedResources/nunit3-junit.xslt TestResults.xml + - name: Publish Unit Test Results + if: always() + uses: dorny/test-reporter@31a54ee7ebcacc03a09ea97a7e5465a47b84aea5 + with: + name: Results Maui.MacCatalyst + path: TestResults.xml_transformed.xml + reporter: java-junit + list-suites: failed + path-replace-backslashes: true + fail-on-error: true + test-ios-xamarin: + name: Test Xamarin.iOS + needs: + - build-packages + if: always() && !cancelled() && !contains(needs.*.result, 'failure') && !contains(needs.*.result, 'cancelled') + timeout-minutes: 60 + runs-on: macos-12 + steps: + - name: Checkout Code + uses: actions/checkout@v4 + with: + submodules: false + ref: ${{ github.event.pull_request.head.sha }} + - name: Register problem matchers + run: |- + echo "::add-matcher::.github/problem-matchers/csc.json" + echo "::add-matcher::.github/problem-matchers/msvc.json" + - name: Fetch Realm + uses: actions/download-artifact@v4 + with: + name: Realm.${{ needs.build-packages.outputs.package_version }} + path: ${{ github.workspace }}/Realm/packages/ + - name: Fetch Realm.PlatformHelpers + uses: actions/download-artifact@v4 + with: + name: Realm.PlatformHelpers.${{ needs.build-packages.outputs.package_version }} + path: ${{ github.workspace }}/Realm/packages/ + - name: Add msbuild to PATH + if: ${{ runner.os == 'Windows' }} + uses: microsoft/setup-msbuild@70b70342ae97ca98d5eaad06cafd26d30f9592a9 + - name: Build Tests/Tests.iOS + run: msbuild Tests/Tests.iOS -restore -p:Configuration=Release -p:Platform=iPhoneSimulator -p:RestoreConfigFile=Tests/Test.NuGet.Config -p:UseRealmNupkgsWithVersion=${{ needs.build-packages.outputs.package_version }} + - name: Run on Simulator + uses: realm/ci-actions/run-ios-simulator@6418e15ed9bbdb19b7d456a347e5623779f95cdf + with: + appPath: Tests/Tests.iOS/bin/iPhoneSimulator/Release/Tests.iOS.app + bundleId: io.realm.dotnettests + iphoneToSimulate: iPhone-8 + arguments: '--headless --result=${{ github.workspace }}/TestResults.xml --labels=All ' + os: iOS + - name: Publish Unit Test Results + if: always() + uses: dorny/test-reporter@31a54ee7ebcacc03a09ea97a7e5465a47b84aea5 + with: + name: Results Xamarin.iOS + path: TestResults.xml + reporter: java-junit + list-suites: failed + path-replace-backslashes: true + fail-on-error: true + test-ios-maui: + name: Test Maui.iOS + needs: + - build-packages + - deploy-baas + if: always() && !cancelled() && !contains(needs.*.result, 'failure') && !contains(needs.*.result, 'cancelled') + timeout-minutes: 60 + runs-on: macos-13 + steps: + - name: Checkout Code + uses: actions/checkout@v4 + with: + submodules: false + ref: ${{ github.event.pull_request.head.sha }} + - name: Register problem matchers + run: |- + echo "::add-matcher::.github/problem-matchers/csc.json" + echo "::add-matcher::.github/problem-matchers/msvc.json" + - name: Fetch Realm + uses: actions/download-artifact@v4 + with: + name: Realm.${{ needs.build-packages.outputs.package_version }} + path: ${{ github.workspace }}/Realm/packages/ + - name: Fetch Realm.PlatformHelpers + uses: actions/download-artifact@v4 + with: + name: Realm.PlatformHelpers.${{ needs.build-packages.outputs.package_version }} + path: ${{ github.workspace }}/Realm/packages/ + - name: Deploy Apps + working-directory: Tools/DeployApps + run: dotnet run deploy-apps --baasaas-api-key=${{ secrets.BAASAAS_API_KEY }} --baas-differentiator=ios-maui-${{ github.run_id }}-${{ github.run_attempt }} + - uses: actions/setup-dotnet@5d1464d5da459f3d7085106d52e499f4dc5d0f59 + with: + dotnet-version: 8.0.x + - name: Setup workloads + run: dotnet workload install maui + - name: Setup Xcode + uses: maxim-lobanov/setup-xcode@60606e260d2fc5762a71e64e74b2174e8ea3c8bd + with: + xcode-version: latest-stable + - name: Build Tests/Tests.Maui + run: dotnet build Tests/Tests.Maui -c Release -f net8.0-ios -p:RestoreConfigFile=Tests/Test.NuGet.Config -p:UseRealmNupkgsWithVersion=${{ needs.build-packages.outputs.package_version }} + - name: Run on Simulator + uses: realm/ci-actions/run-ios-simulator@6418e15ed9bbdb19b7d456a347e5623779f95cdf + with: + appPath: Tests/Tests.Maui/bin/Release/net8.0-ios/iossimulator-x64/Tests.Maui.app + bundleId: io.realm.mauitests + iphoneToSimulate: iPhone-15 + arguments: --headless --result=${{ github.workspace }}/TestResults.xml --labels=All --baasaas-api-key=${{ secrets.BAASAAS_API_KEY}} --baas-differentiator=ios-maui-${{ github.run_id }}-${{ github.run_attempt }} + os: iOS + - name: Transform Results + run: xsltproc --output TestResults.xml_transformed.xml Tests/Realm.Tests/EmbeddedResources/nunit3-junit.xslt TestResults.xml + - name: Publish Unit Test Results + if: always() + uses: dorny/test-reporter@31a54ee7ebcacc03a09ea97a7e5465a47b84aea5 + with: + name: Results Maui.iOS + path: TestResults.xml_transformed.xml + reporter: java-junit + list-suites: failed + path-replace-backslashes: true + fail-on-error: true + test-tvos: + name: Test Xamarin.tvOS needs: - build-packages - if: always() && !cancelled() && !contains(needs.*.result, 'failure') && !contains(needs.*.result, 'cancelled') && (github.event_name == 'push' || github.event.inputs.publish-prerelease) + if: always() && !cancelled() && !contains(needs.*.result, 'failure') && !contains(needs.*.result, 'cancelled') + timeout-minutes: 60 + runs-on: macos-12 steps: - - name: Checkout code - uses: actions/checkout@v3 + - name: Checkout Code + uses: actions/checkout@v4 with: submodules: false ref: ${{ github.event.pull_request.head.sha }} + - name: Register problem matchers + run: |- + echo "::add-matcher::.github/problem-matchers/csc.json" + echo "::add-matcher::.github/problem-matchers/msvc.json" + - name: Fetch Realm + uses: actions/download-artifact@v4 + with: + name: Realm.${{ needs.build-packages.outputs.package_version }} + path: ${{ github.workspace }}/Realm/packages/ - name: Fetch Realm.PlatformHelpers uses: actions/download-artifact@v4 with: name: Realm.PlatformHelpers.${{ needs.build-packages.outputs.package_version }} path: ${{ github.workspace }}/Realm/packages/ + - name: Add msbuild to PATH + if: ${{ runner.os == 'Windows' }} + uses: microsoft/setup-msbuild@70b70342ae97ca98d5eaad06cafd26d30f9592a9 + - name: Build Tests/Tests.XamarinTVOS + run: msbuild Tests/Tests.XamarinTVOS -restore -p:Configuration=Release -p:Platform=iPhoneSimulator -p:RestoreConfigFile=Tests/Test.NuGet.Config -p:UseRealmNupkgsWithVersion=${{ needs.build-packages.outputs.package_version }} + - name: Run on Simulator + uses: realm/ci-actions/run-ios-simulator@6418e15ed9bbdb19b7d456a347e5623779f95cdf + with: + 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.xml --labels=All ' + os: tvOS + - name: Publish Unit Test Results + if: always() + uses: dorny/test-reporter@31a54ee7ebcacc03a09ea97a7e5465a47b84aea5 + with: + name: Results Xamarin.tvOS + path: TestResults.xml + reporter: java-junit + list-suites: failed + path-replace-backslashes: true + fail-on-error: true + test-android-xamarin: + name: Test Xamarin.Android + needs: + - build-packages + if: always() && !cancelled() && !contains(needs.*.result, 'failure') && !contains(needs.*.result, 'cancelled') + timeout-minutes: 60 + runs-on: windows-latest + steps: + - name: Setup JDK + uses: actions/setup-java@2e74cbce18569d23ca8b812590dbb83f13ac7c5a + with: + distribution: microsoft + java-version: 17 + - name: Checkout Code + uses: actions/checkout@v4 + with: + submodules: false + ref: ${{ github.event.pull_request.head.sha }} + - name: Register problem matchers + run: |- + echo "::add-matcher::.github/problem-matchers/csc.json" + echo "::add-matcher::.github/problem-matchers/msvc.json" - name: Fetch Realm uses: actions/download-artifact@v4 with: name: Realm.${{ needs.build-packages.outputs.package_version }} path: ${{ github.workspace }}/Realm/packages/ - - name: Configure .NET - uses: actions/setup-dotnet@3e6b9fe3930cac7c59c651af5de1514b47a805b9 + - name: Fetch Realm.PlatformHelpers + uses: actions/download-artifact@v4 with: - dotnet-version: 8.0.x - - name: Install sleet - run: dotnet tool install -g sleet + name: Realm.PlatformHelpers.${{ needs.build-packages.outputs.package_version }} + path: ${{ github.workspace }}/Realm/packages/ + - name: Add msbuild to PATH + if: ${{ runner.os == 'Windows' }} + uses: microsoft/setup-msbuild@70b70342ae97ca98d5eaad06cafd26d30f9592a9 + - name: Build Tests/Tests.Android + run: msbuild Tests/Tests.Android -t:SignAndroidPackage -restore -p:Configuration=Release -p:AndroidUseSharedRuntime=False -p:EmbedAssembliesIntoApk=True -p:RestoreConfigFile=Tests/Test.NuGet.Config -p:UseRealmNupkgsWithVersion=${{ needs.build-packages.outputs.package_version }} - name: Configure AWS Credentials - uses: aws-actions/configure-aws-credentials@v1-node16 + uses: aws-actions/configure-aws-credentials@v4.0.2 with: - aws-access-key-id: ${{ secrets.NUGET_S3_ACCESS_KEY }} - aws-secret-access-key: ${{ secrets.NUGET_S3_SECRET_KEY }} - aws-region: us-east-1 - - name: NuGet Publish Realm.PlatformHelpers.${{ needs.build-packages.outputs.package_version }} - run: sleet push ${{ github.workspace }}/Realm/packages/Realm.PlatformHelpers.${{ needs.build-packages.outputs.package_version }}.nupkg --config ${{ github.workspace }}/.github/sleet.json --source NugetSource - - name: NuGet Publish Realm.${{ needs.build-packages.outputs.package_version }} - run: sleet push ${{ github.workspace }}/Realm/packages/Realm.${{ needs.build-packages.outputs.package_version }}.nupkg --config ${{ github.workspace }}/.github/sleet.json --source NugetSource - build-unity: - uses: ./.github/workflows/build-unity.yml - name: Package - with: - version: ${{ needs.build-packages.outputs.package_version }} - needs: - - build-packages - if: always() && !cancelled() && !contains(needs.*.result, 'failure') && !contains(needs.*.result, 'cancelled') - test-net-framework: - uses: ./.github/workflows/test-net-framework.yml - name: Test - if: always() && !cancelled() && !contains(needs.*.result, 'failure') && !contains(needs.*.result, 'cancelled') + aws-access-key-id: ${{ secrets.AWS_DEVICEFARM_ACCESS_KEY_ID }} + aws-secret-access-key: ${{ secrets.AWS_DEVICEFARM_SECRET_ACCESS_KEY }} + aws-region: us-west-2 + - name: Run the tests + id: run_tests + uses: ./.github/actions/run-android-device-farm-test + with: + apk-path: ${{ github.workspace }}/Tests/Tests.Android/bin/Release/io.realm.xamarintests-Signed.apk + app-id: io.realm.xamarintests + project-arn: ${{ secrets.DEVICEFARM_PROJECT_ARN }} + device-pool-arn: ${{ secrets.DEVICEFARM_ANDROID_POOL_ARN }} + - name: Publish Unit Test Results + if: always() + uses: dorny/test-reporter@31a54ee7ebcacc03a09ea97a7e5465a47b84aea5 + with: + name: Results Xamarin.Android + path: ${{ steps.run_tests.outputs.test-results-path }} + reporter: java-junit + list-suites: failed + path-replace-backslashes: true + fail-on-error: true + test-android-maui: + name: Test Maui.Android needs: - build-packages - deploy-baas - with: - version: ${{ needs.build-packages.outputs.package_version }} - secrets: - BaaSaasApiKey: ${{ secrets.BAASAAS_API_KEY }} - test-uwp-managed: - uses: ./.github/workflows/test-uwp-managed.yml - name: Test if: always() && !cancelled() && !contains(needs.*.result, 'failure') && !contains(needs.*.result, 'cancelled') + timeout-minutes: 60 + runs-on: windows-latest + steps: + - name: Setup JDK + uses: actions/setup-java@2e74cbce18569d23ca8b812590dbb83f13ac7c5a + with: + distribution: microsoft + java-version: 17 + - name: Checkout Code + uses: actions/checkout@v4 + with: + submodules: false + ref: ${{ github.event.pull_request.head.sha }} + - name: Register problem matchers + run: |- + echo "::add-matcher::.github/problem-matchers/csc.json" + echo "::add-matcher::.github/problem-matchers/msvc.json" + - name: Fetch Realm + uses: actions/download-artifact@v4 + with: + name: Realm.${{ needs.build-packages.outputs.package_version }} + path: ${{ github.workspace }}/Realm/packages/ + - name: Fetch Realm.PlatformHelpers + uses: actions/download-artifact@v4 + with: + name: Realm.PlatformHelpers.${{ needs.build-packages.outputs.package_version }} + path: ${{ github.workspace }}/Realm/packages/ + - name: Deploy Apps + working-directory: Tools/DeployApps + run: dotnet run deploy-apps --baasaas-api-key=${{ secrets.BAASAAS_API_KEY }} --baas-differentiator=android-maui-${{ github.run_id }}-${{ github.run_attempt }} + - uses: actions/setup-dotnet@5d1464d5da459f3d7085106d52e499f4dc5d0f59 + with: + dotnet-version: 8.0.x + - name: Setup workloads + run: dotnet workload install maui + - name: Publish Tests/Tests.Maui + run: dotnet publish Tests/Tests.Maui -c Release -f net8.0-android -p:RestoreConfigFile=Tests/Test.NuGet.Config -p:UseRealmNupkgsWithVersion=${{ needs.build-packages.outputs.package_version }} --no-self-contained + - name: Output executable path + id: dotnet-publish + run: echo 'executable-path=./Tests/Tests.Maui/bin/Release/net8.0-android/null/Tests.Maui' >> $GITHUB_OUTPUT + shell: bash + - name: Configure AWS Credentials + uses: aws-actions/configure-aws-credentials@v4.0.2 + with: + aws-access-key-id: ${{ secrets.AWS_DEVICEFARM_ACCESS_KEY_ID }} + aws-secret-access-key: ${{ secrets.AWS_DEVICEFARM_SECRET_ACCESS_KEY }} + aws-region: us-west-2 + - name: Run the tests + id: run_tests + uses: ./.github/actions/run-android-device-farm-test + with: + apk-path: ${{ github.workspace }}/Tests/Tests.Maui/bin/Release/net8.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 }} + - name: Transform Results + run: xsltproc --output ${{ steps.run_tests.outputs.test-results-path }}_transformed.xml Tests/Realm.Tests/EmbeddedResources/nunit3-junit.xslt ${{ steps.run_tests.outputs.test-results-path }} + - name: Publish Unit Test Results + if: always() + uses: dorny/test-reporter@31a54ee7ebcacc03a09ea97a7e5465a47b84aea5 + with: + name: Results Maui.Android + path: ${{ steps.run_tests.outputs.test-results-path }}_transformed.xml + reporter: java-junit + list-suites: failed + path-replace-backslashes: true + fail-on-error: true + test-woven-classes: + name: Test Woven Classes needs: - build-packages - - deploy-baas - with: - version: ${{ needs.build-packages.outputs.package_version }} - secrets: - BaaSaasApiKey: ${{ secrets.BAASAAS_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 - needs: - - build-packages - uses: ./.github/workflows/test-net-core.yml - with: - version: ${{ needs.build-packages.outputs.package_version }} - framework: '["net6.0", "net8.0"]' - test-macos: - uses: ./.github/workflows/test-macos.yml - name: Test + timeout-minutes: 60 + runs-on: windows-latest + steps: + - name: Checkout Code + uses: actions/checkout@v4 + with: + submodules: false + ref: ${{ github.event.pull_request.head.sha }} + - name: Register problem matchers + run: |- + echo "::add-matcher::.github/problem-matchers/csc.json" + echo "::add-matcher::.github/problem-matchers/msvc.json" + - name: Fetch Realm + uses: actions/download-artifact@v4 + with: + name: Realm.${{ needs.build-packages.outputs.package_version }} + path: ${{ github.workspace }}/Realm/packages/ + - name: Fetch Realm.PlatformHelpers + uses: actions/download-artifact@v4 + with: + name: Realm.PlatformHelpers.${{ needs.build-packages.outputs.package_version }} + path: ${{ github.workspace }}/Realm/packages/ + - name: Publish Tests/Realm.Tests + run: dotnet publish Tests/Realm.Tests -c Release -f net8.0 -r win-x64 -p:RestoreConfigFile=Tests/Test.NuGet.Config -p:UseRealmNupkgsWithVersion=${{ needs.build-packages.outputs.package_version }} -p:RealmTestsStandaloneExe=true -p:TestWeavedClasses=true --no-self-contained + - name: Output executable path + id: dotnet-publish + run: echo 'executable-path=./Tests/Realm.Tests/bin/Release/net8.0/win-x64/Realm.Tests' >> $GITHUB_OUTPUT + shell: bash + - name: Run the tests + run: ${{ steps.dotnet-publish.outputs.executable-path }} --result=TestResults.xml --labels=After + - name: Publish Unit Test Results + if: always() + uses: dorny/test-reporter@31a54ee7ebcacc03a09ea97a7e5465a47b84aea5 + with: + name: Results Woven Classes + path: TestResults.xml + reporter: java-junit + list-suites: failed + path-replace-backslashes: true + fail-on-error: true + test-source-generation: + name: Test Source Generation if: always() && !cancelled() && !contains(needs.*.result, 'failure') && !contains(needs.*.result, 'cancelled') - needs: - - build-packages - - deploy-baas - with: - version: ${{ needs.build-packages.outputs.package_version }} - secrets: - BaaSaasApiKey: ${{ secrets.BAASAAS_API_KEY }} - test-ios: - uses: ./.github/workflows/test-ios.yml - name: Test + timeout-minutes: 60 + runs-on: windows-latest + steps: + - name: Checkout Code + uses: actions/checkout@v4 + with: + submodules: false + ref: ${{ github.event.pull_request.head.sha }} + - name: Register problem matchers + run: |- + echo "::add-matcher::.github/problem-matchers/csc.json" + echo "::add-matcher::.github/problem-matchers/msvc.json" + - uses: actions/setup-dotnet@5d1464d5da459f3d7085106d52e499f4dc5d0f59 + with: + dotnet-version: 6.0.x + - name: Setup workloads + run: dotnet workload install android ${{ (runner.os != 'Linux' && 'tvos ios maccatalyst') || '' }} + - name: Publish Tests/SourceGenerators/Realm.SourceGenerator.Tests + run: dotnet publish Tests/SourceGenerators/Realm.SourceGenerator.Tests -c Release -f net6.0 -r win-x64 --no-self-contained + - name: Output executable path + id: dotnet-publish + run: echo 'executable-path=./Tests/SourceGenerators/Realm.SourceGenerator.Tests/bin/Release/net6.0/win-x64/Realm.SourceGenerator.Tests' >> $GITHUB_OUTPUT + shell: bash + - name: Run the tests + run: ${{ steps.dotnet-publish.outputs.executable-path }} --result=TestResults.xml --labels=After + - name: Publish Unit Test Results + if: always() + uses: dorny/test-reporter@31a54ee7ebcacc03a09ea97a7e5465a47b84aea5 + with: + name: Results Source Generation + path: TestResults.xml + reporter: java-junit + list-suites: failed + path-replace-backslashes: true + fail-on-error: true + test-weaver: + name: Test Weaver if: always() && !cancelled() && !contains(needs.*.result, 'failure') && !contains(needs.*.result, 'cancelled') + timeout-minutes: 60 + runs-on: ${{ matrix.os.runner }} + steps: + - name: Checkout Code + uses: actions/checkout@v4 + with: + submodules: false + ref: ${{ github.event.pull_request.head.sha }} + - name: Register problem matchers + run: |- + echo "::add-matcher::.github/problem-matchers/csc.json" + echo "::add-matcher::.github/problem-matchers/msvc.json" + - uses: actions/setup-dotnet@5d1464d5da459f3d7085106d52e499f4dc5d0f59 + with: + dotnet-version: 6.0.x + - name: Setup workloads + run: dotnet workload install android ${{ (runner.os != 'Linux' && 'tvos ios maccatalyst') || '' }} + - name: Publish Tests/Weaver/Realm.Fody.Tests + run: dotnet publish Tests/Weaver/Realm.Fody.Tests -c Release -f net6.0 -r ${{ matrix.os.runtime }} --no-self-contained + - name: Output executable path + id: dotnet-publish + run: echo 'executable-path=./Tests/Weaver/Realm.Fody.Tests/bin/Release/net6.0/${{ matrix.os.runtime }}/Realm.Fody.Tests' >> $GITHUB_OUTPUT + shell: bash + - name: Run the tests + run: ${{ steps.dotnet-publish.outputs.executable-path }} --result=TestResults.xml --labels=After + - name: Publish Unit Test Results + if: always() + uses: dorny/test-reporter@31a54ee7ebcacc03a09ea97a7e5465a47b84aea5 + with: + name: Results Weaver + path: TestResults.xml + reporter: java-junit + list-suites: failed + path-replace-backslashes: true + fail-on-error: true + strategy: + matrix: + os: + - runner: windows-latest + runtime: win-x64 + - runner: ubuntu-latest + runtime: linux-x64 + - runner: macos-14 + runtime: osx-arm64 + fail-fast: false + test-code-coverage: + name: Test Code Coverage needs: - - build-packages - - deploy-baas - with: - version: ${{ needs.build-packages.outputs.package_version }} - secrets: - BaaSaasApiKey: ${{ secrets.BAASAAS_API_KEY }} - test-tvos: - uses: ./.github/workflows/test-tvos.yml - name: Test + - build-wrappers if: always() && !cancelled() && !contains(needs.*.result, 'failure') && !contains(needs.*.result, 'cancelled') + timeout-minutes: 60 + runs-on: ubuntu-latest + steps: + - name: Checkout Code + uses: actions/checkout@v4 + with: + submodules: false + ref: ${{ github.event.pull_request.head.sha }} + - name: Register problem matchers + run: |- + echo "::add-matcher::.github/problem-matchers/csc.json" + echo "::add-matcher::.github/problem-matchers/msvc.json" + - name: Fetch wrappers for linux-x86_64 + uses: actions/download-artifact@v4 + with: + name: wrappers-linux-x86_64 + path: wrappers/build + - name: Deploy Apps + working-directory: Tools/DeployApps + run: dotnet run deploy-apps --baasaas-api-key=${{ secrets.BAASAAS_API_KEY }} --baas-differentiator=code-coverage-${{ github.run_id }}-${{ github.run_attempt }} + - name: Setup Coverlet & Report Generator + run: |- + dotnet tool install coverlet.console --tool-path tools + dotnet tool install dotnet-reportgenerator-globaltool --tool-path tools + echo "${{ github.workspace }}/tools" >> $GITHUB_PATH + - name: Publish Tests/Realm.Tests + run: dotnet publish Tests/Realm.Tests -c Release -f net8.0 -r linux-x64 -p:RealmTestsStandaloneExe=true --no-self-contained + - name: Output executable path + id: dotnet-publish + run: echo 'executable-path=./Tests/Realm.Tests/bin/Release/net8.0/linux-x64/Realm.Tests' >> $GITHUB_OUTPUT + shell: bash + - name: Run the tests + env: + DOTNET_DbgEnableMiniDump: 1 + DOTNET_EnableCrashReport: 1 + run: ./tools/coverlet ./Tests/Realm.Tests/bin/Release/net8.0/linux-x64 -t ${{ steps.dotnet-publish.outputs.executable-path }} -a '--result=TestResults.xml --labels=After --baasaas-api-key=${{ secrets.BAASAAS_API_KEY}} --baas-differentiator=code-coverage-${{ github.run_id }}-${{ github.run_attempt }}' -f lcov -o ./report.lcov --exclude '[Realm.Tests]*' --exclude '[Realm.Fody]*' --exclude '[Realm.PlatformHelpers]*' + - name: Archive core dump + if: ${{ failure() && runner.os != 'Windows' }} + uses: actions/upload-artifact@v4 + with: + name: crash-report-net-core-${{ runner.os }}-${{ runner.arch }} + path: /tmp/coredump* + retention-days: 30 + if-no-files-found: warn + - name: Publish Coverage + id: publish-coveralls + uses: coverallsapp/github-action@v2.3.0 + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + file: ./report.lcov + git-commit: ${{ github.event.pull_request.head.sha }} + compare-sha: ${{ github.event.pull_request.base.sha }} + - name: Output Coveralls response + run: echo ${{ steps.publish-coveralls.outputs.coveralls-api-result }} + - name: Publish Unit Test Results + if: always() + uses: dorny/test-reporter@31a54ee7ebcacc03a09ea97a7e5465a47b84aea5 + with: + name: Results Code Coverage + path: TestResults.xml + reporter: java-junit + list-suites: failed + path-replace-backslashes: true + fail-on-error: true + cleanup-baas: + name: Cleanup BaaS needs: - - build-packages - with: - version: ${{ needs.build-packages.outputs.package_version }} - secrets: {} - test-android: - uses: ./.github/workflows/test-android.yml - name: Test + - test-code-coverage + - test-net-framework + - test-uwp + - test-macos-maui + - test-android-maui + - test-ios-maui + - test-macos-maui if: always() && !cancelled() && !contains(needs.*.result, 'failure') && !contains(needs.*.result, 'cancelled') + runs-on: ubuntu-latest + steps: + - name: Checkout Code + uses: actions/checkout@v4 + with: + submodules: false + ref: ${{ github.event.pull_request.head.sha }} + - name: Register problem matchers + run: |- + echo "::add-matcher::.github/problem-matchers/csc.json" + echo "::add-matcher::.github/problem-matchers/msvc.json" + - uses: actions/setup-dotnet@5d1464d5da459f3d7085106d52e499f4dc5d0f59 + with: + dotnet-version: 6.0.x + - name: Terminate Baas + working-directory: Tools/DeployApps + run: dotnet run terminate-baas --baasaas-api-key=${{ secrets.BAASAAS_API_KEY }} --baas-differentiator=${{ matrix.differentiator }}-${{ github.run_id }}-${{ github.run_attempt }} + strategy: + matrix: + differentiator: + - code-coverage + - net-framework + - uwp + - macos-maui + - android-maui + - ios-maui + - macos-maui + fail-fast: false + verify-namespaces: + name: Verify Namespaces needs: - build-packages - - deploy-baas - with: - version: ${{ needs.build-packages.outputs.package_version }} - secrets: - BaaSaasApiKey: ${{ secrets.BAASAAS_API_KEY }} - AWS_DEVICEFARM_ACCESS_KEY_ID: ${{ secrets.AWS_DEVICEFARM_ACCESS_KEY_ID }} - AWS_DEVICEFARM_SECRET_ACCESS_KEY: ${{ secrets.AWS_DEVICEFARM_SECRET_ACCESS_KEY }} - DEVICEFARM_PROJECT_ARN: ${{ secrets.DEVICEFARM_PROJECT_ARN }} - DEVICEFARM_ANDROID_POOL_ARN: ${{ secrets.DEVICEFARM_ANDROID_POOL_ARN }} - test-xunit: - runs-on: windows-latest - name: Test xUnit Compatibility - timeout-minutes: 10 + runs-on: ubuntu-latest + steps: + - name: Checkout Code + uses: actions/checkout@v4 + with: + submodules: false + ref: ${{ github.event.pull_request.head.sha }} + - name: Fetch Realm + uses: actions/download-artifact@v4 + with: + name: Realm.${{ needs.build-packages.outputs.package_version }} + path: ${{ github.workspace }}/Realm/packages/ + - name: Fetch Realm.PlatformHelpers + uses: actions/download-artifact@v4 + with: + name: Realm.PlatformHelpers.${{ needs.build-packages.outputs.package_version }} + path: ${{ github.workspace }}/Realm/packages/ + - name: Fetch Realm.UnityUtils + uses: actions/download-artifact@v4 + with: + name: Realm.UnityUtils.${{ needs.build-packages.outputs.package_version }} + path: ${{ github.workspace }}/Realm/packages/ + - name: Fetch Realm.UnityWeaver + uses: actions/download-artifact@v4 + with: + name: Realm.UnityWeaver.${{ needs.build-packages.outputs.package_version }} + path: ${{ github.workspace }}/Realm/packages/ + - run: dotnet tool install ilspycmd -g --version 8.0.0.7345 + - name: Verify Namespaces + run: |- + $isFailure = $false + Get-ChildItem ./Realm/packages -Filter *.nupkg | Foreach-Object { + $targetPath = Join-Path ./Realm/packages $_.BaseName + Expand-Archive $_.FullName -DestinationPath $targetPath + + Get-ChildItem $targetPath -Filter *.dll -Recurse | ForEach-Object { + if (-not ($_.FullName -match "runtimes")) { + $ilspyOutput = ilspycmd $_.FullName + + $parentDll = $_.FullName + + $ilspyOutput | ForEach-Object { + if ($_ -match "namespace.*Realm(\.|$)") { + Write-Output "::error file=$parentDll::Realm present in namespace - $($_)" + Set-Variable "isFailure" -Value $true + } + } + } + } + } + + if ($isFailure) { + exit 1 + } + shell: pwsh + lint: + name: Verify TODOs + runs-on: ubuntu-latest + steps: + - name: Checkout Code + uses: actions/checkout@v4 + with: + submodules: false + ref: ${{ github.event.pull_request.head.sha }} + - uses: nirinchev/verify-todo@ffa352ac028b4cdc8bc626471d33aa341b3ab7c9 + with: + token: ${{ secrets.GITHUB_TOKEN }} + include: '**/*.+(cs|cpp|hpp)' + exclude: wrappers/realm-core/** + pattern: \\WR[A-Z]+-[0-9]+ + publish-packages-to-sleet: + name: Publish package to S3 needs: - build-packages - if: always() && !cancelled() && !contains(needs.*.result, 'failure') && !contains(needs.*.result, 'cancelled') + if: ${{ always() && !cancelled() && !contains(needs.*.result, 'failure') && !contains(needs.*.result, 'cancelled') && (github.event_name == 'push' || github.event.inputs.publish-prerelease) }} + runs-on: ubuntu-latest steps: - - name: Checkout code - uses: actions/checkout@v3 + - name: Checkout Code + uses: actions/checkout@v4 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@v4 + with: + name: Realm.${{ needs.build-packages.outputs.package_version }} + path: ${{ github.workspace }}/Realm/packages/ - name: Fetch Realm.PlatformHelpers uses: actions/download-artifact@v4 with: name: Realm.PlatformHelpers.${{ needs.build-packages.outputs.package_version }} path: ${{ github.workspace }}/Realm/packages/ + - uses: actions/setup-dotnet@5d1464d5da459f3d7085106d52e499f4dc5d0f59 + with: + dotnet-version: 8.0.x + - name: Install sleet + run: dotnet tool install -g sleet + - name: Configure AWS Credentials + uses: aws-actions/configure-aws-credentials@v4.0.2 + with: + aws-access-key-id: ${{ secrets.NUGET_S3_ACCESS_KEY }} + aws-secret-access-key: ${{ secrets.NUGET_S3_SECRET_KEY }} + aws-region: us-east-1 + - name: NuGet Publish Realm.${{ needs.build-packages.outputs.package_version }} + run: sleet push ${{ github.workspace }}/Realm/packages/Realm.${{ needs.build-packages.outputs.package_version }}.nupkg --config ${{ github.workspace }}/.github/sleet.json --source NugetSource + - name: NuGet Publish Realm.PlatformHelpers.${{ needs.build-packages.outputs.package_version }} + run: sleet push ${{ github.workspace }}/Realm/packages/Realm.PlatformHelpers.${{ needs.build-packages.outputs.package_version }}.nupkg --config ${{ github.workspace }}/.github/sleet.json --source NugetSource + test-xunit: + name: Test xUnit Compatibility + needs: + - build-packages + if: always() && !cancelled() && !contains(needs.*.result, 'failure') && !contains(needs.*.result, 'cancelled') + timeout-minutes: 60 + runs-on: windows-latest + steps: + - name: Checkout Code + uses: actions/checkout@v4 + with: + submodules: false + ref: ${{ github.event.pull_request.head.sha }} + - name: Register problem matchers + run: |- + echo "::add-matcher::.github/problem-matchers/csc.json" + echo "::add-matcher::.github/problem-matchers/msvc.json" - name: Fetch Realm uses: actions/download-artifact@v4 with: name: Realm.${{ needs.build-packages.outputs.package_version }} path: ${{ github.workspace }}/Realm/packages/ + - name: Fetch Realm.PlatformHelpers + uses: actions/download-artifact@v4 + with: + name: Realm.PlatformHelpers.${{ needs.build-packages.outputs.package_version }} + path: ${{ github.workspace }}/Realm/packages/ - name: Publish Tests/Tests.XUnit - run: dotnet publish Tests/Tests.XUnit -c Release -f net6.0 -r win-x64 -p:RestoreConfigFile=Tests/Test.NuGet.Config -p:UseRealmNupkgsWithVersion=${{ needs.build-packages.outputs.package_version }} --no-self-contained + run: dotnet publish Tests/Tests.XUnit -c Release -f net6.0 -r win-x64 --no-self-contained - name: Output executable path id: dotnet-publish - run: echo 'executable-path=./Tests/Tests.XUnit/bin/Release/net6.0/win-x64' >> $GITHUB_OUTPUT + run: echo 'executable-path=./Tests/Tests.XUnit/bin/Release/net6.0/win-x64/Tests.XUnit' >> $GITHUB_OUTPUT shell: bash - name: Run Tests run: dotnet test ${{ steps.dotnet-publish.outputs.executable-path }}/Tests.XUnit.dll --logger GitHubActions - test-weaver: - uses: ./.github/workflows/test-weaver.yml - name: Test - test-code-coverage: - uses: ./.github/workflows/test-code-coverage.yml - name: Test - if: always() && !cancelled() && !contains(needs.*.result, 'failure') && !contains(needs.*.result, 'cancelled') + benchmark-linux: + name: Test Benchmark needs: - build-packages - - deploy-baas - with: - version: ${{ needs.build-packages.outputs.package_version }} - secrets: - BaaSaasApiKey: ${{ secrets.BAASAAS_API_KEY }} - benchmark-linux: - name: Benchmark Linux - needs: build-packages - runs-on: performance-tests - if: always() && !cancelled() && !contains(needs.*.result, 'failure') && !contains(needs.*.result, 'cancelled') && (github.event_name == 'push' || github.event.inputs.run-benchmark) + if: ${{ always() && !cancelled() && !contains(needs.*.result, 'failure') && !contains(needs.*.result, 'cancelled') && (github.event_name == 'push' || github.event.inputs.run-benchmark) }} timeout-minutes: 60 + runs-on: performance-tests steps: - - name: Cleanup Workspace - run: rm -rf "${{ github.workspace }}/*" - - name: Checkout code - uses: actions/checkout@v3 + - name: Checkout Code + uses: actions/checkout@v4 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 + - name: Register problem matchers + run: |- + echo "::add-matcher::.github/problem-matchers/csc.json" + echo "::add-matcher::.github/problem-matchers/msvc.json" + - name: Cleanup Workspace + run: git clean -fdx + - name: Fetch Realm uses: actions/download-artifact@v4 with: - name: Realm.PlatformHelpers.${{ needs.build-packages.outputs.package_version }} + name: Realm.${{ needs.build-packages.outputs.package_version }} path: ${{ github.workspace }}/Realm/packages/ - - name: Fetch Realm + - name: Fetch Realm.PlatformHelpers uses: actions/download-artifact@v4 with: - name: Realm.${{ needs.build-packages.outputs.package_version }} + name: Realm.PlatformHelpers.${{ needs.build-packages.outputs.package_version }} path: ${{ github.workspace }}/Realm/packages/ - name: Clear nuget cache run: dotnet nuget locals all --clear @@ -239,19 +1494,19 @@ jobs: run: dotnet publish Tests/Benchmarks/PerformanceTests -c Release -f net6.0 -r linux-x64 -p:RestoreConfigFile=Tests/Test.NuGet.Config -p:UseRealmNupkgsWithVersion=${{ needs.build-packages.outputs.package_version }} -p:RealmTestsStandaloneExe=true --no-self-contained - name: Output executable path id: dotnet-publish - run: echo 'executable-path=./Tests/Benchmarks/PerformanceTests/bin/Release/net6.0/linux-x64' >> $GITHUB_OUTPUT + run: echo 'executable-path=./Tests/Benchmarks/PerformanceTests/bin/Release/net6.0/linux-x64/PerformanceTests' >> $GITHUB_OUTPUT shell: bash - name: Run the tests run: ${{ steps.dotnet-publish.outputs.executable-path }}/PerformanceTests -f "*" --join - name: Find Results file id: find-results-file - run: | + run: |- cd BenchmarkDotNet.Artifacts/results file=$(basename BenchmarkRun*json) echo "benchmark-results=$file" >> $GITHUB_OUTPUT shell: bash - name: Publish Benchmark Results - uses: ./.github/actions/benchmark-uploader + uses: ./github/actions/benchmark-uploader with: realm-token: ${{ secrets.Realm_Token }} file: ${{ github.workspace }}/BenchmarkDotNet.Artifacts/results/${{ steps.find-results-file.outputs.benchmark-results }} @@ -261,22 +1516,6 @@ jobs: uses: actions/upload-artifact@v4 with: name: dashboard.charts - path: ${{ github.workspace }}/dashboard.charts - retention-days: 30 + path: dashboard.charts + retention-days: ${{ github.event_name != 'pull_request' && 30 || 1 }} if-no-files-found: error - cleanup-baas: - uses: ./.github/workflows/cleanup-baas.yml - if: always() - name: Cleanup - needs: - - deploy-baas - - test-net-framework - - test-code-coverage - - test-uwp-managed - - test-macos - - test-ios - - test-android - with: - differentiators: '["net-framework", "code-coverage", "uwp-managed", "xamarinmacos", "ios", "android", "maccatalyst"]' - secrets: - BaaSaasApiKey: ${{ secrets.BAASAAS_API_KEY }} diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index e50e7f65b2..6003878612 100755 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -58,6 +58,7 @@ jobs: name: Package NuGet needs: - build-wrappers + if: always() && !cancelled() && !contains(needs.*.result, 'failure') && !contains(needs.*.result, 'cancelled') outputs: package_version: ${{ steps.get-version.outputs.package_version }} timeout-minutes: 30 @@ -654,7 +655,7 @@ jobs: strategy: matrix: framework: - - net8.0 + - net6.0 os: - runner: windows-latest runtime: win-x64 diff --git a/.github/workflows/publish-prerelease.yml b/.github/workflows/publish-prerelease.yml index bd63896a3e..45019006a8 100644 --- a/.github/workflows/publish-prerelease.yml +++ b/.github/workflows/publish-prerelease.yml @@ -4,6 +4,9 @@ name: Publish Prerelease 'on': workflow_dispatch: {} +env: + REALM_DISABLE_ANALYTICS: true + DOTNET_NOLOGO: true jobs: main: name: Publish package to S3 diff --git a/.github/workflows/publish-release.yml b/.github/workflows/publish-release.yml index ff83d242db..71d54d3e24 100755 --- a/.github/workflows/publish-release.yml +++ b/.github/workflows/publish-release.yml @@ -4,6 +4,9 @@ name: Publish Release 'on': workflow_dispatch: {} +env: + REALM_DISABLE_ANALYTICS: true + DOTNET_NOLOGO: true jobs: main: name: Publish Release From 353ae0b798f30d952e898f517677c31c70ea9110 Mon Sep 17 00:00:00 2001 From: Nikola Irinchev Date: Mon, 27 May 2024 13:57:07 +0200 Subject: [PATCH 37/39] Change .NET verison of DeployApps to 8.x --- .github/pkl-workflows/helpers/BaaS.pkl | 4 ++-- .github/workflows/main.yml | 4 ++-- .github/workflows/pr.yml | 4 ++-- Tools/DeployApps/DeployApps.csproj | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/.github/pkl-workflows/helpers/BaaS.pkl b/.github/pkl-workflows/helpers/BaaS.pkl index 84c4c245b6..52d6e406ab 100644 --- a/.github/pkl-workflows/helpers/BaaS.pkl +++ b/.github/pkl-workflows/helpers/BaaS.pkl @@ -15,7 +15,7 @@ function deploy(differentiators: Listing): gha.Matrix `if` = Common.ifNotCanceledCondition steps { ...Steps.checkout(false) - Steps.setupDotnet("6.0.x") + Steps.setupDotnet("8.0.x") ...deployStep("${{ matrix.differentiator }}", true) } } @@ -37,7 +37,7 @@ function cleanup(differentiators: Listing): gha.Matri `if` = Common.ifNotCanceledCondition steps { ...Steps.checkout(false) - Steps.setupDotnet("6.0.x") + Steps.setupDotnet("8.0.x") new gha.Step { name = "Terminate Baas" run = "dotnet run terminate-baas --baasaas-api-key=${{ secrets.BAASAAS_API_KEY }} --baas-differentiator=${{ matrix.differentiator }}-${{ github.run_id }}-${{ github.run_attempt }}" diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index fd0775c1f1..75accee0d5 100755 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -39,7 +39,7 @@ jobs: echo "::add-matcher::.github/problem-matchers/msvc.json" - uses: actions/setup-dotnet@5d1464d5da459f3d7085106d52e499f4dc5d0f59 with: - dotnet-version: 6.0.x + dotnet-version: 8.0.x - name: Deploy Apps working-directory: Tools/DeployApps run: dotnet run deploy-apps --baasaas-api-key=${{ secrets.BAASAAS_API_KEY }} --baas-differentiator=${{ matrix.differentiator }}-${{ github.run_id }}-${{ github.run_attempt }} @@ -1298,7 +1298,7 @@ jobs: echo "::add-matcher::.github/problem-matchers/msvc.json" - uses: actions/setup-dotnet@5d1464d5da459f3d7085106d52e499f4dc5d0f59 with: - dotnet-version: 6.0.x + dotnet-version: 8.0.x - name: Terminate Baas working-directory: Tools/DeployApps run: dotnet run terminate-baas --baasaas-api-key=${{ secrets.BAASAAS_API_KEY }} --baas-differentiator=${{ matrix.differentiator }}-${{ github.run_id }}-${{ github.run_attempt }} diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index 6003878612..103f093b65 100755 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -45,7 +45,7 @@ jobs: echo "::add-matcher::.github/problem-matchers/msvc.json" - uses: actions/setup-dotnet@5d1464d5da459f3d7085106d52e499f4dc5d0f59 with: - dotnet-version: 6.0.x + dotnet-version: 8.0.x - name: Deploy Apps working-directory: Tools/DeployApps run: dotnet run deploy-apps --baasaas-api-key=${{ secrets.BAASAAS_API_KEY }} --baas-differentiator=${{ matrix.differentiator }}-${{ github.run_id }}-${{ github.run_attempt }} @@ -1271,7 +1271,7 @@ jobs: echo "::add-matcher::.github/problem-matchers/msvc.json" - uses: actions/setup-dotnet@5d1464d5da459f3d7085106d52e499f4dc5d0f59 with: - dotnet-version: 6.0.x + dotnet-version: 8.0.x - name: Terminate Baas working-directory: Tools/DeployApps run: dotnet run terminate-baas --baasaas-api-key=${{ secrets.BAASAAS_API_KEY }} --baas-differentiator=${{ matrix.differentiator }}-${{ github.run_id }}-${{ github.run_attempt }} diff --git a/Tools/DeployApps/DeployApps.csproj b/Tools/DeployApps/DeployApps.csproj index f36fa4f3ea..6220bad62a 100644 --- a/Tools/DeployApps/DeployApps.csproj +++ b/Tools/DeployApps/DeployApps.csproj @@ -1,6 +1,6 @@ - net6.0 + net8.0 Exe Baas ../../global.ruleset From 69437653d02f7b78f0dce5b7a473be5fe21add7d Mon Sep 17 00:00:00 2001 From: Nikola Irinchev Date: Mon, 27 May 2024 16:55:47 +0200 Subject: [PATCH 38/39] Revert core change --- wrappers/realm-core | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wrappers/realm-core b/wrappers/realm-core index cde3adb764..14349903d1 160000 --- a/wrappers/realm-core +++ b/wrappers/realm-core @@ -1 +1 @@ -Subproject commit cde3adb7649d3361806dbbae0cf353b8fdc4d54e +Subproject commit 14349903d1315e13758537a735a649bd1c2d2fec From 578f7ec27ceed418ddc02881838985a2acded3a6 Mon Sep 17 00:00:00 2001 From: Nikola Irinchev Date: Thu, 30 May 2024 10:52:29 +0200 Subject: [PATCH 39/39] Remove some redundant types --- .github/pkl-workflows/codeql.pkl | 4 +-- .github/pkl-workflows/helpers/BaaS.pkl | 2 +- .github/pkl-workflows/helpers/Common.pkl | 3 +- .github/pkl-workflows/helpers/Package.pkl | 8 ++--- .github/pkl-workflows/helpers/Steps.pkl | 44 +++++++++++------------ .github/pkl-workflows/helpers/Test.pkl | 30 ++++++++-------- .github/pkl-workflows/main.pkl | 4 +-- .github/pkl-workflows/pr.pkl | 7 ---- .github/pkl-workflows/publish-release.pkl | 18 +++++----- .github/pkl-workflows/wrappers.pkl | 21 +++++------ 10 files changed, 65 insertions(+), 76 deletions(-) diff --git a/.github/pkl-workflows/codeql.pkl b/.github/pkl-workflows/codeql.pkl index d738695978..6627000c37 100644 --- a/.github/pkl-workflows/codeql.pkl +++ b/.github/pkl-workflows/codeql.pkl @@ -44,7 +44,7 @@ jobs { } steps { Steps.checkoutWithoutMatchers(false) - new Step { + new { name = "Initialize CodeQL" uses = Actions.codeQLInit with { @@ -68,7 +68,7 @@ jobs { ["UseSharedCompilation"] = "false" } }) - new Step { + new { name = "Perform CodeQL Analysis" uses = Actions.codeQLAnalyze } diff --git a/.github/pkl-workflows/helpers/BaaS.pkl b/.github/pkl-workflows/helpers/BaaS.pkl index 52d6e406ab..ae228a428a 100644 --- a/.github/pkl-workflows/helpers/BaaS.pkl +++ b/.github/pkl-workflows/helpers/BaaS.pkl @@ -38,7 +38,7 @@ function cleanup(differentiators: Listing): gha.Matri steps { ...Steps.checkout(false) Steps.setupDotnet("8.0.x") - new gha.Step { + new { name = "Terminate Baas" run = "dotnet run terminate-baas --baasaas-api-key=${{ secrets.BAASAAS_API_KEY }} --baas-differentiator=${{ matrix.differentiator }}-${{ github.run_id }}-${{ github.run_attempt }}" `working-directory` = "Tools/DeployApps" diff --git a/.github/pkl-workflows/helpers/Common.pkl b/.github/pkl-workflows/helpers/Common.pkl index bfc68dfa9c..7b013bed94 100644 --- a/.github/pkl-workflows/helpers/Common.pkl +++ b/.github/pkl-workflows/helpers/Common.pkl @@ -21,7 +21,6 @@ const job_Baas: String = "deploy-baas" const job_Unity: String = "build-unity" local const job_Wrappers: String = "build-wrappers" -local const job_Coverage: String = "test-code-coverage" const mainBranch: String = "main" @@ -51,7 +50,7 @@ const packages: List = nugetPackages + List("Realm.UnityUtils", "Realm.U const testTimeout: Int = 60 -const function defaultBuildJobs(baasDifferentiators: Listing, netCoreVersions: Listing): Mapping = new Mapping { +const function defaultBuildJobs(baasDifferentiators: Listing, netCoreVersions: Listing): Mapping = new { [job_Wrappers] = new gha.ReusableWorkflowJob { uses = "./.github/workflows/wrappers.yml" name = "Wrappers" diff --git a/.github/pkl-workflows/helpers/Package.pkl b/.github/pkl-workflows/helpers/Package.pkl index 16cbe65283..076ec341bd 100644 --- a/.github/pkl-workflows/helpers/Package.pkl +++ b/.github/pkl-workflows/helpers/Package.pkl @@ -12,7 +12,7 @@ local const checkDocfxCacheStep = "check-docfx-cache" local const buildSuffixOutput = "build_suffix" -function nuget(shouldBuildDocsCondition: String): gha.Job = new gha.Job { +function nuget(shouldBuildDocsCondition: String): gha.Job = new { name = "Package NuGet" `runs-on` = new gha.WindowsLatest{} `if` = Common.ifNotCanceledCondition @@ -43,7 +43,7 @@ function nuget(shouldBuildDocsCondition: String): gha.Job = new gha.Job { ...buildDocs(shouldBuildDocsCondition) } } -function unity(): gha.Job = new gha.Job { +function unity(): gha.Job = new { name = "Package Unity" `runs-on` = new gha.WindowsLatest{} `timeout-minutes` = 30 @@ -67,7 +67,7 @@ function unity(): gha.Job = new gha.Job { } } -local const setVersionSuffix = new gha.Step { +local const setVersionSuffix: gha.Step = new { name = "Set version suffix" id = setVersionSuffixStep // Build suffix is pr-1234.5 for pr builds or alpha.123 for branch builds. @@ -89,7 +89,7 @@ local const setVersionSuffix = new gha.Step { shell = "pwsh" } -local const function buildDocs(condition: String) = new Listing { +local const function buildDocs(condition: String): Listing = new { new { name = "Check Docfx cache" id = checkDocfxCacheStep diff --git a/.github/pkl-workflows/helpers/Steps.pkl b/.github/pkl-workflows/helpers/Steps.pkl index b963cecfa7..624381be49 100644 --- a/.github/pkl-workflows/helpers/Steps.pkl +++ b/.github/pkl-workflows/helpers/Steps.pkl @@ -7,7 +7,7 @@ const getVersionOutput = "package_version" const getVersionExpresssion = "${{ steps.\(getVersionStepName).outputs.\(getVersionOutput) }}" -const function checkout(submodules: (Boolean | "recursive")): Listing = new Listing { +const function checkout(submodules: (Boolean | "recursive")): Listing = new { checkoutWithoutMatchers(submodules) registerProblemMatchers() } @@ -52,7 +52,7 @@ const function downloadAllArtifacts(): gha.Step = new { } } -const function setupXcode(version: String): gha.Step = new gha.Step { +const function setupXcode(version: String): gha.Step = new { name = "Setup Xcode" uses = Actions.setupXcode with { @@ -99,7 +99,7 @@ const function fetchWrappers(wrappers: List(every((wrapper) -> Common.wr } }) -const function setupWorkloads(workloads: String?, dotnetVersion: String?): Listing = new Listing { +const function setupWorkloads(workloads: String?, dotnetVersion: String?): Listing = new { setupDotnet(dotnetVersion) new { name = "Setup workloads" @@ -116,7 +116,7 @@ const function setupJDK(): gha.Step = new { } } -const function setupAndroid(): Listing = new Listing { +const function setupAndroid(): Listing = new { setupJDK() new { name = "Setup Android" @@ -149,17 +149,17 @@ const function readVersionFromPackage(): gha.Step = new { shell = "bash" } -const function uploadToNPM(tag: "latest" | "alpha"): Listing = new Listing { +const function uploadToNPM(tag: "latest" | "alpha"): Listing = new { local packageName = "io.realm.unity-\(getVersionExpresssion).tgz" - new gha.Step { + new { uses = Actions.setupNode with { ["node-version"] = "16.x" ["registry-url"] = "https://registry.npmjs.org" } } - new gha.Step { + new { name = "NPM publish \(packageName)" run = "npm publish ${{ github.workspace }}/Realm/packages/\(packageName)/\(packageName) --tag \(tag)" env { @@ -170,7 +170,7 @@ const function uploadToNPM(tag: "latest" | "alpha"): Listing = new Lis const function uploadPackagesToSleet(versionExpression: String, expectShortPath: Boolean): Listing = new { setupDotnet(null) - new gha.Step { + new { name = "Install sleet" run = "dotnet tool install -g sleet" } @@ -179,7 +179,7 @@ const function uploadPackagesToSleet(versionExpression: String, expectShortPath: for (package in Common.nugetPackages) { let (packageWithVersion = "\(package).\(versionExpression)") let (packagePath = "\(if (expectShortPath) "" else "\(packageWithVersion)/")\(packageWithVersion).nupkg") - new gha.Step { + new { name = "NuGet Publish \(packageWithVersion)" run = "sleet push ${{ github.workspace }}/Realm/packages/\(packagePath) --config ${{ github.workspace }}/.github/sleet.json --source NugetSource" } @@ -189,30 +189,30 @@ const function uploadPackagesToSleet(versionExpression: String, expectShortPath: class MSBuildConfig { projects: Listing target: String? - properties: Mapping = new Mapping{} + properties: Mapping = new{} standaloneExe: Boolean = false function getTargetForInvocation(): String = if (target != null) " -t:\(target)" else "" function getPropertiesForInvocation(): String = "-p:Configuration=\(Common.configuration)\(propertiesToString(properties))" } -const function msbuild(config: MSBuildConfig): Listing = new Listing { +const function msbuild(config: MSBuildConfig): Listing = new { addMSBuildToPath() for (project in config.projects) { - new gha.Step { + new { name = "Build \(project)" run = "msbuild \(project)\(config.getTargetForInvocation()) -restore \(config.getPropertiesForInvocation())" } } } -const function dotnetPublish(project: String, framework: Common.NetFramework, runtime: Common.NetRuntime?, properties: Mapping): Listing = new Listing { - new gha.Step { +const function dotnetPublish(project: String, framework: Common.NetFramework, runtime: Common.NetRuntime?, properties: Mapping): Listing = new { + new { name = "Publish \(project)" run = "dotnet publish \(project) -c \(Common.configuration) -f \(framework)\(if (runtime != null) " -r \(runtime)" else "")\(propertiesToString(properties)) --no-self-contained" } - new gha.Step { + new { name = "Output executable path" id = "dotnet-publish" run = "echo 'executable-path=./\(project)/bin/\(Common.configuration)/\(framework)/\(runtime)/\(project.split("/").last)' >> $GITHUB_OUTPUT" @@ -220,7 +220,7 @@ const function dotnetPublish(project: String, framework: Common.NetFramework, ru } } -const function dotnetBuild(project: String, framework: Common.NetFramework, runtime: Common.NetRuntime?, properties: Mapping): gha.Step = new gha.Step { +const function dotnetBuild(project: String, framework: Common.NetFramework, runtime: Common.NetRuntime?, properties: Mapping): gha.Step = new { name = "Build \(project)" run = "dotnet build \(project) -c \(Common.configuration) -f \(framework)\(if (runtime != null) " -r \(runtime)" else "")\(propertiesToString(properties))" } @@ -231,9 +231,9 @@ const function runSimulator(config: SimulatorConfig): gha.Step = new { with = config.toMap().toMapping() } -const function runDeviceFarm(config: DeviceFarmConfig): Listing = new Listing { +const function runDeviceFarm(config: DeviceFarmConfig): Listing = new { configureAWSCredentials("AWS_DEVICEFARM_ACCESS_KEY_ID", "AWS_DEVICEFARM_SECRET_ACCESS_KEY", "us-west-2") - new gha.Step { + new { name = "Run the tests" uses = "./.github/actions/run-android-device-farm-test" id = "run_tests" @@ -246,8 +246,8 @@ const function runDeviceFarm(config: DeviceFarmConfig): Listing = new } } -const function publishCoverage(file: String): Listing = new Listing { - new gha.Step { +const function publishCoverage(file: String): Listing = new { + new { name = "Publish Coverage" id = "publish-coveralls" uses = Actions.coveralls @@ -258,13 +258,13 @@ const function publishCoverage(file: String): Listing = new Listing): gha.StepJobBase = } standaloneExe = true }) - new gha.Step { + new { name = "Run the tests" run = "./Tests/Realm.Tests/bin/\(Common.configuration)/net461/Realm.Tests.exe --result=\(outputFile) --labels=After \(baasTestArgs(config))" } @@ -65,12 +65,12 @@ function netCore(frameworks: Listing): gha.StepJobBase = te (config) -> new Listing { ...prepareTests(config) // To avoid NU5037 error - new gha.Step { + new { name = "Clear nuget cache" run = "dotnet nuget locals all --clear" `if` = "${{ matrix.os.runner == 'win81' }}" } - new gha.Step { + new { id = "get-net-version" name = "Extract .NET version" run = """ @@ -118,7 +118,7 @@ function xunit(): gha.StepJobBase = testJob( (config) -> new Listing { ...prepareTests(config) ...Steps.dotnetPublish("Tests/Tests.XUnit", "net6.0", "win-x64", new Mapping{}).toList() - new gha.Step { + new { name = "Run Tests" run = "dotnet test \(executableExpression)/Tests.XUnit.dll --logger GitHubActions" } @@ -380,7 +380,7 @@ function codeCoverage(wrappersJob: String, _syncDifferentiators: Listing new Listing { ...prepareTests(config) - new gha.Step { + new { name = "Setup Coverlet & Report Generator" run = """ dotnet tool install coverlet.console --tool-path tools @@ -420,7 +420,7 @@ function unity(config: UnityTestConfig): Mapping = new Mapping< Steps.cleanupWorkspace() Steps.downloadArtifacts(Package.unityPkgName, "Realm/Realm.Unity") Steps.downloadArtifacts("UnityTests", "Tests/Tests.Unity") - new gha.Step { + new { name = "Build Unity Tests" run = "unity-editor -runTests -batchmode -projectPath ${{ github.workspace }}/Tests/Tests.Unity -testPlatform Standalone\(config.platform()) -testSettingsFile ${{ github.workspace }}/Tests/Tests.Unity/.TestConfigs/\(config.settings).json -logFile \(if (config.os == "windows") "build.log" else "-")" } @@ -439,11 +439,11 @@ function unity(config: UnityTestConfig): Mapping = new Mapping< ...Steps.checkout(false) Steps.downloadArtifacts("UnityTestsRunner.\(config.os)", "TestRunner") when (config.os == "linux") { - new gha.Step { + new { name = "Install xvfb" run = "sudo apt install -y xvfb libglu1 libxcursor1" } - new gha.Step { + new { name = "Run Tests" run = """ chmod +x ${{ github.workspace }}/TestRunner/PlayerWithTests.x86_64 @@ -452,7 +452,7 @@ function unity(config: UnityTestConfig): Mapping = new Mapping< } } when (config.os == "windows") { - new gha.Step { + new { name = "Run Tests" run = #""" Start-Process ${{ github.workspace }}\TestRunner\PlayerWithTests.exe -Wait -ArgumentList "-logFile","${{ github.workspace }}\test.log","--result=${{ github.workspace }}\\#(outputFile)" @@ -482,16 +482,16 @@ function benchmark(): gha.StepJobBase = testJob( ...prepareTests(config) // To avoid NU5037 error - new gha.Step { + new { name = "Clear nuget cache" run = "dotnet nuget locals all --clear" } ...Steps.dotnetPublish("Tests/Benchmarks/PerformanceTests", "net6.0", "linux-x64", getTestProps(true)) - new gha.Step { + new { name = "Run the tests" run = "\(executableExpression)/PerformanceTests -f \"*\" --join" } - new gha.Step { + new { name = "Find Results file" run = """ cd BenchmarkDotNet.Artifacts/results @@ -501,7 +501,7 @@ function benchmark(): gha.StepJobBase = testJob( shell = "bash" id = find_results_step } - new gha.Step { + new { name = "Publish Benchmark Results" uses = "./github/actions/benchmark-uploader" with { @@ -571,12 +571,12 @@ local function reportTestResults(config: TestConfig): Listing = report local function reportTestResultsWithCustomFile(_outputFile: String, config: TestConfig): Listing = new { local __outputFile = if (config.transformResults) "\(_outputFile)_transformed.xml" else _outputFile when (config.transformResults) { - new gha.Step { + new { name = "Transform Results" run = "xsltproc --output \(__outputFile) Tests/Realm.Tests/EmbeddedResources/nunit3-junit.xslt \(_outputFile)" } } - new gha.Step { + new { name = "Publish Unit Test Results" uses = actionReportTestResults `if` = "always()" diff --git a/.github/pkl-workflows/main.pkl b/.github/pkl-workflows/main.pkl index b6a7e6b931..20e7df3ca8 100644 --- a/.github/pkl-workflows/main.pkl +++ b/.github/pkl-workflows/main.pkl @@ -30,12 +30,12 @@ on { } workflow_dispatch { inputs { - ["publish-prerelease"] = new WorkflowInput { + ["publish-prerelease"] = new { description = "Indicates whether to publish the package to Sleet/npm" required = false type = "boolean" } - ["run-benchmark"] = new WorkflowInput { + ["run-benchmark"] = new { description = "Indicates whether to run the benchmark tests" required = false type = "boolean" diff --git a/.github/pkl-workflows/pr.pkl b/.github/pkl-workflows/pr.pkl index 738ec7d018..3f8de3eaef 100644 --- a/.github/pkl-workflows/pr.pkl +++ b/.github/pkl-workflows/pr.pkl @@ -4,13 +4,6 @@ amends "GithubAction/GithubAction.pkl" import "helpers/Common.pkl" -local class JobNamesDefition { - const wrappers: String = "build-wrappers" - const coverage: String = "test-code-coverage" -} - -local JobNames = new JobNamesDefition{} - local baasDifferentiators: Listing = new { "code-coverage" } diff --git a/.github/pkl-workflows/publish-release.pkl b/.github/pkl-workflows/publish-release.pkl index 7709ac3123..ea65adf8c0 100644 --- a/.github/pkl-workflows/publish-release.pkl +++ b/.github/pkl-workflows/publish-release.pkl @@ -32,7 +32,7 @@ jobs { } } -local function uploadDocs(): Step = new Step { +local function uploadDocs(): Step = new { name = "Upload docs" run = #""" Expand-Archive -Path Realm/packages/Docs.zip/Docs.zip -DestinationPath Realm/packages @@ -44,7 +44,7 @@ local function uploadDocs(): Step = new Step { """# } -local function uploadToNuGet(): Listing = new Listing { +local function uploadToNuGet(): Listing = new { for (package in Common.nugetPackages) { let (packageWithVersion = "\(package).\(Steps.getVersionExpresssion)") new Step { @@ -54,7 +54,7 @@ local function uploadToNuGet(): Listing = new Listing { } } -local function mergeReleasePR(): Listing = new Listing { +local function mergeReleasePR(): Listing = new { local find_pr_step = "find-pull-request" new Step { name = "Find Release PR" @@ -67,7 +67,7 @@ local function mergeReleasePR(): Listing = new Listing { mergePR("${{ steps.\(find_pr_step).outputs.number }}") } -local function mergePR(numberExpression: String): Step = new Step { +local function mergePR(numberExpression: String): Step = new { name = "Merge Pull Request" uses = Actions.mergePR with { @@ -77,7 +77,7 @@ local function mergePR(numberExpression: String): Step = new Step { } } -local function publishGithubReleasee(): Step = new Step { +local function publishGithubReleasee(): Step = new { name = "Publish Github Release" uses = Actions.publishGithubRelease with { @@ -91,9 +91,9 @@ local function publishGithubReleasee(): Step = new Step { } } -local function updateChangelogForvNext(): Listing = new Listing { +local function updateChangelogForvNext(): Listing = new { local create_pr_step = "vnext-pr" - new Step { + new { name = "Update Changelog" run = """ echo "## vNext (TBD) @@ -114,7 +114,7 @@ local function updateChangelogForvNext(): Listing = new Listing { """ shell = "bash" } - new Step { + new { name = "Create vNext PR" id = create_pr_step uses = Actions.createPR @@ -130,7 +130,7 @@ local function updateChangelogForvNext(): Listing = new Listing { mergePR("${{ steps.\(create_pr_step).outputs.pull-request-number }}") } -local function postReleaseToSlack(): Step = new Step { +local function postReleaseToSlack(): Step = new { name = "Post to #realm-releases" uses = Actions.releaseToSlack with { diff --git a/.github/pkl-workflows/wrappers.pkl b/.github/pkl-workflows/wrappers.pkl index 8c2b009716..d060332803 100644 --- a/.github/pkl-workflows/wrappers.pkl +++ b/.github/pkl-workflows/wrappers.pkl @@ -6,10 +6,7 @@ import "helpers/Common.pkl" import "helpers/Steps.pkl" import "helpers/Actions.pkl" -local class JobNamesDefition { - const checkCache: String = "check-cache" -} -local JobNames = new JobNamesDefition{} +local job_CheckCache = "check-cache" local WrappersBuildTimeout = 90 local WrappersCacheCondition = "steps.check-cache.outputs.cache-hit != 'true'" @@ -21,7 +18,7 @@ on { env = Common.defaultEnv jobs { - [JobNames.checkCache] = new MatrixJob { + [job_CheckCache] = new MatrixJob { strategy { matrix { ["os"] { @@ -79,7 +76,7 @@ jobs { intermediateSteps { Steps.setupXcode("14") } - ifCondition = "\(Common.applePlatformTargets((platform, target) -> "needs.\(JobNames.checkCache).outputs.wrappers-\(platform)-\(target) != 'true'").join(" || "))" + ifCondition = "\(Common.applePlatformTargets((platform, target) -> "needs.\(job_CheckCache).outputs.wrappers-\(platform)-\(target) != 'true'").join(" || "))" }) ["linux"] = new MatrixJob { `runs-on` = new UbuntuLatest {} @@ -94,7 +91,7 @@ jobs { ifCondition = "\(Common.linuxArchs.map((arch) -> "needs.check-cache.outputs.wrappers-linux-\(arch) != 'true'").join(" || "))" platform = "linux-${{ matrix.arch }}" intermediateSteps { - new Step { + new { name = "Install Ninja" run = "sudo apt install ninja-build" `if` = WrappersCacheCondition @@ -149,7 +146,7 @@ jobs { }) } -local function withCondition(platform: String, _conditionToAppend: String?) = new Mixin { +local function withCondition(platform: String, _conditionToAppend: String?): Mixin = new { `if` = "matrix.os == \(if (platform.contains("windows")) "'windows'" else "'ubuntu'")\(if (_conditionToAppend == null) "" else " && \(_conditionToAppend)")" } @@ -161,7 +158,7 @@ local function checkCache(platform: String): Step = new Step { uses = Actions.cache } |> cacheStep(platform, null) -local function cacheStep(platform: String, idSuffix: String?) = new Mixin { +local function cacheStep(platform: String, idSuffix: String?): Mixin = new { name = "Check Cache for \(platform)" id = "check-cache\(if (idSuffix == null) "" else "-\(idSuffix)")" with { @@ -170,10 +167,10 @@ local function cacheStep(platform: String, idSuffix: String?) = new Mixin } } -local function wrappersJob(config: JobConfig) = new Mixin { +local function wrappersJob(config: JobConfig): Mixin = new { `timeout-minutes` = WrappersBuildTimeout needs { - JobNames.checkCache + job_CheckCache } `if` = config.ifCondition steps { @@ -182,7 +179,7 @@ local function wrappersJob(config: JobConfig) = new Mixin { ...config.intermediateSteps.toList().map((step) -> (step) { `if` = WrappersCacheCondition }) - new Step { + new { name = "Build Wrappers" run = config.toString() `if` = WrappersCacheCondition