diff --git a/.github/actions/environment/action.yml b/.github/actions/environment/action.yml index 5e4c5e836f..0ab866f67b 100644 --- a/.github/actions/environment/action.yml +++ b/.github/actions/environment/action.yml @@ -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 @@ -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' }} diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 8a85342b33..1cab070a6f 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -128,6 +146,7 @@ jobs: enableCrossOsArchive: true - name: Build Native Dependencies + if: ${{ !matrix.container }} uses: ./.github/actions/buildnative - name: Restore .NET Dependencies @@ -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 @@ -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 diff --git a/CHANGELOG.md b/CHANGELOG.md index 3388c89041..18ce173165 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ # Changelog +## Unreleased + +### Fixes + +- Support musl on Linux ([#4188](https://github.com/getsentry/sentry-dotnet/pull/4188)) + ## 5.8.0 ### Features diff --git a/Sentry-CI-Build-Linux-musl.slnf b/Sentry-CI-Build-Linux-musl.slnf new file mode 100644 index 0000000000..9d305e5df8 --- /dev/null +++ b/Sentry-CI-Build-Linux-musl.slnf @@ -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" + ] + } +} diff --git a/integration-test/cli.Tests.ps1 b/integration-test/cli.Tests.ps1 index 5875adc44a..d5ce17efdc 100644 --- a/integration-test/cli.Tests.ps1 +++ b/integration-test/cli.Tests.ps1 @@ -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 () - normal build' -ForEach @( @{ framework = "net8.0" } @@ -107,7 +108,7 @@ Describe 'Console apps () - native AOT publish' -ForEach @( Describe 'MAUI' -ForEach @( @{ framework = "net8.0" } -) { +) -Skip:$IsLinuxMusl { BeforeAll { RegisterLocalPackage 'Sentry.Android.AssemblyReader' RegisterLocalPackage 'Sentry.Bindings.Android' diff --git a/integration-test/runtime.Tests.ps1 b/integration-test/runtime.Tests.ps1 index 81f75fe245..047b5e9594 100644 --- a/integration-test/runtime.Tests.ps1 +++ b/integration-test/runtime.Tests.ps1 @@ -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" diff --git a/scripts/build-sentry-native.ps1 b/scripts/build-sentry-native.ps1 index 901399033d..50f58439f8 100644 --- a/scripts/build-sentry-native.ps1 +++ b/scripts/build-sentry-native.ps1 @@ -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 { diff --git a/scripts/generate-solution-filters-config.yaml b/scripts/generate-solution-filters-config.yaml index 750b22c095..25752d7765 100644 --- a/scripts/generate-solution-filters-config.yaml +++ b/scripts/generate-solution-filters-config.yaml @@ -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: diff --git a/src/Sentry/Platforms/Native/Sentry.Native.targets b/src/Sentry/Platforms/Native/Sentry.Native.targets index a03d405f27..a3b365ef90 100644 --- a/src/Sentry/Platforms/Native/Sentry.Native.targets +++ b/src/Sentry/Platforms/Native/Sentry.Native.targets @@ -13,11 +13,14 @@ $(SentryNativeOutputDirectory)$(NativeLibRelativePath-win-arm64)\ linux-x64 $(SentryNativeOutputDirectory)$(NativeLibRelativePath-linux-x64)\ + linux-musl-x64 + $(SentryNativeOutputDirectory)$(NativeLibRelativePath-linux-musl-x64)\ osx $(SentryNativeOutputDirectory)$(NativeLibRelativePath-osx)\ $(SentryNativeOutputDirectory-win-x64)lib$(SentryNativeLibraryName).lib $(SentryNativeOutputDirectory-win-arm64)lib$(SentryNativeLibraryName).lib - $(SentryNativeOutputDirectory-linux-x64)lib$(SentryNativeLibraryName).a + $(SentryNativeOutputDirectory-linux-x64)lib$(SentryNativeLibraryName).a + $(SentryNativeOutputDirectory-linux-musl-x64)lib$(SentryNativeLibraryName).a $(SentryNativeOutputDirectory-osx)lib$(SentryNativeLibraryName).a @@ -42,13 +45,20 @@ - + true \sentry-native\$(NativeLibRelativePath-linux-x64) + + + true + \sentry-native\$(NativeLibRelativePath-linux-musl-x64) + + + true diff --git a/src/Sentry/Platforms/Native/buildTransitive/Sentry.Native.targets b/src/Sentry/Platforms/Native/buildTransitive/Sentry.Native.targets index 7b3e800790..3e08ba467f 100644 --- a/src/Sentry/Platforms/Native/buildTransitive/Sentry.Native.targets +++ b/src/Sentry/Platforms/Native/buildTransitive/Sentry.Native.targets @@ -40,6 +40,16 @@ + + + + + + + + + +