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
64 changes: 37 additions & 27 deletions .github/actions/environment/action.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
name: Setup Environment
description: Sets env vars and installs dependencies
inputs:
projects:
description: The solution filters and project files the job builds, separated by spaces, so only the workloads they need are installed. Jobs that build everything pass Sentry.slnx.
required: true
runs:
using: composite

Expand Down Expand Up @@ -39,37 +43,20 @@ runs:

# Java 21 is needed by .NET Android
- name: Install Java 21
if: ${{ !matrix.container }}
if: ${{ !matrix.container && env.NO_MOBILE != 'true' }}
uses: actions/setup-java@b843ebf9b913146b38da2eaa7aeddf76074ae1ad # v6.1.0
with:
distribution: temurin
java-version: '21'

- name: Setup Android SDK
if: ${{ !matrix.container }}
if: ${{ !matrix.container && env.NO_MOBILE != 'true' }}
uses: android-actions/setup-android@be39fa834029ff78f1a44aa3bb0819b8fc2bd8fd # v4.0.4
with:
# Exclude "tools" because the emulator is not needed (nor available for Windows/Linux ARM64)
packages: platform-tools platforms;android-35 platforms;android-36 build-tools;36.0.0
log-accepted-android-sdk-licenses: false

- name: Install Mono (macOS)
if: runner.os == 'macOS'
shell: bash
# Attempt to install Mono, allowing it to fail silently
# Then ensure mono is correctly linked, overwriting any conflicting symlinks
run: |
brew install mono || true
brew link --overwrite mono

- name: Install Mono (Ubuntu)
if: ${{ runner.os == 'Linux' && !matrix.container }}
shell: bash
run: |
sudo apt install -y mono-devel
# restore perms for actions/setup-dotnet
sudo chmod -R a+rw /usr/share/dotnet

- name: Install .NET SDK
uses: actions/setup-dotnet@a98b56852c35b8e3190ac28c8c2271da59106c68 # v6.0.0
with:
Expand All @@ -87,14 +74,37 @@ runs:

