Skip to content

Commit

Permalink
Improve Build and CI workflows (#2241)
Browse files Browse the repository at this point in the history
* Update Android workflow

* Update iOS workflow

* Update main build workflow

* Support conditional removing of platforms (helps with workloads)

* Reduce Sentry CLI downloads

* Use arm64 RID where needed

* Fix retry in iOS workflow
  • Loading branch information
mattjohnsonpint authored Mar 23, 2023
1 parent 4a0a30d commit e4c4e09
Show file tree
Hide file tree
Showing 17 changed files with 177 additions and 56 deletions.
10 changes: 7 additions & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@ jobs:
with:
submodules: recursive

# We use macOS for the final publishing build so we we get all the iOS/macCatalyst targets in the packages
- name: Set Environment Variables
if: startsWith(matrix.os, 'macos') && startsWith(github.ref_name, 'release/')
run: echo "CI_PUBLISHING_BUILD=true" >> $GITHUB_ENV

- name: Setup Environment
uses: ./.github/actions/environment

Expand Down Expand Up @@ -58,14 +63,13 @@ jobs:
path: "**/*.received.*"

# To save time and disk space, we only create and archive the Nuget packages when we're actually releasing.
# We use macOS for that so we we get all the iOS/macCatalyst targets in the packages

- name: Create Nuget Packages (release only)
if: startsWith(matrix.os, 'macos') && startsWith(github.ref_name, 'release/')
if: env.CI_PUBLISHING_BUILD == 'true'
run: dotnet pack Sentry-CI-Pack.slnf -c Release --no-build --nologo

- name: Archive Nuget Packages (release only)
if: startsWith(matrix.os, 'macos') && startsWith(github.ref_name, 'release/')
if: env.CI_PUBLISHING_BUILD == 'true'
uses: actions/upload-artifact@v3
with:
name: ${{ github.sha }}
Expand Down
18 changes: 11 additions & 7 deletions .github/workflows/device-tests-android.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ on:
jobs:
build:
runs-on: ubuntu-latest
env:
DOTNET_CLI_TELEMETRY_OPTOUT: 1
DOTNET_NOLOGO: 1
steps:
- name: Cancel Previous Runs
uses: styfle/cancel-workflow-action@b173b6ec0100793626c2d9e6b90435061f4fc3e5 # Tag: 0.11.0
Expand All @@ -19,12 +22,18 @@ jobs:
with:
submodules: recursive

- name: Setup Environment
uses: ./.github/actions/environment
- name: Set Java Version
uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: '11'

- name: Build Native Dependencies
uses: ./.github/actions/buildnative

- name: Install .NET Workloads
run: dotnet workload install maui-android --temp-dir "${{ runner.temp }}"

- name: Restore .NET Dependencies
run: dotnet restore test/Sentry.Maui.Device.TestApp --nologo

Expand Down Expand Up @@ -70,11 +79,6 @@ jobs:
name: device-test-android
path: bin

- name: Install .NET 7 SDK (for XHarness)
uses: actions/setup-dotnet@v3
with:
dotnet-version: 7.x.x

- name: Install XHarness
run: dotnet tool install Microsoft.DotNet.XHarness.CLI --global --version "1.*-*"

Expand Down
54 changes: 49 additions & 5 deletions .github/workflows/device-tests-ios.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,12 @@ on:

jobs:
build:
runs-on: macos-12
runs-on: macos-latest
env:
DOTNET_CLI_TELEMETRY_OPTOUT: 1
DOTNET_NOLOGO: 1
NO_ANDROID: true
NO_MACCATALYST: true
steps:
- name: Cancel Previous Runs
uses: styfle/cancel-workflow-action@b173b6ec0100793626c2d9e6b90435061f4fc3e5 # Tag: 0.11.0
Expand All @@ -19,25 +24,64 @@ jobs:
with:
submodules: recursive

- name: Setup Environment
uses: ./.github/actions/environment

- name: Build Cocoa SDK
uses: ./.github/actions/buildcocoasdk

- name: Install .NET Workloads
run: dotnet workload install maui-ios --temp-dir "${{ runner.temp }}"

- name: Restore .NET Dependencies
run: dotnet restore test/Sentry.Maui.Device.TestApp --nologo

- name: Build iOS Test App
run: dotnet build test/Sentry.Maui.Device.TestApp -c Release -f net7.0-ios --no-restore --nologo

- name: Upload iOS Test App
uses: actions/upload-artifact@v3
with:
name: device-test-ios
if-no-files-found: error
path: test/Sentry.Maui.Device.TestApp/bin/Release/net7.0-ios/iossimulator-x64/Sentry.Maui.Device.TestApp.app

ios:
needs: [build]
name: Run iOS Tests
runs-on: macos-latest
strategy:
fail-fast: false
env:
DOTNET_CLI_TELEMETRY_OPTOUT: 1
DOTNET_NOLOGO: 1
steps:

- name: Checkout
uses: actions/checkout@v3

- name: Download test app artifact
uses: actions/download-artifact@v3
with:
name: device-test-ios
path: bin/Sentry.Maui.Device.TestApp.app

- name: Install XHarness
run: dotnet tool install Microsoft.DotNet.XHarness.CLI --global --version "1.*-*"

- name: Run Tests
id: first-run
shell: bash +e {0}
run: >
xharness apple test \
--app=bin/Sentry.Maui.Device.TestApp.app \
--target=ios-simulator-64 \
--launch-timeout=00:10:00 \
--output-directory=./test_output \
; export exitcode=$? ; echo "exitcode=$exitcode" >> "$GITHUB_OUTPUT" ; exit $exitcode
- name: Retry Tests (if previous failed to run)
if: failure() && steps.first-run.outputs.exitcode > 1
run: >
xharness apple test \
--app=test/Sentry.Maui.Device.TestApp/bin/Release/net7.0-ios/iossimulator-x64/Sentry.Maui.Device.TestApp.app \
--app=bin/Sentry.Maui.Device.TestApp.app \
--target=ios-simulator-64 \
--launch-timeout=00:10:00 \
--output-directory=./test_output
Expand Down
9 changes: 9 additions & 0 deletions samples/Sentry.Samples.Ios/Sentry.Samples.Ios.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,13 @@
<ProjectReference Include="..\..\src\Sentry\Sentry.csproj" />
</ItemGroup>

<!--
Use the arm64 runtime when building on arm64 Macs.
See https://github.com/xamarin/xamarin-macios/issues/17841
-->
<PropertyGroup>
<OSArchitecture>$([System.Runtime.InteropServices.RuntimeInformation]::OSArchitecture)</OSArchitecture>
<RuntimeIdentifier Condition="'$(OSArchitecture)' == 'Arm64' And ('$(_iOSRuntimeIdentifier)' == 'iossimulator-x64' Or ('$(_iOSRuntimeIdentifier)' == '' And '$(RuntimeIdentifier)' == ''))">iossimulator-arm64</RuntimeIdentifier>
</PropertyGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0-maccatalyst</TargetFramework>
<RuntimeIdentifier>maccatalyst-x64</RuntimeIdentifier>
<OutputType>Exe</OutputType>
<Nullable>enable</Nullable>
<ImplicitUsings>true</ImplicitUsings>
Expand All @@ -18,4 +17,13 @@
<ProjectReference Include="..\..\src\Sentry\Sentry.csproj" />
</ItemGroup>

<!--
Use the arm64 runtime when building on arm64 Macs.
See https://github.com/xamarin/xamarin-macios/issues/17841
-->
<PropertyGroup>
<OSArchitecture>$([System.Runtime.InteropServices.RuntimeInformation]::OSArchitecture)</OSArchitecture>
<RuntimeIdentifier Condition="'$(OSArchitecture)' == 'Arm64' And ('$(_MacCatalystRuntimeIdentifier)' == 'maccatalyst-x64' Or ('$(_MacCatalystRuntimeIdentifier)' == '' And '$(RuntimeIdentifier)' == ''))">maccatalyst-arm64</RuntimeIdentifier>
</PropertyGroup>

</Project>
11 changes: 11 additions & 0 deletions samples/Sentry.Samples.Maui/Sentry.Samples.Maui.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,17 @@

</PropertyGroup>

<!--
Use the arm64 runtime when building on arm64 Macs.
See https://github.com/xamarin/xamarin-macios/issues/17841
-->
<PropertyGroup>
<OSArchitecture>$([System.Runtime.InteropServices.RuntimeInformation]::OSArchitecture)</OSArchitecture>
<TargetPlatformIdentifier>$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)'))</TargetPlatformIdentifier>
<RuntimeIdentifier Condition="'$(TargetPlatformIdentifier)' == 'ios' And '$(OSArchitecture)' == 'Arm64' And ('$(_iOSRuntimeIdentifier)' == 'iossimulator-x64' Or ('$(_iOSRuntimeIdentifier)' == '' And '$(RuntimeIdentifier)' == ''))">iossimulator-arm64</RuntimeIdentifier>
<RuntimeIdentifier Condition="'$(TargetPlatformIdentifier)' == 'maccatalyst' And '$(OSArchitecture)' == 'Arm64' And ('$(_MacCatalystRuntimeIdentifier)' == 'maccatalyst-x64' Or ('$(_MacCatalystRuntimeIdentifier)' == '' And '$(RuntimeIdentifier)' == ''))">maccatalyst-arm64</RuntimeIdentifier>
</PropertyGroup>

