Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions .github/actions/environment/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@ runs:
echo "DOTNET_CLI_TELEMETRY_OPTOUT=1" >> $GITHUB_ENV
echo "DOTNET_NOLOGO=1" >> $GITHUB_ENV

# Android SDK Build Tools are musl-incompatible
- name: Set Environment Variables for Alpine Linux
if: ${{ contains(matrix.container, 'alpine') }}
shell: bash
run: echo "NO_MOBILE=true" >> $GITHUB_ENV

# zstd is needed for cross OS actions/cache but missing from windows-11-arm
# https://github.com/actions/partner-runner-images/issues/99
- name: Install zstd on Windows ARM64
Expand All @@ -26,18 +32,21 @@ runs:

# Java 17 is needed for Android SDK setup step
- name: Install Java 17
if: ${{ !matrix.container }}
uses: actions/setup-java@v4
with:
distribution: ${{ runner.os == 'Windows' && runner.arch == 'ARM64' && 'microsoft' || 'temurin' }}
java-version: '17'

- name: Setup Android SDK
if: ${{ !matrix.container }}
uses: android-actions/setup-android@07976c6290703d34c16d382cb36445f98bb43b1f # v3.2.0
with:
log-accepted-android-sdk-licenses: false

# Java 11 is needed by .NET Android
- name: Install Java 11
if: ${{ !matrix.container }}
uses: actions/setup-java@v4
with:
distribution: ${{ runner.os == 'Windows' && runner.arch == 'ARM64' && 'microsoft' || 'temurin' }}
Expand Down
34 changes: 28 additions & 6 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,17 @@ on:

jobs:
build-sentry-native:
name: sentry-native (${{ matrix.os }})
name: sentry-native (${{ matrix.container || matrix.os }})
runs-on: ${{ matrix.os }}
container: ${{ matrix.container }}
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-22.04 # Pin ubuntu to ensure mono is installed
- os: ubuntu-latest
target: Linux-musl
container: ghcr.io/getsentry/sentry-dotnet-alpine:3.21
- os: macos-15 # Pin macos to get the version of Xcode that we need: https://github.com/actions/runner-images/issues/10703
- os: windows-latest
- os: windows-11-arm
Expand All @@ -44,10 +48,11 @@ jobs:
enableCrossOsArchive: true

- name: Remove unused applications
if: ${{ !matrix.container }}
uses: ./.github/actions/freediskspace

- name: Install build dependencies
if: steps.cache.outputs.cache-hit != 'true' && runner.os == 'Linux'
if: steps.cache.outputs.cache-hit != 'true' && runner.os == 'Linux' && !matrix.container
run: |
sudo apt update
sudo apt install libcurl4-openssl-dev
Expand All @@ -58,14 +63,18 @@ jobs:

build:
needs: build-sentry-native
name: .NET (${{ matrix.os }})
name: .NET (${{ matrix.container || matrix.os }})
runs-on: ${{ matrix.os }}
container: ${{ matrix.container }}

strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-22.04 # Pin ubuntu to ensure mono is installed
- os: ubuntu-latest
target: Linux-musl
container: ghcr.io/getsentry/sentry-dotnet-alpine:3.21
- os: macos-15 # Pin macos to get the version of Xcode that we need: https://github.com/actions/runner-images/issues/10703
- os: windows-latest
- os: windows-11-arm
Expand All @@ -83,6 +92,7 @@ jobs:
fetch-depth: 2 # default is 1 and codecov needs > 1

- name: Remove unused applications
if: ${{ !matrix.container }}
uses: ./.github/actions/freediskspace

- name: Setup Environment
Expand All @@ -94,13 +104,21 @@ jobs:
run: echo "CI_PUBLISHING_BUILD=true" >> $GITHUB_ENV

- name: Download sentry-native (Linux)
if: ${{ (env.CI_PUBLISHING_BUILD == 'true') || (runner.os == 'Linux') }}
if: ${{ (env.CI_PUBLISHING_BUILD == 'true') || (runner.os == 'Linux' && !matrix.container) }}
uses: actions/cache/restore@v4
with:
path: src/Sentry/Platforms/Native/sentry-native
key: sentry-native-Linux-${{ hashFiles('scripts/build-sentry-native.ps1') }}-${{ hashFiles('.git/modules/modules/sentry-native/HEAD') }}
fail-on-cache-miss: true