- name: Install .NET Workloads
shell: bash
env:
PROJECTS: ${{ inputs.projects }}
run: |
set -euo pipefail
pwd
dotnet workload restore \
--temp-dir "${{ runner.temp }}" \
--skip-sign-check
dotnet workload restore test/AndroidTestApp/AndroidTestApp.csproj \
--temp-dir "${{ runner.temp }}" \
--skip-sign-check
# Restore the Android test app explicitly to ensure runtime packs are available
dotnet restore test/AndroidTestApp/AndroidTestApp.csproj -r android-x64 --nologo || true
projects=()
for item in $PROJECTS; do
if [[ "$item" == *.slnf ]]; then
# dotnet workload restore doesn't accept a solution filter, but it accepts the projects in one
found=$(grep -o '"[^"]*\.csproj"' "$item" | tr -d '"' | sed 's#\\\\#/#g' || true)
if [[ -z "$found" ]]; then
echo "::error::Found no projects in $item, so there are no workloads to restore"
exit 1
fi
projects+=($found)
else
projects+=("$item")
fi
done
if [[ ${#projects[@]} -eq 0 ]]; then
echo "::error::Pass the solution filters or project files this job builds as projects, so only their workloads are installed"
exit 1
fi
dotnet workload restore "${projects[@]}" --temp-dir "${{ runner.temp }}" --skip-sign-check
# Sentry.Android.AssemblyReader.Tests builds the Android test app with an MSBuild task, not a project reference,
# so workload restore doesn't see it. grep reads a here-string because with pipefail, printf piped into grep -q
# fails with SIGPIPE when grep exits before printf has written everything.
if grep -q -E 'Sentry\.slnx$|Sentry\.Android\.AssemblyReader\.Tests|AndroidTestApp' <<< "$(printf '%s\n' "${projects[@]}")"; then
dotnet workload restore test/AndroidTestApp/AndroidTestApp.csproj \
--temp-dir "${{ runner.temp }}" \
--skip-sign-check
# Restore the Android test app explicitly to ensure runtime packs are available
dotnet restore test/AndroidTestApp/AndroidTestApp.csproj -r android-x64 --nologo || true
fi
20 changes: 11 additions & 9 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,8 @@ jobs:

- name: Setup Environment
uses: ./.github/actions/environment
with:
projects: ${{ matrix.slnf }}

# We use macOS for the final publishing build so we get all the iOS/macCatalyst targets in the packages
- name: Set Environment Variables
Expand Down Expand Up @@ -234,7 +236,7 @@ jobs:

- name: Build
id: build
run: dotnet build ${{ matrix.slnf }} -c Release --no-restore --nologo -v:minimal -flp:logfile=build.log -p:CopyLocalLockFileAssemblies=true -bl:build.binlog
run: dotnet build ${{ matrix.slnf }} -c Release --no-restore --nologo -v:minimal -p:CopyLocalLockFileAssemblies=true -bl:build.binlog

# Only a completed Cocoa build writes the stamp, so a failed one is never cached.
- name: Save Cocoa SDK
Expand All @@ -249,9 +251,7 @@ jobs:
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
with:
name: ${{ matrix.rid }}-build-logs
path: |
build.log
build.binlog
path: build.binlog
if-no-files-found: ignore

- name: Free disk space before tests
Expand Down Expand Up @@ -357,6 +357,8 @@ jobs:

- name: Setup Environment
uses: ./.github/actions/environment
with:
projects: Sentry-CI-Build-Windows.slnf

- name: Build Native Dependencies
uses: ./.github/actions/buildnative
Expand All @@ -366,7 +368,7 @@ jobs:

- name: Run MSBuild
id: msbuild
run: msbuild Sentry-CI-Build-Windows.slnf -t:Restore,Build,Pack -p:Configuration=Release --nologo -v:minimal -flp:logfile=msbuild.log -p:CopyLocalLockFileAssemblies=true -bl:msbuild.binlog
run: msbuild Sentry-CI-Build-Windows.slnf -t:Restore,Build,Pack -p:Configuration=Release --nologo -v:minimal -p:CopyLocalLockFileAssemblies=true -bl:msbuild.binlog

- name: Test MSBuild
uses: getsentry/github-workflows/sentry-cli/integration-test@959162c159b866489d3fabe93327f48f9b8cb7ee # 3.4.1
Expand All @@ -378,9 +380,7 @@ jobs:
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
with:
name: ${{ runner.os }}-msbuild-logs
path: |
msbuild.log
msbuild.binlog
path: msbuild.binlog
if-no-files-found: ignore

# Unsupported Native AOT runtimes should have SentryNative auto-disabled
Expand All @@ -404,7 +404,7 @@ jobs:

# This job is on the critical path, after the whole build-sentry matrix. aot.Tests.ps1 only publishes a
# console app against the packages from the macOS build, so it needs the .NET SDK but not the full
# Setup Environment (Java, Android SDK, Mono, workloads).
# Setup Environment (Java, Android SDK, workloads).
steps:
- name: Checkout
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
Expand Down Expand Up @@ -459,6 +459,8 @@ jobs:

- name: Setup Environment
uses: ./.github/actions/environment
with:
projects: test/Sentry.TrimTest/Sentry.TrimTest.csproj test/Sentry.MauiTrimTest/Sentry.MauiTrimTest.csproj

- name: Build Native Dependencies
uses: ./.github/actions/buildnative
Expand Down
7 changes: 3 additions & 4 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,17 +33,16 @@ jobs:

- name: Setup Environment
uses: ./.github/actions/environment
with:
projects: Sentry-CI-CodeQL.slnf

- name: Initialize CodeQL
uses: github/codeql-action/init@6f2ac81f5cd81fe351a197ba0b00d91d03cd2aee # v4.39.0
with:
languages: csharp

- name: Restore .NET Dependencies
# We should be able to get rid of the restore here, if we install the correct workloads in actions/environment
run: |
dotnet workload restore
dotnet restore Sentry-CI-CodeQL.slnf --nologo
run: dotnet restore Sentry-CI-CodeQL.slnf --nologo

- name: Build
run: dotnet build Sentry-CI-CodeQL.slnf --no-restore --nologo
Expand Down
5 changes: 5 additions & 0 deletions .github/workflows/device-tests-android.yml
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,11 @@ jobs:
with:
submodules: recursive

# The device test app references Sentry.Android.AssemblyReader.Tests, which builds the Android test app
- name: Setup Environment
uses: ./.github/actions/environment
with:
projects: test/Sentry.Maui.Device.TestApp/Sentry.Maui.Device.TestApp.csproj test/AndroidTestApp/AndroidTestApp.csproj

- name: Build Native Dependencies
uses: ./.github/actions/buildnative
Expand Down Expand Up @@ -164,6 +167,8 @@ jobs:

- name: Setup Environment
uses: ./.github/actions/environment
with:
projects: integration-test/net9-maui/Sentry.Maui.Device.IntegrationTestApp.csproj

- name: Select Java 21
uses: actions/setup-java@b843ebf9b913146b38da2eaa7aeddf76074ae1ad # v6.1.0
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/device-tests-ios.yml
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@ jobs:

- name: Setup Environment
uses: ./.github/actions/environment
with:
projects: test/Sentry.Maui.Device.TestApp/Sentry.Maui.Device.TestApp.csproj integration-test/net9-maui/Sentry.Maui.Device.IntegrationTestApp.csproj

# See build.yml
- name: Get Cocoa SDK cache key
Expand Down
7 changes: 3 additions & 4 deletions .github/workflows/format-code.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,11 @@ jobs:

- name: Setup Environment
uses: ./.github/actions/environment
with:
projects: Sentry.slnx

- name: Restore .NET Dependencies
# We should be able to get rid of the restore here, if we install the correct workloads in actions/environment
run: |
dotnet workload restore
dotnet restore Sentry.slnx --nologo
run: dotnet restore Sentry.slnx --nologo

- name: Format Code
# We exclude `./**/*OptionsSetup.cs` from the format because the tool struggles with
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/playwright-blazor-wasm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ jobs:
global-json-file: global.json

- name: Install .NET Workloads
run: dotnet workload restore --temp-dir "${{ runner.temp }}" --skip-sign-check
run: dotnet workload restore test/Sentry.AspNetCore.Blazor.WebAssembly.PlaywrightTests/Sentry.AspNetCore.Blazor.WebAssembly.PlaywrightTests.csproj --temp-dir "${{ runner.temp }}" --skip-sign-check

- name: Build
run: dotnet build test/Sentry.AspNetCore.Blazor.WebAssembly.PlaywrightTests -c Release
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/verify-api.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ jobs:

- name: Setup Environment
uses: ./.github/actions/environment
with:
projects: ${{ matrix.slnf }}

- name: Restore sentry-native cache
id: cache-native
Expand All @@ -62,9 +64,7 @@ jobs:
uses: ./.github/actions/buildnative

- name: Restore .NET Dependencies
run: |
dotnet workload restore
dotnet restore ${{ matrix.slnf }} --nologo
run: dotnet restore ${{ matrix.slnf }} --nologo

- name: Build
run: dotnet build ${{ matrix.slnf }} -c Release --no-restore --nologo -v:minimal
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/vulnerabilities.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ jobs:

- name: Setup Environment
uses: ./.github/actions/environment
with:
projects: Sentry.slnx

# We only need to restore to check for vulnerable packages
- name: Restore .NET Dependencies
Expand Down
2 changes: 1 addition & 1 deletion integration-test/common.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ BeforeAll {
Write-Host "::group::${action}ing $project"
try
{
dotnet $action $project -flp:logfile=build.log `
dotnet $action $project `
-c Release `
--nologo `
--framework $TargetFramework `
Expand Down
Loading