<ItemGroup>
<!-- App Icon -->
<MauiIcon Include="Resources\AppIcon\appicon.svg" ForegroundFile="Resources\AppIcon\appiconfg.svg" Color="#512BD4" />
Expand Down
4 changes: 3 additions & 1 deletion src/Sentry.Bindings.Cocoa/Sentry.Bindings.Cocoa.csproj
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net6.0-ios;net6.0-maccatalyst</TargetFrameworks>
<TargetFrameworks />
<TargetFrameworks Condition="'$(NO_IOS)' == '' And $([MSBuild]::IsOSPlatform('OSX'))">$(TargetFrameworks);net6.0-ios</TargetFrameworks>
<TargetFrameworks Condition="'$(NO_MACCATALYST)' == '' And $([MSBuild]::IsOSPlatform('OSX'))">$(TargetFrameworks);net6.0-maccatalyst</TargetFrameworks>
<IsBindingProject>true</IsBindingProject>
<MtouchNoSymbolStrip>true</MtouchNoSymbolStrip>
<Description>.NET Bindings for the Sentry Cocoa SDK</Description>
Expand Down
10 changes: 6 additions & 4 deletions src/Sentry.Maui/Sentry.Maui.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,14 @@
Target net6.0 so we can run unit tests on platform-neutral code.
Target other platforms so we can include platform-specific code, and bundle native SDKs.
-->
<TargetFrameworks>net6.0;net6.0-android</TargetFrameworks>
<TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('OSX'))">$(TargetFrameworks);net6.0-ios;net6.0-maccatalyst</TargetFrameworks>
<TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('Windows')) Or $([MSBuild]::IsOSPlatform('OSX'))">$(TargetFrameworks);net6.0-windows10.0.19041.0</TargetFrameworks>
<TargetFrameworks>net6.0</TargetFrameworks>
<TargetFrameworks Condition="'$(NO_ANDROID)' == ''">$(TargetFrameworks);net6.0-android</TargetFrameworks>
<TargetFrameworks Condition="'$(NO_IOS)' == '' And $([MSBuild]::IsOSPlatform('OSX'))">$(TargetFrameworks);net6.0-ios</TargetFrameworks>
<TargetFrameworks Condition="'$(NO_MACCATALYST)' == '' And $([MSBuild]::IsOSPlatform('OSX'))">$(TargetFrameworks);net6.0-maccatalyst</TargetFrameworks>
<TargetFrameworks Condition="'$(NO_WINDOWS)' == '' And !$([MSBuild]::IsOSPlatform('Linux'))">$(TargetFrameworks);net6.0-windows10.0.19041.0</TargetFrameworks>