- name: Download sentry-native (Linux musl)
if: ${{ (env.CI_PUBLISHING_BUILD == 'true') || (matrix.target == 'Linux-musl') }}
uses: actions/cache/restore@v4
with:
path: src/Sentry/Platforms/Native/sentry-native
key: sentry-native-Linux-musl-${{ hashFiles('scripts/build-sentry-native.ps1') }}-${{ hashFiles('.git/modules/modules/sentry-native/HEAD') }}
fail-on-cache-miss: true

- name: Download sentry-native (macOS)
if: ${{ (env.CI_PUBLISHING_BUILD == 'true') || (runner.os == 'macOS') }}
uses: actions/cache/restore@v4
Expand Down Expand Up @@ -128,6 +146,7 @@ jobs:
enableCrossOsArchive: true

- name: Build Native Dependencies
if: ${{ !matrix.container }}
uses: ./.github/actions/buildnative

- name: Restore .NET Dependencies
Expand Down Expand Up @@ -175,14 +194,17 @@ jobs:

integration-test:
needs: build
name: Integration test (${{ matrix.os }})
name: Integration test (${{ matrix.container || matrix.os }})
runs-on: ${{ matrix.os }}
container: ${{ matrix.container }}

strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-22.04 # Pin ubuntu to ensure mono is installed
- os: ubuntu-latest
container: ghcr.io/getsentry/sentry-dotnet-alpine:3.21
- os: macos-15 # Pin macos to get the version of Xcode that we need: https://github.com/actions/runner-images/issues/10703
- os: windows-latest
- os: windows-11-arm
Expand All @@ -204,7 +226,7 @@ jobs:
path: src

- name: Install build dependencies
if: runner.os == 'Linux'
if: runner.os == 'Linux' && !matrix.container
run: |
sudo apt update
sudo apt install libcurl4-openssl-dev
Expand Down
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changelog

## Unreleased

### Fixes

