Skip to content

Commit

Permalink
Target .NET 6 (#2906)
Browse files Browse the repository at this point in the history
* wip

* multi-target the Realm assembly

* update workflows for the new xcframework-less build

* update workflow if condition for iOS wrappers caching

* try change the changelog path

* fix up package paths

* fix up more paths

* fix even more paths

* fix unity packaging

* codeQL .net 6

* Add test project

* teach VSCode the default solution

* changelog

* Disable String.Contains(string, StringComparison) in newer .NET
  • Loading branch information
fealebenpae authored May 5, 2022
1 parent ce874c4 commit 441a08e
Show file tree
Hide file tree
Showing 64 changed files with 1,210 additions and 196 deletions.
7 changes: 6 additions & 1 deletion .github/templates/codeql.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#@ load("@ytt:template", "template")
#@ load("common.lib.yml", "configuration", "nugetPackages", "checkoutCode", "setupVcpkg", "actionCodeQLInit", "actionCodeQLAnalyze", "actionSetupMSBuild")
#@ load("common.lib.yml", "configuration", "nugetPackages", "checkoutCode", "setupVcpkg", "actionCodeQLInit", "actionCodeQLAnalyze", "actionSetupMSBuild", "actionSetupDotnet")

#@ def runCodeQL(language, buildSteps = []):
- name: Initialize CodeQL
Expand All @@ -22,6 +22,11 @@
#@ def buildPackages():
- name: Add msbuild to PATH
uses: #@ actionSetupMSBuild
- name: Configure .NET 6
uses: #@ actionSetupDotnet
with:
dotnet-version: '6.0.x'
include-prerelease: true
#@ for pkgName in nugetPackages:
- name: #@ "Build " + pkgName
run: #@ "msbuild Realm/" + pkgName + " -p:UseSharedCompilation=false -restore -p:Configuration=" + configuration
Expand Down
5 changes: 4 additions & 1 deletion .github/templates/common.lib.yml
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,10 @@ with:
#@ end

#@ def getWrapperBinaryNames():
#@ wrapperPlatforms = [ 'macos', 'ios', 'linux' ]
#@ wrapperPlatforms = [ 'macos', 'linux' ]
#@ for iOSArch in iOSArchs:
#@ wrapperPlatforms.append("ios-" + iOSArch)
#@ end
#@ for androidABI in androidABIs:
#@ wrapperPlatforms.append("android-" + androidABI)
#@ end
Expand Down
41 changes: 5 additions & 36 deletions .github/templates/wrappers.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,17 +48,6 @@ steps:
- #@ uploadArtifacts(outputVar, artifactsPath, 1)
#@ end

#@ def fetchiOSFrameworks():
#@ for platform in iOSArchs:
- name: #@ "Fetch Framework for " + platform
uses: #@ actionDownloadArtifact
with:
name: #@ "wrappers-ios-" + platform
path: wrappers/cmake
if: #@ wrappersCacheCondition
#@ end
#@ end

---
name: wrappers
"on":
Expand Down Expand Up @@ -97,35 +86,15 @@ jobs:
runs-on: macos-latest
name: macOS
_: #@ template.replace(buildWrappers("./wrappers/build-macos.sh", "wrappers-macos"))
ios-frameworks:
ios:
runs-on: macos-latest
name: iOS frameworks
name: iOS
strategy:
matrix:
arch: #@ iOSArchs
_: #@ template.replace(buildWrappers("pwsh ./wrappers/build-ios.ps1 ${{ matrix.arch }} -SkipXCFramework", "wrappers-ios-${{ matrix.arch }}", enableLto = False, artifactsPath = "wrappers/cmake/**/realm-wrappers.framework", cacheVariable = "wrappers-ios"))
ios:
runs-on: macos-latest
name: iOS XCframework
needs:
- check-cache
- ios-frameworks
if: needs.check-cache.outputs.wrappers-ios != 'true'
timeout-minutes: #@ wrappersTimeout
steps:
- #@ template.replace(checkoutCode("recursive", False))
- #@ checkCache("wrappers-ios")
- #@ template.replace(fetchiOSFrameworks())
- name: Create xcframework
#@yaml/text-templated-strings
run: |
$build_directory = "${{ github.workspace }}/wrappers/cmake/iOS"
$install_prefix = "${{ github.workspace }}/wrappers/build"
$xcframework_path = "$install_prefix/iOS/(@= configuration @)/realm-wrappers.xcframework"
xcodebuild -create-xcframework -framework $build_directory/src/(@= configuration @)-iphonesimulator/realm-wrappers.framework -framework $build_directory/src/(@= configuration @)-iphoneos/realm-wrappers.framework -output "$xcframework_path"
shell: powershell
if: #@ wrappersCacheCondition
- #@ uploadArtifacts("wrappers-ios", "wrappers/build/**", 1)
_: #@ template.replace(buildWrappers("pwsh ./wrappers/build-ios.ps1 ${{ matrix.arch }}", "wrappers-ios-${{ matrix.arch }}", enableLto = False))
#@yaml/map-key-override
if: #@ " || ".join([ "needs.check-cache.outputs.wrappers-ios-" + x + " != 'true'" for x in iOSArchs ])
linux:
runs-on: ubuntu-latest
name: Linux
Expand Down
13 changes: 9 additions & 4 deletions .github/workflows/build-packages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,15 +50,20 @@ jobs:
with:
name: wrappers-macos
path: wrappers/build
- name: Fetch artifacts for ios
- name: Fetch artifacts for linux
uses: actions/download-artifact@v2
with:
name: wrappers-ios
name: wrappers-linux
path: wrappers/build
- name: Fetch artifacts for linux
- name: Fetch artifacts for ios-Simulator
uses: actions/download-artifact@v2
with:
name: wrappers-linux
name: wrappers-ios-Simulator
path: wrappers/build
- name: Fetch artifacts for ios-Device
uses: actions/download-artifact@v2
with:
name: wrappers-ios-Device
path: wrappers/build
- name: Fetch artifacts for android-armeabi-v7a
uses: actions/download-artifact@v2
Expand Down
5 changes: 5 additions & 0 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,11 @@ jobs:
queries: security-and-quality
- name: Add msbuild to PATH
uses: microsoft/[email protected]
- name: Configure .NET 6
uses: actions/setup-dotnet@v1
with:
dotnet-version: 6.0.x
include-prerelease: true
- name: Build Realm.Fody
run: msbuild Realm/Realm.Fody -p:UseSharedCompilation=false -restore -p:Configuration=Release
- name: Build Realm
Expand Down
13 changes: 9 additions & 4 deletions .github/workflows/test-code-coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,20 @@ jobs:
with:
name: wrappers-macos
path: wrappers/build
- name: Fetch artifacts for ios
- name: Fetch artifacts for linux
uses: actions/download-artifact@v2
with:
name: wrappers-ios
name: wrappers-linux
path: wrappers/build
- name: Fetch artifacts for linux
- name: Fetch artifacts for ios-Simulator
uses: actions/download-artifact@v2
with:
name: wrappers-linux
name: wrappers-ios-Simulator
path: wrappers/build
- name: Fetch artifacts for ios-Device
uses: actions/download-artifact@v2
with:
name: wrappers-ios-Device
path: wrappers/build
- name: Fetch artifacts for android-armeabi-v7a
uses: actions/download-artifact@v2
Expand Down
99 changes: 35 additions & 64 deletions .github/workflows/wrappers.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@ jobs:
CACHE_SKIP_SAVE: true
outputs:
wrappers-macos: ${{ steps.check-cache-macos.outputs.cache-hit }}
wrappers-ios: ${{ steps.check-cache-ios.outputs.cache-hit }}
wrappers-linux: ${{ steps.check-cache-linux.outputs.cache-hit }}
wrappers-ios-Simulator: ${{ steps.check-cache-ios-Simulator.outputs.cache-hit }}
wrappers-ios-Device: ${{ steps.check-cache-ios-Device.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 }}
Expand Down Expand Up @@ -52,36 +53,52 @@ jobs:
if: matrix.os == 'ubuntu' && steps.check-cache-macos.outputs.cache-hit == 'true'
- run: git clean -fdx
if: matrix.os == 'ubuntu'
- name: Check cache for ios
id: check-cache-ios
- name: Check cache for linux
id: check-cache-linux
uses: nirinchev/cache@d7c96a77c26ab70dd32b202c885cb4b34d95d8a8
with:
path: ./wrappers/build/**
key: wrappers-ios-Release-${{hashFiles('./wrappers/**')}}
key: wrappers-linux-Release-${{hashFiles('./wrappers/**')}}
if: matrix.os == 'ubuntu'
- name: Store artifacts for wrappers-ios
- name: Store artifacts for wrappers-linux
uses: actions/upload-artifact@v2
with:
name: wrappers-ios
name: wrappers-linux
path: ${{ github.workspace }}/wrappers/build/**
retention-days: 1
if: matrix.os == 'ubuntu' && steps.check-cache-ios.outputs.cache-hit == 'true'
if: matrix.os == 'ubuntu' && steps.check-cache-linux.outputs.cache-hit == 'true'
- run: git clean -fdx
if: matrix.os == 'ubuntu'
- name: Check cache for linux
id: check-cache-linux
- name: Check cache for ios-Simulator
id: check-cache-ios-Simulator
uses: nirinchev/cache@d7c96a77c26ab70dd32b202c885cb4b34d95d8a8
with:
path: ./wrappers/build/**
key: wrappers-linux-Release-${{hashFiles('./wrappers/**')}}
key: wrappers-ios-Simulator-Release-${{hashFiles('./wrappers/**')}}
if: matrix.os == 'ubuntu'
- name: Store artifacts for wrappers-linux
- name: Store artifacts for wrappers-ios-Simulator
uses: actions/upload-artifact@v2
with:
name: wrappers-linux
name: wrappers-ios-Simulator
path: ${{ github.workspace }}/wrappers/build/**
retention-days: 1
if: matrix.os == 'ubuntu' && steps.check-cache-linux.outputs.cache-hit == 'true'
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 ios-Device
id: check-cache-ios-Device
uses: nirinchev/cache@d7c96a77c26ab70dd32b202c885cb4b34d95d8a8
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@v2
with:
name: wrappers-ios-Device
path: ${{ github.workspace }}/wrappers/build/**
retention-days: 1
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 android-armeabi-v7a
Expand Down Expand Up @@ -288,9 +305,9 @@ jobs:
name: wrappers-macos
path: ${{ github.workspace }}/wrappers/build/**
retention-days: 1
ios-frameworks:
ios:
runs-on: macos-latest
name: iOS frameworks
name: iOS
strategy:
matrix:
arch:
Expand All @@ -299,7 +316,6 @@ jobs:
timeout-minutes: 90
needs:
- check-cache
if: needs.check-cache.outputs.wrappers-ios != 'true'
steps:
- name: Checkout code
uses: actions/checkout@v2
Expand All @@ -310,63 +326,18 @@ jobs:
id: check-cache
uses: nirinchev/cache@d7c96a77c26ab70dd32b202c885cb4b34d95d8a8
with:
path: ./wrappers/cmake/**/realm-wrappers.framework
path: ./wrappers/build/**
key: wrappers-ios-${{ matrix.arch }}-Release-${{hashFiles('./wrappers/**')}}
- name: Build wrappers
run: pwsh ./wrappers/build-ios.ps1 ${{ matrix.arch }} -SkipXCFramework -Configuration Release
run: pwsh ./wrappers/build-ios.ps1 ${{ matrix.arch }} -Configuration Release
if: steps.check-cache.outputs.cache-hit != 'true'
- name: Store artifacts for wrappers-ios-${{ matrix.arch }}
uses: actions/upload-artifact@v2
with:
name: wrappers-ios-${{ matrix.arch }}
path: ${{ github.workspace }}/wrappers/cmake/**/realm-wrappers.framework
retention-days: 1
ios:
runs-on: macos-latest
name: iOS XCframework
needs:
- check-cache
- ios-frameworks
if: needs.check-cache.outputs.wrappers-ios != 'true'
timeout-minutes: 90
steps:
- name: Checkout code
uses: actions/checkout@v2
with:
submodules: recursive
ref: ${{ github.event.pull_request.head.sha }}
- name: Check cache
id: check-cache
uses: nirinchev/cache@d7c96a77c26ab70dd32b202c885cb4b34d95d8a8
with:
path: ./wrappers/build/**
key: wrappers-ios-Release-${{hashFiles('./wrappers/**')}}
- name: Fetch Framework for Simulator
uses: actions/download-artifact@v2
with:
name: wrappers-ios-Simulator
path: wrappers/cmake
if: steps.check-cache.outputs.cache-hit != 'true'
- name: Fetch Framework for Device
uses: actions/download-artifact@v2
with:
name: wrappers-ios-Device
path: wrappers/cmake
if: steps.check-cache.outputs.cache-hit != 'true'
- name: Create xcframework
run: |
$build_directory = "${{ github.workspace }}/wrappers/cmake/iOS"
$install_prefix = "${{ github.workspace }}/wrappers/build"
$xcframework_path = "$install_prefix/iOS/Release/realm-wrappers.xcframework"
xcodebuild -create-xcframework -framework $build_directory/src/Release-iphonesimulator/realm-wrappers.framework -framework $build_directory/src/Release-iphoneos/realm-wrappers.framework -output "$xcframework_path"
shell: powershell
if: steps.check-cache.outputs.cache-hit != 'true'
- name: Store artifacts for wrappers-ios
uses: actions/upload-artifact@v2
with:
name: wrappers-ios
path: ${{ github.workspace }}/wrappers/build/**
retention-days: 1
if: needs.check-cache.outputs.wrappers-ios-Simulator != 'true' || needs.check-cache.outputs.wrappers-ios-Device != 'true'
linux:
runs-on: ubuntu-latest
name: Linux
Expand Down
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"omnisharp.defaultLaunchSolution": "Realm.sln"
}
5 changes: 3 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
## vNext (TBD)

### Enhancements
* None
* Preview support for .NET 6 with iOS, Android, and MAUI.
We've added tentative support for the new .NET 6 Mobile workloads (except MacCatalyst, which will be enabled later). The .NET tooling itself is still in preview so we don't have good test coverage of the new platforms just yet. Please report any issues you find at https://github.com/realm/realm-dotnet/issues/new/choose.

### Fixed
* None
Expand All @@ -10,7 +11,7 @@
* Realm Studio: 11.0.0 or later.

### Internal
* Using Core x.y.z.
* Using Core 11.14.0.

## 10.11.2 (2022-04-12)

Expand Down
Loading

0 comments on commit 441a08e

Please sign in to comment.