<!-- Target Tizen only if the Tizen SDK workload pack is installed. -->
<TargetFrameworks Condition="Exists('$(MSBuildBinPath)\..\..\packs\Samsung.Tizen.Sdk')">$(TargetFrameworks);net6.0-tizen</TargetFrameworks>
<TargetFrameworks Condition="'$(NO_TIZEN)' == '' And Exists('$(MSBuildBinPath)\..\..\packs\Samsung.Tizen.Sdk')">$(TargetFrameworks);net6.0-tizen</TargetFrameworks>

<!--
This flag allows us to target Windows-specific code when building on OSX, so we can build and pack all platforms on a single machine.
Expand Down
39 changes: 28 additions & 11 deletions src/Sentry/Sentry.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
</PropertyGroup>

<PropertyGroup Condition="'$(SolutionName)' != 'Sentry.Unity'">
<TargetFrameworks>net6.0;net5.0;netcoreapp3.0;netstandard2.1;netstandard2.0;net461;net6.0-android</TargetFrameworks>

<!-- On macOS, build the iOS and Mac Catalyst targets also. -->
<TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('OSX'))">$(TargetFrameworks);net6.0-ios;net6.0-maccatalyst</TargetFrameworks>
<TargetFrameworks>net6.0;net5.0;netcoreapp3.0;netstandard2.1;netstandard2.0;net461</TargetFrameworks>
<TargetFrameworks Condition="'$(NO_ANDROID)' == ''">$(TargetFrameworks);net6.0-android</TargetFrameworks>
<TargetFrameworks Condition="'$(NO_IOS)' == '' And $([MSBuild]::IsOSPlatform('OSX'))">$(TargetFrameworks);net6.0-ios</TargetFrameworks>
<TargetFrameworks Condition="'$(NO_MACCATALYST)' == '' And $([MSBuild]::IsOSPlatform('OSX'))">$(TargetFrameworks);net6.0-maccatalyst</TargetFrameworks>
</PropertyGroup>