- Support musl on Linux ([#4188](https://github.com/getsentry/sentry-dotnet/pull/4188))

## 5.8.0

### Features
Expand Down
73 changes: 73 additions & 0 deletions Sentry-CI-Build-Linux-musl.slnf
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
{
"solution": {
"path": "Sentry.sln",
"projects": [
"benchmarks\\Sentry.Benchmarks\\Sentry.Benchmarks.csproj",
"samples\\Sentry.Samples.AspNetCore.Basic\\Sentry.Samples.AspNetCore.Basic.csproj",
"samples\\Sentry.Samples.AspNetCore.Blazor.Server\\Sentry.Samples.AspNetCore.Blazor.Server.csproj",
"samples\\Sentry.Samples.AspNetCore.Blazor.Wasm\\Sentry.Samples.AspNetCore.Blazor.Wasm.csproj",
"samples\\Sentry.Samples.AspNetCore.Grpc\\Sentry.Samples.AspNetCore.Grpc.csproj",
"samples\\Sentry.Samples.AspNetCore.Mvc\\Sentry.Samples.AspNetCore.Mvc.csproj",
"samples\\Sentry.Samples.AspNetCore.Serilog\\Sentry.Samples.AspNetCore.Serilog.csproj",
"samples\\Sentry.Samples.AspNetCore.WebAPI.Profiling\\Sentry.Samples.AspNetCore.WebAPI.Profiling.csproj",
"samples\\Sentry.Samples.Aws.Lambda.AspNetCoreServer\\Sentry.Samples.Aws.Lambda.AspNetCoreServer.csproj",
"samples\\Sentry.Samples.Azure.Functions.Worker\\Sentry.Samples.Azure.Functions.Worker.csproj",
"samples\\Sentry.Samples.Console.Basic\\Sentry.Samples.Console.Basic.csproj",
"samples\\Sentry.Samples.Console.Customized\\Sentry.Samples.Console.Customized.csproj",
"samples\\Sentry.Samples.Console.HeapDump\\Sentry.Samples.Console.HeapDump.csproj",
"samples\\Sentry.Samples.Console.Native\\Sentry.Samples.Console.Native.csproj",
"samples\\Sentry.Samples.Console.Profiling\\Sentry.Samples.Console.Profiling.csproj",
"samples\\Sentry.Samples.EntityFramework\\Sentry.Samples.EntityFramework.csproj",
"samples\\Sentry.Samples.GenericHost\\Sentry.Samples.GenericHost.csproj",
"samples\\Sentry.Samples.Google.Cloud.Functions\\Sentry.Samples.Google.Cloud.Functions.csproj",
"samples\\Sentry.Samples.GraphQL.Client.Http\\Sentry.Samples.GraphQL.Client.Http.csproj",
"samples\\Sentry.Samples.GraphQL.Server\\Sentry.Samples.GraphQL.Server.csproj",
"samples\\Sentry.Samples.Hangfire\\Sentry.Samples.Hangfire.csproj",
"samples\\Sentry.Samples.Log4Net\\Sentry.Samples.Log4Net.csproj",
"samples\\Sentry.Samples.ME.Logging\\Sentry.Samples.ME.Logging.csproj",
"samples\\Sentry.Samples.NLog\\Sentry.Samples.NLog.csproj",
"samples\\Sentry.Samples.OpenTelemetry.AspNetCore\\Sentry.Samples.OpenTelemetry.AspNetCore.csproj",
"samples\\Sentry.Samples.OpenTelemetry.Console\\Sentry.Samples.OpenTelemetry.Console.csproj",
"samples\\Sentry.Samples.Serilog\\Sentry.Samples.Serilog.csproj",
"src\\Sentry.Analyzers\\Sentry.Analyzers.csproj",
"src\\Sentry.AspNetCore.Blazor.WebAssembly\\Sentry.AspNetCore.Blazor.WebAssembly.csproj",
"src\\Sentry.AspNetCore.Grpc\\Sentry.AspNetCore.Grpc.csproj",
"src\\Sentry.AspNetCore\\Sentry.AspNetCore.csproj",
"src\\Sentry.Azure.Functions.Worker\\Sentry.Azure.Functions.Worker.csproj",
"src\\Sentry.DiagnosticSource\\Sentry.DiagnosticSource.csproj",
"src\\Sentry.EntityFramework\\Sentry.EntityFramework.csproj",
"src\\Sentry.Extensions.Logging\\Sentry.Extensions.Logging.csproj",
"src\\Sentry.Google.Cloud.Functions\\Sentry.Google.Cloud.Functions.csproj",
"src\\Sentry.Hangfire\\Sentry.Hangfire.csproj",
"src\\Sentry.Log4Net\\Sentry.Log4Net.csproj",
"src\\Sentry.NLog\\Sentry.NLog.csproj",
"src\\Sentry.OpenTelemetry\\Sentry.OpenTelemetry.csproj",
"src\\Sentry.Profiling\\Sentry.Profiling.csproj",
"src\\Sentry.Serilog\\Sentry.Serilog.csproj",
"src\\Sentry.SourceGenerators\\Sentry.SourceGenerators.csproj",
"src\\Sentry\\Sentry.csproj",
"test\\Sentry.Analyzers.Tests\\Sentry.Analyzers.Tests.csproj",
"test\\Sentry.AspNet.Tests\\Sentry.AspNet.Tests.csproj",
"test\\Sentry.AspNetCore.Grpc.Tests\\Sentry.AspNetCore.Grpc.Tests.csproj",
"test\\Sentry.AspNetCore.Tests\\Sentry.AspNetCore.Tests.csproj",
"test\\Sentry.AspNetCore.TestUtils\\Sentry.AspNetCore.TestUtils.csproj",
"test\\Sentry.Azure.Functions.Worker.Tests\\Sentry.Azure.Functions.Worker.Tests.csproj",
"test\\Sentry.DiagnosticSource.IntegrationTests\\Sentry.DiagnosticSource.IntegrationTests.csproj",
"test\\Sentry.DiagnosticSource.Tests\\Sentry.DiagnosticSource.Tests.csproj",
"test\\Sentry.EntityFramework.Tests\\Sentry.EntityFramework.Tests.csproj",
"test\\Sentry.Extensions.Logging.Tests\\Sentry.Extensions.Logging.Tests.csproj",
"test\\Sentry.Google.Cloud.Functions.Tests\\Sentry.Google.Cloud.Functions.Tests.csproj",
"test\\Sentry.Hangfire.Tests\\Sentry.Hangfire.Tests.csproj",
"test\\Sentry.Log4Net.Tests\\Sentry.Log4Net.Tests.csproj",
"test\\Sentry.NLog.Tests\\Sentry.NLog.Tests.csproj",
"test\\Sentry.OpenTelemetry.Tests\\Sentry.OpenTelemetry.Tests.csproj",
"test\\Sentry.Profiling.Tests\\Sentry.Profiling.Tests.csproj",
"test\\Sentry.Serilog.Tests\\Sentry.Serilog.Tests.csproj",
"test\\Sentry.SourceGenerators.Tests\\Sentry.SourceGenerators.Tests.csproj",
"test\\Sentry.Testing.CrashableApp\\Sentry.Testing.CrashableApp.csproj",
"test\\Sentry.Testing\\Sentry.Testing.csproj",
"test\\Sentry.Tests\\Sentry.Tests.csproj",
"test\\SingleFileTestApp\\SingleFileTestApp.csproj"
]
}
}
3 changes: 2 additions & 1 deletion integration-test/cli.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
Set-StrictMode -Version Latest
$ErrorActionPreference = 'Stop'
. $PSScriptRoot/common.ps1
$IsLinuxMusl = $IsLinux -and (ldd --version 2>&1) -match 'musl'

Describe 'Console apps (<framework>) - normal build' -ForEach @(
@{ framework = "net8.0" }
Expand Down Expand Up @@ -107,7 +108,7 @@ Describe 'Console apps (<framework>) - native AOT publish' -ForEach @(

Describe 'MAUI' -ForEach @(
@{ framework = "net8.0" }
) {
) -Skip:$IsLinuxMusl {
BeforeAll {
RegisterLocalPackage 'Sentry.Android.AssemblyReader'
RegisterLocalPackage 'Sentry.Bindings.Android'
Expand Down
4 changes: 4 additions & 0 deletions integration-test/runtime.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,10 @@ internal class FakeTransport : ITransport
return "./console-app/bin/Release/$framework/win-x64/publish/console-app.exe"
}
}
elseif ((ldd --version 2>&1) -match 'musl')
{
return "./console-app/bin/Release/$framework/linux-musl-x64/publish/console-app"
}
else
{
return "./console-app/bin/Release/$framework/linux-x64/publish/console-app"
Expand Down
9 changes: 8 additions & 1 deletion scripts/build-sentry-native.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,14 @@ try
}
elseif ($IsLinux)
{
$outDir += '/linux-x64'
if ((ldd --version 2>&1) -match 'musl')
{
$outDir += '/linux-musl-x64'
}
else
{
$outDir += '/linux-x64'
}
}
else
{
Expand Down
15 changes: 15 additions & 0 deletions scripts/generate-solution-filters-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,21 @@ filterConfigs:
- "**/*DeviceTests*.csproj"
- "**/*Maui.Device.TestApp.csproj"

- outputPath: Sentry-CI-Build-Linux-musl.slnf
include:
groups:
- "allProjects"
exclude:
groups:
- "macOnly"
- "windowsOnly"
- "artefacts"
- "trimTests"
patterns:
- "**/*Android*.csproj"
- "**/*DeviceTests*.csproj"
- "**/*Maui*.csproj"

- outputPath: Sentry-CI-Build-macOS.slnf
include:
groups:
Expand Down
14 changes: 12 additions & 2 deletions src/Sentry/Platforms/Native/Sentry.Native.targets
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,14 @@
<SentryNativeOutputDirectory-win-arm64>$(SentryNativeOutputDirectory)$(NativeLibRelativePath-win-arm64)\</SentryNativeOutputDirectory-win-arm64>
<NativeLibRelativePath-linux-x64>linux-x64</NativeLibRelativePath-linux-x64>
<SentryNativeOutputDirectory-linux-x64>$(SentryNativeOutputDirectory)$(NativeLibRelativePath-linux-x64)\</SentryNativeOutputDirectory-linux-x64>
<NativeLibRelativePath-linux-musl-x64>linux-musl-x64</NativeLibRelativePath-linux-musl-x64>
<SentryNativeOutputDirectory-linux-musl-x64>$(SentryNativeOutputDirectory)$(NativeLibRelativePath-linux-musl-x64)\</SentryNativeOutputDirectory-linux-musl-x64>
<NativeLibRelativePath-osx>osx</NativeLibRelativePath-osx>
<SentryNativeOutputDirectory-osx>$(SentryNativeOutputDirectory)$(NativeLibRelativePath-osx)\</SentryNativeOutputDirectory-osx>
<SentryNativeBuildOutputs Condition="'$(RuntimeIdentifier)' == 'win-x64'">$(SentryNativeOutputDirectory-win-x64)lib$(SentryNativeLibraryName).lib</SentryNativeBuildOutputs>
<SentryNativeBuildOutputs Condition="'$(RuntimeIdentifier)' == 'win-arm64'">$(SentryNativeOutputDirectory-win-arm64)lib$(SentryNativeLibraryName).lib</SentryNativeBuildOutputs>
<SentryNativeBuildOutputs Condition="$([MSBuild]::IsOsPlatform('Linux'))">$(SentryNativeOutputDirectory-linux-x64)lib$(SentryNativeLibraryName).a</SentryNativeBuildOutputs>
<SentryNativeBuildOutputs Condition="'$(RuntimeIdentifier)' == 'linux-x64'">$(SentryNativeOutputDirectory-linux-x64)lib$(SentryNativeLibraryName).a</SentryNativeBuildOutputs>
<SentryNativeBuildOutputs Condition="'$(RuntimeIdentifier)' == 'linux-musl-x64'">$(SentryNativeOutputDirectory-linux-musl-x64)lib$(SentryNativeLibraryName).a</SentryNativeBuildOutputs>
<SentryNativeBuildOutputs Condition="$([MSBuild]::IsOsPlatform('OSX'))">$(SentryNativeOutputDirectory-osx)lib$(SentryNativeLibraryName).a</SentryNativeBuildOutputs>
</PropertyGroup>

Expand All @@ -42,13 +45,20 @@
</None>
</ItemGroup>

<ItemGroup Condition="'$(CI_PUBLISHING_BUILD)' == 'true' or $([MSBuild]::IsOsPlatform('Linux'))">
<ItemGroup Condition="'$(CI_PUBLISHING_BUILD)' == 'true' or '$(RuntimeIdentifier)' == 'linux-x64'">
<None Include="$(SentryNativeOutputDirectory-linux-x64)lib$(SentryNativeLibraryName).a">
<Pack>true</Pack>
<PackagePath>\sentry-native\$(NativeLibRelativePath-linux-x64)</PackagePath>
</None>
</ItemGroup>

<ItemGroup Condition="'$(CI_PUBLISHING_BUILD)' == 'true' or '$(RuntimeIdentifier)' == 'linux-musl-x64'">
<None Include="$(SentryNativeOutputDirectory-linux-musl-x64)lib$(SentryNativeLibraryName).a">
<Pack>true</Pack>
<PackagePath>\sentry-native\$(NativeLibRelativePath-linux-musl-x64)</PackagePath>
</None>
</ItemGroup>

<ItemGroup Condition="'$(CI_PUBLISHING_BUILD)' == 'true' or $([MSBuild]::IsOsPlatform('OSX'))">
<None Include="$(SentryNativeOutputDirectory-osx)lib$(SentryNativeLibraryName).a">
<Pack>true</Pack>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,16 @@
<NativeSystemLibrary Include="curl" />
</ItemGroup>

<ItemGroup Condition="'$(FrameworkSupportsNative)' == 'true' and '$(RuntimeIdentifier)' == 'linux-musl-x64'">
<DirectPInvoke Include="sentry-native" />
<!-- When musl is detected, static sentry-native links to static libunwind -->
<LinkerArg Include="-Wl,-Bstatic -Wl,--whole-archive -lunwind -Wl,--no-whole-archive -Wl,-Bdynamic" />
<NativeSystemLibrary Include="lzma" />
<NativeLibrary Include="$(MSBuildThisFileDirectory)..\sentry-native\linux-musl-x64\libsentry-native.a" />
<!-- See: https://github.com/dotnet/runtime/issues/97414 -->
<NativeSystemLibrary Include="curl" />
</ItemGroup>

<ItemGroup Condition="'$(FrameworkSupportsNative)' == 'true' and ('$(RuntimeIdentifier)' == 'osx-x64' or '$(RuntimeIdentifier)' == 'osx-arm64')">
<DirectPInvoke Include="sentry-native" />
<NativeLibrary Include="$(MSBuildThisFileDirectory)..\sentry-native\osx\libsentry-native.a" />
Expand Down
Loading