diff --git a/.github/pkl-workflows/GithubAction/GithubAction.pkl b/.github/pkl-workflows/GithubAction/GithubAction.pkl new file mode 100644 index 0000000000..d99ca79acd --- /dev/null +++ b/.github/pkl-workflows/GithubAction/GithubAction.pkl @@ -0,0 +1,690 @@ +// 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 + `fail-fast`: Boolean = false +} + +// Jobs +abstract class JobBase { + name: String? + needs: Listing? + `if`: String? + concurrency: Concurrency? + env: EnvironmentVariables? + outputs: Mapping? + `timeout-minutes`: Int? + permissions: (*Permissions|"read-all"|"write-all")? + environment: String? +} + +abstract class StepJobBase extends JobBase { + `runs-on`: Machine|String|Listing + 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|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) })) + ) + } + } +} + +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/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/codeql.pkl b/.github/pkl-workflows/codeql.pkl new file mode 100644 index 0000000000..6627000c37 --- /dev/null +++ b/.github/pkl-workflows/codeql.pkl @@ -0,0 +1,77 @@ +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 { + name = "Initialize CodeQL" + uses = Actions.codeQLInit + with { + ["languages"] = "csharp" + ["config"] = """ + queries: + - uses: security-and-quality + query-filters: + - exclude: + id: cs/call-to-unmanaged-code + - exclude: + id: 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 { + 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 new file mode 100644 index 0000000000..c7d54b3d54 --- /dev/null +++ b/.github/pkl-workflows/helpers/Actions.pkl @@ -0,0 +1,24 @@ +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 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" +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/helpers/BaaS.pkl b/.github/pkl-workflows/helpers/BaaS.pkl new file mode 100644 index 0000000000..ae228a428a --- /dev/null +++ b/.github/pkl-workflows/helpers/BaaS.pkl @@ -0,0 +1,47 @@ +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(false) + Steps.setupDotnet("8.0.x") + ...deployStep("${{ matrix.differentiator }}", true) + } +} + +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 { + name = "Cleanup BaaS" + `runs-on` = new gha.UbuntuLatest{} + strategy { + matrix { + ["differentiator"] = differentiators + } + } + `if` = Common.ifNotCanceledCondition + steps { + ...Steps.checkout(false) + Steps.setupDotnet("8.0.x") + 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" + } + } +} \ 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..7b013bed94 --- /dev/null +++ b/.github/pkl-workflows/helpers/Common.pkl @@ -0,0 +1,90 @@ +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") +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 job_Packages: String = "build-packages" +const job_Baas: String = "deploy-baas" +const job_Unity: String = "build-unity" + +local const job_Wrappers: String = "build-wrappers" + +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")) + +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() + +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: Int = 60 + +const function defaultBuildJobs(baasDifferentiators: Listing, netCoreVersions: Listing): Mapping = new { + [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/Lint.pkl b/.github/pkl-workflows/helpers/Lint.pkl new file mode 100644 index 0000000000..16c1ae04bb --- /dev/null +++ b/.github/pkl-workflows/helpers/Lint.pkl @@ -0,0 +1,69 @@ +module lint + +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 = actionVerifyTODO + with { + ["token"] = "${{ secrets.GITHUB_TOKEN }}" + ["include"] = "**/*.+(cs|cpp|hpp)" + ["exclude"] = "wrappers/realm-core/**" + ["pattern"] = "\\\\WR[A-Z]+-[0-9]+" + } + } + } +} + +function verifyNamespaces(): gha.Job = new { + `runs-on` = new gha.UbuntuLatest{} + name = "Verify Namespaces" + needs { + Common.job_Packages + } + steps { + Steps.checkoutWithoutMatchers(false) + ...Steps.fetchPackages(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/Package.pkl b/.github/pkl-workflows/helpers/Package.pkl new file mode 100644 index 0000000000..076ec341bd --- /dev/null +++ b/.github/pkl-workflows/helpers/Package.pkl @@ -0,0 +1,119 @@ +module package + +import "../GithubAction/GithubAction.pkl" as gha +import "Common.pkl" +import "Steps.pkl" +import "Actions.pkl" + +const unityPkgName = "io.realm.unity-${{ needs.\(Common.job_Packages).outputs.\(Steps.getVersionOutput) }}.tgz" + +local const setVersionSuffixStep = "set-version-suffix" +local const checkDocfxCacheStep = "check-docfx-cache" + +local const buildSuffixOutput = "build_suffix" + +function nuget(shouldBuildDocsCondition: String): gha.Job = new { + name = "Package NuGet" + `runs-on` = new gha.WindowsLatest{} + `if` = Common.ifNotCanceledCondition + outputs { + [Steps.getVersionOutput] = Steps.getVersionExpresssion + } + `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.packages.map((pkg) -> "Realm/\(pkg)").toListing() + target = "Pack" + properties { + ["PackageOutputPath"] = "${{ github.workspace }}/Realm/packages" + ["VersionSuffix"] = "${{ steps.\(setVersionSuffixStep).outputs.\(buildSuffixOutput) }}" + } + }) + Steps.readVersionFromPackage() + for (pkgName in Common.packages) { + let (finalPkgName = "\(pkgName).\(Steps.getVersionExpresssion)") + Steps.uploadArtifacts(finalPkgName, "Realm/packages/\(finalPkgName).*nupkg") + } + Steps.uploadArtifacts("ExtractedChangelog", "Realm/Realm/ExtractedChangelog.md") + ...buildDocs(shouldBuildDocsCondition) + } +} +function unity(): gha.Job = new { + 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: gha.Step = new { + 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 function buildDocs(condition: String): Listing = new { + 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 new file mode 100644 index 0000000000..624381be49 --- /dev/null +++ b/.github/pkl-workflows/helpers/Steps.pkl @@ -0,0 +1,291 @@ +import "../GithubAction/GithubAction.pkl" as gha +import "Common.pkl" +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 { + checkoutWithoutMatchers(submodules) + registerProblemMatchers() +} + +const function checkoutWithoutMatchers(submodules: (Boolean | "recursive")): gha.Step = new { + name = "Checkout Code" + uses = Actions.checkout + with { + ["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.uploadArtifact + with { + ["name"] = artifactName + ["path"] = relPath + ["retention-days"] = "${{ github.event_name != 'pull_request' && 30 || 1 }}" + ["if-no-files-found"] = "error" + } +} + +const function downloadArtifacts(artifactName: String, relPath: String): gha.Step = new { + name = "Fetch \(artifactName)" + uses = Actions.downloadArtifact + with { + ["name"] = artifactName + ["path"] = relPath + } +} + +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 { + name = "Setup Xcode" + uses = Actions.setupXcode + with { + ["xcode-version"] = version + } +} + +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(version: String?): gha.Step = new { + uses = Actions.setupDotnet + with { + ["dotnet-version"] = version ?? "8.0.x" + } +} + +const function registerProblemMatchers(): gha.Step = new { + name = "Register problem matchers" + run = """ + echo "::add-matcher::.github/problem-matchers/csc.json" + echo "::add-matcher::.github/problem-matchers/msvc.json" + """ +} + +const function fetchPackages(_packages: List(every((package) -> Common.packages.contains(package)))?): List = (_packages ?? Common.packages).map((package) -> new gha.Step { + name = "Fetch \(package)" + uses = Actions.downloadArtifact + with { + ["name"] = "\(package).${{ needs.\(Common.job_Packages).outputs.\(getVersionOutput) }}" + ["path"] = "${{ github.workspace }}/Realm/packages/" + } +}) + +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 = Actions.downloadArtifact + with { + ["name"] = "wrappers-\(wrapper)" + ["path"] = "wrappers/build" + } +}) + +const function setupWorkloads(workloads: String?, dotnetVersion: String?): Listing = new { + setupDotnet(dotnetVersion) + new { + name = "Setup workloads" + run = "dotnet workload install \(workloads ?? "android ${{ (runner.os != 'Linux' && 'tvos ios maccatalyst') || '' }}")" + } +} + +const function setupJDK(): gha.Step = new { + name = "Setup JDK" + uses = Actions.setupJDK + with { + ["distribution"] = "microsoft" + ["java-version"] = 17 + } +} + +const function setupAndroid(): Listing = new { + setupJDK() + new { + name = "Setup Android" + uses = Actions.setupAndroid + } + new { + name = "Install SDK platform 21" + run = "sdkmanager --install \"platforms;android-21\"" + } +} + +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 { + ["aws-access-key-id"] = "${{ secrets.\(accessKey) }}" + ["aws-secret-access-key"] = "${{ secrets.\(secretKey) }}" + ["aws-region"] = region + } +} + +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 { + local packageName = "io.realm.unity-\(getVersionExpresssion).tgz" + + new { + uses = Actions.setupNode + with { + ["node-version"] = "16.x" + ["registry-url"] = "https://registry.npmjs.org" + } + } + new { + name = "NPM publish \(packageName)" + run = "npm publish ${{ github.workspace }}/Realm/packages/\(packageName)/\(packageName) --tag \(tag)" + env { + ["NODE_AUTH_TOKEN"] = "${{ secrets.NPM_TOKEN }}" + } + } +} + +const function uploadPackagesToSleet(versionExpression: String, expectShortPath: Boolean): Listing = new { + setupDotnet(null) + new { + 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 { + 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? + 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 { + addMSBuildToPath() + + for (project in config.projects) { + 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 { + 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 { + name = "Output executable path" + id = "dotnet-publish" + run = "echo 'executable-path=./\(project)/bin/\(Common.configuration)/\(framework)/\(runtime)/\(project.split("/").last)' >> $GITHUB_OUTPUT" + shell = "bash" + } +} + +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))" +} + +const function runSimulator(config: SimulatorConfig): gha.Step = new { + name = "Run on Simulator" + uses = Actions.runSimulator + with = config.toMap().toMapping() +} + +const function runDeviceFarm(config: DeviceFarmConfig): Listing = new { + configureAWSCredentials("AWS_DEVICEFARM_ACCESS_KEY_ID", "AWS_DEVICEFARM_SECRET_ACCESS_KEY", "us-west-2") + new { + 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 }}" + } + } +} + +const function publishCoverage(file: String): Listing = new { + new { + name = "Publish Coverage" + id = "publish-coveralls" + uses = Actions.coveralls + 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 { + name = "Output Coveralls response" + run = "echo ${{ steps.publish-coveralls.outputs.coveralls-api-result }}" + } +} + +const function cleanupWorkspace(): gha.Step = new { + name = "Cleanup Workspace" + run = "git clean -fdx" +} + +class SimulatorConfig { + appPath: String + bundleId: String + iphoneToSimulate: "Apple-TV-1080p" | "iPhone-8" | "iPhone-15" + arguments: String + os: "tvOS" | "iOS" +} + +class DeviceFarmConfig { + apkPath: String + appId: String +} + +local const function addMSBuildToPath(): gha.Step = new { + name = "Add msbuild to PATH" + uses = Actions.setupMsBuild + `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 diff --git a/.github/pkl-workflows/helpers/Test.pkl b/.github/pkl-workflows/helpers/Test.pkl new file mode 100644 index 0000000000..7b6dcc7c0b --- /dev/null +++ b/.github/pkl-workflows/helpers/Test.pkl @@ -0,0 +1,644 @@ +module test + +import "../GithubAction/GithubAction.pkl" as gha +import "Common.pkl" +import "Steps.pkl" +import "BaaS.pkl" +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( + new TestConfig { + title = ".NET Framework" + needsPackages = true + syncDifferentiator = "net-framework" + syncDifferentiators = _syncDifferentiators + }, + new gha.WindowsLatest{}, + null, + (config) -> new Listing { + ...prepareTests(config) + ...buildTests(new Steps.MSBuildConfig { + projects { + "Tests/Realm.Tests" + } + properties { + ["TargetFramework"] = "net461" + } + standaloneExe = true + }) + new { + name = "Run the tests" + run = "./Tests/Realm.Tests/bin/\(Common.configuration)/net461/Realm.Tests.exe --result=\(outputFile) --labels=After \(baasTestArgs(config))" + } + ...reportTestResults(config) + }) + +function netCore(frameworks: Listing): gha.StepJobBase = testJob( + new TestConfig { + needsPackages = true + title = "${{ matrix.framework }}, ${{ (matrix.os.runner == 'win81' && 'win81') || matrix.os.runtime }}" + shouldCleanWorkspace = true + }, + "${{ matrix.os.runner }}", + new gha.MatrixStrategy { + 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 MatrixOS { runner = "macos-14" runtime = "osx-arm64" } + } + } + } + }, + (config) -> new Listing { + ...prepareTests(config) + // To avoid NU5037 error + new { + name = "Clear nuget cache" + run = "dotnet nuget locals all --clear" + `if` = "${{ matrix.os.runner == 'win81' }}" + } + new { + 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 }}") + ...Steps.dotnetPublish("Tests/Realm.Tests", "${{ matrix.framework }}", "${{ matrix.os.runtime }}", getTestProps(true)) + ...dotnetRunTests(true) + ...reportTestResults(config) + }) + +function weaver(): gha.StepJobBase = testJob( + new TestConfig { + title = "Weaver" + shouldCleanWorkspace = true + }, + "${{ matrix.os.runner }}", + new gha.MatrixStrategy { + 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" } + } + } + }, + (config) -> new Listing { + ...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) + ...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 { + name = "Run Tests" + run = "dotnet test \(executableExpression)/Tests.XUnit.dll --logger GitHubActions" + } + }) + +function sourceGeneration(): gha.StepJobBase = testJob( + new TestConfig { + title = "Source Generation" + }, + new gha.WindowsLatest{}, + null, + (config) -> new Listing { + ...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) + ...reportTestResults(config) + }) + +function wovenClasses(): gha.StepJobBase = testJob( + new TestConfig { + needsPackages = true + title = "Woven Classes" + }, + new gha.WindowsLatest{}, + null, + (config) -> new Listing { + ...prepareTests(config) + ...Steps.dotnetPublish("Tests/Realm.Tests", "net8.0", "win-x64", (getTestProps(true)) { + ["TestWeavedClasses"] = "true" + }) + ...dotnetRunTests(false) + ...reportTestResults(config) + } +) + +function tvOS(_syncDifferentiators: Listing): gha.StepJobBase = testJob( + new TestConfig { + needsPackages = true + title = "Xamarin.tvOS" + syncDifferentiator = "tvos" + syncDifferentiators = _syncDifferentiators + }, + "macos-12", + null, + (config) -> new Listing { + ...prepareTests(config) + ...buildTests(new Steps.MSBuildConfig { + projects { + "Tests/Tests.XamarinTVOS" + } + properties { + ["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) + }) + +function iOS_Xamarin(): gha.StepJobBase = testJob( + new TestConfig { + needsPackages = true + title = "Xamarin.iOS" + }, + "macos-12", + null, + (config) -> new Listing { + ...prepareTests(config) + ...buildTests(new Steps.MSBuildConfig { + projects { + "Tests/Tests.iOS" + } + properties { + ["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(_syncDifferentiators: Listing): gha.StepJobBase = testJob( + new TestConfig { + needsPackages = true + title = "Maui.iOS" + syncDifferentiator = "ios-maui" + syncDifferentiators = _syncDifferentiators + transformResults = true + }, + "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(false)) + Steps.runSimulator(new Steps.SimulatorConfig{ + 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" + os = "iOS" + }) + ...reportTestResults(config) + }) + +function macOS_Xamarin(): gha.StepJobBase = testJob( + new TestConfig { + needsPackages = true + title = "Xamarin.macOS" + }, + "macos-12", + null, + (config) -> new Listing { + ...prepareTests(config) + ...buildTests(new Steps.MSBuildConfig { + projects { + "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" + } + ...reportTestResults(config) + }) + +function macOS_Maui(_syncDifferentiators: Listing): gha.StepJobBase = testJob( + new TestConfig { + needsPackages = true + title = "Maui.MacCatalyst" + syncDifferentiator = "macos-maui" + syncDifferentiators = _syncDifferentiators + transformResults = true + }, + "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(false)) + new { + name = "Run the tests" + 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) + }) + +function uwp(_syncDifferentiators: Listing): gha.StepJobBase = testJob( + new TestConfig { + needsPackages = true + 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(new Steps.MSBuildConfig { + projects { + "Tests/Tests.UWP" + } + properties { + ["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(): gha.StepJobBase = testJob( + new TestConfig { + needsPackages = true + title = "Xamarin.Android" + }, + new gha.WindowsLatest{}, + null, + (config) -> new Listing { + Steps.setupJDK() + ...prepareTests(config) + ...buildTests(new Steps.MSBuildConfig { + projects { + "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" + appId = "io.realm.xamarintests" + }) + ...reportTestResultsWithCustomFile("${{ steps.run_tests.outputs.test-results-path }}", config) + }) + +function android_Maui(_syncDifferentiators: Listing): gha.StepJobBase = testJob( + new TestConfig { + needsPackages = true + title = "Maui.Android" + syncDifferentiator = "android-maui" + 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(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" + }) + ...reportTestResultsWithCustomFile("${{ steps.run_tests.outputs.test-results-path }}", config) + }) + +function codeCoverage(wrappersJob: String, _syncDifferentiators: Listing): gha.StepJobBase = (testJob( + new TestConfig { + title = "Code Coverage" + syncDifferentiator = "code-coverage" + syncDifferentiators = _syncDifferentiators + usedWrappers = List("linux-x86_64") + }, + new gha.UbuntuLatest{}, + null, + (config) -> new Listing { + ...prepareTests(config) + new { + 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 \(executableExpression) -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) + })) { + needs { + wrappersJob + } + } + +function unity(config: UnityTestConfig): Mapping = new Mapping { + ["build-unity-tests-\(config.os)"] = new gha.Job { + name = "Build Unity \(config.os)" + `runs-on` = new Listing { + "unity" + config.os + } + needs { + Common.job_Packages + Common.job_Unity + } + `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 { + 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 { + name = "Install xvfb" + run = "sudo apt install -y xvfb libglu1 libxcursor1" + } + new { + 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 { + 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)" + }) + } + } +} + +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 { + name = "Clear nuget cache" + run = "dotnet nuget locals all --clear" + } + ...Steps.dotnetPublish("Tests/Benchmarks/PerformanceTests", "net6.0", "linux-x64", getTestProps(true)) + new { + name = "Run the tests" + run = "\(executableExpression)/PerformanceTests -f \"*\" --join" + } + new { + 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 { + 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" + + 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 +} else new gha.Job{}) { + name = "Test \(config.title)" + `runs-on` = runsOn + when (config.needsPackages) { + needs { + Common.job_Packages + when (config.runSyncTests) { + Common.job_Baas + } + } + } + `if` = Common.ifNotCanceledCondition + `timeout-minutes` = Common.testTimeout + steps = _steps.apply(config) +} + +local function prepareTests(config: TestConfig(needsPackages == true || !usedWrappers.isEmpty)): Listing = new Listing { + ...Steps.checkout(false) + ...cleanWorkspace(config.shouldCleanWorkspace) + ...fetchTestArtifacts(config.usedWrappers) + ...BaaS.deployStep(config.syncDifferentiator, config.runSyncTests) +} + +local function cleanWorkspace(shouldClean: Boolean): Listing = new Listing { + when (shouldClean) { + Steps.cleanupWorkspace() + } +} + +local function fetchTestArtifacts(wrappers: List(every((wrapper) -> Common.wrapperBinaryNames.contains(wrapper)))): List = + if (!wrappers.isEmpty) Steps.fetchWrappers(wrappers) + else Steps.fetchPackages(Common.nugetPackages) + +local function buildTests(config: Steps.MSBuildConfig): Listing = Steps.msbuild((config) { + properties { + ...getTestProps(config.standaloneExe) + } +}) + +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 = 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 { + name = "Transform Results" + run = "xsltproc --output \(__outputFile) Tests/Realm.Tests/EmbeddedResources/nunit3-junit.xslt \(_outputFile)" + } + } + new { + name = "Publish Unit Test Results" + uses = actionReportTestResults + `if` = "always()" + with { + ["name"] = "Results \(config.title)" + ["path"] = __outputFile + ["reporter"] = "java-junit" + ["list-suites"] = "failed" + ["path-replace-backslashes"] = true + ["fail-on-error"] = true + } + } +} + +local function getTestProps(standaloneExe: Boolean): Mapping = new Mapping { + ["RestoreConfigFile"] = "Tests/Test.NuGet.Config" + ["UseRealmNupkgsWithVersion"] = "${{ needs.\(Common.job_Packages).outputs.\(Steps.getVersionOutput) }}" + when (standaloneExe) { + ["RealmTestsStandaloneExe"] = "true" + } +} + +local function dotnetRunTests(enableCoreDumps: Boolean): Listing = new Listing { + new gha.Step { + name = "Run the tests" + run = "\(executableExpression) --result=\(outputFile) --labels=After" + } |> enableCoreDumps(enableCoreDumps) + when (enableCoreDumps) { + archiveCoreDump() + } +} + +local function enableCoreDumps(enable: Boolean): Mixin = new Mixin { + when (enable) { + env { + ["DOTNET_DbgEnableMiniDump"] = 1 + ["DOTNET_EnableCrashReport"] = 1 + } + } +} + +local function archiveCoreDump(): gha.Step = (Steps.uploadArtifacts("crash-report-net-core-${{ runner.os }}-${{ runner.arch }}", "/tmp/coredump*")) { + name = "Archive core dump" + `if` = "${{ failure() && runner.os != 'Windows' }}" + with { + ["retention-days"] = 30 + ["if-no-files-found"] = "warn" + } +} + +local class MatrixOS { + runner: "windows-latest" | "ubuntu-latest" | "macos-13" | "macos-14" + runtime: Common.NetRuntime +} + +local class TestConfig { + title: String + needsPackages: Boolean = false + usedWrappers: List(every((wrapper) -> Common.wrapperBinaryNames.contains(wrapper))) + shouldCleanWorkspace: Boolean = false + syncDifferentiator: Common.SyncDifferentiator? = null + transformResults: Boolean = false + syncDifferentiators: Listing? + runSyncTests: Boolean = syncDifferentiator != null && (syncDifferentiators?.toList()?.contains(syncDifferentiator) ?? false) +} diff --git a/.github/pkl-workflows/main.pkl b/.github/pkl-workflows/main.pkl new file mode 100644 index 0000000000..20e7df3ca8 --- /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 { + description = "Indicates whether to publish the package to Sleet/npm" + required = false + type = "boolean" + } + ["run-benchmark"] = new { + 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 new file mode 100644 index 0000000000..3f8de3eaef --- /dev/null +++ b/.github/pkl-workflows/pr.pkl @@ -0,0 +1,44 @@ +module pr + +amends "GithubAction/GithubAction.pkl" + +import "helpers/Common.pkl" + +local baasDifferentiators: Listing = new { + "code-coverage" +} + +local netCoreFrameworks: Listing = new { + "net6.0" +} + +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 = 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 new file mode 100644 index 0000000000..af5c685994 --- /dev/null +++ b/.github/pkl-workflows/publish-prerelease.pkl @@ -0,0 +1,25 @@ +module prerelease + +amends "GithubAction/GithubAction.pkl" + +import "helpers/Common.pkl" +import "helpers/Steps.pkl" + +name = "Publish Prerelease" +on { + workflow_dispatch{} +} +env = Common.defaultEnv +jobs { + ["main"] = new Job { + `runs-on` = new UbuntuLatest{} + name = "Publish package to S3" + steps { + Steps.checkoutWithoutMatchers(false) + Steps.downloadAllArtifacts() + Steps.readVersionFromPackage() + ...Steps.uploadPackagesToSleet(Steps.getVersionExpresssion, false) + ...Steps.uploadToNPM("alpha") + } + } +} diff --git a/.github/pkl-workflows/publish-release.pkl b/.github/pkl-workflows/publish-release.pkl new file mode 100644 index 0000000000..ea65adf8c0 --- /dev/null +++ b/.github/pkl-workflows/publish-release.pkl @@ -0,0 +1,142 @@ +module release + +amends "GithubAction/GithubAction.pkl" + +import "helpers/Common.pkl" +import "helpers/Steps.pkl" +import "helpers/Actions.pkl" + +name = "Publish Release" +on { + workflow_dispatch{} +} +env = Common.defaultEnv +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 { + 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 { + 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 { + 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 { + name = "Merge Pull Request" + uses = Actions.mergePR + with { + ["github-token"] = "${{ secrets.GITHUB_TOKEN }}" + ["number"] = numberExpression + ["method"] = "squash" + } +} + +local function publishGithubReleasee(): Step = new { + 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 { + local create_pr_step = "vnext-pr" + new { + 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 { + 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 { + 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/pkl-workflows/wrappers.pkl b/.github/pkl-workflows/wrappers.pkl new file mode 100644 index 0000000000..d060332803 --- /dev/null +++ b/.github/pkl-workflows/wrappers.pkl @@ -0,0 +1,202 @@ +module wrappers + +amends "GithubAction/GithubAction.pkl" + +import "helpers/Common.pkl" +import "helpers/Steps.pkl" +import "helpers/Actions.pkl" + +local job_CheckCache = "check-cache" + +local WrappersBuildTimeout = 90 +local WrappersCacheCondition = "steps.check-cache.outputs.cache-hit != 'true'" + +name = "wrappers" +on { + workflow_call {} +} +env = Common.defaultEnv + +jobs { + [job_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.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'") + 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("14") + } + ifCondition = "\(Common.applePlatformTargets((platform, target) -> "needs.\(job_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 { + 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-uwp-${{ 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?): Mixin = new { + `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.restoreCache +} |> cacheStep(platform, platform) + +local function checkCache(platform: String): Step = new Step { + uses = Actions.cache +} |> cacheStep(platform, null) + +local function cacheStep(platform: String, idSuffix: String?): Mixin = new { + 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): Mixin = new { + `timeout-minutes` = WrappersBuildTimeout + needs { + job_CheckCache + } + `if` = config.ifCondition + steps { + Steps.checkoutWithoutMatchers("recursive") + checkCache(config.platform) + ...config.intermediateSteps.toList().map((step) -> (step) { + `if` = WrappersCacheCondition + }) + new { + 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/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-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/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/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/common.lib.yml b/.github/templates/common.lib.yml deleted file mode 100644 index cd4e6cb582..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@v3" -#@ actionDownloadArtifact = "actions/download-artifact@v3" -#@ 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/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/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/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/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-code-coverage.yml b/.github/templates/test-code-coverage.yml deleted file mode 100644 index 5e01ad8d95..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@v3 - 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/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/templates/test-net-core.yml b/.github/templates/test-net-core.yml deleted file mode 100644 index c2dc524126..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@v3 - 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-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/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-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/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/templates/test-weaver.yml b/.github/templates/test-weaver.yml deleted file mode 100644 index 06377ba431..0000000000 --- a/.github/templates/test-weaver.yml +++ /dev/null @@ -1,34 +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: - fail-fast: false - 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/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/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/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/build-packages.yml b/.github/workflows/build-packages.yml deleted file mode 100755 index 051719deb3..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@v3 - with: - name: wrappers-macos - path: wrappers/build - - name: Fetch artifacts for catalyst - uses: actions/download-artifact@v3 - with: - name: wrappers-catalyst - path: wrappers/build - - name: Fetch artifacts for linux-x86_64 - uses: actions/download-artifact@v3 - with: - name: wrappers-linux-x86_64 - path: wrappers/build - - name: Fetch artifacts for linux-armhf - uses: actions/download-artifact@v3 - with: - name: wrappers-linux-armhf - path: wrappers/build - - name: Fetch artifacts for linux-aarch64 - uses: actions/download-artifact@v3 - with: - name: wrappers-linux-aarch64 - path: wrappers/build - - name: Fetch artifacts for iOS-Device - uses: actions/download-artifact@v3 - with: - name: wrappers-iOS-Device - path: wrappers/build - - name: Fetch artifacts for iOS-Simulator - uses: actions/download-artifact@v3 - with: - name: wrappers-iOS-Simulator - path: wrappers/build - - name: Fetch artifacts for tvOS-Device - uses: actions/download-artifact@v3 - with: - name: wrappers-tvOS-Device - path: wrappers/build - - name: Fetch artifacts for tvOS-Simulator - uses: actions/download-artifact@v3 - with: - name: wrappers-tvOS-Simulator - path: wrappers/build - - name: Fetch artifacts for android-armeabi-v7a - uses: actions/download-artifact@v3 - with: - name: wrappers-android-armeabi-v7a - path: wrappers/build - - name: Fetch artifacts for android-arm64-v8a - uses: actions/download-artifact@v3 - with: - name: wrappers-android-arm64-v8a - path: wrappers/build - - name: Fetch artifacts for android-x86 - uses: actions/download-artifact@v3 - with: - name: wrappers-android-x86 - path: wrappers/build - - name: Fetch artifacts for android-x86_64 - uses: actions/download-artifact@v3 - with: - name: wrappers-android-x86_64 - path: wrappers/build - - name: Fetch artifacts for windows-Win32 - uses: actions/download-artifact@v3 - with: - name: wrappers-windows-Win32 - path: wrappers/build - - name: Fetch artifacts for windows-x64 - uses: actions/download-artifact@v3 - with: - name: wrappers-windows-x64 - path: wrappers/build - - name: Fetch artifacts for windows-ARM64 - uses: actions/download-artifact@v3 - with: - name: wrappers-windows-ARM64 - path: wrappers/build - - name: Fetch artifacts for windows-uwp-Win32 - uses: actions/download-artifact@v3 - with: - name: wrappers-windows-uwp-Win32 - path: wrappers/build - - name: Fetch artifacts for windows-uwp-x64 - uses: actions/download-artifact@v3 - with: - name: wrappers-windows-uwp-x64 - path: wrappers/build - - name: Fetch artifacts for windows-uwp-ARM - uses: actions/download-artifact@v3 - with: - name: wrappers-windows-uwp-ARM - path: wrappers/build - - name: Fetch artifacts for windows-uwp-ARM64 - uses: actions/download-artifact@v3 - 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@v3 - 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 - 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 - 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 - 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 - 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@v3 - 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 178da4b8a0..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@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: Fetch Realm.UnityUtils - uses: actions/download-artifact@v3 - with: - name: Realm.UnityUtils.${{ inputs.version }} - path: ${{ github.workspace }}/Realm/packages/ - - name: Fetch Realm.UnityWeaver - uses: actions/download-artifact@v3 - 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@v3 - 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 - 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@v3 - 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/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 diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index 533a060bec..a7d2f8b2bf 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,53 @@ 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" + - exclude: + id: cs/call-to-unmanaged-code + - exclude: + id: cs/unmanaged-code - 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/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/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/main.yml b/.github/workflows/main.yml index 573602e82a..75accee0d5 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,265 +21,1501 @@ 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: 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 }} + 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: - runs-on: ubuntu-latest - name: Publish package to S3 + 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') && (github.event_name == 'push' || github.event.inputs.publish-prerelease) + 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@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@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 + - name: Fetch Realm.UnityUtils + uses: actions/download-artifact@v4 with: - name: Realm.${{ needs.build-packages.outputs.package_version }} + name: Realm.UnityUtils.${{ needs.build-packages.outputs.package_version }} path: ${{ github.workspace }}/Realm/packages/ - - name: Configure .NET - uses: actions/setup-dotnet@3e6b9fe3930cac7c59c651af5de1514b47a805b9 + - name: Fetch Realm.UnityWeaver + uses: actions/download-artifact@v4 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 + 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: - 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 }} + 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') - test-net-framework: - uses: ./.github/workflows/test-net-framework.yml - name: Test + 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 + 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 - 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: 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 - 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 }} + 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') - name: Test + 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 - 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 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 - with: - version: ${{ needs.build-packages.outputs.package_version }} - secrets: - BaaSaasApiKey: ${{ secrets.BAASAAS_API_KEY }} - test-ios: - uses: ./.github/workflows/test-ios.yml - name: Test 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 - with: - version: ${{ needs.build-packages.outputs.package_version }} - secrets: - BaaSaasApiKey: ${{ secrets.BAASAAS_API_KEY }} - test-tvos: - uses: ./.github/workflows/test-tvos.yml - name: Test 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 - 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') + 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.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 - - 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: + if: always() && !cancelled() && !contains(needs.*.result, 'failure') && !contains(needs.*.result, 'cancelled') + timeout-minutes: 60 runs-on: windows-latest - name: Test xUnit Compatibility - timeout-minutes: 10 + 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: 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@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: 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 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@v3 + - 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 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: 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@v3 + 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 + 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@v3 + uses: actions/download-artifact@v4 with: name: Realm.${{ 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 + - 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/Tests.XUnit/bin/Release/net6.0/win-x64' >> $GITHUB_OUTPUT + run: echo 'executable-path=./Tests/Realm.Tests/bin/Release/net8.0/win-x64/Realm.Tests' >> $GITHUB_OUTPUT shell: bash - - name: Run Tests - run: dotnet test ${{ steps.dotnet-publish.outputs.executable-path }}/Tests.XUnit.dll --logger GitHubActions + - 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') + 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: - uses: ./.github/workflows/test-weaver.yml - name: Test + 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: - uses: ./.github/workflows/test-code-coverage.yml - name: Test + name: Test Code Coverage + needs: + - 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: + - 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: 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 }} + 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 }} - 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) + 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') && (github.event_name == 'push' || github.event.inputs.publish-prerelease) }} + 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/ + - 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: 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: 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@v3 + 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 --no-self-contained + - name: Output executable path + id: dotnet-publish + 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 + benchmark-linux: + name: Test Benchmark + needs: + - build-packages + 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: 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@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@v4 + with: + name: Realm.PlatformHelpers.${{ needs.build-packages.outputs.package_version }} + path: ${{ github.workspace }}/Realm/packages/ - name: Clear nuget cache run: dotnet nuget locals all --clear - name: Publish Tests/Benchmarks/PerformanceTests 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 }} 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 - 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 6529e3a712..103f093b65 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,202 +27,1330 @@ 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: - 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: 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: 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 }} + strategy: + matrix: + differentiator: + - code-coverage + fail-fast: false build-packages: - uses: ./.github/workflows/build-packages.yml - name: Package + name: Package NuGet needs: - build-wrappers - with: - build-docs: ${{ contains(github.head_ref, 'release') }} + 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: - uses: ./.github/workflows/build-unity.yml - name: Package - with: - version: ${{ needs.build-packages.outputs.package_version }} + name: Package Unity needs: - build-packages if: always() && !cancelled() && !contains(needs.*.result, 'failure') && !contains(needs.*.result, 'cancelled') - test-unity: - 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" }]' + 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') - test-net-framework: - uses: ./.github/workflows/test-net-framework.yml - name: Test + 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 + 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 - 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') + 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: 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 ' + - 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 - with: - version: ${{ needs.build-packages.outputs.package_version }} - secrets: - Pfx_Password: ${{ secrets.Pfx_Password }} - Base64_Encoded_Pfx: ${{ secrets.Base64_Encoded_Pfx }} + 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: 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 '' + 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') - name: Test + 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 + 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 - 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') + 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/ + - 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 ' + - 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 - 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') + 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 - with: - version: ${{ needs.build-packages.outputs.package_version }} - secrets: {} + 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/ + - 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 ' + 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: - uses: ./.github/workflows/test-tvos.yml - name: Test + name: Test Xamarin.tvOS + 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.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 - 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') + 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: 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@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: 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 - 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-weaved-classes: if: always() && !cancelled() && !contains(needs.*.result, 'failure') && !contains(needs.*.result, 'cancelled') - name: Test + 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/ + - 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 - uses: ./.github/workflows/test-woven-classes.yml - with: - version: ${{ needs.build-packages.outputs.package_version }} + 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/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') - name: Test - uses: ./.github/workflows/test-source-generation.yml + 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: - uses: ./.github/workflows/test-weaver.yml - name: Test - test-code-coverage: - uses: ./.github/workflows/test-code-coverage.yml - name: Test + 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 }} + - 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: - uses: ./.github/workflows/cleanup-baas.yml - if: always() - name: Cleanup + name: Cleanup BaaS needs: - - deploy-baas - test-code-coverage - with: - differentiators: '["code-coverage"]' - secrets: - BaaSaasApiKey: ${{ secrets.BAASAAS_API_KEY }} - verify-namespaces: + 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: 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 }} + strategy: + matrix: + differentiator: + - code-coverage + fail-fast: false + verify-namespaces: name: Verify Namespaces needs: - build-packages + runs-on: ubuntu-latest steps: - - name: Checkout code - uses: actions/checkout@v3 + - name: Checkout Code + uses: actions/checkout@v4 with: - submodules: recursive + submodules: false ref: ${{ github.event.pull_request.head.sha }} - - 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 - 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@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/ - 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 + 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]+ diff --git a/.github/workflows/publish-prerelease.yml b/.github/workflows/publish-prerelease.yml index f5c9a36f02..45019006a8 100644 --- a/.github/workflows/publish-prerelease.yml +++ b/.github/workflows/publish-prerelease.yml @@ -1,50 +1,56 @@ +# 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: {} +env: + REALM_DISABLE_ANALYTICS: true + DOTNET_NOLOGO: true 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 diff --git a/.github/workflows/publish-release.yml b/.github/workflows/publish-release.yml index e04b5a7aaa..71d54d3e24 100755 --- a/.github/workflows/publish-release.yml +++ b/.github/workflows/publish-release.yml @@ -1,78 +1,86 @@ +# 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: {} +env: + REALM_DISABLE_ANALYTICS: true + DOTNET_NOLOGO: true 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 +99,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 +108,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 +119,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 }} diff --git a/.github/workflows/test-android.yml b/.github/workflows/test-android.yml deleted file mode 100755 index 879350e3a1..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@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=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@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: 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-code-coverage.yml b/.github/workflows/test-code-coverage.yml deleted file mode 100755 index de8242ef77..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@v3 - with: - name: wrappers-macos - path: wrappers/build - - name: Fetch artifacts for catalyst - uses: actions/download-artifact@v3 - with: - name: wrappers-catalyst - path: wrappers/build - - name: Fetch artifacts for linux-x86_64 - uses: actions/download-artifact@v3 - with: - name: wrappers-linux-x86_64 - path: wrappers/build - - name: Fetch artifacts for linux-armhf - uses: actions/download-artifact@v3 - with: - name: wrappers-linux-armhf - path: wrappers/build - - name: Fetch artifacts for linux-aarch64 - uses: actions/download-artifact@v3 - with: - name: wrappers-linux-aarch64 - path: wrappers/build - - name: Fetch artifacts for iOS-Device - uses: actions/download-artifact@v3 - with: - name: wrappers-iOS-Device - path: wrappers/build - - name: Fetch artifacts for iOS-Simulator - uses: actions/download-artifact@v3 - with: - name: wrappers-iOS-Simulator - path: wrappers/build - - name: Fetch artifacts for tvOS-Device - uses: actions/download-artifact@v3 - with: - name: wrappers-tvOS-Device - path: wrappers/build - - name: Fetch artifacts for tvOS-Simulator - uses: actions/download-artifact@v3 - with: - name: wrappers-tvOS-Simulator - path: wrappers/build - - name: Fetch artifacts for android-armeabi-v7a - uses: actions/download-artifact@v3 - with: - name: wrappers-android-armeabi-v7a - path: wrappers/build - - name: Fetch artifacts for android-arm64-v8a - uses: actions/download-artifact@v3 - with: - name: wrappers-android-arm64-v8a - path: wrappers/build - - name: Fetch artifacts for android-x86 - uses: actions/download-artifact@v3 - with: - name: wrappers-android-x86 - path: wrappers/build - - name: Fetch artifacts for android-x86_64 - uses: actions/download-artifact@v3 - with: - name: wrappers-android-x86_64 - path: wrappers/build - - name: Fetch artifacts for windows-Win32 - uses: actions/download-artifact@v3 - with: - name: wrappers-windows-Win32 - path: wrappers/build - - name: Fetch artifacts for windows-x64 - uses: actions/download-artifact@v3 - with: - name: wrappers-windows-x64 - path: wrappers/build - - name: Fetch artifacts for windows-ARM64 - uses: actions/download-artifact@v3 - with: - name: wrappers-windows-ARM64 - path: wrappers/build - - name: Fetch artifacts for windows-uwp-Win32 - uses: actions/download-artifact@v3 - with: - name: wrappers-windows-uwp-Win32 - path: wrappers/build - - name: Fetch artifacts for windows-uwp-x64 - uses: actions/download-artifact@v3 - with: - name: wrappers-windows-uwp-x64 - path: wrappers/build - - name: Fetch artifacts for windows-uwp-ARM - uses: actions/download-artifact@v3 - with: - name: wrappers-windows-uwp-ARM - path: wrappers/build - - name: Fetch artifacts for windows-uwp-ARM64 - uses: actions/download-artifact@v3 - 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@v3 - 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 diff --git a/.github/workflows/test-ios.yml b/.github/workflows/test-ios.yml deleted file mode 100755 index 1154de38ad..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@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=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@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: 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 80f39ada4d..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@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=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@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: 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 diff --git a/.github/workflows/test-net-core.yml b/.github/workflows/test-net-core.yml deleted file mode 100755 index b7b81910f3..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@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: 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@v3 - 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-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 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 diff --git a/.github/workflows/test-tvos.yml b/.github/workflows/test-tvos.yml deleted file mode 100755 index 396f232543..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@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: 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-unity.yml b/.github/workflows/test-unity.yml deleted file mode 100755 index 8a41017505..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@v3 - with: - name: io.realm.unity-${{ inputs.version }}.tgz - path: Realm/Realm.Unity - - name: Fetch Unity Tests - uses: actions/download-artifact@v3 - 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@v3 - 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@v3 - 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@v3 - 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 diff --git a/.github/workflows/test-uwp-managed.yml b/.github/workflows/test-uwp-managed.yml deleted file mode 100755 index 18cd63991a..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@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=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/.github/workflows/test-weaver.yml b/.github/workflows/test-weaver.yml deleted file mode 100755 index d4b21050e7..0000000000 --- a/.github/workflows/test-weaver.yml +++ /dev/null @@ -1,60 +0,0 @@ -name: test-weaver -"on": - workflow_call: null -env: - REALM_DISABLE_ANALYTICS: true - DOTNET_NOLOGO: true -jobs: - run-tests-weaver: - strategy: - fail-fast: false - 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 diff --git a/.github/workflows/test-woven-classes.yml b/.github/workflows/test-woven-classes.yml deleted file mode 100644 index a81b28827d..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@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: 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 diff --git a/.github/workflows/wrappers.yml b/.github/workflows/wrappers.yml index ea7020c00f..a570993417 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,618 @@ 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 + path: wrappers/build/** + 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 + path: wrappers/build/** + 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 + path: wrappers/build/** + 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 + path: wrappers/build/** + 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 - 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 + uses: actions/upload-artifact@v4 with: - name: wrappers-tvOS-Simulator - path: ${{ github.workspace }}/wrappers/build/** - retention-days: 1 + name: wrappers-linux-aarch64 + path: wrappers/build/** + 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 + path: wrappers/build/** + 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 + path: wrappers/build/** + 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 + path: wrappers/build/** + 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 + path: wrappers/build/** + 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 + path: wrappers/build/** + 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 + path: wrappers/build/** + 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 + path: wrappers/build/** + 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 + path: wrappers/build/** + 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 + path: wrappers/build/** + 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 + path: wrappers/build/** + 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 + path: wrappers/build/** + 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: 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: 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: 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: 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 + fail-fast: false 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 + path: wrappers/build/** + 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 -Configuration Release -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 + path: wrappers/build/** + 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 }} -Configuration Release ' - 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 + path: wrappers/build/** + 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 + fail-fast: false + 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 + path: wrappers/build/** + 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 + fail-fast: false + 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 + path: wrappers/build/** + 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 + fail-fast: false + 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 + 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' - - name: Build wrappers run: pwsh ./wrappers/build.ps1 Windows -Platforms ${{ matrix.arch }} -ExtraCMakeArgs "-T v143,version=14.35" -Configuration Release -EnableLTO - if: steps.check-cache.outputs.cache-hit != 'true' - 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 + path: wrappers/build/** + 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 + fail-fast: false + 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-uwp-${{ 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/**')}} - 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 + 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' - - name: Build wrappers run: pwsh ./wrappers/build.ps1 WindowsStore -Platforms ${{ matrix.arch }} -ExtraCMakeArgs "-T v143,version=14.35" -Configuration Release -EnableLTO - if: steps.check-cache.outputs.cache-hit != 'true' - name: Store artifacts for wrappers-windows-uwp-${{ matrix.arch }} - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: wrappers-windows-uwp-${{ matrix.arch }} - path: ${{ github.workspace }}/wrappers/build/** - retention-days: 1 + path: wrappers/build/** + 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 + fail-fast: false diff --git a/Tests/Realm.Tests/Database/DynamicAccessTests.cs b/Tests/Realm.Tests/Database/DynamicAccessTests.cs index 4e31047325..2cc7017a26 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'); @@ -86,14 +79,7 @@ public void SimpleTest() 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'; @@ -297,10 +283,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 +477,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 +488,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 +500,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 +512,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 +524,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 +658,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 +669,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 +707,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 +719,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 +760,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 +772,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 +784,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 +796,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 +822,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 +843,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 +855,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 +867,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 +879,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 +905,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 +926,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 +938,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 +950,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 +962,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 +989,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..fc4f843254 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 { @@ -718,7 +718,7 @@ 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 !UNITY Assert.Throws(() => @@ -963,7 +963,7 @@ public void Dictionary_Remove() #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"); @@ -971,8 +971,6 @@ public void Dictionary_Remove() first.Summary = "first"; second.Summary = "second"; - - return second; }); dynamic dynamicParent = realm.DynamicApi.Find(nameof(DynamicTask), dynamicId)!; @@ -1012,10 +1010,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)!; @@ -1045,8 +1043,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)!; diff --git a/Tests/Realm.Tests/Database/InstanceTests.cs b/Tests/Realm.Tests/Database/InstanceTests.cs index 509d07f409..91b956c96b 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 { diff --git a/Tests/Realm.Tests/Database/MigrationTests.cs b/Tests/Realm.Tests/Database/MigrationTests.cs index d507100660..b913064762 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,11 +23,18 @@ 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 { [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!; } } diff --git a/Tests/Realm.Tests/Database/PrimaryKeyTests.cs b/Tests/Realm.Tests/Database/PrimaryKeyTests.cs index af372e9d90..ecab20f06d 100644 --- a/Tests/Realm.Tests/Database/PrimaryKeyTests.cs +++ b/Tests/Realm.Tests/Database/PrimaryKeyTests.cs @@ -165,7 +165,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 7f109511fc..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": @@ -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/Realm.Tests/Sync/AsymmetricObjectTests.cs b/Tests/Realm.Tests/Sync/AsymmetricObjectTests.cs index cea99a78f0..21c83b068e 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 { 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 () => 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) 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