<PropertyGroup Condition="'$(SolutionName)' == 'Sentry.Unity'">
Expand Down Expand Up @@ -74,14 +74,31 @@
Hashes are from https://release-registry.services.sentry.io/apps/sentry-cli/latest
Update with each new version.
-->
<PropertyGroup>
<_OSArchitecture>$([System.Runtime.InteropServices.RuntimeInformation]::OSArchitecture)</_OSArchitecture>
</PropertyGroup>
<ItemGroup>
<SentryCLIDownload Include="sentry-cli-Darwin-arm64" FileHash="e703b97e1a270f807bb926649b250ca5cd64425063ebe118badde431e6e5057d" />
<SentryCLIDownload Include="sentry-cli-Darwin-x86_64" FileHash="8e934aa5cd690350bfa2304ce35c815b9c4f2538446363a5b42238d537fb7182" />
<SentryCLIDownload Include="sentry-cli-Linux-aarch64" FileHash="8d80b70438ba496dc20dccf2c3beeff6ab43fe5e9c461f98b1141981d3058500" />
<SentryCLIDownload Include="sentry-cli-Linux-i686" FileHash="2363302bbdf7e2d655e3acbf52229b8a6e90e8f99a2bcac0c4ef926610f93dda" />
<SentryCLIDownload Include="sentry-cli-Linux-x86_64" FileHash="80a6fbd0b371aa14715e4fcdc0104ea9f36f249e06edac445920a0a5dc22c16a" />
<SentryCLIDownload Include="sentry-cli-Windows-i686.exe" FileHash="0be3746bef8c40bdb7965b8ada6e1ee342de43d0b612f9cb6a7702896c055a8d" />
<SentryCLIDownload Include="sentry-cli-Windows-x86_64.exe" FileHash="b6d2b243d6bd319b37a060a7357332783dd6af10c6a4a08991fd89d34846b9df" />
<SentryCLIDownload
Condition="'$(CI_PUBLISHING_BUILD)' == 'true' Or ($([MSBuild]::IsOSPlatform('OSX')) And $(_OSArchitecture) == 'Arm64')"
Include="sentry-cli-Darwin-arm64" FileHash="e703b97e1a270f807bb926649b250ca5cd64425063ebe118badde431e6e5057d" />
<SentryCLIDownload
Condition="'$(CI_PUBLISHING_BUILD)' == 'true' Or ($([MSBuild]::IsOSPlatform('OSX')) And $(_OSArchitecture) == 'X64')"
Include="sentry-cli-Darwin-x86_64" FileHash="8e934aa5cd690350bfa2304ce35c815b9c4f2538446363a5b42238d537fb7182" />
<SentryCLIDownload
Condition="'$(CI_PUBLISHING_BUILD)' == 'true' Or ($([MSBuild]::IsOSPlatform('Linux')) And $(_OSArchitecture) == 'Arm64')"
Include="sentry-cli-Linux-aarch64" FileHash="8d80b70438ba496dc20dccf2c3beeff6ab43fe5e9c461f98b1141981d3058500" />
<SentryCLIDownload
Condition="'$(CI_PUBLISHING_BUILD)' == 'true' Or ($([MSBuild]::IsOSPlatform('Linux')) And $(_OSArchitecture) == 'X86')"
Include="sentry-cli-Linux-i686" FileHash="2363302bbdf7e2d655e3acbf52229b8a6e90e8f99a2bcac0c4ef926610f93dda" />
<SentryCLIDownload
Condition="'$(CI_PUBLISHING_BUILD)' == 'true' Or ($([MSBuild]::IsOSPlatform('Linux')) And $(_OSArchitecture) == 'X64')"
Include="sentry-cli-Linux-x86_64" FileHash="80a6fbd0b371aa14715e4fcdc0104ea9f36f249e06edac445920a0a5dc22c16a" />
<SentryCLIDownload
Condition="'$(CI_PUBLISHING_BUILD)' == 'true' Or ($([MSBuild]::IsOSPlatform('Windows')) And $(_OSArchitecture) == 'X86')"
Include="sentry-cli-Windows-i686.exe" FileHash="0be3746bef8c40bdb7965b8ada6e1ee342de43d0b612f9cb6a7702896c055a8d" />
<SentryCLIDownload
Condition="'$(CI_PUBLISHING_BUILD)' == 'true' Or ($([MSBuild]::IsOSPlatform('Windows')) And $(_OSArchitecture) != 'X86')"
Include="sentry-cli-Windows-x86_64.exe" FileHash="b6d2b243d6bd319b37a060a7357332783dd6af10c6a4a08991fd89d34846b9df" />
</ItemGroup>

<!-- Download the files -->
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net7.0-android</TargetFrameworks>
<TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('windows'))">$(TargetFrameworks);net7.0-windows10.0.19041.0</TargetFrameworks>
<TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('OSX'))">$(TargetFrameworks);net7.0-ios;net7.0-maccatalyst</TargetFrameworks>
<TargetFrameworks/>
<TargetFrameworks Condition="'$(NO_ANDROID)' == ''">$(TargetFrameworks);net7.0-android</TargetFrameworks>
<TargetFrameworks Condition="'$(NO_WINDOWS)' == '' And $([MSBuild]::IsOSPlatform('windows'))">$(TargetFrameworks);net7.0-windows10.0.19041.0</TargetFrameworks>
<TargetFrameworks Condition="'$(NO_IOS)' == '' And $([MSBuild]::IsOSPlatform('OSX'))">$(TargetFrameworks);net7.0-ios</TargetFrameworks>
<TargetFrameworks Condition="'$(NO_MACCATALYST)' == '' And $([MSBuild]::IsOSPlatform('OSX'))">$(TargetFrameworks);net7.0-maccatalyst</TargetFrameworks>
<SingleProject>true</SingleProject>
<RootNamespace>Microsoft.Maui.TestUtils.DeviceTests.Runners</RootNamespace>
<AssemblyName>Microsoft.Maui.TestUtils.DeviceTests.Runners</AssemblyName>
Expand Down
9 changes: 6 additions & 3 deletions test/MauiTestUtils/DeviceTests/TestUtils.DeviceTests.csproj
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net7.0-android</TargetFrameworks>
<TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('windows'))">$(TargetFrameworks);net7.0-windows10.0.19041.0</TargetFrameworks>
<TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('OSX'))">$(TargetFrameworks);net7.0-ios;net7.0-maccatalyst</TargetFrameworks>
<TargetFrameworks/>
<TargetFrameworks Condition="'$(NO_ANDROID)' == ''">$(TargetFrameworks);net7.0-android</TargetFrameworks>
<TargetFrameworks Condition="'$(NO_WINDOWS)' == '' And $([MSBuild]::IsOSPlatform('windows'))">$(TargetFrameworks);net7.0-windows10.0.19041.0</TargetFrameworks>
<TargetFrameworks Condition="'$(NO_IOS)' == '' And $([MSBuild]::IsOSPlatform('OSX'))">$(TargetFrameworks);net7.0-ios</TargetFrameworks>
<TargetFrameworks Condition="'$(NO_MACCATALYST)' == '' And $([MSBuild]::IsOSPlatform('OSX'))">$(TargetFrameworks);net7.0-maccatalyst</TargetFrameworks>

<SingleProject>true</SingleProject>
<RootNamespace>Microsoft.Maui.TestUtils.DeviceTests</RootNamespace>
<AssemblyName>Microsoft.Maui.TestUtils.DeviceTests</AssemblyName>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net7.0;net6.0;netcoreapp3.1;net7.0-android</TargetFrameworks>
<TargetFrameworks>net7.0;net6.0;netcoreapp3.1</TargetFrameworks>
<TargetFrameworks Condition="'$(NO_ANDROID)' == ''">$(TargetFrameworks);net7.0-android</TargetFrameworks>
<Nullable>enable</Nullable>
</PropertyGroup>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net7.0;net6.0;netcoreapp3.1;net48;net7.0-android</TargetFrameworks>
<TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('OSX'))">$(TargetFrameworks);net7.0-ios;net7.0-maccatalyst</TargetFrameworks>
<TargetFrameworks>net7.0;net6.0;netcoreapp3.1;net48</TargetFrameworks>
<TargetFrameworks Condition="'$(NO_ANDROID)' == ''">$(TargetFrameworks);net7.0-android</TargetFrameworks>
<TargetFrameworks Condition="'$(NO_IOS)' == '' And $([MSBuild]::IsOSPlatform('OSX'))">$(TargetFrameworks);net7.0-ios</TargetFrameworks>
<TargetFrameworks Condition="'$(NO_MACCATALYST)' == '' And $([MSBuild]::IsOSPlatform('OSX'))">$(TargetFrameworks);net7.0-maccatalyst</TargetFrameworks>
</PropertyGroup>

<ItemGroup>
Expand Down
Loading

0 comments on commit e4c4e09

Please sign in to comment.